8243491: Implementation of Foreign-Memory Access API (Second Incubator)

Upstream latest changes of the Foreign-Memory Access API

Co-authored-by: Jorn Vernee <jorn.vernee@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Paul Sandoz <paul.sandoz@oracle.com>
Co-authored-by: Peter Levart <peter.levart@gmail.com>
Reviewed-by: chegar, psandoz
This commit is contained in:
Chris Hegarty 2020-05-25 10:54:39 +01:00 committed by Maurizio Cimadamore
parent 9b94b9d1a1
commit f3eb44a94d
94 changed files with 7496 additions and 1388 deletions

View file

@ -45,38 +45,45 @@ final class VarForm {
VarForm(Class<?> implClass, Class<?> receiver, Class<?> value, Class<?>... intermediate) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
if (receiver == null) {
initMethodTypes(value, intermediate);
} else {
Class<?>[] coordinates = new Class<?>[intermediate.length + 1];
coordinates[0] = receiver;
System.arraycopy(intermediate, 0, coordinates, 1, intermediate.length);
initMethodTypes(value, coordinates);
}
// TODO lazily calculate
this.memberName_table = linkFromStatic(implClass);
}
// (Receiver, <Intermediates>)
List<Class<?>> l = new ArrayList<>();
if (receiver != null)
l.add(receiver);
for (Class<?> c : intermediate)
l.add(c);
VarForm(Class<?> value, Class<?>[] coordinates) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
this.memberName_table = null;
initMethodTypes(value, coordinates);
}
void initMethodTypes(Class<?> value, Class<?>... coordinates) {
// (Receiver, <Intermediates>)Value
methodType_table[VarHandle.AccessType.GET.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).erase();
// (Receiver, <Intermediates>, Value)void
l.add(value);
methodType_table[VarHandle.AccessType.SET.ordinal()] =
MethodType.methodType(void.class, l).erase();
MethodType.methodType(void.class, coordinates).appendParameterTypes(value).erase();
// (Receiver, <Intermediates>, Value)Value
methodType_table[VarHandle.AccessType.GET_AND_UPDATE.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).appendParameterTypes(value).erase();
// (Receiver, <Intermediates>, Value, Value)boolean
l.add(value);
methodType_table[VarHandle.AccessType.COMPARE_AND_SET.ordinal()] =
MethodType.methodType(boolean.class, l).erase();
MethodType.methodType(boolean.class, coordinates).appendParameterTypes(value, value).erase();
// (Receiver, <Intermediates>, Value, Value)Value
methodType_table[VarHandle.AccessType.COMPARE_AND_EXCHANGE.ordinal()] =
MethodType.methodType(value, l).erase();
MethodType.methodType(value, coordinates).appendParameterTypes(value, value).erase();
}
@ForceInline