Mercurial > hg > truffle
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 7154:5d0bb7d52783
changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 12 Dec 2012 21:36:40 +0100 |
parents | 045c5f8ae689 |
children | 0b646334c5f7 |
comparison
equal
deleted
inserted
replaced
7153:c421c19b7bf8 | 7154:5d0bb7d52783 |
---|---|
446 _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); | 446 _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 | 450 |
451 // If deoptimization happens, the interpreter should reexecute these bytecodes. | |
452 // This function mainly helps the compilers to set up the reexecute bit. | |
453 static bool bytecode_should_reexecute(Bytecodes::Code code) { | |
454 switch (code) { | |
455 case Bytecodes::_invokedynamic: | |
456 case Bytecodes::_invokevirtual: | |
457 case Bytecodes::_invokeinterface: | |
458 case Bytecodes::_invokespecial: | |
459 case Bytecodes::_invokestatic: | |
460 return false; | |
461 default: | |
462 return true; | |
463 } | |
464 return true; | |
465 } | |
466 | |
451 void CodeInstaller::record_scope(jint pc_offset, oop frame, GrowableArray<ScopeValue*>* objects) { | 467 void CodeInstaller::record_scope(jint pc_offset, oop frame, GrowableArray<ScopeValue*>* objects) { |
452 assert(frame->klass() == BytecodeFrame::klass(), "BytecodeFrame expected"); | 468 assert(frame->klass() == BytecodeFrame::klass(), "BytecodeFrame expected"); |
453 oop caller_frame = BytecodePosition::caller(frame); | 469 oop caller_frame = BytecodePosition::caller(frame); |
454 if (caller_frame != NULL) { | 470 if (caller_frame != NULL) { |
455 record_scope(pc_offset, caller_frame, objects); | 471 record_scope(pc_offset, caller_frame, objects); |
461 bool reexecute; | 477 bool reexecute; |
462 if (bci == -1 || bci == -2){ | 478 if (bci == -1 || bci == -2){ |
463 reexecute = false; | 479 reexecute = false; |
464 } else { | 480 } else { |
465 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); | 481 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); |
466 reexecute = Interpreter::bytecode_should_reexecute(code); | 482 reexecute = bytecode_should_reexecute(code); |
467 if (frame != NULL) { | 483 if (frame != NULL) { |
468 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); | 484 reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); |
469 } | 485 } |
470 } | 486 } |
471 | 487 |
795 _implicit_exception_table.append(pc_offset, pc_offset); | 811 _implicit_exception_table.append(pc_offset, pc_offset); |
796 break; | 812 break; |
797 case MARK_POLL_NEAR: { | 813 case MARK_POLL_NEAR: { |
798 NativeInstruction* ni = nativeInstruction_at(instruction); | 814 NativeInstruction* ni = nativeInstruction_at(instruction); |
799 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); | 815 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); |
800 intptr_t new_disp = (intptr_t) (os::get_polling_page() + (SafepointPollOffset % os::vm_page_size())) - (intptr_t) ni; | 816 int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand |
817 intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; | |
801 *disp = (int32_t)new_disp; | 818 *disp = (int32_t)new_disp; |
802 } | 819 } |
803 case MARK_POLL_FAR: | 820 case MARK_POLL_FAR: |
804 _instructions->relocate(instruction, relocInfo::poll_type); | 821 _instructions->relocate(instruction, relocInfo::poll_type); |
805 break; | 822 break; |
806 case MARK_POLL_RETURN_NEAR: { | 823 case MARK_POLL_RETURN_NEAR: { |
807 NativeInstruction* ni = nativeInstruction_at(instruction); | 824 NativeInstruction* ni = nativeInstruction_at(instruction); |
808 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); | 825 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand); |
809 intptr_t new_disp = (intptr_t) (os::get_polling_page() + (SafepointPollOffset % os::vm_page_size())) - (intptr_t) ni; | 826 int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand |
827 intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; | |
810 *disp = (int32_t)new_disp; | 828 *disp = (int32_t)new_disp; |
811 } | 829 } |
812 case MARK_POLL_RETURN_FAR: | 830 case MARK_POLL_RETURN_FAR: |
813 _instructions->relocate(instruction, relocInfo::poll_return_type); | 831 _instructions->relocate(instruction, relocInfo::poll_return_type); |
814 break; | 832 break; |
815 case MARK_KLASS_PATCHING: | |
816 case MARK_ACCESS_FIELD_PATCHING: { | |
817 unsigned char* byte_count = (unsigned char*) (instruction - 1); | |
818 unsigned char* byte_skip = (unsigned char*) (instruction - 2); | |
819 unsigned char* being_initialized_entry_offset = (unsigned char*) (instruction - 3); | |
820 | |
821 assert(*byte_skip == 5, "unexpected byte_skip"); | |
822 | |
823 assert(references->length() == 2, "MARK_KLASS_PATCHING/MARK_ACCESS_FIELD_PATCHING needs 2 references"); | |
824 oop ref1 = ((oop*) references->base(T_OBJECT))[0]; | |
825 oop ref2 = ((oop*) references->base(T_OBJECT))[1]; | |
826 int i_byte_count = CompilationResult_Site::pcOffset(ref2) - CompilationResult_Site::pcOffset(ref1); | |
827 assert(i_byte_count == (unsigned char)i_byte_count, "invalid offset"); | |
828 *byte_count = i_byte_count; | |
829 *being_initialized_entry_offset = *byte_count + *byte_skip; | |
830 | |
831 // we need to correct the offset of a field access - it's created with MAX_INT to ensure the correct size, and HotSpot expects 0 | |
832 if (id == MARK_ACCESS_FIELD_PATCHING) { | |
833 NativeMovRegMem* inst = nativeMovRegMem_at(_instructions->start() + CompilationResult_Site::pcOffset(ref1)); | |
834 assert(inst->offset() == max_jint, "unexpected offset value"); | |
835 inst->set_offset(0); | |
836 } | |
837 break; | |
838 } | |
839 case MARK_DUMMY_OOP_RELOCATION: { | |
840 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); | |
841 | |
842 RelocIterator iter(_instructions, (address) instruction, (address) (instruction + 1)); | |
843 relocInfo::change_reloc_info_for_address(&iter, (address) instruction, relocInfo::oop_type, relocInfo::none); | |
844 break; | |
845 } | |
846 default: | 833 default: |
847 ShouldNotReachHere(); | 834 ShouldNotReachHere(); |
848 break; | 835 break; |
849 } | 836 } |
850 } | 837 } |