599 } |
599 } |
600 JRT_END |
600 JRT_END |
601 |
601 |
602 |
602 |
603 static klassOop resolve_field_return_klass(methodHandle caller, int bci, TRAPS) { |
603 static klassOop resolve_field_return_klass(methodHandle caller, int bci, TRAPS) { |
604 Bytecode_field* field_access = Bytecode_field_at(caller(), caller->bcp_from(bci)); |
604 Bytecode_field* field_access = Bytecode_field_at(caller, bci); |
605 // This can be static or non-static field access |
605 // This can be static or non-static field access |
606 Bytecodes::Code code = field_access->code(); |
606 Bytecodes::Code code = field_access->code(); |
607 |
607 |
608 // We must load class, initialize class and resolvethe field |
608 // We must load class, initialize class and resolvethe field |
609 FieldAccessInfo result; // initialize class if needed |
609 FieldAccessInfo result; // initialize class if needed |
719 int patch_field_offset = -1; |
719 int patch_field_offset = -1; |
720 KlassHandle init_klass(THREAD, klassOop(NULL)); // klass needed by access_field_patching code |
720 KlassHandle init_klass(THREAD, klassOop(NULL)); // klass needed by access_field_patching code |
721 Handle load_klass(THREAD, NULL); // oop needed by load_klass_patching code |
721 Handle load_klass(THREAD, NULL); // oop needed by load_klass_patching code |
722 if (stub_id == Runtime1::access_field_patching_id) { |
722 if (stub_id == Runtime1::access_field_patching_id) { |
723 |
723 |
724 Bytecode_field* field_access = Bytecode_field_at(caller_method(), caller_method->bcp_from(bci)); |
724 Bytecode_field* field_access = Bytecode_field_at(caller_method, bci); |
725 FieldAccessInfo result; // initialize class if needed |
725 FieldAccessInfo result; // initialize class if needed |
726 Bytecodes::Code code = field_access->code(); |
726 Bytecodes::Code code = field_access->code(); |
727 constantPoolHandle constants(THREAD, caller_method->constants()); |
727 constantPoolHandle constants(THREAD, caller_method->constants()); |
728 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK); |
728 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK); |
729 patch_field_offset = result.field_offset(); |
729 patch_field_offset = result.field_offset(); |
779 } |
779 } |
780 break; |
780 break; |
781 case Bytecodes::_ldc: |
781 case Bytecodes::_ldc: |
782 case Bytecodes::_ldc_w: |
782 case Bytecodes::_ldc_w: |
783 { |
783 { |
784 Bytecode_loadconstant* cc = Bytecode_loadconstant_at(caller_method(), |
784 Bytecode_loadconstant* cc = Bytecode_loadconstant_at(caller_method, bci); |
785 caller_method->bcp_from(bci)); |
785 k = cc->resolve_constant(CHECK); |
786 klassOop resolved = caller_method->constants()->klass_at(cc->index(), CHECK); |
786 assert(k != NULL && !k->is_klass(), "must be class mirror or other Java constant"); |
787 // ldc wants the java mirror. |
|
788 k = resolved->klass_part()->java_mirror(); |
|
789 } |
787 } |
790 break; |
788 break; |
791 default: Unimplemented(); |
789 default: Unimplemented(); |
792 } |
790 } |
793 // convert to handle |
791 // convert to handle |
814 VMThread::execute(&deopt); |
812 VMThread::execute(&deopt); |
815 |
813 |
816 // Return to the now deoptimized frame. |
814 // Return to the now deoptimized frame. |
817 } |
815 } |
818 |
816 |
|
817 // If we are patching in a non-perm oop, make sure the nmethod |
|
818 // is on the right list. |
|
819 if (ScavengeRootsInCode && load_klass.not_null() && load_klass->is_scavengable()) { |
|
820 MutexLockerEx ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag); |
|
821 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); |
|
822 guarantee(nm != NULL, "only nmethods can contain non-perm oops"); |
|
823 if (!nm->on_scavenge_root_list()) |
|
824 CodeCache::add_scavenge_root_nmethod(nm); |
|
825 } |
819 |
826 |
820 // Now copy code back |
827 // Now copy code back |
821 |
828 |
822 { |
829 { |
823 MutexLockerEx ml_patch (Patching_lock, Mutex::_no_safepoint_check_flag); |
830 MutexLockerEx ml_patch (Patching_lock, Mutex::_no_safepoint_check_flag); |