@@ -606,18 +606,26 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
606
606
*/
607
607
@ Children private Node [] adoptedNodes ;
608
608
@ Child private CalleeContext calleeContext = CalleeContext .create ();
609
- // TODO: make some of those lazy?
610
609
@ Child private ExceptionStateNodes .GetCaughtExceptionNode getCaughtExceptionNode ;
611
610
@ Child private ChainExceptionsNode chainExceptionsNode ;
612
611
613
- @ Child private MaterializeFrameNode traceMaterializeFrameNewNode ;
614
- @ Child private MaterializeFrameNode traceMaterializeFrameExistingNode ;
615
612
private static final byte TRACE_PROFILE_LINE = 1 ;
616
613
private static final byte TRACE_PROFILE_NEW_FRAME = 1 << 1 ;
617
614
private static final byte TRACE_PROFILE_EXISTING_FRAME = 1 << 2 ;
618
615
private static final byte TRACE_PROFILE_SYNC_LOCALS_BACK = 1 << 3 ;
619
616
private static final byte TRACE_PROFILE_DID_JUMP = 1 << 4 ;
620
- @ CompilationFinal (dimensions = 1 ) byte [] traceProfileData ;
617
+
618
+ private static final class TracingNodes extends Node {
619
+ @ Child MaterializeFrameNode traceMaterializeFrameNewNode = MaterializeFrameNode .create ();
620
+ @ Child MaterializeFrameNode traceMaterializeFrameExistingNode = MaterializeFrameNode .create ();
621
+ @ CompilationFinal (dimensions = 1 ) byte [] traceProfileData ;
622
+
623
+ public TracingNodes (int bytecodeLength ) {
624
+ traceProfileData = new byte [bytecodeLength ];
625
+ }
626
+ }
627
+
628
+ @ Child private TracingNodes tracingNodes ;
621
629
622
630
@ CompilationFinal private Object osrMetadata ;
623
631
@@ -3210,33 +3218,30 @@ private int generalizeBinarySubscr(VirtualFrame virtualFrame, int stackTop, int
3210
3218
return bytecodeBinarySubscrOO (virtualFrame , stackTop , bci , localNodes , bcioffset );
3211
3219
}
3212
3220
3213
- private void enterTraceProfile ( int bci , byte profileBits ) {
3214
- if (traceProfileData == null ) {
3221
+ private TracingNodes getTracingNodes ( ) {
3222
+ if (tracingNodes == null ) {
3215
3223
CompilerDirectives .transferToInterpreterAndInvalidate ();
3216
- traceProfileData = new byte [ bytecode .length ] ;
3224
+ tracingNodes = insert ( new TracingNodes ( bytecode .length )) ;
3217
3225
}
3218
- if ((traceProfileData [bci ] & profileBits ) == 0 ) {
3226
+ return tracingNodes ;
3227
+ }
3228
+
3229
+ private void enterTraceProfile (int bci , byte profileBits ) {
3230
+ byte [] profile = getTracingNodes ().traceProfileData ;
3231
+ if ((profile [bci ] & profileBits ) == 0 ) {
3219
3232
CompilerDirectives .transferToInterpreterAndInvalidate ();
3220
- traceProfileData [bci ] |= profileBits ;
3233
+ profile [bci ] |= profileBits ;
3221
3234
}
3222
3235
}
3223
3236
3224
3237
private PFrame ensurePyFrame (VirtualFrame virtualFrame , int bci ) {
3225
3238
PFrame pyFrame = PArguments .getCurrentFrameInfo (virtualFrame ).getPyFrame ();
3226
3239
if (pyFrame == null ) {
3227
- if (traceMaterializeFrameNewNode == null ) {
3228
- CompilerDirectives .transferToInterpreterAndInvalidate ();
3229
- traceMaterializeFrameNewNode = insert (MaterializeFrameNode .create ());
3230
- }
3231
3240
enterTraceProfile (bci , TRACE_PROFILE_NEW_FRAME );
3232
- return traceMaterializeFrameNewNode .execute (virtualFrame , this , true , true );
3241
+ return getTracingNodes (). traceMaterializeFrameNewNode .execute (virtualFrame , this , true , true );
3233
3242
} else {
3234
- if (traceMaterializeFrameExistingNode == null ) {
3235
- CompilerDirectives .transferToInterpreterAndInvalidate ();
3236
- traceMaterializeFrameExistingNode = insert (MaterializeFrameNode .create ());
3237
- }
3238
3243
enterTraceProfile (bci , TRACE_PROFILE_EXISTING_FRAME );
3239
- return traceMaterializeFrameExistingNode .execute (virtualFrame , this , true , true );
3244
+ return getTracingNodes (). traceMaterializeFrameExistingNode .execute (virtualFrame , this , true , true );
3240
3245
}
3241
3246
}
3242
3247
0 commit comments