File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -463,6 +463,7 @@ abstract static class NormalizingNode extends PNodeWithContext {
463
463
@ Child private NormalizeIndexNode normalizeIndexNode ;
464
464
@ Child private PythonObjectLibrary lib ;
465
465
@ CompilationFinal private ValueProfile storeProfile ;
466
+ @ CompilationFinal private ConditionProfile gotFrameProfile ;
466
467
467
468
protected NormalizingNode (NormalizeIndexNode normalizeIndexNode ) {
468
469
this .normalizeIndexNode = normalizeIndexNode ;
@@ -477,7 +478,16 @@ private PythonObjectLibrary getLibrary() {
477
478
}
478
479
479
480
protected final int normalizeIndex (VirtualFrame frame , Object idx , SequenceStorage store ) {
480
- int intIdx = getLibrary ().asSizeWithState (idx , PythonBuiltinClassType .IndexError , PArguments .getThreadState (frame ));
481
+ if (gotFrameProfile == null ) {
482
+ CompilerDirectives .transferToInterpreterAndInvalidate ();
483
+ gotFrameProfile = ConditionProfile .createBinaryProfile ();
484
+ }
485
+ int intIdx ;
486
+ if (gotFrameProfile .profile (frame != null )) {
487
+ intIdx = getLibrary ().asSizeWithState (idx , PythonBuiltinClassType .IndexError , PArguments .getThreadState (frame ));
488
+ } else {
489
+ intIdx = getLibrary ().asSize (idx , PythonBuiltinClassType .IndexError );
490
+ }
481
491
if (normalizeIndexNode != null ) {
482
492
return normalizeIndexNode .execute (intIdx , getStoreProfile ().profile (store ).length ());
483
493
}
Original file line number Diff line number Diff line change @@ -352,7 +352,7 @@ public static PDict getGeneratorFrameLocals(Object[] arguments) {
352
352
}
353
353
354
354
public static ThreadState getThreadState (VirtualFrame frame ) {
355
- assert frame != null ;
355
+ assert frame != null : "cannot get thread state without a frame" ;
356
356
return new ThreadState (PArguments .getCurrentFrameInfo (frame ), PArguments .getException (frame ));
357
357
}
358
358
You can’t perform that action at this time.
0 commit comments