24
24
*/
25
25
package jdk .graal .compiler .libgraal ;
26
26
27
- import java .io .Closeable ;
28
27
import java .io .IOException ;
29
28
import java .io .PrintStream ;
30
- import java .lang .invoke .MethodHandle ;
31
- import java .lang .invoke .MethodHandles ;
32
- import java .lang .invoke .MethodType ;
33
29
import java .util .Comparator ;
34
30
import java .util .List ;
35
31
import java .util .Map ;
57
53
import jdk .graal .compiler .libgraal .truffle .HSTruffleCompilerRuntime ;
58
54
import jdk .graal .compiler .options .OptionValues ;
59
55
import jdk .graal .compiler .word .Word ;
56
+ import jdk .vm .ci .hotspot .CompilerThreadCanCallJavaScope ;
60
57
import jdk .vm .ci .hotspot .HotSpotJVMCIRuntime ;
61
58
import jdk .vm .ci .hotspot .HotSpotVMConfigAccess ;
62
59
import jdk .vm .ci .hotspot .HotSpotVMConfigStore ;
@@ -229,7 +226,7 @@ public void initialize() {
229
226
@ Override
230
227
@ SuppressWarnings ("try" )
231
228
public void shutdown (String callbackClassName , String callbackMethodName ) {
232
- try (CanCallJavaScope ignore = CanCallJavaScope . open ( )) {
229
+ try (CompilerThreadCanCallJavaScope ignore = new CompilerThreadCanCallJavaScope ( true )) {
233
230
if (callbackClassName != null ) {
234
231
JNI .JNIEnv env = Word .unsigned (getJNIEnv ());
235
232
JNI .JClass cbClass = JNIUtil .findClass (env , JNIUtil .getSystemClassLoader (env ),
@@ -247,46 +244,6 @@ public void shutdown(String callbackClassName, String callbackMethodName) {
247
244
248
245
}
249
246
250
- private static final class CanCallJavaScope implements Closeable {
251
-
252
- private static final MethodHandle CAN_CALL_JAVA_SCOPE = findCompilerThreadCanCallJavaScopeConstructor ();
253
-
254
- private static MethodHandle findCompilerThreadCanCallJavaScopeConstructor () {
255
- try {
256
- return MethodHandles .lookup ().findConstructor (Class .forName ("jdk.vm.ci.hotspot.CompilerThreadCanCallJavaScope" ), MethodType .methodType (void .class , boolean .class ));
257
- } catch (ReflectiveOperationException e ) {
258
- throw new InternalError (e );
259
- }
260
- }
261
-
262
- private final AutoCloseable impl ;
263
-
264
- private CanCallJavaScope () {
265
- try {
266
- impl = (AutoCloseable ) CAN_CALL_JAVA_SCOPE .invoke (true );
267
- } catch (Error | RuntimeException e ) {
268
- throw e ;
269
- } catch (Throwable throwable ) {
270
- throw new InternalError (throwable );
271
- }
272
- }
273
-
274
- @ Override
275
- public void close () {
276
- try {
277
- impl .close ();
278
- } catch (RuntimeException e ) {
279
- throw e ;
280
- } catch (Exception e ) {
281
- throw new AssertionError (e );
282
- }
283
- }
284
-
285
- static CanCallJavaScope open () {
286
- return CAN_CALL_JAVA_SCOPE != null ? new CanCallJavaScope () : null ;
287
- }
288
- }
289
-
290
247
@ Override
291
248
public void notifyLowMemoryPoint (boolean suggestFullGC ) {
292
249
LibGraalRuntime .notifyLowMemoryPoint (suggestFullGC );
0 commit comments