Skip to content

Commit 9b41a3a

Browse files
committed
added static to some specializations in cext
1 parent e42d17d commit 9b41a3a

16 files changed

+153
-153
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ Object index(VirtualFrame frame, Object obj,
185185
abstract static class PyNumberLongNode extends PythonUnaryBuiltinNode {
186186

187187
@Specialization
188-
int nlong(int i) {
188+
static int nlong(int i) {
189189
return i;
190190
}
191191

192192
@Specialization
193-
long nlong(long i) {
193+
static long nlong(long i) {
194194
return i;
195195
}
196196

@@ -672,7 +672,7 @@ private LookupAndCallInplaceNode ensureCallNode() {
672672
@GenerateNodeFactory
673673
public abstract static class PySequenceTupleNode extends PythonUnaryBuiltinNode {
674674
@Specialization(guards = "isTuple(obj, getClassNode)")
675-
public PTuple values(PTuple obj,
675+
public static PTuple values(PTuple obj,
676676
@SuppressWarnings("unused") @Cached GetClassNode getClassNode) {
677677
return obj;
678678
}
@@ -777,7 +777,7 @@ Object getSlice(VirtualFrame frame, Object obj, @SuppressWarnings("unused") Obje
777777
abstract static class PySequenceContainsNode extends PythonBinaryBuiltinNode {
778778

779779
@Specialization
780-
Object contains(VirtualFrame frame, Object haystack, Object needle,
780+
static Object contains(VirtualFrame frame, Object haystack, Object needle,
781781
@Cached ContainsNode containsNode,
782782
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
783783
try {
@@ -919,7 +919,7 @@ protected BinaryArithmetic.AddNode createAdd() {
919919
@GenerateNodeFactory
920920
public abstract static class PySequenceDelItemNode extends PythonBinaryBuiltinNode {
921921
@Specialization
922-
Object run(VirtualFrame frame, Object o, Object i,
922+
static Object run(VirtualFrame frame, Object o, Object i,
923923
@Cached PyObjectDelItem delItemNode,
924924
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
925925
try {

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public abstract static class ToJavaClassNode extends ToJavaObjectNode {
371371
abstract static class TruffleString_AsString extends NativeBuiltin {
372372

373373
@Specialization(guards = "isString(str)")
374-
Object run(Object str,
374+
static Object run(Object str,
375375
@Cached AsCharPointerNode asCharPointerNode) {
376376
return asCharPointerNode.execute(str);
377377
}
@@ -386,7 +386,7 @@ Object run(VirtualFrame frame, Object o) {
386386
@GenerateNodeFactory
387387
public abstract static class PyErrorHandlerNode extends PythonUnaryBuiltinNode {
388388
@Specialization
389-
Object run(PythonModule cextPython) {
389+
static Object run(PythonModule cextPython) {
390390
return ((PythonCextBuiltins) cextPython.getBuiltins()).errorHandler;
391391
}
392392
}
@@ -395,7 +395,7 @@ Object run(PythonModule cextPython) {
395395
@GenerateNodeFactory
396396
public abstract static class PyNotImplementedNode extends PythonBuiltinNode {
397397
@Specialization
398-
Object run() {
398+
static Object run() {
399399
return PNotImplemented.NOT_IMPLEMENTED;
400400
}
401401
}
@@ -404,7 +404,7 @@ Object run() {
404404
@GenerateNodeFactory
405405
public abstract static class PyTrueNode extends PythonBuiltinNode {
406406
@Specialization
407-
Object run() {
407+
static Object run() {
408408
return true;
409409
}
410410
}
@@ -413,7 +413,7 @@ Object run() {
413413
@GenerateNodeFactory
414414
public abstract static class PyFalseNode extends PythonBuiltinNode {
415415
@Specialization
416-
Object run() {
416+
static Object run() {
417417
return false;
418418
}
419419
}
@@ -422,7 +422,7 @@ Object run() {
422422
@GenerateNodeFactory
423423
public abstract static class PyEllipsisNode extends PythonBuiltinNode {
424424
@Specialization
425-
Object run() {
425+
static Object run() {
426426
return PEllipsis.INSTANCE;
427427
}
428428
}
@@ -433,7 +433,7 @@ Object run() {
433433
@GenerateNodeFactory
434434
public abstract static class PyDictProxyNewNode extends PythonUnaryBuiltinNode {
435435
@Specialization
436-
public Object values(VirtualFrame frame, Object obj,
436+
public static Object values(VirtualFrame frame, Object obj,
437437
@Cached MappingproxyNode mappingNode) {
438438
return mappingNode.execute(frame, PythonBuiltinClassType.PMappingproxy, obj);
439439
}
@@ -446,7 +446,7 @@ public Object values(VirtualFrame frame, Object obj,
446446
public abstract static class PyChangeREFNode extends PythonUnaryBuiltinNode {
447447
@SuppressWarnings("unused")
448448
@Specialization
449-
public Object values(Object obj) {
449+
public static Object values(Object obj) {
450450
// pass
451451
return PNone.NONE;
452452
}
@@ -463,7 +463,7 @@ public Object values(Object obj) {
463463
public abstract static class ToSulongNode extends PythonUnaryBuiltinNode {
464464

465465
@Specialization
466-
Object run(Object obj,
466+
static Object run(Object obj,
467467
@Cached CExtNodes.ToSulongNode toSulongNode) {
468468
return toSulongNode.execute(obj);
469469
}
@@ -732,7 +732,7 @@ Object doWithoutTraceback(@SuppressWarnings("unused") Object typ, PBaseException
732732

733733
@Fallback
734734
@SuppressWarnings("unused")
735-
Object doFallback(Object typ, Object val, Object tb) {
735+
static Object doFallback(Object typ, Object val, Object tb) {
736736
// TODO we should still store the values to return them with 'PyErr_GetExcInfo' (or
737737
// 'sys.exc_info')
738738
return PNone.NONE;
@@ -749,7 +749,7 @@ abstract static class PyErrDisplay extends PythonBuiltinNode {
749749

750750
@Specialization
751751
@SuppressWarnings("unused")
752-
Object run(Object typ, PBaseException val, Object tb) {
752+
static Object run(Object typ, PBaseException val, Object tb) {
753753
if (val.getException() != null) {
754754
ExceptionUtils.printPythonLikeStackTrace(val.getException());
755755
}
@@ -778,21 +778,21 @@ abstract static class PyObject_Setattr extends PythonTernaryBuiltinNode {
778778
abstract Object execute(Object object, String key, Object value);
779779

780780
@Specialization
781-
Object doBuiltinClass(PythonBuiltinClass object, String key, Object value,
781+
static Object doBuiltinClass(PythonBuiltinClass object, String key, Object value,
782782
@Exclusive @Cached("createForceType()") WriteAttributeToObjectNode writeAttrNode) {
783783
writeAttrNode.execute(object, key, value);
784784
return PNone.NONE;
785785
}
786786

787787
@Specialization
788-
Object doNativeClass(PythonNativeClass object, String key, Object value,
788+
static Object doNativeClass(PythonNativeClass object, String key, Object value,
789789
@Exclusive @Cached("createForceType()") WriteAttributeToObjectNode writeAttrNode) {
790790
writeAttrNode.execute(object, key, value);
791791
return PNone.NONE;
792792
}
793793

794794
@Specialization(guards = {"!isPythonBuiltinClass(object)"})
795-
Object doObject(PythonObject object, String key, Object value,
795+
static Object doObject(PythonObject object, String key, Object value,
796796
@Exclusive @Cached WriteAttributeToDynamicObjectNode writeAttrToDynamicObjectNode) {
797797
writeAttrToDynamicObjectNode.execute(object.getStorage(), key, value);
798798
return PNone.NONE;
@@ -865,7 +865,7 @@ private static Object[] collect(MroSequenceStorage mro, int idx) {
865865
@GenerateNodeFactory
866866
abstract static class Py_NoValue extends PythonBuiltinNode {
867867
@Specialization
868-
PNone doNoValue() {
868+
static PNone doNoValue() {
869869
return PNone.NO_VALUE;
870870
}
871871
}
@@ -874,7 +874,7 @@ PNone doNoValue() {
874874
@GenerateNodeFactory
875875
abstract static class PyNoneNode extends PythonBuiltinNode {
876876
@Specialization
877-
PNone doNativeNone() {
877+
static PNone doNativeNone() {
878878
return PNone.NONE;
879879
}
880880
}
@@ -1150,12 +1150,12 @@ Object doUnicode(VirtualFrame frame, Object s, long elementSize, Object errorMar
11501150
@GenerateNodeFactory
11511151
abstract static class PyTruffle_Bytes_AsString extends NativeBuiltin {
11521152
@Specialization
1153-
Object doBytes(PBytes bytes, @SuppressWarnings("unused") Object errorMarker) {
1153+
static Object doBytes(PBytes bytes, @SuppressWarnings("unused") Object errorMarker) {
11541154
return new PySequenceArrayWrapper(bytes, 1);
11551155
}
11561156

11571157
@Specialization
1158-
Object doUnicode(PString str, @SuppressWarnings("unused") Object errorMarker) {
1158+
static Object doUnicode(PString str, @SuppressWarnings("unused") Object errorMarker) {
11591159
return new CStringWrapper(str.getValue());
11601160
}
11611161

@@ -1169,7 +1169,7 @@ Object doUnicode(VirtualFrame frame, Object o, Object errorMarker) {
11691169
@GenerateNodeFactory
11701170
abstract static class PyHashImagNode extends PythonBuiltinNode {
11711171
@Specialization
1172-
long getHash() {
1172+
static long getHash() {
11731173
return SysModuleBuiltins.HASH_IMAG;
11741174
}
11751175
}
@@ -1500,7 +1500,7 @@ static Object upcall(VirtualFrame frame, @SuppressWarnings("unused") Object self
15001500
abstract static class UpcallDNode extends UpcallLandingNode {
15011501

15021502
@Specialization
1503-
double upcall(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
1503+
static double upcall(VirtualFrame frame, @SuppressWarnings("unused") Object self, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
15041504
@Cached CastToJavaDoubleNode castToDoubleNode,
15051505
@Cached ObjectUpcallNode upcallNode,
15061506
@Cached TransformExceptionToNativeNode transformExceptionToNativeNode) {
@@ -1535,14 +1535,14 @@ Object upcall(VirtualFrame frame, @SuppressWarnings("unused") PythonModule cextM
15351535
abstract static class UpcallCextBorrowedNode extends UpcallLandingNode {
15361536

15371537
@Specialization(guards = "isStringCallee(args)")
1538-
Object upcall(VirtualFrame frame, PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
1538+
static Object upcall(VirtualFrame frame, PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
15391539
@Cached CextUpcallNode upcallNode,
15401540
@Shared("toSulongNode") @Cached CExtNodes.ToSulongNode toSulongNode) {
15411541
return toSulongNode.execute(upcallNode.execute(frame, cextModule, args));
15421542
}
15431543

15441544
@Specialization(guards = "!isStringCallee(args)")
1545-
Object doDirect(VirtualFrame frame, @SuppressWarnings("unused") PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
1545+
static Object doDirect(VirtualFrame frame, @SuppressWarnings("unused") PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
15461546
@Cached DirectUpcallNode upcallNode,
15471547
@Shared("toSulongNode") @Cached CExtNodes.ToSulongNode toSulongNode) {
15481548
return toSulongNode.execute(upcallNode.execute(frame, args));
@@ -1579,14 +1579,14 @@ static Object doDirect(VirtualFrame frame, @SuppressWarnings("unused") PythonMod
15791579
abstract static class UpcallCextDNode extends UpcallLandingNode {
15801580

15811581
@Specialization(guards = "isStringCallee(args)")
1582-
double upcall(VirtualFrame frame, PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
1582+
static double upcall(VirtualFrame frame, PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
15831583
@Cached CextUpcallNode upcallNode,
15841584
@Shared("castToDoubleNode") @Cached CastToJavaDoubleNode castToDoubleNode) {
15851585
return castToDoubleNode.execute(upcallNode.execute(frame, cextModule, args));
15861586
}
15871587

15881588
@Specialization(guards = "!isStringCallee(args)")
1589-
double doDirect(VirtualFrame frame, @SuppressWarnings("unused") PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
1589+
static double doDirect(VirtualFrame frame, @SuppressWarnings("unused") PythonModule cextModule, Object[] args, @SuppressWarnings("unused") PKeyword[] kwargs,
15901590
@Cached DirectUpcallNode upcallNode,
15911591
@Shared("castToDoubleNode") @Cached CastToJavaDoubleNode castToDoubleNode) {
15921592
return castToDoubleNode.execute(upcallNode.execute(frame, args));
@@ -1699,7 +1699,7 @@ Object doIt(VirtualFrame frame, Object object,
16991699
@GenerateNodeFactory
17001700
abstract static class AsDouble extends PythonUnaryBuiltinNode {
17011701
@Specialization
1702-
double doIt(Object object,
1702+
static double doIt(Object object,
17031703
@Cached CastToJavaDoubleNode castToDoubleNode) {
17041704
return castToDoubleNode.execute(object);
17051705
}
@@ -1761,7 +1761,7 @@ protected static Class<?> getClazz(Object v) {
17611761
}
17621762

17631763
@Specialization(replaces = "doCached", guards = {"cachedClassA == getClazz(a)", "cachedClassB == getClazz(b)"}, limit = "getVariableArgumentInlineCacheLimit()")
1764-
int doCachedClass(VirtualFrame frame, Object a, Object b,
1764+
static int doCachedClass(VirtualFrame frame, Object a, Object b,
17651765
@Cached("getClazz(a)") Class<?> cachedClassA,
17661766
@Cached("getClazz(b)") Class<?> cachedClassB,
17671767
@Cached ToJavaNode leftToJavaNode,
@@ -1773,7 +1773,7 @@ int doCachedClass(VirtualFrame frame, Object a, Object b,
17731773
}
17741774

17751775
@Specialization(replaces = {"doCached", "doCachedClass"})
1776-
int doGeneric(VirtualFrame frame, Object a, Object b,
1776+
static int doGeneric(VirtualFrame frame, Object a, Object b,
17771777
@Cached ToJavaNode leftToJavaNode,
17781778
@Cached ToJavaNode rightToJavaNode,
17791779
@Cached IsSubtypeNode isSubtypeNode) {
@@ -1782,7 +1782,7 @@ int doGeneric(VirtualFrame frame, Object a, Object b,
17821782
return isSubtypeNode.execute(frame, ua, ub) ? 1 : 0;
17831783
}
17841784

1785-
int doSlow(VirtualFrame frame, Object derived, Object cls) {
1785+
static int doSlow(VirtualFrame frame, Object derived, Object cls) {
17861786
return doGeneric(frame, derived, cls, ToJavaNodeGen.getUncached(), ToJavaNodeGen.getUncached(), IsSubtypeNodeGen.getUncached());
17871787
}
17881788
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,21 @@ public void initialize(Python3Core core) {
113113
@GenerateNodeFactory
114114
public abstract static class PyBytesSizeNode extends PythonUnaryBuiltinNode {
115115
@Specialization
116-
public int size(VirtualFrame frame, PBytes obj,
116+
public static int size(VirtualFrame frame, PBytes obj,
117117
@Cached PyObjectSizeNode sizeNode) {
118118
return sizeNode.execute(frame, obj);
119119
}
120120

121121
@Specialization(guards = {"!isPBytes(obj)", "isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)"})
122-
public int sizeNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj,
122+
public static int sizeNative(VirtualFrame frame, @SuppressWarnings("unused") Object obj,
123123
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
124124
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
125125
@Cached PRaiseNativeNode raiseNativeNode) {
126126
return raiseNativeNode.raiseInt(frame, -1, PythonBuiltinClassType.NotImplementedError, NATIVE_S_SUBTYPES_NOT_IMPLEMENTED, "bytes");
127127
}
128128

129129
@Specialization(guards = {"!isPBytes(obj)", "!isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)"})
130-
public int size(VirtualFrame frame, Object obj,
130+
public static int size(VirtualFrame frame, Object obj,
131131
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
132132
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode,
133133
@Cached StrNode strNode,
@@ -145,12 +145,12 @@ protected boolean isBytesSubtype(VirtualFrame frame, Object obj, GetClassNode ge
145145
public abstract static class PyBytesCheckNode extends PythonUnaryBuiltinNode {
146146
@SuppressWarnings("unused")
147147
@Specialization
148-
public Object check(PBytes obj) {
148+
public static Object check(PBytes obj) {
149149
return true;
150150
}
151151

152152
@Specialization(guards = "!isPBytes(obj)")
153-
public Object check(VirtualFrame frame, Object obj,
153+
public static Object check(VirtualFrame frame, Object obj,
154154
@Cached GetClassNode getClassNode,
155155
@Cached IsSubtypeNode isSubtypeNode) {
156156
return isSubtypeNode.execute(frame, getClassNode.execute(obj), PythonBuiltinClassType.PBytes);
@@ -253,7 +253,7 @@ public Object fromFormat(VirtualFrame frame, String fmt, Object args,
253253
@GenerateNodeFactory
254254
public abstract static class PyBytesFromObjectNode extends PythonUnaryBuiltinNode {
255255
@Specialization(guards = {"isPBytes(obj) || isBytesSubtype(frame, obj, getClassNode, isSubtypeNode)"})
256-
public Object fromObject(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") Object obj,
256+
public static Object fromObject(@SuppressWarnings("unused") VirtualFrame frame, @SuppressWarnings("unused") Object obj,
257257
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
258258
@SuppressWarnings("unused") @Cached IsSubtypeNode isSubtypeNode) {
259259
return obj;
@@ -283,11 +283,11 @@ public Object fromObject(VirtualFrame frame, Object obj,
283283
return raiseNativeNode.raise(frame, getContext().getNativeNull(), TypeError, CANNOT_CONVERT_P_OBJ_TO_S, obj, "bytes");
284284
}
285285

286-
protected boolean isBytesSubtype(VirtualFrame frame, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) {
286+
protected static boolean isBytesSubtype(VirtualFrame frame, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode) {
287287
return isSubtypeNode.execute(frame, getClassNode.execute(obj), PythonBuiltinClassType.PBytes);
288288
}
289289

290-
protected boolean isAcceptedSubtype(VirtualFrame frame, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode, PyObjectLookupAttr lookupAttrNode) {
290+
protected static boolean isAcceptedSubtype(VirtualFrame frame, Object obj, GetClassNode getClassNode, IsSubtypeNode isSubtypeNode, PyObjectLookupAttr lookupAttrNode) {
291291
Object klass = getClassNode.execute(obj);
292292
return isSubtypeNode.execute(frame, klass, PythonBuiltinClassType.PList) ||
293293
isSubtypeNode.execute(frame, klass, PythonBuiltinClassType.PTuple) ||
@@ -341,7 +341,7 @@ Object doNativePointer(VirtualFrame frame, Object nativePointer, long size,
341341
public abstract static class PyBytesResize extends PythonBinaryBuiltinNode {
342342

343343
@Specialization
344-
int resize(VirtualFrame frame, PBytes self, long newSizeL,
344+
static int resize(VirtualFrame frame, PBytes self, long newSizeL,
345345
@Cached SequenceStorageNodes.LenNode lenNode,
346346
@Cached SequenceStorageNodes.GetItemNode getItemNode,
347347
@Cached PyNumberAsSizeNode asSizeNode,
@@ -359,7 +359,7 @@ int resize(VirtualFrame frame, PBytes self, long newSizeL,
359359
}
360360

361361
@Specialization(guards = "!isBytes(self)")
362-
int add(VirtualFrame frame, Object self, @SuppressWarnings("unused") Object o,
362+
static int add(VirtualFrame frame, Object self, @SuppressWarnings("unused") Object o,
363363
@Cached PRaiseNativeNode raiseNativeNode) {
364364
return raiseNativeNode.raiseInt(frame, -1, SystemError, ErrorMessages.EXPECTED_S_NOT_P, "a set object", self);
365365
}

0 commit comments

Comments
 (0)