File tree Expand file tree Collapse file tree 4 files changed +29
-15
lines changed
compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp Expand file tree Collapse file tree 4 files changed +29
-15
lines changed Original file line number Diff line number Diff line change @@ -73,4 +73,11 @@ public interface CompilationProxies {
7373 * @return a debug closeable object representing the debug context
7474 */
7575 DebugCloseable withDebugContext (DebugContext debugContext );
76+
77+ /**
78+ * Enters the context of a method compilation.
79+ *
80+ * @return a scope for the context
81+ */
82+ DebugCloseable enterCompilationContext ();
7683}
Original file line number Diff line number Diff line change @@ -139,11 +139,7 @@ public List<OperationRecorder.RecordedOperation> collectOperationsForSerializati
139139 return recorder .getCurrentRecordedOperations ();
140140 }
141141
142- /**
143- * Enters the context of a method compilation for the current compilation thread.
144- *
145- * @return a scope for the context
146- */
142+ @ Override
147143 public DebugCloseable enterCompilationContext () {
148144 return recorder .enterCompilationContext ();
149145 }
Original file line number Diff line number Diff line change 4141import jdk .graal .compiler .debug .GlobalMetrics ;
4242import jdk .graal .compiler .debug .GraalError ;
4343import jdk .graal .compiler .debug .TimerKey ;
44+ import jdk .graal .compiler .hotspot .CompilationContext ;
45+ import jdk .graal .compiler .hotspot .HotSpotGraalServices ;
4446import jdk .graal .compiler .hotspot .Platform ;
4547import jdk .graal .compiler .hotspot .replaycomp .proxy .CompilationProxy ;
4648import jdk .graal .compiler .hotspot .replaycomp .proxy .CompilationProxyBase ;
@@ -222,6 +224,17 @@ public DebugCloseable withDebugContext(DebugContext debugContext) {
222224 };
223225 }
224226
227+ @ Override
228+ public DebugCloseable enterCompilationContext () {
229+ // The handles created during replay are cached across compilations.
230+ CompilationContext context = HotSpotGraalServices .enterGlobalCompilationContext ();
231+ if (context == null ) {
232+ return DebugCloseable .VOID_CLOSEABLE ;
233+ } else {
234+ return context ::close ;
235+ }
236+ }
237+
225238 /**
226239 * Loads the recorded operations from a collection.
227240 *
Original file line number Diff line number Diff line change @@ -263,18 +263,16 @@ public DebugCloseable withDebugContext(DebugContext debug) {
263263 * @return a debug closeable that should be closed after the compilation
264264 */
265265 public DebugCloseable enterCompilationContext (HotSpotCompilationRequest originalRequest , OptionValues initialOptions ) {
266- if ( proxies instanceof RecordingCompilationProxies recordingCompilationProxies ) {
267- DebugCloseable context = recordingCompilationProxies . enterCompilationContext ();
268- return () -> {
269- try {
266+ DebugCloseable context = proxies . enterCompilationContext ();
267+ return () -> {
268+ try {
269+ if ( proxies instanceof RecordingCompilationProxies ) {
270270 serializeRecordedCompilation (originalRequest , initialOptions );
271- } finally {
272- context .close ();
273271 }
274- };
275- } else {
276- return DebugCloseable . VOID_CLOSEABLE ;
277- }
272+ } finally {
273+ context . close ();
274+ }
275+ };
278276 }
279277
280278 private void serializeRecordedCompilation (HotSpotCompilationRequest originalRequest , OptionValues initialOptions ) {
You can’t perform that action at this time.
0 commit comments