Mercurial > hg > truffle
comparison src/share/vm/graal/graalCompiler.cpp @ 3650:0e8a2a629afb
Pass-by compilation broker.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Nov 2011 21:27:28 +0100 |
parents | 5a8c44b5fb80 |
children | a31028282e3e |
comparison
equal
deleted
inserted
replaced
3649:5a8c44b5fb80 | 3650:0e8a2a629afb |
---|---|
39 _instance = this; | 39 _instance = this; |
40 } | 40 } |
41 | 41 |
42 // Initialization | 42 // Initialization |
43 void GraalCompiler::initialize() { | 43 void GraalCompiler::initialize() { |
44 if (_initialized) return; | 44 |
45 _initialized = true; | 45 ThreadToNativeFromVM trans(JavaThread::current()); |
46 CompilerThread* THREAD = CompilerThread::current(); | 46 JavaThread* THREAD = JavaThread::current(); |
47 TRACE_graal_1("GraalCompiler::initialize"); | 47 TRACE_graal_1("GraalCompiler::initialize"); |
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 |
55 tty->print_cr("graal VMEntries class not found"); | 55 tty->print_cr("graal VMEntries 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, VMEntries_methods, VMEntries_methods_count()); |
59 | 59 |
60 ResourceMark rm; | |
61 HandleMark hm; | |
60 { | 62 { |
61 VM_ENTRY_MARK; | 63 VM_ENTRY_MARK; |
62 check_pending_exception("Could not register natives"); | 64 check_pending_exception("Could not register natives"); |
63 } | 65 } |
64 | 66 |
76 if (!result) { | 78 if (!result) { |
77 tty->print_cr("Invalid option for graal!"); | 79 tty->print_cr("Invalid option for graal!"); |
78 vm_abort(false); | 80 vm_abort(false); |
79 } | 81 } |
80 } | 82 } |
83 VMExits::startCompiler(); | |
84 } | |
85 | |
86 _initialized = true; | |
87 if (BootstrapGraal) { | |
88 VMExits::bootstrap(); | |
81 } | 89 } |
82 } | 90 } |
83 | 91 |
84 void GraalCompiler::initialize_buffer_blob() { | 92 void GraalCompiler::initialize_buffer_blob() { |
85 | 93 |
94 guarantee(blob != NULL, "must create code buffer"); | 102 guarantee(blob != NULL, "must create code buffer"); |
95 THREAD->set_buffer_blob(blob); | 103 THREAD->set_buffer_blob(blob); |
96 } | 104 } |
97 } | 105 } |
98 | 106 |
107 void GraalCompiler::compile_method(methodHandle method, int entry_bci) { | |
108 EXCEPTION_CONTEXT | |
109 if (!_initialized) return; | |
110 assert(_initialized, "must already be initialized"); | |
111 ResourceMark rm; | |
112 ciEnv* current_env = JavaThread::current()->env(); | |
113 JavaThread::current()->set_env(NULL); | |
114 JavaThread::current()->set_compiling(true); | |
115 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK); | |
116 VMExits::compileMethod(hotspot_method, entry_bci); | |
117 JavaThread::current()->set_compiling(false); | |
118 JavaThread::current()->set_env(current_env); | |
119 } | |
120 | |
99 // Compilation entry point for methods | 121 // Compilation entry point for methods |
100 void GraalCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { | 122 void GraalCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { |
101 assert(_initialized, "must already be initialized"); | |
102 VM_ENTRY_MARK; | 123 VM_ENTRY_MARK; |
103 ResourceMark rm; | 124 ResourceMark rm; |
104 HandleMark hm; | 125 HandleMark hm; |
105 | 126 |
106 TRACE_graal_2("GraalCompiler::compile_method"); | 127 TRACE_graal_2("GraalCompiler::compile_method"); |
107 | 128 |
108 CompilerThread::current()->set_compiling(true); | 129 |
109 methodOop method = (methodOop) target->get_oop(); | 130 compile_method((methodOop)target->get_oop(), entry_bci); |
110 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK); | |
111 VMExits::compileMethod(hotspot_method, entry_bci); | |
112 CompilerThread::current()->set_compiling(false); | |
113 | 131 |
114 TRACE_graal_2("GraalCompiler::compile_method exit"); | 132 TRACE_graal_2("GraalCompiler::compile_method exit"); |
115 } | 133 } |
116 | 134 |
117 void GraalCompiler::exit() { | 135 void GraalCompiler::exit() { |
195 assert(obj() != NULL, "must succeed in allocating instance"); | 213 assert(obj() != NULL, "must succeed in allocating instance"); |
196 | 214 |
197 HotSpotTypeResolved::set_compiler(obj, VMExits::compilerInstance()()); | 215 HotSpotTypeResolved::set_compiler(obj, VMExits::compilerInstance()()); |
198 | 216 |
199 if (klass->oop_is_instance()) { | 217 if (klass->oop_is_instance()) { |
218 ResourceMark rm; | |
200 instanceKlass* ik = (instanceKlass*)klass()->klass_part(); | 219 instanceKlass* ik = (instanceKlass*)klass()->klass_part(); |
201 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL); | 220 Handle full_name = java_lang_String::create_from_str(ik->signature_name(), CHECK_NULL); |
202 HotSpotType::set_name(obj, full_name()); | 221 HotSpotType::set_name(obj, full_name()); |
203 } else { | 222 } else { |
204 HotSpotType::set_name(obj, name()); | 223 HotSpotType::set_name(obj, name()); |