Skip to content

Commit 4f1dd1a

Browse files
otethaltimfel
authored andcommitted
Fix truffle warnings
1 parent b6fbb86 commit 4f1dd1a

File tree

92 files changed

+1034
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1034
-842
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,8 @@ private void initializeImportlib() {
909909
if (zipimporter == PNone.NO_VALUE) {
910910
LOGGER.log(Level.FINE, () -> "# can't import zipimport.zipimporter");
911911
} else {
912-
SequenceStorageNodes.InsertItemNode insertItem = SequenceStorageNodes.InsertItemNode.getUncached();
913912
SequenceStorage store = pathHooksList.getSequenceStorage();
914-
pathHooksList.setSequenceStorage(insertItem.execute(store, 0, zipimporter));
913+
pathHooksList.setSequenceStorage(SequenceStorageNodes.InsertItemNode.executeUncached(store, 0, zipimporter));
915914
LOGGER.log(Level.FINE, () -> "# installed zipimport hook");
916915
}
917916
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ PArray array(Object cls, TruffleString typeCode, @SuppressWarnings("unused") PNo
183183

184184
@Specialization
185185
PArray arrayWithRangeInitializer(Object cls, TruffleString typeCode, PIntRange range,
186+
@Bind("this") Node inliningTarget,
186187
@Shared @Cached ArrayNodes.PutValueNode putValueNode,
187188
@Shared @Cached TruffleString.CodePointLengthNode lengthNode,
188189
@Shared @Cached TruffleString.CodePointAtIndexNode atIndexNode) {
@@ -200,7 +201,7 @@ PArray arrayWithRangeInitializer(Object cls, TruffleString typeCode, PIntRange r
200201
int len = range.getIntLength();
201202

202203
for (int index = 0, value = start; index < len; index++, value += step) {
203-
putValueNode.execute(null, array, index, value);
204+
putValueNode.execute(null, inliningTarget, array, index, value);
204205
}
205206

206207
return array;
@@ -231,7 +232,9 @@ PArray arrayWithStringInitializer(VirtualFrame frame, Object cls, TruffleString
231232
}
232233

233234
@Specialization
235+
@SuppressWarnings("truffle-static-method")
234236
PArray arrayArrayInitializer(VirtualFrame frame, Object cls, TruffleString typeCode, PArray initializer,
237+
@Bind("this") Node inliningTarget,
235238
@Shared @Cached ArrayNodes.PutValueNode putValueNode,
236239
@Cached ArrayNodes.GetValueNode getValueNode,
237240
@Shared @Cached TruffleString.CodePointLengthNode lengthNode,
@@ -240,7 +243,7 @@ PArray arrayArrayInitializer(VirtualFrame frame, Object cls, TruffleString typeC
240243
try {
241244
PArray array = getFactory().createArray(cls, typeCode, format, initializer.getLength());
242245
for (int i = 0; i < initializer.getLength(); i++) {
243-
putValueNode.execute(frame, array, i, getValueNode.execute(initializer, i));
246+
putValueNode.execute(frame, inliningTarget, array, i, getValueNode.execute(inliningTarget, initializer, i));
244247
}
245248
return array;
246249
} catch (OverflowException e) {
@@ -250,7 +253,9 @@ PArray arrayArrayInitializer(VirtualFrame frame, Object cls, TruffleString typeC
250253
}
251254

252255
@Specialization(guards = "!isBytes(initializer)")
256+
@SuppressWarnings("truffle-static-method")
253257
PArray arraySequenceInitializer(VirtualFrame frame, Object cls, TruffleString typeCode, PSequence initializer,
258+
@Bind("this") Node inliningTarget,
254259
@Shared @Cached ArrayNodes.PutValueNode putValueNode,
255260
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
256261
@Cached SequenceStorageNodes.GetItemScalarNode getItemNode,
@@ -262,7 +267,7 @@ PArray arraySequenceInitializer(VirtualFrame frame, Object cls, TruffleString ty
262267
try {
263268
PArray array = getFactory().createArray(cls, typeCode, format, length);
264269
for (int i = 0; i < length; i++) {
265-
putValueNode.execute(frame, array, i, getItemNode.execute(storage, i));
270+
putValueNode.execute(frame, inliningTarget, array, i, getItemNode.execute(storage, i));
266271
}
267272
return array;
268273
} catch (OverflowException e) {
@@ -302,7 +307,7 @@ PArray arrayIteratorInitializer(VirtualFrame frame, Object cls, TruffleString ty
302307
CompilerDirectives.transferToInterpreterAndInvalidate();
303308
throw raise(MemoryError);
304309
}
305-
putValueNode.execute(frame, array, length - 1, nextValue);
310+
putValueNode.execute(frame, inliningTarget, array, length - 1, nextValue);
306311
}
307312

308313
array.setLength(length);

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

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@
131131
import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
132132
import com.oracle.graal.python.builtins.objects.common.HashingStorage;
133133
import com.oracle.graal.python.builtins.objects.common.SequenceNodes.GetObjectArrayNode;
134-
import com.oracle.graal.python.builtins.objects.common.SequenceNodesFactory.GetObjectArrayNodeGen;
135134
import com.oracle.graal.python.builtins.objects.complex.PComplex;
136135
import com.oracle.graal.python.builtins.objects.dict.PDict;
137136
import com.oracle.graal.python.builtins.objects.ellipsis.PEllipsis;
@@ -318,13 +317,14 @@ PBytes doCallBytes(VirtualFrame frame, Object cls, Object source, PNone encoding
318317
throw raise(TypeError, ErrorMessages.RETURNED_NONBYTES, T___BYTES__, bytes);
319318
}
320319
}
321-
return factory().createBytes(cls, bytesInitNode.execute(frame, source, encoding, errors));
320+
return factory().createBytes(cls, bytesInitNode.execute(frame, inliningTarget, source, encoding, errors));
322321
}
323322

324323
@Specialization(guards = {"isNoValue(source) || (!isNoValue(encoding) || !isNoValue(errors))"})
325324
PBytes dontCallBytes(VirtualFrame frame, Object cls, Object source, Object encoding, Object errors,
325+
@Bind("this") Node inliningTarget,
326326
@Shared @Cached BytesNodes.BytesInitNode bytesInitNode) {
327-
return factory().createBytes(cls, bytesInitNode.execute(frame, source, encoding, errors));
327+
return factory().createBytes(cls, bytesInitNode.execute(frame, inliningTarget, source, encoding, errors));
328328
}
329329
}
330330

@@ -1056,8 +1056,9 @@ public PFrozenSet subFrozensetIdentity(Object cls, PFrozenSet arg,
10561056

10571057
@Specialization(guards = {"!isNoValue(iterable)", "!isPFrozenSet(iterable)"})
10581058
public PFrozenSet frozensetIterable(VirtualFrame frame, Object cls, Object iterable,
1059+
@Bind("this") Node inliningTarget,
10591060
@Cached HashingCollectionNodes.GetClonedHashingStorageNode getHashingStorageNode) {
1060-
HashingStorage storage = getHashingStorageNode.doNoValue(frame, iterable);
1061+
HashingStorage storage = getHashingStorageNode.doNoValue(frame, inliningTarget, iterable);
10611062
return factory().createFrozenSet(cls, storage);
10621063
}
10631064
}
@@ -2313,8 +2314,9 @@ public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD
23132314
@Specialization
23142315
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, @SuppressWarnings("unused") PNone defaultArgs,
23152316
PTuple closure,
2317+
@Bind("this") Node inliningTarget,
23162318
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
2317-
return factory().createFunction(T_LAMBDA_NAME, code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure)));
2319+
return factory().createFunction(T_LAMBDA_NAME, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure)));
23182320
}
23192321

23202322
@Specialization
@@ -2326,30 +2328,34 @@ public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PD
23262328

23272329
@Specialization
23282330
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, @SuppressWarnings("unused") PNone defaultArgs, PTuple closure,
2331+
@Bind("this") Node inliningTarget,
23292332
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
2330-
return factory().createFunction(name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(closure)));
2333+
return factory().createFunction(name, code, globals, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure)));
23312334
}
23322335

23332336
@Specialization
23342337
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, @SuppressWarnings("unused") PNone name, PTuple defaultArgs,
23352338
@SuppressWarnings("unused") PNone closure,
2339+
@Bind("this") Node inliningTarget,
23362340
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
23372341
// TODO split defaults of positional args from kwDefaults
2338-
return factory().createFunction(code.getName(), code, globals, getObjectArrayNode.execute(defaultArgs), null, null);
2342+
return factory().createFunction(code.getName(), code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null);
23392343
}
23402344

23412345
@Specialization
23422346
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, PTuple defaultArgs, @SuppressWarnings("unused") PNone closure,
2347+
@Bind("this") Node inliningTarget,
23432348
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
23442349
// TODO split defaults of positional args from kwDefaults
2345-
return factory().createFunction(name, code, globals, getObjectArrayNode.execute(defaultArgs), null, null);
2350+
return factory().createFunction(name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, null);
23462351
}
23472352

23482353
@Specialization
23492354
public PFunction function(@SuppressWarnings("unused") Object cls, PCode code, PDict globals, TruffleString name, PTuple defaultArgs, PTuple closure,
2355+
@Bind("this") Node inliningTarget,
23502356
@Shared("getObjectArrayNode") @Cached GetObjectArrayNode getObjectArrayNode) {
23512357
// TODO split defaults of positional args from kwDefaults
2352-
return factory().createFunction(name, code, globals, getObjectArrayNode.execute(defaultArgs), null, PCell.toCellArray(getObjectArrayNode.execute(closure)));
2358+
return factory().createFunction(name, code, globals, getObjectArrayNode.execute(inliningTarget, defaultArgs), null, PCell.toCellArray(getObjectArrayNode.execute(inliningTarget, closure)));
23532359
}
23542360

23552361
@Fallback
@@ -2375,7 +2381,6 @@ public PFunction function(Object cls, Object method_def, Object def, Object name
23752381
@GenerateNodeFactory
23762382
public abstract static class TypeNode extends PythonVarargsBuiltinNode {
23772383
@Child private IsSubtypeNode isSubtypeNode;
2378-
@Child private GetObjectArrayNode getObjectArrayNode;
23792384
@Child private IsAcceptableBaseNode isAcceptableBaseNode;
23802385

23812386
public abstract Object execute(VirtualFrame frame, Object cls, Object name, Object bases, Object dict, PKeyword[] kwds);
@@ -2411,11 +2416,12 @@ Object typeNew(VirtualFrame frame, Object cls, Object wName, PTuple bases, PDict
24112416
@Cached PyObjectLookupAttr lookupMroEntriesNode,
24122417
@Cached CastToTruffleStringNode castStr,
24132418
@Cached CallNode callNewFuncNode,
2414-
@Cached CreateTypeNode createType) {
2419+
@Cached CreateTypeNode createType,
2420+
@Cached GetObjectArrayNode getObjectArrayNode) {
24152421
// Determine the proper metatype to deal with this
24162422
TruffleString name = castStr.execute(wName);
24172423
Object metaclass = cls;
2418-
Object winner = calculateMetaclass(frame, inliningTarget, metaclass, bases, getClassNode, isTypeNode, lookupMroEntriesNode);
2424+
Object winner = calculateMetaclass(frame, inliningTarget, metaclass, bases, getClassNode, isTypeNode, lookupMroEntriesNode, getObjectArrayNode);
24192425
if (winner != metaclass) {
24202426
Object newFunc = getNewFuncNode.execute(winner);
24212427
if (newFunc instanceof PBuiltinMethod && (((PBuiltinMethod) newFunc).getFunction().getFunctionRootNode().getCallTarget() == getRootNode().getCallTarget())) {
@@ -2442,9 +2448,9 @@ Object generic(@SuppressWarnings("unused") Object cls, @SuppressWarnings("unused
24422448
}
24432449

24442450
private Object calculateMetaclass(VirtualFrame frame, Node inliningTarget, Object cls, PTuple bases, InlinedGetClassNode getClassNode, IsTypeNode isTypeNode,
2445-
PyObjectLookupAttr lookupMroEntries) {
2451+
PyObjectLookupAttr lookupMroEntries, GetObjectArrayNode getObjectArrayNode) {
24462452
Object winner = cls;
2447-
for (Object base : ensureGetObjectArrayNode().execute(bases)) {
2453+
for (Object base : getObjectArrayNode.execute(inliningTarget, bases)) {
24482454
if (!isTypeNode.execute(base) && lookupMroEntries.execute(frame, base, T___MRO_ENTRIES__) != PNone.NO_VALUE) {
24492455
throw raise(TypeError, ErrorMessages.TYPE_DOESNT_SUPPORT_MRO_ENTRY_RESOLUTION);
24502456
}
@@ -2493,14 +2499,6 @@ Object typeGeneric(VirtualFrame frame, Object cls, Object name, Object bases, Ob
24932499
return nextTypeNode.execute(frame, cls, name, bases, dict, kwds);
24942500
}
24952501

2496-
private GetObjectArrayNode ensureGetObjectArrayNode() {
2497-
if (getObjectArrayNode == null) {
2498-
CompilerDirectives.transferToInterpreterAndInvalidate();
2499-
getObjectArrayNode = insert(GetObjectArrayNodeGen.create());
2500-
}
2501-
return getObjectArrayNode;
2502-
}
2503-
25042502
private IsAcceptableBaseNode ensureIsAcceptableBaseNode() {
25052503
if (isAcceptableBaseNode == null) {
25062504
CompilerDirectives.transferToInterpreterAndInvalidate();
@@ -2792,18 +2790,19 @@ PCode call(VirtualFrame frame, @SuppressWarnings("unused") Object cls, int argco
27922790
PTuple varnames, TruffleString filename, TruffleString name,
27932791
int firstlineno, PBytes linetable,
27942792
PTuple freevars, PTuple cellvars,
2793+
@Bind("this") Node inliningTarget,
27952794
@CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib,
27962795
@Cached CodeNodes.CreateCodeNode createCodeNode,
27972796
@Cached GetObjectArrayNode getObjectArrayNode,
27982797
@Cached CastToTruffleStringNode castToTruffleStringNode) {
27992798
byte[] codeBytes = bufferLib.getCopiedByteArray(codestring);
28002799
byte[] linetableBytes = bufferLib.getCopiedByteArray(linetable);
28012800

2802-
Object[] constantsArr = getObjectArrayNode.execute(constants);
2803-
TruffleString[] namesArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(names), castToTruffleStringNode);
2804-
TruffleString[] varnamesArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(varnames), castToTruffleStringNode);
2805-
TruffleString[] freevarsArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(freevars), castToTruffleStringNode);
2806-
TruffleString[] cellcarsArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(cellvars), castToTruffleStringNode);
2801+
Object[] constantsArr = getObjectArrayNode.execute(inliningTarget, constants);
2802+
TruffleString[] namesArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(inliningTarget, names), castToTruffleStringNode);
2803+
TruffleString[] varnamesArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(inliningTarget, varnames), castToTruffleStringNode);
2804+
TruffleString[] freevarsArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(inliningTarget, freevars), castToTruffleStringNode);
2805+
TruffleString[] cellcarsArr = objectArrayToTruffleStringArray(getObjectArrayNode.execute(inliningTarget, cellvars), castToTruffleStringNode);
28072806

28082807
return createCodeNode.execute(frame, argcount, posonlyargcount, kwonlyargcount,
28092808
nlocals, stacksize, flags,

0 commit comments

Comments
 (0)