Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalVMToCompiler.cpp @ 6505:1ecf984d490c
fixed an ordering issue in the initialization and retrieval of the platform specific HotSpotGraalRuntime instance
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Oct 2012 23:44:38 +0200 |
parents | ac3a4ea144a6 |
children | e522a00b91aa |
comparison
equal
deleted
inserted
replaced
6504:cc863a159645 | 6505:1ecf984d490c |
---|---|
23 | 23 |
24 #include "precompiled.hpp" | 24 #include "precompiled.hpp" |
25 #include "graal/graalVMToCompiler.hpp" | 25 #include "graal/graalVMToCompiler.hpp" |
26 | 26 |
27 // this is a *global* handle | 27 // this is a *global* handle |
28 jobject VMToCompiler::_compilerPermObject = NULL; | 28 jobject VMToCompiler::_graalRuntimePermObject = NULL; |
29 jobject VMToCompiler::_vmToCompilerPermObject = NULL; | 29 jobject VMToCompiler::_vmToCompilerPermObject = NULL; |
30 jobject VMToCompiler::_vmToCompilerPermKlass = NULL; | 30 jobject VMToCompiler::_vmToCompilerPermKlass = NULL; |
31 | 31 |
32 static klassOop loadClass(Symbol* name) { | 32 static klassOop loadClass(Symbol* name) { |
33 klassOop klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), NULL, Thread::current()); | 33 klassOop klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), NULL, Thread::current()); |
44 _vmToCompilerPermKlass = JNIHandles::make_global(result); | 44 _vmToCompilerPermKlass = JNIHandles::make_global(result); |
45 } | 45 } |
46 return KlassHandle((klassOop)JNIHandles::resolve_non_null(_vmToCompilerPermKlass)); | 46 return KlassHandle((klassOop)JNIHandles::resolve_non_null(_vmToCompilerPermKlass)); |
47 } | 47 } |
48 | 48 |
49 Handle VMToCompiler::compilerInstance() { | 49 Handle VMToCompiler::graalRuntime() { |
50 if (JNIHandles::resolve(_compilerPermObject) == NULL) { | 50 if (JNIHandles::resolve(_graalRuntimePermObject) == NULL) { |
51 #ifdef AMD64 | 51 #ifdef AMD64 |
52 Symbol* name = vmSymbols::com_oracle_graal_hotspot_amd64_AMD64HotSpotGraalRuntime(); | 52 Symbol* name = vmSymbols::com_oracle_graal_hotspot_amd64_AMD64HotSpotGraalRuntime(); |
53 #endif | 53 #endif |
54 KlassHandle klass = loadClass(name); | 54 KlassHandle klass = loadClass(name); |
55 | 55 |
56 JavaValue result(T_OBJECT); | 56 JavaValue result(T_OBJECT); |
57 JavaCalls::call_static(&result, klass, vmSymbols::initialize_name(), vmSymbols::getInstance_signature(), Thread::current()); | 57 JavaCalls::call_static(&result, klass, vmSymbols::makeInstance_name(), vmSymbols::getInstance_signature(), Thread::current()); |
58 check_pending_exception("Couldn't initialize HotSpotGraalRuntime"); | 58 check_pending_exception("Couldn't initialize HotSpotGraalRuntime"); |
59 _compilerPermObject = JNIHandles::make_global((oop) result.get_jobject()); | 59 _graalRuntimePermObject = JNIHandles::make_global((oop) result.get_jobject()); |
60 } | 60 } |
61 return Handle(JNIHandles::resolve_non_null(_compilerPermObject)); | 61 return Handle(JNIHandles::resolve_non_null(_graalRuntimePermObject)); |
62 } | 62 } |
63 | 63 |
64 Handle VMToCompiler::instance() { | 64 Handle VMToCompiler::instance() { |
65 if (JNIHandles::resolve(_vmToCompilerPermObject) == NULL) { | 65 if (JNIHandles::resolve(_vmToCompilerPermObject) == NULL) { |
66 KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotGraalRuntime()); | 66 KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotGraalRuntime()); |
67 | 67 |
68 JavaValue result(T_OBJECT); | 68 JavaValue result(T_OBJECT); |
69 JavaCallArguments args; | 69 JavaCallArguments args; |
70 args.set_receiver(compilerInstance()); | 70 args.set_receiver(graalRuntime()); |
71 JavaCalls::call_virtual(&result, compilerKlass, vmSymbols::getVMToCompiler_name(), vmSymbols::getVMToCompiler_signature(), &args, Thread::current()); | 71 JavaCalls::call_virtual(&result, compilerKlass, vmSymbols::getVMToCompiler_name(), vmSymbols::getVMToCompiler_signature(), &args, Thread::current()); |
72 check_pending_exception("Couldn't get VMToCompiler"); | 72 check_pending_exception("Couldn't get VMToCompiler"); |
73 _vmToCompilerPermObject = JNIHandles::make_global((oop) result.get_jobject()); | 73 _vmToCompilerPermObject = JNIHandles::make_global((oop) result.get_jobject()); |
74 } | 74 } |
75 return Handle(JNIHandles::resolve_non_null(_vmToCompilerPermObject)); | 75 return Handle(JNIHandles::resolve_non_null(_vmToCompilerPermObject)); |
109 check_pending_exception("Error while calling compileMethod"); | 109 check_pending_exception("Error while calling compileMethod"); |
110 return result.get_jboolean(); | 110 return result.get_jboolean(); |
111 } | 111 } |
112 | 112 |
113 void VMToCompiler::shutdownCompiler() { | 113 void VMToCompiler::shutdownCompiler() { |
114 if (_compilerPermObject != NULL) { | 114 if (_graalRuntimePermObject != NULL) { |
115 HandleMark hm; | 115 HandleMark hm; |
116 JavaThread* THREAD = JavaThread::current(); | 116 JavaThread* THREAD = JavaThread::current(); |
117 JavaValue result(T_VOID); | 117 JavaValue result(T_VOID); |
118 JavaCallArguments args; | 118 JavaCallArguments args; |
119 args.push_oop(instance()); | 119 args.push_oop(instance()); |
120 JavaCalls::call_interface(&result, vmToCompilerKlass(), vmSymbols::shutdownCompiler_name(), vmSymbols::void_method_signature(), &args, THREAD); | 120 JavaCalls::call_interface(&result, vmToCompilerKlass(), vmSymbols::shutdownCompiler_name(), vmSymbols::void_method_signature(), &args, THREAD); |
121 check_pending_exception("Error while calling shutdownCompiler"); | 121 check_pending_exception("Error while calling shutdownCompiler"); |
122 | 122 |
123 JNIHandles::destroy_global(_compilerPermObject); | 123 JNIHandles::destroy_global(_graalRuntimePermObject); |
124 JNIHandles::destroy_global(_vmToCompilerPermObject); | 124 JNIHandles::destroy_global(_vmToCompilerPermObject); |
125 JNIHandles::destroy_global(_vmToCompilerPermKlass); | 125 JNIHandles::destroy_global(_vmToCompilerPermKlass); |
126 | 126 |
127 _compilerPermObject = NULL; | 127 _graalRuntimePermObject = NULL; |
128 _vmToCompilerPermObject = NULL; | 128 _vmToCompilerPermObject = NULL; |
129 _vmToCompilerPermKlass = NULL; | 129 _vmToCompilerPermKlass = NULL; |
130 } | 130 } |
131 } | 131 } |
132 | 132 |