[foreign-memaccess+abi] RFR: 8308293: A linker should expose the layouts it supports
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Jun 15 17:03:10 UTC 2023
On Thu, 15 Jun 2023 16:31:09 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> For the fallback linker I agree, but for the other platforms, it seems that only the layout of `long` and `size_t` changes? I was thinking something like:
>>
>>
>> static Map<String, MemoryLayout> makeCanonicalLayouts(ValueLayout longLayout, ValueLayout sizeTLayout) {
>> return Map.ofEntries(
>> // specified canonical layouts
>> Map.entry("bool", ValueLayout.JAVA_BOOLEAN),
>> Map.entry("char", ValueLayout.JAVA_BYTE),
>> Map.entry("short", ValueLayout.JAVA_SHORT),
>> Map.entry("int", ValueLayout.JAVA_INT),
>> Map.entry("float", ValueLayout.JAVA_FLOAT),
>> Map.entry("long", longLayout),
>> Map.entry("long long", ValueLayout.JAVA_LONG),
>> Map.entry("double", ValueLayout.JAVA_DOUBLE),
>> Map.entry("void*", ValueLayout.ADDRESS),
>> Map.entry("size_t", sizeTLayout),
>> // unspecified size-dependent layouts
>> Map.entry("int8_t", ValueLayout.JAVA_BYTE),
>> Map.entry("int16_t", ValueLayout.JAVA_SHORT),
>> Map.entry("int32_t", ValueLayout.JAVA_INT),
>> Map.entry("int64_t", ValueLayout.JAVA_LONG),
>> // unspecified JNI layouts
>> Map.entry("jboolean", ValueLayout.JAVA_BOOLEAN),
>> Map.entry("jchar", ValueLayout.JAVA_CHAR),
>> Map.entry("jbyte", ValueLayout.JAVA_BYTE),
>> Map.entry("jshort", ValueLayout.JAVA_SHORT),
>> Map.entry("jint", ValueLayout.JAVA_INT),
>> Map.entry("jlong", ValueLayout.JAVA_LONG),
>> Map.entry("jfloat", ValueLayout.JAVA_FLOAT),
>> Map.entry("jdouble", ValueLayout.JAVA_DOUBLE)
>> );
>> }
>>
>>
>> Then each linker can have:
>>
>>
>> private static final ValueLayout C_LONG = ...
>> private static final ValueLayout C_SIZE_T = ...
>> private static final Map<String, MemoryLayout> CANONICAL_LAYOUTS_MAP = SharedUtils.makeCanonicalLayouts(C_LONG, C_SIZE_T);
>>
>> @Override
>> public Map<String, MemoryLayout> canonicalLayouts() {
>> return CANONICAL_LAYOUTS_MAP;
>> }
>
> And then the fallback linker could do it's own thing.
ok - I can try that
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/839#discussion_r1231308329
More information about the panama-dev
mailing list