RFR: 8303524: Check FunctionDescriptor byte order when linking
ExE Boss
duke at openjdk.org
Mon Mar 27 13:26:33 UTC 2023
On Thu, 23 Mar 2023 16:47:08 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> Linkers are strongly tied to a particular byte order, because they are tied to a particular platform. So, the linker should reject layouts that have another byte order. This patch implements that check.
src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java line 114:
> 112: private void checkLayouts(FunctionDescriptor descriptor) {
> 113: descriptor.returnLayout().ifPresent(this::checkLayoutsRecursive);
> 114: descriptor.argumentLayouts().forEach(this::checkLayoutsRecursive);
Storing `this::checkLayoutsRecursive` in a local variable allows the `Consumer` to be reused for the return and argument layouts, thus only one lambda class and instance needs to be allocated instead of two.
Suggestion:
final Consumer<MemoryLayout> checker = this::checkLayoutsRecursive;
descriptor.returnLayout().ifPresent(checker);
descriptor.argumentLayouts().forEach(checker);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13161#discussion_r1147232059
More information about the core-libs-dev
mailing list