Skip to content

Commit 62868ae

Browse files
committed
Clean up SlotMethodDef
1 parent 4de9b95 commit 62868ae

File tree

3 files changed

+5
-52
lines changed

3 files changed

+5
-52
lines changed

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

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -45,7 +45,6 @@
4545
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyAsyncMethods__am_await;
4646
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyMappingMethods__mp_ass_subscript;
4747
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_absolute;
48-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_divmod;
4948
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_float;
5049
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_floor_divide;
5150
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_index;
@@ -63,16 +62,9 @@
6362
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_inplace_xor;
6463
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_int;
6564
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_invert;
66-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_lshift;
6765
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_negative;
68-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_or;
6966
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_positive;
7067
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_power;
71-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_remainder;
72-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_rshift;
73-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_subtract;
74-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_true_divide;
75-
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyNumberMethods__nb_xor;
7668
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PySequenceMethods__sq_ass_item;
7769
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_mapping;
7870
import static com.oracle.graal.python.builtins.objects.cext.structs.CFields.PyTypeObject__tp_as_number;
@@ -90,7 +82,6 @@
9082
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ANEXT__;
9183
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___AWAIT__;
9284
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___CALL__;
93-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DIVMOD__;
9485
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOAT__;
9586
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___FLOORDIV__;
9687
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___HASH__;
@@ -111,22 +102,15 @@
111102
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITER__;
112103
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___ITRUEDIV__;
113104
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___IXOR__;
114-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___LSHIFT__;
115-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___MOD__;
116105
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEG__;
117106
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___NEXT__;
118-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___OR__;
119107
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POS__;
120108
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___POW__;
121109
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___REPR__;
122-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___RSHIFT__;
123110
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETATTR__;
124111
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETITEM__;
125112
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___STR__;
126-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SUB__;
127-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUEDIV__;
128113
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___TRUFFLE_RICHCOMPARE__;
129-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___XOR__;
130114

131115
import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.BinaryFuncWrapper;
132116
import com.oracle.graal.python.builtins.objects.cext.capi.PyProcsWrapper.HashfuncWrapper;
@@ -164,7 +148,6 @@ public enum SlotMethodDef {
164148
SQ_ASS_ITEM(PySequenceMethods__sq_ass_item, T___SETITEM__, SsizeobjargfuncWrapper::new, MethodsFlags.SQ_ASS_ITEM),
165149

166150
NB_ABSOLUTE(PyNumberMethods__nb_absolute, T___ABS__, UnaryFuncWrapper::new, MethodsFlags.NB_ABSOLUTE),
167-
NB_DIVMOD(PyNumberMethods__nb_divmod, T___DIVMOD__, BinaryFuncWrapper::new, MethodsFlags.NB_DIVMOD),
168151
NB_FLOAT(PyNumberMethods__nb_float, T___FLOAT__, UnaryFuncWrapper::new, MethodsFlags.NB_FLOAT),
169152
NB_FLOOR_DIVIDE(PyNumberMethods__nb_floor_divide, T___FLOORDIV__, BinaryFuncWrapper::new, MethodsFlags.NB_FLOOR_DIVIDE),
170153
NB_INDEX(PyNumberMethods__nb_index, T___INDEX__, UnaryFuncWrapper::new, MethodsFlags.NB_INDEX),
@@ -182,16 +165,9 @@ public enum SlotMethodDef {
182165
NB_INPLACE_XOR(PyNumberMethods__nb_inplace_xor, T___IXOR__, BinaryFuncWrapper::new, MethodsFlags.NB_INPLACE_XOR),
183166
NB_INT(PyNumberMethods__nb_int, T___INT__, UnaryFuncWrapper::new, MethodsFlags.NB_INT),
184167
NB_INVERT(PyNumberMethods__nb_invert, T___INVERT__, UnaryFuncWrapper::new, MethodsFlags.NB_INVERT),
185-
NB_LSHIFT(PyNumberMethods__nb_lshift, T___LSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_LSHIFT),
186168
NB_NEGATIVE(PyNumberMethods__nb_negative, T___NEG__, UnaryFuncWrapper::new, MethodsFlags.NB_NEGATIVE),
187-
NB_OR(PyNumberMethods__nb_or, T___OR__, BinaryFuncWrapper::new, MethodsFlags.NB_OR),
188169
NB_POSITIVE(PyNumberMethods__nb_positive, T___POS__, UnaryFuncWrapper::new, MethodsFlags.NB_POSITIVE),
189-
NB_POWER(PyNumberMethods__nb_power, T___POW__, TernaryFunctionWrapper::new, MethodsFlags.NB_POWER),
190-
NB_REMAINDER(PyNumberMethods__nb_remainder, T___MOD__, BinaryFuncWrapper::new, MethodsFlags.NB_REMAINDER),
191-
NB_RSHIFT(PyNumberMethods__nb_rshift, T___RSHIFT__, BinaryFuncWrapper::new, MethodsFlags.NB_RSHIFT),
192-
NB_SUBTRACT(PyNumberMethods__nb_subtract, T___SUB__, BinaryFuncWrapper::new, MethodsFlags.NB_SUBTRACT),
193-
NB_TRUE_DIVIDE(PyNumberMethods__nb_true_divide, T___TRUEDIV__, BinaryFuncWrapper::new, MethodsFlags.NB_TRUE_DIVIDE),
194-
NB_XOR(PyNumberMethods__nb_xor, T___XOR__, BinaryFuncWrapper::new, MethodsFlags.NB_XOR);
170+
NB_POWER(PyNumberMethods__nb_power, T___POW__, TernaryFunctionWrapper::new, MethodsFlags.NB_POWER);
195171

196172
public final TruffleString methodName;
197173
public final Function<Object, PyProcsWrapper> wrapperFactory;
@@ -235,9 +211,7 @@ public enum SlotMethodDef {
235211
initGroup(
236212
PyTypeObject__tp_as_number,
237213
NB_ABSOLUTE,
238-
NB_DIVMOD,
239214
NB_FLOAT,
240-
NB_FLOOR_DIVIDE,
241215
NB_INDEX,
242216
NB_INPLACE_ADD,
243217
NB_INPLACE_AND,
@@ -253,16 +227,9 @@ public enum SlotMethodDef {
253227
NB_INPLACE_XOR,
254228
NB_INT,
255229
NB_INVERT,
256-
NB_LSHIFT,
257230
NB_NEGATIVE,
258-
NB_OR,
259231
NB_POSITIVE,
260-
NB_POWER,
261-
NB_REMAINDER,
262-
NB_RSHIFT,
263-
NB_SUBTRACT,
264-
NB_TRUE_DIVIDE,
265-
NB_XOR);
232+
NB_POWER);
266233
}
267234

268235
private static void initGroup(CFields typeField, SlotMethodDef... slots) {

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -157,9 +157,7 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl
157157
writeGroupSlots(CFields.PyTypeObject__tp_as_number, slots, writePointerNode, mem, nullValue);
158158

159159
writePointerNode.write(mem, CFields.PyNumberMethods__nb_absolute, getSlot(obj, SlotMethodDef.NB_ABSOLUTE));
160-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_divmod, getSlot(obj, SlotMethodDef.NB_DIVMOD));
161160
writePointerNode.write(mem, CFields.PyNumberMethods__nb_float, getSlot(obj, SlotMethodDef.NB_FLOAT));
162-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_floor_divide, getSlot(obj, SlotMethodDef.NB_FLOOR_DIVIDE));
163161
writePointerNode.write(mem, CFields.PyNumberMethods__nb_index, getSlot(obj, SlotMethodDef.NB_INDEX));
164162
writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_add, getSlot(obj, SlotMethodDef.NB_INPLACE_ADD));
165163
writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_and, getSlot(obj, SlotMethodDef.NB_INPLACE_AND));
@@ -176,18 +174,10 @@ private static Object allocatePyNumberMethods(PythonManagedClass obj, TpSlots sl
176174
writePointerNode.write(mem, CFields.PyNumberMethods__nb_inplace_xor, getSlot(obj, SlotMethodDef.NB_INPLACE_XOR));
177175
writePointerNode.write(mem, CFields.PyNumberMethods__nb_int, getSlot(obj, SlotMethodDef.NB_INT));
178176
writePointerNode.write(mem, CFields.PyNumberMethods__nb_invert, getSlot(obj, SlotMethodDef.NB_INVERT));
179-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_lshift, getSlot(obj, SlotMethodDef.NB_LSHIFT));
180-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_matrix_multiply, nullValue);
181177
writePointerNode.write(mem, CFields.PyNumberMethods__nb_negative, getSlot(obj, SlotMethodDef.NB_NEGATIVE));
182-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_or, getSlot(obj, SlotMethodDef.NB_OR));
183178
writePointerNode.write(mem, CFields.PyNumberMethods__nb_positive, getSlot(obj, SlotMethodDef.NB_POSITIVE));
184179
writePointerNode.write(mem, CFields.PyNumberMethods__nb_power, getSlot(obj, SlotMethodDef.NB_POWER));
185-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_remainder, getSlot(obj, SlotMethodDef.NB_REMAINDER));
186180
writePointerNode.write(mem, CFields.PyNumberMethods__nb_reserved, nullValue);
187-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_rshift, getSlot(obj, SlotMethodDef.NB_RSHIFT));
188-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_subtract, getSlot(obj, SlotMethodDef.NB_SUBTRACT));
189-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_true_divide, getSlot(obj, SlotMethodDef.NB_TRUE_DIVIDE));
190-
writePointerNode.write(mem, CFields.PyNumberMethods__nb_xor, getSlot(obj, SlotMethodDef.NB_XOR));
191181
return mem;
192182
}
193183

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/MethodsFlags.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -99,10 +99,6 @@ public abstract class MethodsFlags {
9999
// this is helpful to determine if the binop slot is of a heaptype.
100100
public static final long SLOT1BINFULL = 1L << 39;
101101

102-
private static final long SLOT1BINFULL_METHODS = SLOT1BINFULL | NB_SUBTRACT | NB_POWER | NB_FLOOR_DIVIDE |
103-
NB_TRUE_DIVIDE | NB_LSHIFT | NB_RSHIFT | NB_AND | NB_XOR | NB_OR | NB_MULTIPLY | NB_REMAINDER |
104-
NB_DIVMOD | NB_MATRIX_MULTIPLY;
105-
106102
// PySequenceMethods
107103

108104
public static final long SQ_LENGTH = 1L << 40;

0 commit comments

Comments
 (0)