comparison src/share/vm/graal/graalCompiler.cpp @ 3555:22d11b3bc561

Various hacks to be able to install machine code from a Java thread.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 24 Aug 2011 01:05:02 +0200
parents 536528f48708
children b3f0f8a01ca2
comparison
equal deleted inserted replaced
3554:b20889b42d12 3555:22d11b3bc561
82 } 82 }
83 } 83 }
84 84
85 void GraalCompiler::initialize_buffer_blob() { 85 void GraalCompiler::initialize_buffer_blob() {
86 86
87 CompilerThread* THREAD = CompilerThread::current(); 87 JavaThread* THREAD = JavaThread::current();
88 if (THREAD->get_buffer_blob() == NULL) { 88 if (THREAD->get_buffer_blob() == NULL) {
89 // setup CodeBuffer. Preallocate a BufferBlob of size 89 // setup CodeBuffer. Preallocate a BufferBlob of size
90 // NMethodSizeLimit plus some extra space for constants. 90 // NMethodSizeLimit plus some extra space for constants.
91 int code_buffer_size = Compilation::desired_max_code_buffer_size() + 91 int code_buffer_size = Compilation::desired_max_code_buffer_size() +
92 Compilation::desired_max_constant_size(); 92 Compilation::desired_max_constant_size();
102 assert(_initialized, "must already be initialized"); 102 assert(_initialized, "must already be initialized");
103 VM_ENTRY_MARK; 103 VM_ENTRY_MARK;
104 ResourceMark rm; 104 ResourceMark rm;
105 HandleMark hm; 105 HandleMark hm;
106 106
107 initialize_buffer_blob();
108 VmIds::initializeObjects(); 107 VmIds::initializeObjects();
109 108
110 TRACE_graal_2("GraalCompiler::compile_method"); 109 TRACE_graal_2("GraalCompiler::compile_method");
111 110
112 CompilerThread::current()->set_compiling(true); 111 CompilerThread::current()->set_compiling(true);
113 methodOop method = (methodOop) target->get_oop(); 112 methodOop method = (methodOop) target->get_oop();
114 Handle name = VmIds::toString<Handle>(method->name(), CHECK); 113 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, CHECK);
115 Handle hotspot_method = GraalCompiler::createHotSpotMethodResolved(method, name, CHECK);
116 VMExits::compileMethod(hotspot_method, entry_bci); 114 VMExits::compileMethod(hotspot_method, entry_bci);
117 CompilerThread::current()->set_compiling(false); 115 CompilerThread::current()->set_compiling(false);
118 116
119 VmIds::cleanupLocalObjects(); 117 VmIds::cleanupLocalObjects();
120 TRACE_graal_2("GraalCompiler::compile_method exit"); 118 TRACE_graal_2("GraalCompiler::compile_method exit");
200 klass->set_graal_mirror(obj()); 198 klass->set_graal_mirror(obj());
201 199
202 return obj(); 200 return obj();
203 } 201 }
204 202
205 oop GraalCompiler::createHotSpotMethodResolved(methodHandle method, Handle name, TRAPS) { 203 oop GraalCompiler::createHotSpotMethodResolved(methodHandle method, TRAPS) {
206 if (method->graal_mirror() != NULL) { 204 if (method->graal_mirror() != NULL) {
207 assert(method->graal_mirror()->is_a(HotSpotMethodResolved::klass()), "unexpected class..."); 205 assert(method->graal_mirror()->is_a(HotSpotMethodResolved::klass()), "unexpected class...");
208 return method->graal_mirror(); 206 return method->graal_mirror();
209 } 207 }
208
209 Handle name = VmIds::toString<Handle>(method->name(), CHECK_NULL);
210 210
211 instanceKlass::cast(HotSpotMethodResolved::klass())->initialize(CHECK_NULL); 211 instanceKlass::cast(HotSpotMethodResolved::klass())->initialize(CHECK_NULL);
212 Handle obj = instanceKlass::cast(HotSpotMethodResolved::klass())->allocate_instance(CHECK_NULL); 212 Handle obj = instanceKlass::cast(HotSpotMethodResolved::klass())->allocate_instance(CHECK_NULL);
213 assert(obj() != NULL, "must succeed in allocating instance"); 213 assert(obj() != NULL, "must succeed in allocating instance");
214 214