Skip to content

Commit 03d8a43

Browse files
fangererotethal
authored andcommitted
Rename NfiType to NativeSimpleType
1 parent 755a63e commit 03d8a43

14 files changed

Lines changed: 78 additions & 78 deletions

File tree

‎graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/CApiBuiltinsProcessor.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,10 +1122,10 @@ private void collectExternalFunctionAndWrapperDescs(Element element, List<Invoke
11221122

11231123
/**
11241124
* Maps an {@code com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgBehavior} to
1125-
* the NFI Java type.
1125+
* the native Java carrier type.
11261126
*/
11271127
private String toJavaNfiType(String argDescriptor) {
1128-
// TODO: types should be inferred with: 'ArgDescriptor.behavior.nfi2Type'
1128+
// TODO: types should be inferred with: 'ArgDescriptor.behavior.nativeSimpleType'
11291129
return switch (argDescriptor) {
11301130
case "Void" -> "void";
11311131
case "Int", "InquiryResult", "InitResult", "PrimitiveResult32" -> "int";
@@ -1445,17 +1445,17 @@ private void generateNativeAccessSupport(Element[] origins) throws IOException {
14451445
lines.add("");
14461446
lines.add(" @Override");
14471447
lines.add(" @SuppressWarnings(\"restricted\")");
1448-
lines.add(" protected long createClosureImpl(MethodHandle staticMethodHandle, NfiType resType, NfiType[] argTypes, Object arena) {");
1448+
lines.add(" protected long createClosureImpl(MethodHandle staticMethodHandle, NativeSimpleType resType, NativeSimpleType[] argTypes, Object arena) {");
14491449
lines.add(" FunctionDescriptor functionDescriptor = createFunctionDescriptor(resType, argTypes);");
14501450
lines.add(" return Linker.nativeLinker().upcallStub(staticMethodHandle, functionDescriptor, (Arena) arena).address();");
14511451
lines.add(" }");
14521452
lines.add("");
1453-
lines.add(" private static FunctionDescriptor createFunctionDescriptor(NfiType resType, NfiType[] argTypes) {");
1453+
lines.add(" private static FunctionDescriptor createFunctionDescriptor(NativeSimpleType resType, NativeSimpleType[] argTypes) {");
14541454
lines.add(" MemoryLayout[] argLayouts = new MemoryLayout[argTypes.length];");
14551455
lines.add(" for (int i = 0; i < argTypes.length; i++) {");
14561456
lines.add(" argLayouts[i] = asLayout(argTypes[i]);");
14571457
lines.add(" }");
1458-
lines.add(" return resType == NfiType.VOID ? FunctionDescriptor.ofVoid(argLayouts) : FunctionDescriptor.of(asLayout(resType), argLayouts);");
1458+
lines.add(" return resType == NativeSimpleType.VOID ? FunctionDescriptor.ofVoid(argLayouts) : FunctionDescriptor.of(asLayout(resType), argLayouts);");
14591459
lines.add(" }");
14601460
lines.add("");
14611461
lines.add(" private static FunctionDescriptor createFunctionDescriptor(MethodType methodType) {");
@@ -1485,7 +1485,7 @@ private void generateNativeAccessSupport(Element[] origins) throws IOException {
14851485
lines.add(" throw shouldNotReachHere(\"Unsupported layout carrier: \" + type);");
14861486
lines.add(" }");
14871487
lines.add("");
1488-
lines.add(" private static MemoryLayout asLayout(NfiType type) {");
1488+
lines.add(" private static MemoryLayout asLayout(NativeSimpleType type) {");
14891489
lines.add(" return switch (type) {");
14901490
lines.add(" case VOID -> throw shouldNotReachHere(\"VOID has no layout\");");
14911491
lines.add(" case SINT8 -> ValueLayout.JAVA_BYTE;");
@@ -1543,7 +1543,7 @@ private void generateDummyNativeAccessSupport(Element[] origins) throws IOExcept
15431543
lines.add(" }");
15441544
lines.add("");
15451545
lines.add(" @Override");
1546-
lines.add(" protected long createClosureImpl(MethodHandle staticMethodHandle, NfiType resType, NfiType[] argTypes, Object arena) {");
1546+
lines.add(" protected long createClosureImpl(MethodHandle staticMethodHandle, NativeSimpleType resType, NativeSimpleType[] argTypes, Object arena) {");
15471547
lines.add(" throw unsupported();");
15481548
lines.add(" }");
15491549
lines.add("}");

‎graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/objects/TpSlotsTests.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
import com.oracle.graal.python.runtime.nativeaccess.NativeAccess;
5959
import com.oracle.graal.python.runtime.nativeaccess.NativeContext;
6060
import com.oracle.graal.python.runtime.nativeaccess.NativeFunctionPointer;
61-
import com.oracle.graal.python.runtime.nativeaccess.NfiType;
61+
import com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType;
6262
import com.oracle.graal.python.util.Function;
6363

6464
public class TpSlotsTests {
@@ -164,7 +164,7 @@ private static void verifySlots(TpSlots slots, Function<TpSlotMeta, Boolean> che
164164
// verify that the slot values were properly assigned to the right fields of TpSlots
165165
// record
166166
private TpSlotNative createCExtSlot(TpSlotMeta def) {
167-
return TpSlotNative.createCExtSlot(NativeFunctionPointer.create(nativeContext, def.ordinal(), NfiType.VOID));
167+
return TpSlotNative.createCExtSlot(NativeFunctionPointer.create(nativeContext, def.ordinal(), NativeSimpleType.VOID));
168168
}
169169

170170
private static void checkSlotValue(TpSlotMeta def, TpSlot slotValue) {

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
import com.oracle.graal.python.lib.PyObjectGetAttr;
171171
import com.oracle.graal.python.runtime.nativeaccess.NativeAccess;
172172
import com.oracle.graal.python.runtime.nativeaccess.NativeSignature;
173-
import com.oracle.graal.python.runtime.nativeaccess.NfiType;
173+
import com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType;
174174
import com.oracle.graal.python.nodes.ErrorMessages;
175175
import com.oracle.graal.python.nodes.HiddenAttr;
176176
import com.oracle.graal.python.nodes.PConstructAndRaiseNode;
@@ -634,7 +634,7 @@ CExtToNativeNode createRetNode() {
634634
}
635635

636636
Object getErrorReturnValue() {
637-
return switch (ret.getNFI2Type()) {
637+
return switch (ret.getNativeSimpleType()) {
638638
case VOID -> PNone.NO_VALUE;
639639
case SINT8 -> (byte) -1;
640640
case SINT16 -> (short) -1;
@@ -684,11 +684,11 @@ public long getNativePointer() {
684684
PythonContext context = PythonContext.get(null);
685685
long pointer = context.getCApiContext().getClosurePointer(this);
686686
if (pointer == -1) {
687-
NfiType[] argTypes = new NfiType[args.length];
687+
NativeSimpleType[] argTypes = new NativeSimpleType[args.length];
688688
for (int i = 0; i < args.length; i++) {
689-
argTypes[i] = args[i].getNFI2Type();
689+
argTypes[i] = args[i].getNativeSimpleType();
690690
}
691-
NativeSignature signature = NativeAccess.createSignature(ret.getNFI2Type(), argTypes);
691+
NativeSignature signature = NativeAccess.createSignature(ret.getNativeSimpleType(), argTypes);
692692
try {
693693
pointer = signature.createClosure(context.ensureNativeContext(), name, PythonCextBuiltinRegistry.getMethodHandle(id));
694694
context.getCApiContext().setClosurePointer(null, this, pointer);

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyCFunctionWrapper.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
import com.oracle.graal.python.builtins.objects.function.Signature;
6161
import com.oracle.graal.python.runtime.nativeaccess.NativeAccess;
6262
import com.oracle.graal.python.runtime.nativeaccess.NativeSignature;
63-
import com.oracle.graal.python.runtime.nativeaccess.NfiType;
63+
import com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType;
6464
import com.oracle.graal.python.nodes.argument.CreateArgumentsNode;
6565
import com.oracle.graal.python.nodes.argument.keywords.ExpandKeywordStarargsNode;
6666
import com.oracle.graal.python.nodes.argument.positional.ExecutePositionalStarargsNode;
@@ -86,9 +86,9 @@
8686
*/
8787
public abstract class PyCFunctionWrapper {
8888

89-
private static final NativeSignature SIGNATURE_1_ARG = NativeAccess.createSignature(NfiType.RAW_POINTER, NfiType.RAW_POINTER);
90-
private static final NativeSignature SIGNATURE_2_ARG = NativeAccess.createSignature(NfiType.RAW_POINTER, NfiType.RAW_POINTER, NfiType.RAW_POINTER);
91-
private static final NativeSignature SIGNATURE_3_ARG = NativeAccess.createSignature(NfiType.RAW_POINTER, NfiType.RAW_POINTER, NfiType.RAW_POINTER, NfiType.RAW_POINTER);
89+
private static final NativeSignature SIGNATURE_1_ARG = NativeAccess.createSignature(NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER);
90+
private static final NativeSignature SIGNATURE_2_ARG = NativeAccess.createSignature(NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER);
91+
private static final NativeSignature SIGNATURE_3_ARG = NativeAccess.createSignature(NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER, NativeSimpleType.RAW_POINTER);
9292

9393
private static final MethodHandle HANDLE_UNARY;
9494
private static final MethodHandle HANDLE_BINARY;

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/TpSlotWrapper.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242

4343
import static com.oracle.graal.python.builtins.modules.cext.PythonCextBuiltins.checkThrowableBeforeNative;
4444
import static com.oracle.graal.python.runtime.nativeaccess.NativeMemory.NULLPTR;
45-
import static com.oracle.graal.python.runtime.nativeaccess.NfiType.RAW_POINTER;
46-
import static com.oracle.graal.python.runtime.nativeaccess.NfiType.SINT32;
47-
import static com.oracle.graal.python.runtime.nativeaccess.NfiType.SINT64;
45+
import static com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType.RAW_POINTER;
46+
import static com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType.SINT32;
47+
import static com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType.SINT64;
4848
import static com.oracle.graal.python.util.PythonUtils.EMPTY_OBJECT_ARRAY;
4949

5050
import java.lang.invoke.MethodHandle;

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/transitions/ArgDescriptor.java‎

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,54 +52,54 @@
5252
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions.PythonToNativeNode;
5353
import com.oracle.graal.python.builtins.objects.cext.common.CExtToJavaNode;
5454
import com.oracle.graal.python.builtins.objects.cext.common.CExtToNativeNode;
55-
import com.oracle.graal.python.runtime.nativeaccess.NfiType;
55+
import com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType;
5656
import com.oracle.graal.python.util.Supplier;
5757

5858
enum ArgBehavior {
5959
PyObject(
60-
NfiType.RAW_POINTER,
60+
NativeSimpleType.RAW_POINTER,
6161
PythonToNativeNode::create,
6262
NativeToPythonNode::create,
6363
NativeToPythonNode.getUncached(),
6464
PythonToNativeNewRefNode::create,
6565
NativeToPythonTransferNode::create,
6666
NativeToPythonTransferNode.getUncached()),
67-
PyObjectBorrowed(NfiType.RAW_POINTER, ToNativeBorrowedNode::new, NativeToPythonNode::create, NativeToPythonNode.getUncached(), null, null, null),
68-
PyObjectAsTruffleString(NfiType.RAW_POINTER, null, ToPythonStringNode::create, ToPythonStringNode.getUncached(), null, null, null),
67+
PyObjectBorrowed(NativeSimpleType.RAW_POINTER, ToNativeBorrowedNode::new, NativeToPythonNode::create, NativeToPythonNode.getUncached(), null, null, null),
68+
PyObjectAsTruffleString(NativeSimpleType.RAW_POINTER, null, ToPythonStringNode::create, ToPythonStringNode.getUncached(), null, null, null),
6969
PyTypeObject(
70-
NfiType.RAW_POINTER,
70+
NativeSimpleType.RAW_POINTER,
7171
PythonToNativeNode::create,
7272
NativeToPythonClassNode::create,
7373
NativeToPythonClassNode.getUncached(),
7474
PythonToNativeNewRefNode::create,
7575
NativeToPythonTransferNode::create,
7676
NativeToPythonTransferNode.getUncached()),
77-
Pointer(NfiType.RAW_POINTER),
78-
TruffleStringPointer(NfiType.RAW_POINTER, null, CharPtrToPythonNode::create, CharPtrToPythonNode.getUncached()),
79-
Char8(NfiType.SINT8),
80-
UChar8(NfiType.SINT8),
81-
Char16(NfiType.SINT16),
82-
Int32(NfiType.SINT32),
83-
UInt32(NfiType.SINT32),
84-
Int64(NfiType.SINT64),
85-
UInt64(NfiType.SINT64),
86-
Long(NfiType.SINT64, null, FromLongNode::create, FromLongNode.getUncached()),
87-
Float32(NfiType.FLOAT),
88-
Float64(NfiType.DOUBLE),
89-
Void(NfiType.VOID),
90-
Unknown(NfiType.SINT64);
77+
Pointer(NativeSimpleType.RAW_POINTER),
78+
TruffleStringPointer(NativeSimpleType.RAW_POINTER, null, CharPtrToPythonNode::create, CharPtrToPythonNode.getUncached()),
79+
Char8(NativeSimpleType.SINT8),
80+
UChar8(NativeSimpleType.SINT8),
81+
Char16(NativeSimpleType.SINT16),
82+
Int32(NativeSimpleType.SINT32),
83+
UInt32(NativeSimpleType.SINT32),
84+
Int64(NativeSimpleType.SINT64),
85+
UInt64(NativeSimpleType.SINT64),
86+
Long(NativeSimpleType.SINT64, null, FromLongNode::create, FromLongNode.getUncached()),
87+
Float32(NativeSimpleType.FLOAT),
88+
Float64(NativeSimpleType.DOUBLE),
89+
Void(NativeSimpleType.VOID),
90+
Unknown(NativeSimpleType.SINT64);
9191

92-
public final NfiType nfi2Type;
92+
public final NativeSimpleType nativeSimpleType;
9393
public final Supplier<CExtToNativeNode> pythonToNative;
9494
public final Supplier<CExtToJavaNode> nativeToPython;
9595
public final CExtToJavaNode uncachedNativeToPython;
9696
public final Supplier<CExtToNativeNode> pythonToNativeTransfer;
9797
public final Supplier<CExtToJavaNode> nativeToPythonTransfer;
9898
public final CExtToJavaNode uncachedNativeToPythonTransfer;
9999

100-
ArgBehavior(NfiType nfi2Type, Supplier<CExtToNativeNode> pythonToNative, Supplier<CExtToJavaNode> nativeToPython, CExtToJavaNode uncachedNativeToPython,
100+
ArgBehavior(NativeSimpleType nativeSimpleType, Supplier<CExtToNativeNode> pythonToNative, Supplier<CExtToJavaNode> nativeToPython, CExtToJavaNode uncachedNativeToPython,
101101
Supplier<CExtToNativeNode> pythonToNativeTransfer, Supplier<CExtToJavaNode> nativeToPythonTransfer, CExtToJavaNode uncachedNativeToPythonTransfer) {
102-
this.nfi2Type = nfi2Type;
102+
this.nativeSimpleType = nativeSimpleType;
103103
this.pythonToNative = pythonToNative;
104104
this.nativeToPython = nativeToPython;
105105
this.uncachedNativeToPython = uncachedNativeToPython;
@@ -108,12 +108,12 @@ enum ArgBehavior {
108108
this.uncachedNativeToPythonTransfer = uncachedNativeToPythonTransfer;
109109
}
110110

111-
ArgBehavior(NfiType nfi2Type, Supplier<CExtToNativeNode> pythonToNative, Supplier<CExtToJavaNode> nativeToPython, CExtToJavaNode uncachedNativeToPython) {
112-
this(nfi2Type, pythonToNative, nativeToPython, uncachedNativeToPython, null, null, null);
111+
ArgBehavior(NativeSimpleType nativeSimpleType, Supplier<CExtToNativeNode> pythonToNative, Supplier<CExtToJavaNode> nativeToPython, CExtToJavaNode uncachedNativeToPython) {
112+
this(nativeSimpleType, pythonToNative, nativeToPython, uncachedNativeToPython, null, null, null);
113113
}
114114

115-
ArgBehavior(NfiType nfi2Type) {
116-
this(nfi2Type, null, null, null, null, null, null);
115+
ArgBehavior(NativeSimpleType nativeSimpleType) {
116+
this(nativeSimpleType, null, null, null, null, null, null);
117117
}
118118

119119
}
@@ -423,8 +423,8 @@ public CExtToJavaNode getUncachedNativeToPythonNode() {
423423
return node;
424424
}
425425

426-
public NfiType getNFI2Type() {
427-
return behavior.nfi2Type;
426+
public NativeSimpleType getNativeSimpleType() {
427+
return behavior.nativeSimpleType;
428428
}
429429

430430
public boolean isPyObjectOrPointer() {

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/NativeCExtSymbol.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import com.oracle.graal.python.builtins.objects.cext.capi.transitions.ArgDescriptor;
4444
import com.oracle.graal.python.runtime.nativeaccess.NativeContext;
4545
import com.oracle.graal.python.runtime.nativeaccess.NativeFunctionPointer;
46-
import com.oracle.graal.python.runtime.nativeaccess.NfiType;
46+
import com.oracle.graal.python.runtime.nativeaccess.NativeSimpleType;
4747
import com.oracle.truffle.api.strings.TruffleString;
4848

4949
public interface NativeCExtSymbol {
@@ -61,10 +61,10 @@ default NativeFunctionPointer bind(NativeContext context, long pointer) {
6161
throw new UnsupportedOperationException("No signature for " + getName());
6262
}
6363
ArgDescriptor[] arguments = getArguments();
64-
NfiType[] argTypes = new NfiType[arguments.length];
64+
NativeSimpleType[] argTypes = new NativeSimpleType[arguments.length];
6565
for (int i = 0; i < arguments.length; i++) {
66-
argTypes[i] = arguments[i].getNFI2Type();
66+
argTypes[i] = arguments[i].getNativeSimpleType();
6767
}
68-
return NativeFunctionPointer.create(context, pointer, returnValue.getNFI2Type(), argTypes);
68+
return NativeFunctionPointer.create(context, pointer, returnValue.getNativeSimpleType(), argTypes);
6969
}
7070
}

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/nativeaccess/NativeAccess.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static NativeContext createContext() {
4747
return new NativeContext();
4848
}
4949

50-
public static NativeSignature createSignature(NfiType resType, NfiType... argTypes) {
50+
public static NativeSignature createSignature(NativeSimpleType resType, NativeSimpleType... argTypes) {
5151
return new NativeSignature(resType, argTypes);
5252
}
5353
}

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/nativeaccess/NativeAccessSupport.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected static MethodHandle unsupportedDowncallHandle(MethodType methodType) {
6969
return MethodHandles.dropArguments(methodHandle, 0, methodType.parameterList());
7070
}
7171

72-
protected static Class<?> asJavaType(NfiType type) {
72+
protected static Class<?> asJavaType(NativeSimpleType type) {
7373
return switch (type) {
7474
case VOID -> void.class;
7575
case SINT8 -> byte.class;
@@ -102,19 +102,19 @@ public static long lookupDefault(String name) {
102102
return INSTANCE.lookupDefaultImpl(name);
103103
}
104104

105-
public static MethodHandle createDowncallHandle(NfiType resType, NfiType... argTypes) {
105+
public static MethodHandle createDowncallHandle(NativeSimpleType resType, NativeSimpleType... argTypes) {
106106
return INSTANCE.createTypedDowncallHandle(resType, argTypes);
107107
}
108108

109109
public static MethodHandle createDowncallHandle(MethodType methodType, boolean critical) {
110110
return INSTANCE.createDowncallHandleImpl(methodType, critical);
111111
}
112112

113-
public static long createClosure(MethodHandle staticMethodHandle, NfiType resType, NfiType[] argTypes, Object arena) {
113+
public static long createClosure(MethodHandle staticMethodHandle, NativeSimpleType resType, NativeSimpleType[] argTypes, Object arena) {
114114
return INSTANCE.createClosureImpl(staticMethodHandle, resType, argTypes, arena);
115115
}
116116

117-
private MethodHandle createTypedDowncallHandle(NfiType resType, NfiType... argTypes) {
117+
private MethodHandle createTypedDowncallHandle(NativeSimpleType resType, NativeSimpleType... argTypes) {
118118
Class<?>[] parameterTypes = new Class<?>[argTypes.length + 1];
119119
parameterTypes[0] = long.class;
120120
for (int i = 0; i < argTypes.length; i++) {
@@ -133,5 +133,5 @@ private MethodHandle createTypedDowncallHandle(NfiType resType, NfiType... argTy
133133

134134
protected abstract MethodHandle createDowncallHandleImpl(MethodType methodType, boolean critical);
135135

136-
protected abstract long createClosureImpl(MethodHandle staticMethodHandle, NfiType resType, NfiType[] argTypes, Object arena);
136+
protected abstract long createClosureImpl(MethodHandle staticMethodHandle, NativeSimpleType resType, NativeSimpleType[] argTypes, Object arena);
137137
}

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/nativeaccess/NativeAccessSupportJdk21.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected MethodHandle createDowncallHandleImpl(MethodType methodType, boolean c
6969
}
7070

7171
@Override
72-
protected long createClosureImpl(MethodHandle staticMethodHandle, NfiType resType, NfiType[] argTypes, Object arena) {
72+
protected long createClosureImpl(MethodHandle staticMethodHandle, NativeSimpleType resType, NativeSimpleType[] argTypes, Object arena) {
7373
throw unsupported();
7474
}
7575
}

0 commit comments

Comments
 (0)