Skip to content

Commit 2496082

Browse files
committed
Resolve more DSL warnings in the builtin modules Java package
1 parent fe69d51 commit 2496082

26 files changed

+202
-126
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ PArray arraySequenceInitializer(VirtualFrame frame, Object cls, TruffleString ty
272272
}
273273

274274
@Specialization(guards = {"!isBytes(initializer)", "!isString(initializer)", "!isPSequence(initializer)"})
275+
@SuppressWarnings("truffle-static-method")
275276
PArray arrayIteratorInitializer(VirtualFrame frame, Object cls, TruffleString typeCode, Object initializer,
276277
@Bind("this") Node inliningTarget,
277278
@Cached PyObjectGetIter getIter,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ PBytes doEmpty(VirtualFrame frame, Object cls, PNone source, PNone encoding, PNo
293293
}
294294

295295
@Specialization(guards = "!isNoValue(source)")
296+
@SuppressWarnings("truffle-static-method")
296297
PBytes doCallBytes(VirtualFrame frame, Object cls, Object source, PNone encoding, PNone errors,
297298
@Bind("this") Node inliningTarget,
298299
@Cached InlinedGetClassNode getClassNode,
@@ -892,6 +893,7 @@ public PythonObject reversed(Object cls, TruffleString value) {
892893
}
893894

894895
@Specialization(guards = {"!isString(sequence)", "!isPRange(sequence)"})
896+
@SuppressWarnings("truffle-static-method")
895897
public Object reversed(VirtualFrame frame, Object cls, Object sequence,
896898
@Bind("this") Node inliningTarget,
897899
@Cached InlinedGetClassNode getClassNode,
@@ -980,6 +982,7 @@ protected final boolean isPrimitiveFloat(Node inliningTarget, Object cls, Inline
980982

981983
@Specialization(guards = {"isPrimitiveFloat(this, cls, isPrimitiveFloatProfile)", "!isNoValue(obj)"}, //
982984
replaces = "floatFromString", limit = "1")
985+
@SuppressWarnings("truffle-static-method")
983986
double floatFromObject(VirtualFrame frame, @SuppressWarnings("unused") Object cls, Object obj,
984987
@Bind("this") Node inliningTarget,
985988
@Shared("isFloat") @Cached InlineIsBuiltinClassProfile isPrimitiveFloatProfile,
@@ -1499,6 +1502,7 @@ Object fail(Object cls, Object arg, Object base) {
14991502
}
15001503

15011504
@Specialization(guards = {"isNoValue(base)", "!isNoValue(obj)", "!isHandledType(obj)"})
1505+
@SuppressWarnings("truffle-static-method")
15021506
@Megamorphic
15031507
Object createIntGeneric(VirtualFrame frame, Object cls, Object obj, @SuppressWarnings("unused") PNone base,
15041508
@Bind("this") Node inliningTarget,
@@ -2058,6 +2062,7 @@ Object strOneArg(VirtualFrame frame, Object strClass, Object obj, @SuppressWarni
20582062
}
20592063

20602064
@Specialization(guards = {"!isNativeClass(strClass)", "!isNoValue(encoding) || !isNoValue(errors)"}, limit = "3")
2065+
@SuppressWarnings("truffle-static-method")
20612066
Object doBuffer(VirtualFrame frame, Object strClass, Object obj, Object encoding, Object errors,
20622067
@Bind("this") Node inliningTarget,
20632068
@Shared("isPrimitive") @Cached InlineIsBuiltinClassProfile isPrimitiveProfile,
@@ -2332,6 +2337,7 @@ public Object varArgExecute(VirtualFrame frame, Object self, Object[] arguments,
23322337
}
23332338

23342339
@Specialization(guards = "isString(wName)")
2340+
@SuppressWarnings("truffle-static-method")
23352341
Object typeNew(VirtualFrame frame, Object cls, Object wName, PTuple bases, PDict namespaceOrig, PKeyword[] kwds,
23362342
@Bind("this") Node inliningTarget,
23372343
@Cached InlinedGetClassNode getClassNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@
227227
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
228228
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
229229
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinObjectProfile;
230-
import com.oracle.graal.python.nodes.object.GetClassNode;
231230
import com.oracle.graal.python.nodes.object.GetOrCreateDictNode;
232231
import com.oracle.graal.python.nodes.object.InlinedGetClassNode;
233232
import com.oracle.graal.python.nodes.object.InlinedGetClassNode.GetPythonObjectClassNode;
@@ -486,6 +485,7 @@ static boolean doHashColl(VirtualFrame frame, PHashingCollection object,
486485
}
487486

488487
@Specialization
488+
@SuppressWarnings("truffle-static-method")
489489
boolean doObject(VirtualFrame frame, Object object,
490490
@Bind("this") Node inliningTarget,
491491
@Cached PyObjectGetIter getIter,
@@ -543,6 +543,7 @@ static boolean doHashColl(VirtualFrame frame, PHashingCollection object,
543543
}
544544

545545
@Specialization
546+
@SuppressWarnings("truffle-static-method")
546547
boolean doObject(VirtualFrame frame, Object object,
547548
@Bind("this") Node inliningTarget,
548549
@Cached PyObjectGetIter getIter,
@@ -639,6 +640,7 @@ TruffleString doPI(PInt x,
639640
}
640641

641642
@Specialization(replaces = {"doL", "doD", "doPI"})
643+
@SuppressWarnings("truffle-static-method")
642644
TruffleString doO(VirtualFrame frame, Object x,
643645
@Bind("this") Node inliningTarget,
644646
@Cached InlinedConditionProfile isMinLong,
@@ -1305,7 +1307,7 @@ public static GetAttrNode create() {
13051307

13061308
public abstract Object executeWithArgs(VirtualFrame frame, Object primary, TruffleString name, Object defaultValue);
13071309

1308-
@SuppressWarnings("unused")
1310+
@SuppressWarnings({"unused", "truffle-static-method"})
13091311
@Specialization(limit = "getAttributeAccessInlineCacheMaxDepth()", guards = {"stringEquals(cachedName, name, equalNode, inliningTarget, stringProfile)", "isNoValue(defaultValue)"})
13101312
public Object getAttrDefault(VirtualFrame frame, Object primary, TruffleString name, PNone defaultValue,
13111313
@Bind("this") Node inliningTarget,
@@ -1316,7 +1318,7 @@ public Object getAttrDefault(VirtualFrame frame, Object primary, TruffleString n
13161318
return getAttributeNode.executeObject(frame, primary);
13171319
}
13181320

1319-
@SuppressWarnings("unused")
1321+
@SuppressWarnings({"unused", "truffle-static-method"})
13201322
@Specialization(limit = "getAttributeAccessInlineCacheMaxDepth()", guards = {"stringEquals(cachedName, name, equalNode, inliningTarget, stringProfile)", "!isNoValue(defaultValue)"})
13211323
Object getAttr(VirtualFrame frame, Object primary, TruffleString name, Object defaultValue,
13221324
@Bind("this") Node inliningTarget,
@@ -1340,6 +1342,7 @@ Object getAttrFromObject(VirtualFrame frame, Object primary, TruffleString name,
13401342
}
13411343

13421344
@Specialization(replaces = {"getAttr", "getAttrDefault"}, guards = "!isNoValue(defaultValue)")
1345+
@SuppressWarnings("truffle-static-method")
13431346
Object getAttrFromObject(VirtualFrame frame, Object primary, TruffleString name, Object defaultValue,
13441347
@Bind("this") Node inliningTarget,
13451348
@Cached GetAnyAttributeNode getAttributeNode,
@@ -1509,13 +1512,14 @@ private static TriState isInstanceCheckInternal(VirtualFrame frame, Object insta
15091512

15101513
@Specialization(guards = "isPythonClass(cls)")
15111514
static boolean isInstance(VirtualFrame frame, Object instance, Object cls,
1515+
@Bind("this") Node inliningTarget,
15121516
@Shared("instanceCheck") @Cached("create(InstanceCheck)") LookupAndCallBinaryNode instanceCheckNode,
15131517
@Shared("boolCast") @Cached("createIfTrueNode()") CoerceToBooleanNode castToBooleanNode,
1514-
@Cached GetClassNode getClassNode,
1515-
@Cached TypeNodes.IsSameTypeNode isSameTypeNode,
1518+
@Cached InlinedGetClassNode getClassNode,
1519+
@Cached TypeNodes.InlinedIsSameTypeNode isSameTypeNode,
15161520
@Cached IsSubtypeNode isSubtypeNode) {
1517-
Object instanceClass = getClassNode.execute(instance);
1518-
return isSameTypeNode.execute(instanceClass, cls) || isSubtypeNode.execute(frame, instanceClass, cls)//
1521+
Object instanceClass = getClassNode.execute(inliningTarget, instance);
1522+
return isSameTypeNode.execute(inliningTarget, instanceClass, cls) || isSubtypeNode.execute(frame, instanceClass, cls)//
15191523
|| isInstanceCheckInternal(frame, instance, cls, instanceCheckNode, castToBooleanNode) == TriState.TRUE;
15201524
}
15211525

@@ -2165,19 +2169,19 @@ public abstract static class SumFunctionNode extends PythonBuiltinNode {
21652169
@Specialization(rewriteOn = UnexpectedResultException.class)
21662170
int sumIntNone(VirtualFrame frame, Object arg1, @SuppressWarnings("unused") PNone start,
21672171
@Bind("this") Node inliningTarget,
2168-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile1,
2169-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile2,
2170-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile3,
2172+
@Shared @Cached IsBuiltinObjectProfile errorProfile1,
2173+
@Shared @Cached IsBuiltinObjectProfile errorProfile2,
2174+
@Shared @Cached IsBuiltinObjectProfile errorProfile3,
21712175
@Shared("getIter") @Cached PyObjectGetIter getIter) throws UnexpectedResultException {
21722176
return sumIntInternal(frame, arg1, 0, getIter, inliningTarget, errorProfile1, errorProfile2, errorProfile3);
21732177
}
21742178

21752179
@Specialization(rewriteOn = UnexpectedResultException.class)
21762180
int sumIntInt(VirtualFrame frame, Object arg1, int start,
21772181
@Bind("this") Node inliningTarget,
2178-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile1,
2179-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile2,
2180-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile3,
2182+
@Shared @Cached IsBuiltinObjectProfile errorProfile1,
2183+
@Shared @Cached IsBuiltinObjectProfile errorProfile2,
2184+
@Shared @Cached IsBuiltinObjectProfile errorProfile3,
21812185
@Shared("getIter") @Cached PyObjectGetIter getIter) throws UnexpectedResultException {
21822186
return sumIntInternal(frame, arg1, start, getIter, inliningTarget, errorProfile1, errorProfile2, errorProfile3);
21832187
}
@@ -2209,9 +2213,9 @@ private int sumIntInternal(VirtualFrame frame, Object arg1, int start, PyObjectG
22092213
@Specialization(rewriteOn = UnexpectedResultException.class)
22102214
double sumDoubleDouble(VirtualFrame frame, Object arg1, double start,
22112215
@Bind("this") Node inliningTarget,
2212-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile1,
2213-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile2,
2214-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile3,
2216+
@Shared @Cached IsBuiltinObjectProfile errorProfile1,
2217+
@Shared @Cached IsBuiltinObjectProfile errorProfile2,
2218+
@Shared @Cached IsBuiltinObjectProfile errorProfile3,
22152219
@Shared("getIter") @Cached PyObjectGetIter getIter) throws UnexpectedResultException {
22162220
return sumDoubleInternal(frame, arg1, start, getIter, inliningTarget, errorProfile1, errorProfile2, errorProfile3);
22172221
}
@@ -2243,7 +2247,7 @@ private double sumDoubleInternal(VirtualFrame frame, Object arg1, double start,
22432247
@Specialization(replaces = {"sumIntNone", "sumIntInt", "sumDoubleDouble"})
22442248
Object sum(VirtualFrame frame, Object arg1, Object start,
22452249
@Bind("this") Node inliningTarget,
2246-
/* @Shared */ @Cached IsBuiltinObjectProfile errorProfile1,
2250+
@Shared @Cached IsBuiltinObjectProfile errorProfile1,
22472251
@Shared("getIter") @Cached PyObjectGetIter getIter,
22482252
@Cached InlinedConditionProfile hasStart) {
22492253
if (PGuards.isString(start)) {
@@ -2407,7 +2411,8 @@ abstract static class CalculateMetaclassNode extends PNodeWithRaise {
24072411
/* Determine the most derived metatype. */
24082412
@Specialization
24092413
Object calculate(Object metatype, PTuple bases,
2410-
@Cached GetClassNode getClass,
2414+
@Bind("this") Node inliningTarget,
2415+
@Cached InlinedGetClassNode getClass,
24112416
@Cached IsSubtypeNode isSubType,
24122417
@Cached IsSubtypeNode isSubTypeReverse) {
24132418
CompilerAsserts.neverPartOfCompilation();
@@ -2422,7 +2427,7 @@ Object calculate(Object metatype, PTuple bases,
24222427
Object winner = metatype;
24232428
for (int i = 0; i < nbases; i++) {
24242429
Object tmp = storage.getItemNormalized(i);
2425-
Object tmpType = getClass.execute(tmp);
2430+
Object tmpType = getClass.execute(inliningTarget, tmp);
24262431
if (isSubType.execute(winner, tmpType)) {
24272432
// nothing to do
24282433
} else if (isSubTypeReverse.execute(tmpType, winner)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/FunctoolsModuleBuiltins.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ protected boolean atLeastOneArg(Object[] args) {
186186
}
187187

188188
@Specialization(guards = {"atLeastOneArg(args)", "isPartialWithoutDict(getDict, args, lenNode, false)"}, limit = "1")
189+
@SuppressWarnings("truffle-static-method")
189190
Object createFromPartialWoDictWoKw(Object cls, Object[] args, PKeyword[] keywords,
190191
@Bind("this") Node inliningTarget,
191192
@SuppressWarnings("unused") @Cached GetDictIfExistsNode getDict,
@@ -207,6 +208,7 @@ Object createFromPartialWoDictWoKw(Object cls, Object[] args, PKeyword[] keyword
207208
}
208209

209210
@Specialization(guards = {"atLeastOneArg(args)", "isPartialWithoutDict(getDict, args, lenNode, true)", "!withKeywords(keywords)"}, limit = "1")
211+
@SuppressWarnings("truffle-static-method")
210212
Object createFromPartialWoDictWKw(Object cls, Object[] args, @SuppressWarnings("unused") PKeyword[] keywords,
211213
@Bind("this") Node inliningTarget,
212214
@SuppressWarnings("unused") @Cached GetDictIfExistsNode getDict,
@@ -220,6 +222,7 @@ Object createFromPartialWoDictWKw(Object cls, Object[] args, @SuppressWarnings("
220222
}
221223

222224
@Specialization(guards = {"atLeastOneArg(args)", "isPartialWithoutDict(getDict, args, lenNode, true)", "withKeywords(keywords)"}, limit = "1")
225+
@SuppressWarnings("truffle-static-method")
223226
Object createFromPartialWoDictWKwKw(VirtualFrame frame, Object cls, Object[] args, PKeyword[] keywords,
224227
@Bind("this") Node inliningTarget,
225228
@SuppressWarnings("unused") @Cached GetDictIfExistsNode getDict,
@@ -240,6 +243,7 @@ Object createFromPartialWoDictWKwKw(VirtualFrame frame, Object cls, Object[] arg
240243
}
241244

242245
@Specialization(guards = {"atLeastOneArg(args)", "!isPartialWithoutDict(getDict, args)"}, limit = "1")
246+
@SuppressWarnings("truffle-static-method")
243247
Object createGeneric(Object cls, Object[] args, PKeyword[] keywords,
244248
@Bind("this") Node inliningTarget,
245249
@SuppressWarnings("unused") @Cached GetDictIfExistsNode getDict,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/GraalPythonModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
import com.oracle.graal.python.nodes.function.builtins.PythonQuaternaryBuiltinNode;
117117
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
118118
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
119-
import com.oracle.graal.python.nodes.object.GetClassNode;
119+
import com.oracle.graal.python.nodes.object.InlinedGetClassNode;
120120
import com.oracle.graal.python.nodes.statement.AbstractImportNode;
121121
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
122122
import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
@@ -342,7 +342,7 @@ private static boolean getImporter(PythonModule sysModule, TruffleString inputFi
342342
importer = CallNode.getUncached().execute(hooks[i], inputFilePath);
343343
break;
344344
} catch (PException e) {
345-
if (!IsSubtypeNode.getUncached().execute(GetClassNode.getUncached().execute(e.getUnreifiedException()), ImportError)) {
345+
if (!IsSubtypeNode.getUncached().execute(InlinedGetClassNode.executeUncached(e.getUnreifiedException()), ImportError)) {
346346
throw e;
347347
}
348348
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ItertoolsModuleBuiltins.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ protected Object zeroN(Object iterable, int n) {
505505
}
506506

507507
@Specialization(guards = "n > 0")
508+
@SuppressWarnings("truffle-static-method")
508509
protected Object tee(VirtualFrame frame, Object iterable, int n,
509510
@Bind("this") Node inliningTarget,
510511
@Cached IterNode iterNode,
@@ -576,6 +577,7 @@ Object constructNoR(VirtualFrame frame, Object cls, Object iterable, @SuppressWa
576577
}
577578

578579
@Specialization(guards = {"isTypeNode.execute(cls)", "!isNone(rArg)"}, limit = "1")
580+
@SuppressWarnings("truffle-static-method")
579581
Object construct(VirtualFrame frame, Object cls, Object iterable, Object rArg,
580582
@Bind("this") Node inliningTarget,
581583
@Cached ToArrayNode toArrayNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,9 @@ private void writeObject(Object v) throws IOException {
660660
writeByte(TYPE_NONE);
661661
} else if (v == PNone.NO_VALUE) {
662662
writeByte(TYPE_NOVALUE);
663-
} else if (TypeNodes.IsSameTypeNode.getUncached().execute(v, PythonBuiltinClassType.StopIteration)) {
663+
} else if (TypeNodes.InlinedIsSameTypeNode.executeUncached(v, PythonBuiltinClassType.StopIteration)) {
664664
writeByte(TYPE_STOPITER);
665-
} else if (TypeNodes.IsSameTypeNode.getUncached().execute(v, PythonBuiltinClassType.PEllipsis)) {
665+
} else if (TypeNodes.InlinedIsSameTypeNode.executeUncached(v, PythonBuiltinClassType.PEllipsis)) {
666666
writeByte(TYPE_ELLIPSIS);
667667
} else if (v == Boolean.TRUE || v == pyTrue) {
668668
writeByte(TYPE_TRUE);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
730730
}
731731

732732
@Specialization(limit = "3")
733+
@SuppressWarnings("truffle-static-method")
733734
long doWrite(VirtualFrame frame, int fd, Object dataBuffer,
734735
@Bind("this") Node inliningTarget,
735736
@CachedLibrary("dataBuffer") PythonBufferAccessLibrary bufferLib,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static Object[] doNone(@SuppressWarnings("unused") PNone processArgs) {
115115
}
116116

117117
@Specialization
118+
@SuppressWarnings("truffle-static-method")
118119
Object[] doSequence(VirtualFrame frame, Object processArgs,
119120
@Bind("this") Node inliningTarget,
120121
@Cached FastConstructListNode fastConstructListNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SREModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ protected Source doString(TruffleString pattern, TruffleString flags, TruffleStr
150150
}
151151

152152
@Specialization
153+
@SuppressWarnings("truffle-static-method")
153154
protected Source doGeneric(VirtualFrame frame, Object pattern, TruffleString flags, TruffleString options,
154155
@Bind("this") Node inliningTarget,
155156
@Shared("nonEmptyOptions") @Cached InlinedConditionProfile nonEmptyOptionsProfile,

0 commit comments

Comments
 (0)