comparison src/share/vm/graal/graalCodeInstaller.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 b20889b42d12
children bc95d122df79
comparison
equal deleted inserted replaced
3554:b20889b42d12 3555:22d11b3bc561
229 return NULL; 229 return NULL;
230 } 230 }
231 231
232 // constructor used to create a method 232 // constructor used to create a method
233 CodeInstaller::CodeInstaller(Handle target_method) { 233 CodeInstaller::CodeInstaller(Handle target_method) {
234 _env = CURRENT_ENV;
234 ciMethod *ciMethodObject = NULL; 235 ciMethod *ciMethodObject = NULL;
235 { 236 {
237 methodOop method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method));
238 ciMethodObject = (ciMethod *) _env->get_object(method);
239 _parameter_count = method->size_of_parameters();
240
236 No_Safepoint_Verifier no_safepoint; 241 No_Safepoint_Verifier no_safepoint;
237 _env = CURRENT_ENV;
238 242
239 initialize_fields(target_method); 243 initialize_fields(target_method);
240 assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name"); 244 assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name");
241 assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved"); 245 assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved");
242 246
243 methodOop method = getMethodFromHotSpotMethod(_hotspot_method);
244 ciMethodObject = (ciMethod *) _env->get_object(method);
245 _parameter_count = method->size_of_parameters();
246 } 247 }
247 248
248 // (very) conservative estimate: each site needs a relocation 249 // (very) conservative estimate: each site needs a relocation
249 //CodeBuffer buffer("temp graal method", _total_size, _sites->length() * relocInfo::length_limit); 250 //CodeBuffer buffer("temp graal method", _total_size, _sites->length() * relocInfo::length_limit);
250 CodeBuffer buffer(CompilerThread::current()->get_buffer_blob()); 251 GraalCompiler::initialize_buffer_blob();
252 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
251 initialize_buffer(buffer); 253 initialize_buffer(buffer);
252 process_exception_handlers(); 254 process_exception_handlers();
253 255
254 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer 256 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
255 ThreadToNativeFromVM t((JavaThread*) Thread::current()); 257 ThreadToNativeFromVM t((JavaThread*) Thread::current());
265 267
266 initialize_fields(target_method); 268 initialize_fields(target_method);
267 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method"); 269 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method");
268 270
269 // (very) conservative estimate: each site needs a relocation 271 // (very) conservative estimate: each site needs a relocation
270 CodeBuffer buffer(CompilerThread::current()->get_buffer_blob()); 272 GraalCompiler::initialize_buffer_blob();
273 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
271 initialize_buffer(buffer); 274 initialize_buffer(buffer);
272 275
273 const char* cname = java_lang_String::as_utf8_string(_name); 276 const char* cname = java_lang_String::as_utf8_string(_name);
274 BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created 277 BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created
275 IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob); 278 IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob);