@@ -606,18 +606,26 @@ public final class PBytecodeRootNode extends PRootNode implements BytecodeOSRNod
606606 */
607607 @ Children private Node [] adoptedNodes ;
608608 @ Child private CalleeContext calleeContext = CalleeContext .create ();
609- // TODO: make some of those lazy?
610609 @ Child private ExceptionStateNodes .GetCaughtExceptionNode getCaughtExceptionNode ;
611610 @ Child private ChainExceptionsNode chainExceptionsNode ;
612611
613- @ Child private MaterializeFrameNode traceMaterializeFrameNewNode ;
614- @ Child private MaterializeFrameNode traceMaterializeFrameExistingNode ;
615612 private static final byte TRACE_PROFILE_LINE = 1 ;
616613 private static final byte TRACE_PROFILE_NEW_FRAME = 1 << 1 ;
617614 private static final byte TRACE_PROFILE_EXISTING_FRAME = 1 << 2 ;
618615 private static final byte TRACE_PROFILE_SYNC_LOCALS_BACK = 1 << 3 ;
619616 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 ;
621629
622630 @ CompilationFinal private Object osrMetadata ;
623631
@@ -3210,33 +3218,30 @@ private int generalizeBinarySubscr(VirtualFrame virtualFrame, int stackTop, int
32103218 return bytecodeBinarySubscrOO (virtualFrame , stackTop , bci , localNodes , bcioffset );
32113219 }
32123220
3213- private void enterTraceProfile ( int bci , byte profileBits ) {
3214- if (traceProfileData == null ) {
3221+ private TracingNodes getTracingNodes ( ) {
3222+ if (tracingNodes == null ) {
32153223 CompilerDirectives .transferToInterpreterAndInvalidate ();
3216- traceProfileData = new byte [ bytecode .length ] ;
3224+ tracingNodes = insert ( new TracingNodes ( bytecode .length )) ;
32173225 }
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 ) {
32193232 CompilerDirectives .transferToInterpreterAndInvalidate ();
3220- traceProfileData [bci ] |= profileBits ;
3233+ profile [bci ] |= profileBits ;
32213234 }
32223235 }
32233236
32243237 private PFrame ensurePyFrame (VirtualFrame virtualFrame , int bci ) {
32253238 PFrame pyFrame = PArguments .getCurrentFrameInfo (virtualFrame ).getPyFrame ();
32263239 if (pyFrame == null ) {
3227- if (traceMaterializeFrameNewNode == null ) {
3228- CompilerDirectives .transferToInterpreterAndInvalidate ();
3229- traceMaterializeFrameNewNode = insert (MaterializeFrameNode .create ());
3230- }
32313240 enterTraceProfile (bci , TRACE_PROFILE_NEW_FRAME );
3232- return traceMaterializeFrameNewNode .execute (virtualFrame , this , true , true );
3241+ return getTracingNodes (). traceMaterializeFrameNewNode .execute (virtualFrame , this , true , true );
32333242 } else {
3234- if (traceMaterializeFrameExistingNode == null ) {
3235- CompilerDirectives .transferToInterpreterAndInvalidate ();
3236- traceMaterializeFrameExistingNode = insert (MaterializeFrameNode .create ());
3237- }
32383243 enterTraceProfile (bci , TRACE_PROFILE_EXISTING_FRAME );
3239- return traceMaterializeFrameExistingNode .execute (virtualFrame , this , true , true );
3244+ return getTracingNodes (). traceMaterializeFrameExistingNode .execute (virtualFrame , this , true , true );
32403245 }
32413246 }
32423247
0 commit comments