comparison src/share/vm/graal/graalCodeInstaller.cpp @ 5839:58a607307306

renaming in native code for CiTargetMethod -> CompilationResult
author Doug Simon <doug.simon@oracle.com>
date Mon, 16 Jul 2012 15:18:38 +0200
parents f238fe91dc7f
children c5024000ff0f
comparison
equal deleted inserted replaced
5829:0095a9c235c6 5839:58a607307306
271 } 271 }
272 } 272 }
273 } 273 }
274 274
275 // constructor used to create a method 275 // constructor used to create a method
276 CodeInstaller::CodeInstaller(Handle& target_method, nmethod*& nm, bool install_code) { 276 CodeInstaller::CodeInstaller(Handle& comp_result, nmethod*& nm, bool install_code) {
277 _env = CURRENT_ENV; 277 _env = CURRENT_ENV;
278 GraalCompiler::initialize_buffer_blob(); 278 GraalCompiler::initialize_buffer_blob();
279 CodeBuffer buffer(JavaThread::current()->get_buffer_blob()); 279 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
280 jobject target_method_obj = JNIHandles::make_local(target_method()); 280 jobject comp_result_obj = JNIHandles::make_local(comp_result());
281 initialize_assumptions(JNIHandles::resolve(target_method_obj)); 281 initialize_assumptions(JNIHandles::resolve(comp_result_obj));
282 282
283 { 283 {
284 No_Safepoint_Verifier no_safepoint; 284 No_Safepoint_Verifier no_safepoint;
285 initialize_fields(JNIHandles::resolve(target_method_obj)); 285 initialize_fields(JNIHandles::resolve(comp_result_obj));
286 initialize_buffer(buffer); 286 initialize_buffer(buffer);
287 process_exception_handlers(); 287 process_exception_handlers();
288 } 288 }
289 289
290 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words 290 int stack_slots = _total_frame_size / HeapWordSize; // conversion to words
291 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(JNIHandles::resolve(target_method_obj))); 291 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(JNIHandles::resolve(comp_result_obj)));
292 292
293 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, 293 nm = GraalEnv::register_method(method, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
294 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, install_code); 294 &_implicit_exception_table, GraalCompiler::instance(), _debug_recorder, _dependencies, NULL, -1, true, false, install_code);
295 295
296 method->clear_queued_for_compilation(); 296 method->clear_queued_for_compilation();
315 blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created 315 blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created
316 IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob); 316 IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob);
317 id = VmIds::addStub(blob->code_begin()); 317 id = VmIds::addStub(blob->code_begin());
318 } 318 }
319 319
320 void CodeInstaller::initialize_fields(oop target_method) { 320 void CodeInstaller::initialize_fields(oop comp_result) {
321 _citarget_method = HotSpotCompilationResult::comp(target_method); 321 _comp_result = HotSpotCompilationResult::comp(comp_result);
322 _hotspot_method = HotSpotCompilationResult::method(target_method); 322 _hotspot_method = HotSpotCompilationResult::method(comp_result);
323 if (_hotspot_method != NULL) { 323 if (_hotspot_method != NULL) {
324 _parameter_count = getMethodFromHotSpotMethod(_hotspot_method)->size_of_parameters(); 324 methodOop method = getMethodFromHotSpotMethod(_hotspot_method);
325 } 325 _parameter_count = method->size_of_parameters();
326 _name = HotSpotCompilationResult::name(target_method); 326 TRACE_graal_1("installing code for %s", method->name_and_sig_as_C_string());
327 _sites = (arrayOop) HotSpotCompilationResult::sites(target_method); 327 }
328 _exception_handlers = (arrayOop) HotSpotCompilationResult::exceptionHandlers(target_method); 328 _name = HotSpotCompilationResult::name(comp_result);
329 329 _sites = (arrayOop) HotSpotCompilationResult::sites(comp_result);
330 _code = (arrayOop) InstalledCode::targetCode(_citarget_method); 330 _exception_handlers = (arrayOop) HotSpotCompilationResult::exceptionHandlers(comp_result);
331 _code_size = InstalledCode::targetCodeSize(_citarget_method); 331
332 _code = (arrayOop) InstalledCode::targetCode(_comp_result);
333 _code_size = InstalledCode::targetCodeSize(_comp_result);
332 // The frame size we get from the target method does not include the return address, so add one word for it here. 334 // The frame size we get from the target method does not include the return address, so add one word for it here.
333 _total_frame_size = InstalledCode::frameSize(_citarget_method) + HeapWordSize; 335 _total_frame_size = InstalledCode::frameSize(_comp_result) + HeapWordSize;
334 _custom_stack_area_offset = InstalledCode::customStackAreaOffset(_citarget_method); 336 _custom_stack_area_offset = InstalledCode::customStackAreaOffset(_comp_result);
335
336 337
337 // (very) conservative estimate: each site needs a constant section entry 338 // (very) conservative estimate: each site needs a constant section entry
338 _constants_size = _sites->length() * (BytesPerLong*2); 339 _constants_size = _sites->length() * (BytesPerLong*2);
339 _total_size = align_size_up(_code_size, HeapWordSize) + _constants_size; 340 _total_size = align_size_up(_code_size, HeapWordSize) + _constants_size;
340 341
625 next_pc_offset = pc_offset + NativeMovConstReg::instruction_size; 626 next_pc_offset = pc_offset + NativeMovConstReg::instruction_size;
626 u_char* call = (u_char*) (_instructions->start() + next_pc_offset); 627 u_char* call = (u_char*) (_instructions->start() + next_pc_offset);
627 assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte"); 628 assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte");
628 next_pc_offset += 3; /* prefix byte + opcode byte + modrm byte */ 629 next_pc_offset += 3; /* prefix byte + opcode byte + modrm byte */
629 } else if (inst->is_call_reg()) { 630 } else if (inst->is_call_reg()) {
630 // the inlined vtable stub contains a "call register" instruction, which isn't recognized here 631 // the inlined vtable stub contains a "call register" instruction
631 assert(hotspot_method != NULL, "only valid for virtual calls"); 632 assert(hotspot_method != NULL, "only valid for virtual calls");
632 is_call_reg = true; 633 is_call_reg = true;
633 next_pc_offset = pc_offset + NativeCallReg::instruction_size; 634 next_pc_offset = pc_offset + ((NativeCallReg *) inst)->next_instruction_offset();
634 } else { 635 } else {
636 tty->print_cr("at pc_offset %d", pc_offset);
635 runtime_call->print(); 637 runtime_call->print();
636 fatal("unsupported type of instruction for call site"); 638 fatal("unsupported type of instruction for call site");
637 } 639 }
638 640
639 if (target->is_a(SystemDictionary::HotSpotCompiledMethod_klass())) { 641 if (target->is_a(SystemDictionary::HotSpotCompiledMethod_klass())) {