comparison src/share/vm/graal/graalCompiler.cpp @ 4221:bcbb918f5ac6

Renaming of VMExits and VMEntries part 2.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 04 Jan 2012 21:07:44 +0100
parents feb590a8497f
children d089b71a5237 f7251c729b31
comparison
equal deleted inserted replaced
4220:5c80ccb80036 4221:bcbb918f5ac6
22 */ 22 */
23 23
24 #include "precompiled.hpp" 24 #include "precompiled.hpp"
25 #include "graal/graalCompiler.hpp" 25 #include "graal/graalCompiler.hpp"
26 #include "graal/graalJavaAccess.hpp" 26 #include "graal/graalJavaAccess.hpp"
27 #include "graal/graalVMExits.hpp" 27 #include "graal/graalVMToCompiler.hpp"
28 #include "graal/graalVMEntries.hpp" 28 #include "graal/graalCompilerToVM.hpp"
29 #include "graal/graalVmIds.hpp" 29 #include "graal/graalVmIds.hpp"
30 #include "graal/graalEnv.hpp" 30 #include "graal/graalEnv.hpp"
31 #include "c1/c1_Runtime1.hpp" 31 #include "c1/c1_Runtime1.hpp"
32 #include "runtime/arguments.hpp" 32 #include "runtime/arguments.hpp"
33 33
48 48
49 initialize_buffer_blob(); 49 initialize_buffer_blob();
50 Runtime1::initialize(THREAD->get_buffer_blob()); 50 Runtime1::initialize(THREAD->get_buffer_blob());
51 51
52 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment(); 52 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment();
53 jclass klass = env->FindClass("com/oracle/max/graal/hotspot/VMEntriesNative"); 53 jclass klass = env->FindClass("com/oracle/max/graal/hotspot/bridge/CompilerToVMImpl");
54 if (klass == NULL) { 54 if (klass == NULL) {
55 tty->print_cr("graal VMEntries class not found"); 55 tty->print_cr("graal CompilerToVMImpl class not found");
56 vm_abort(false); 56 vm_abort(false);
57 } 57 }
58 env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count()); 58 env->RegisterNatives(klass, CompilerToVM_methods, CompilerToVM_methods_count());
59 59
60 ResourceMark rm; 60 ResourceMark rm;
61 HandleMark hm; 61 HandleMark hm;
62 { 62 {
63 VM_ENTRY_MARK; 63 VM_ENTRY_MARK;
67 graal_compute_offsets(); 67 graal_compute_offsets();
68 68
69 { 69 {
70 VM_ENTRY_MARK; 70 VM_ENTRY_MARK;
71 HandleMark hm; 71 HandleMark hm;
72 VMExits::initializeCompiler(); 72 VMToCompiler::initializeCompiler();
73 VMExits::setDefaultOptions(); 73 VMToCompiler::setDefaultOptions();
74 for (int i = 0; i < Arguments::num_graal_args(); ++i) { 74 for (int i = 0; i < Arguments::num_graal_args(); ++i) {
75 const char* arg = Arguments::graal_args_array()[i]; 75 const char* arg = Arguments::graal_args_array()[i];
76 Handle option = java_lang_String::create_from_str(arg, THREAD); 76 Handle option = java_lang_String::create_from_str(arg, THREAD);
77 jboolean result = VMExits::setOption(option); 77 jboolean result = VMToCompiler::setOption(option);
78 if (!result) { 78 if (!result) {
79 tty->print_cr("Invalid option for graal!"); 79 tty->print_cr("Invalid option for graal!");
80 vm_abort(false); 80 vm_abort(false);
81 } 81 }
82 } 82 }
83 if (UseCompiler) { 83 if (UseCompiler) {
84 VMExits::startCompiler(); 84 VMToCompiler::startCompiler();
85 _initialized = true; 85 _initialized = true;
86 if (BootstrapGraal) { 86 if (BootstrapGraal) {
87 VMExits::bootstrap(); 87 VMToCompiler::bootstrap();
88 } 88 }
89 } 89 }
90 } 90 }
91 } 91 }
92 92
117 ResourceMark rm; 117 ResourceMark rm;
118 ciEnv* current_env = JavaThread::current()->env(); 118 ciEnv* current_env = JavaThread::current()->env();
119 JavaThread::current()->set_env(NULL); 119 JavaThread::current()->set_env(NULL);
120 JavaThread::current()->set_compiling(true); 120 JavaThread::current()->set_compiling(true);
121 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK); 121 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK);
122 VMExits::compileMethod(hotspot_method, entry_bci, blocking); 122 VMToCompiler::compileMethod(hotspot_method, entry_bci, blocking);
123 JavaThread::current()->set_compiling(false); 123 JavaThread::current()->set_compiling(false);
124 JavaThread::current()->set_env(current_env); 124 JavaThread::current()->set_env(current_env);
125 } 125 }
126 126
127 // Compilation entry point for methods 127 // Compilation entry point for methods
129 ShouldNotReachHere(); 129 ShouldNotReachHere();
130 } 130 }
131 131
132 void GraalCompiler::exit() { 132 void GraalCompiler::exit() {
133 if (_initialized) { 133 if (_initialized) {
134 VMExits::shutdownCompiler(); 134 VMToCompiler::shutdownCompiler();
135 } 135 }
136 } 136 }
137 137
138 // Print compilation timers and statistics 138 // Print compilation timers and statistics
139 void GraalCompiler::print_timers() { 139 void GraalCompiler::print_timers() {
140 TRACE_graal_1("GraalCompiler::print_timers"); 140 TRACE_graal_1("GraalCompiler::print_timers");
141 } 141 }
142 142
143 Handle GraalCompiler::get_RiType(Symbol* klass_name, TRAPS) { 143 Handle GraalCompiler::get_RiType(Symbol* klass_name, TRAPS) {
144 return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(klass_name, THREAD), THREAD); 144 return VMToCompiler::createRiTypeUnresolved(VmIds::toString<Handle>(klass_name, THREAD), THREAD);
145 } 145 }
146 146
147 Handle GraalCompiler::get_RiTypeFromSignature(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { 147 Handle GraalCompiler::get_RiTypeFromSignature(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) {
148 148
149 Symbol* signature = cp->symbol_at(index); 149 Symbol* signature = cp->symbol_at(index);
156 return get_RiType(signature, CHECK_NULL); 156 return get_RiType(signature, CHECK_NULL);
157 } else { 157 } else {
158 return get_RiType(handle, CHECK_NULL); 158 return get_RiType(handle, CHECK_NULL);
159 } 159 }
160 } else { 160 } else {
161 return VMExits::createRiTypePrimitive(field_type, CHECK_NULL); 161 return VMToCompiler::createRiTypePrimitive(field_type, CHECK_NULL);
162 } 162 }
163 } 163 }
164 164
165 Handle GraalCompiler::get_RiType(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) { 165 Handle GraalCompiler::get_RiType(constantPoolHandle cp, int index, KlassHandle loading_klass, TRAPS) {
166 bool is_accessible = false; 166 bool is_accessible = false;
195 return createHotSpotTypeResolved(klass, name, CHECK_NULL); 195 return createHotSpotTypeResolved(klass, name, CHECK_NULL);
196 } 196 }
197 197
198 Handle GraalCompiler::get_RiField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS) { 198 Handle GraalCompiler::get_RiField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS) {
199 Handle name = VmIds::toString<Handle>(field_name, CHECK_NULL); 199 Handle name = VmIds::toString<Handle>(field_name, CHECK_NULL);
200 return VMExits::createRiField(field_holder, name, field_type, offset, flags, CHECK_NULL); 200 return VMToCompiler::createRiField(field_holder, name, field_type, offset, flags, CHECK_NULL);
201 } 201 }
202 202
203 Handle GraalCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) { 203 Handle GraalCompiler::createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS) {
204 if (klass->graal_mirror() != NULL) { 204 if (klass->graal_mirror() != NULL) {
205 return klass->graal_mirror(); 205 return klass->graal_mirror();
207 207
208 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL); 208 instanceKlass::cast(HotSpotTypeResolved::klass())->initialize(CHECK_NULL);
209 Handle obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL); 209 Handle obj = instanceKlass::cast(HotSpotTypeResolved::klass())->allocate_instance(CHECK_NULL);
210 assert(obj() != NULL, "must succeed in allocating instance"); 210 assert(obj() != NULL, "must succeed in allocating instance");
211 211
212 HotSpotTypeResolved::set_compiler(obj, VMExits::compilerInstance()()); 212 HotSpotTypeResolved::set_compiler(obj, VMToCompiler::compilerInstance()());
213 213
214 if (klass->oop_is_instance()) { 214 if (klass->oop_is_instance()) {
215 ResourceMark rm; 215 ResourceMark rm;
216 instanceKlass* ik = (instanceKlass*)klass()->klass_part(); 216 instanceKlass* ik = (instanceKlass*)klass()->klass_part();
217 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL); 217 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL);
253 253
254 instanceKlass::cast(HotSpotMethodResolved::klass())->initialize(CHECK_NULL); 254 instanceKlass::cast(HotSpotMethodResolved::klass())->initialize(CHECK_NULL);
255 Handle obj = instanceKlass::cast(HotSpotMethodResolved::klass())->allocate_instance(CHECK_NULL); 255 Handle obj = instanceKlass::cast(HotSpotMethodResolved::klass())->allocate_instance(CHECK_NULL);
256 assert(obj() != NULL, "must succeed in allocating instance"); 256 assert(obj() != NULL, "must succeed in allocating instance");
257 257
258 HotSpotMethodResolved::set_compiler(obj, VMExits::compilerInstance()()); 258 HotSpotMethodResolved::set_compiler(obj, VMToCompiler::compilerInstance()());
259 // (tw) Cannot use reflection here, because the compiler thread could dead lock with the running application. 259 // (tw) Cannot use reflection here, because the compiler thread could dead lock with the running application.
260 // oop reflected = getReflectedMethod(method(), CHECK_NULL); 260 // oop reflected = getReflectedMethod(method(), CHECK_NULL);
261 HotSpotMethodResolved::set_javaMirror(obj, method()); 261 HotSpotMethodResolved::set_javaMirror(obj, method());
262 HotSpotMethodResolved::set_name(obj, name()); 262 HotSpotMethodResolved::set_name(obj, name());
263 263