Skip to content

Commit 592fd2d

Browse files
committed
fix another instance of a potential `null' frame
1 parent a026b9b commit 592fd2d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,15 @@ Object doI(String typeName) {
355355
abstract static class PyTuple_New extends PythonUnaryBuiltinNode {
356356
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
357357
PTuple doGeneric(VirtualFrame frame, Object size,
358+
@Cached("createBinaryProfile()") ConditionProfile gotFrame,
358359
@CachedLibrary("size") PythonObjectLibrary lib) {
359-
return factory().createTuple(new Object[lib.asIndexWithState(size, PArguments.getThreadState(frame))]);
360+
int index;
361+
if (gotFrame.profile(frame != null)) {
362+
index = lib.asIndexWithState(size, PArguments.getThreadState(frame));
363+
} else {
364+
index = lib.asIndex(size);
365+
}
366+
return factory().createTuple(new Object[index]);
360367
}
361368
}
362369

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ protected final int normalizeIndex(@SuppressWarnings("unused") VirtualFrame fram
491491
return idx;
492492
}
493493

494-
protected final int normalizeIndex(VirtualFrame frame, long idx, SequenceStorage store) {
495-
int intIdx = getLibrary().asIndexWithState(idx, PArguments.getThreadState(frame));
494+
protected final int normalizeIndex(@SuppressWarnings("unused") VirtualFrame frame, long idx, SequenceStorage store) {
495+
int intIdx = getLibrary().asIndex(idx);
496496
if (normalizeIndexNode != null) {
497497
return normalizeIndexNode.execute(intIdx, getStoreProfile().profile(store).length());
498498
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PArguments.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
352352
}
353353

354354
public static ThreadState getThreadState(VirtualFrame frame) {
355+
assert frame != null;
355356
return new ThreadState(PArguments.getCurrentFrameInfo(frame), PArguments.getException(frame));
356357
}
357358

0 commit comments

Comments
 (0)