85 |
85 |
86 //------------------------------------------------------------------------------------------------------------------------ |
86 //------------------------------------------------------------------------------------------------------------------------ |
87 // State accessors |
87 // State accessors |
88 |
88 |
89 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { |
89 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { |
90 last_frame(thread).interpreter_frame_set_bcp(bcp); |
90 LastFrameAccessor last_frame(thread); |
|
91 last_frame.set_bcp(bcp); |
91 if (ProfileInterpreter) { |
92 if (ProfileInterpreter) { |
92 // ProfileTraps uses MDOs independently of ProfileInterpreter. |
93 // ProfileTraps uses MDOs independently of ProfileInterpreter. |
93 // That is why we must check both ProfileInterpreter and mdo != NULL. |
94 // That is why we must check both ProfileInterpreter and mdo != NULL. |
94 MethodData* mdo = last_frame(thread).interpreter_frame_method()->method_data(); |
95 MethodData* mdo = last_frame.method()->method_data(); |
95 if (mdo != NULL) { |
96 if (mdo != NULL) { |
96 NEEDS_CLEANUP; |
97 NEEDS_CLEANUP; |
97 last_frame(thread).interpreter_frame_set_mdp(mdo->bci_to_dp(last_frame(thread).interpreter_frame_bci())); |
98 last_frame.set_mdp(mdo->bci_to_dp(last_frame.bci())); |
98 } |
99 } |
99 } |
100 } |
100 } |
101 } |
101 |
102 |
102 //------------------------------------------------------------------------------------------------------------------------ |
103 //------------------------------------------------------------------------------------------------------------------------ |
103 // Constants |
104 // Constants |
104 |
105 |
105 |
106 |
106 IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide)) |
107 IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide)) |
107 // access constant pool |
108 // access constant pool |
108 ConstantPool* pool = method(thread)->constants(); |
109 LastFrameAccessor last_frame(thread); |
109 int index = wide ? get_index_u2(thread, Bytecodes::_ldc_w) : get_index_u1(thread, Bytecodes::_ldc); |
110 ConstantPool* pool = last_frame.method()->constants(); |
|
111 int index = wide ? last_frame.get_index_u2(Bytecodes::_ldc_w) : last_frame.get_index_u1(Bytecodes::_ldc); |
110 constantTag tag = pool->tag_at(index); |
112 constantTag tag = pool->tag_at(index); |
111 |
113 |
112 assert (tag.is_unresolved_klass() || tag.is_klass(), "wrong ldc call"); |
114 assert (tag.is_unresolved_klass() || tag.is_klass(), "wrong ldc call"); |
113 Klass* klass = pool->klass_at(index, CHECK); |
115 Klass* klass = pool->klass_at(index, CHECK); |
114 oop java_class = klass->java_mirror(); |
116 oop java_class = klass->java_mirror(); |
117 |
119 |
118 IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) { |
120 IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) { |
119 assert(bytecode == Bytecodes::_fast_aldc || |
121 assert(bytecode == Bytecodes::_fast_aldc || |
120 bytecode == Bytecodes::_fast_aldc_w, "wrong bc"); |
122 bytecode == Bytecodes::_fast_aldc_w, "wrong bc"); |
121 ResourceMark rm(thread); |
123 ResourceMark rm(thread); |
122 methodHandle m (thread, method(thread)); |
124 LastFrameAccessor last_frame(thread); |
123 Bytecode_loadconstant ldc(m, bci(thread)); |
125 methodHandle m (thread, last_frame.method()); |
|
126 Bytecode_loadconstant ldc(m, last_frame.bci()); |
124 oop result = ldc.resolve_constant(CHECK); |
127 oop result = ldc.resolve_constant(CHECK); |
125 #ifdef ASSERT |
128 #ifdef ASSERT |
126 { |
129 { |
127 // The bytecode wrappers aren't GC-safe so construct a new one |
130 // The bytecode wrappers aren't GC-safe so construct a new one |
128 Bytecode_loadconstant ldc2(m, bci(thread)); |
131 Bytecode_loadconstant ldc2(m, last_frame.bci()); |
129 oop coop = m->constants()->resolved_references()->obj_at(ldc2.cache_index()); |
132 oop coop = m->constants()->resolved_references()->obj_at(ldc2.cache_index()); |
130 assert(result == coop, "expected result for assembly code"); |
133 assert(result == coop, "expected result for assembly code"); |
131 } |
134 } |
132 #endif |
135 #endif |
133 thread->set_vm_result(result); |
136 thread->set_vm_result(result); |
180 IRT_END |
183 IRT_END |
181 |
184 |
182 |
185 |
183 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address)) |
186 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address)) |
184 // We may want to pass in more arguments - could make this slightly faster |
187 // We may want to pass in more arguments - could make this slightly faster |
185 ConstantPool* constants = method(thread)->constants(); |
188 LastFrameAccessor last_frame(thread); |
186 int i = get_index_u2(thread, Bytecodes::_multianewarray); |
189 ConstantPool* constants = last_frame.method()->constants(); |
187 Klass* klass = constants->klass_at(i, CHECK); |
190 int i = last_frame.get_index_u2(Bytecodes::_multianewarray); |
188 int nof_dims = number_of_dimensions(thread); |
191 Klass* klass = constants->klass_at(i, CHECK); |
|
192 int nof_dims = last_frame.number_of_dimensions(); |
189 assert(klass->is_klass(), "not a class"); |
193 assert(klass->is_klass(), "not a class"); |
190 assert(nof_dims >= 1, "multianewarray rank must be nonzero"); |
194 assert(nof_dims >= 1, "multianewarray rank must be nonzero"); |
191 |
195 |
192 // We must create an array of jints to pass to multi_allocate. |
196 // We must create an array of jints to pass to multi_allocate. |
193 ResourceMark rm(thread); |
197 ResourceMark rm(thread); |
215 |
219 |
216 |
220 |
217 // Quicken instance-of and check-cast bytecodes |
221 // Quicken instance-of and check-cast bytecodes |
218 IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread)) |
222 IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread)) |
219 // Force resolving; quicken the bytecode |
223 // Force resolving; quicken the bytecode |
220 int which = get_index_u2(thread, Bytecodes::_checkcast); |
224 LastFrameAccessor last_frame(thread); |
221 ConstantPool* cpool = method(thread)->constants(); |
225 int which = last_frame.get_index_u2(Bytecodes::_checkcast); |
|
226 ConstantPool* cpool = last_frame.method()->constants(); |
222 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded |
227 // We'd expect to assert that we're only here to quicken bytecodes, but in a multithreaded |
223 // program we might have seen an unquick'd bytecode in the interpreter but have another |
228 // program we might have seen an unquick'd bytecode in the interpreter but have another |
224 // thread quicken the bytecode before we get here. |
229 // thread quicken the bytecode before we get here. |
225 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" ); |
230 // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" ); |
226 Klass* klass = cpool->klass_at(which, CHECK); |
231 Klass* klass = cpool->klass_at(which, CHECK); |
255 |
260 |
256 // Assume the compiler is (or will be) interested in this event. |
261 // Assume the compiler is (or will be) interested in this event. |
257 // If necessary, create an MDO to hold the information, and record it. |
262 // If necessary, create an MDO to hold the information, and record it. |
258 void InterpreterRuntime::note_trap(JavaThread* thread, int reason, TRAPS) { |
263 void InterpreterRuntime::note_trap(JavaThread* thread, int reason, TRAPS) { |
259 assert(ProfileTraps, "call me only if profiling"); |
264 assert(ProfileTraps, "call me only if profiling"); |
260 methodHandle trap_method(thread, method(thread)); |
265 LastFrameAccessor last_frame(thread); |
261 int trap_bci = trap_method->bci_from(bcp(thread)); |
266 methodHandle trap_method(thread, last_frame.method()); |
|
267 int trap_bci = trap_method->bci_from(last_frame.bcp()); |
262 note_trap_inner(thread, reason, trap_method, trap_bci, THREAD); |
268 note_trap_inner(thread, reason, trap_method, trap_bci, THREAD); |
263 } |
269 } |
264 |
270 |
265 #ifdef CC_INTERP |
271 #ifdef CC_INTERP |
266 // As legacy note_trap, but we have more arguments. |
272 // As legacy note_trap, but we have more arguments. |
389 // bci where the exception happened. If the exception was propagated back |
395 // bci where the exception happened. If the exception was propagated back |
390 // from a call, the expression stack contains the values for the bci at the |
396 // from a call, the expression stack contains the values for the bci at the |
391 // invoke w/o arguments (i.e., as if one were inside the call). |
397 // invoke w/o arguments (i.e., as if one were inside the call). |
392 IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception)) |
398 IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception)) |
393 |
399 |
|
400 LastFrameAccessor last_frame(thread); |
394 Handle h_exception(thread, exception); |
401 Handle h_exception(thread, exception); |
395 methodHandle h_method (thread, method(thread)); |
402 methodHandle h_method (thread, last_frame.method()); |
396 constantPoolHandle h_constants(thread, h_method->constants()); |
403 constantPoolHandle h_constants(thread, h_method->constants()); |
397 bool should_repeat; |
404 bool should_repeat; |
398 int handler_bci; |
405 int handler_bci; |
399 int current_bci = bci(thread); |
406 int current_bci = last_frame.bci(); |
400 |
407 |
401 if (thread->frames_to_pop_failed_realloc() > 0) { |
408 if (thread->frames_to_pop_failed_realloc() > 0) { |
402 // Allocation of scalar replaced object used in this frame |
409 // Allocation of scalar replaced object used in this frame |
403 // failed. Unconditionally pop the frame. |
410 // failed. Unconditionally pop the frame. |
404 thread->dec_frames_to_pop_failed_realloc(); |
411 thread->dec_frames_to_pop_failed_realloc(); |
491 #endif |
498 #endif |
492 |
499 |
493 // notify JVMTI of an exception throw; JVMTI will detect if this is a first |
500 // notify JVMTI of an exception throw; JVMTI will detect if this is a first |
494 // time throw or a stack unwinding throw and accordingly notify the debugger |
501 // time throw or a stack unwinding throw and accordingly notify the debugger |
495 if (JvmtiExport::can_post_on_exceptions()) { |
502 if (JvmtiExport::can_post_on_exceptions()) { |
496 JvmtiExport::post_exception_throw(thread, h_method(), bcp(thread), h_exception()); |
503 JvmtiExport::post_exception_throw(thread, h_method(), last_frame.bcp(), h_exception()); |
497 } |
504 } |
498 |
505 |
499 #ifdef CC_INTERP |
506 #ifdef CC_INTERP |
500 address continuation = (address)(intptr_t) handler_bci; |
507 address continuation = (address)(intptr_t) handler_bci; |
501 #else |
508 #else |
554 |
561 |
555 void InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode) { |
562 void InterpreterRuntime::resolve_get_put(JavaThread* thread, Bytecodes::Code bytecode) { |
556 Thread* THREAD = thread; |
563 Thread* THREAD = thread; |
557 // resolve field |
564 // resolve field |
558 fieldDescriptor info; |
565 fieldDescriptor info; |
559 constantPoolHandle pool(thread, method(thread)->constants()); |
566 LastFrameAccessor last_frame(thread); |
560 methodHandle m(thread, method(thread)); |
567 constantPoolHandle pool(thread, last_frame.method()->constants()); |
|
568 methodHandle m(thread, last_frame.method()); |
561 bool is_put = (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_nofast_putfield || |
569 bool is_put = (bytecode == Bytecodes::_putfield || bytecode == Bytecodes::_nofast_putfield || |
562 bytecode == Bytecodes::_putstatic); |
570 bytecode == Bytecodes::_putstatic); |
563 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); |
571 bool is_static = (bytecode == Bytecodes::_getstatic || bytecode == Bytecodes::_putstatic); |
564 |
572 |
565 { |
573 { |
566 JvmtiHideSingleStepping jhss(thread); |
574 JvmtiHideSingleStepping jhss(thread); |
567 LinkResolver::resolve_field_access(info, pool, get_index_u2_cpcache(thread, bytecode), |
575 LinkResolver::resolve_field_access(info, pool, last_frame.get_index_u2_cpcache(bytecode), |
568 m, bytecode, CHECK); |
576 m, bytecode, CHECK); |
569 } // end JvmtiHideSingleStepping |
577 } // end JvmtiHideSingleStepping |
570 |
578 |
571 // check if link resolution caused cpCache to be updated |
579 // check if link resolution caused cpCache to be updated |
572 ConstantPoolCacheEntry* cp_cache_entry = cache_entry(thread); |
580 ConstantPoolCacheEntry* cp_cache_entry = last_frame.cache_entry(); |
573 if (cp_cache_entry->is_resolved(bytecode)) return; |
581 if (cp_cache_entry->is_resolved(bytecode)) return; |
574 |
582 |
575 // compute auxiliary field attributes |
583 // compute auxiliary field attributes |
576 TosState state = as_TosState(info.field_type()); |
584 TosState state = as_TosState(info.field_type()); |
577 |
585 |
716 JvmtiExport::post_raw_breakpoint(thread, method, bcp); |
724 JvmtiExport::post_raw_breakpoint(thread, method, bcp); |
717 IRT_END |
725 IRT_END |
718 |
726 |
719 void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode) { |
727 void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode) { |
720 Thread* THREAD = thread; |
728 Thread* THREAD = thread; |
|
729 LastFrameAccessor last_frame(thread); |
721 // extract receiver from the outgoing argument list if necessary |
730 // extract receiver from the outgoing argument list if necessary |
722 Handle receiver(thread, NULL); |
731 Handle receiver(thread, NULL); |
723 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface || |
732 if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface || |
724 bytecode == Bytecodes::_invokespecial) { |
733 bytecode == Bytecodes::_invokespecial) { |
725 ResourceMark rm(thread); |
734 ResourceMark rm(thread); |
726 methodHandle m (thread, method(thread)); |
735 methodHandle m (thread, last_frame.method()); |
727 Bytecode_invoke call(m, bci(thread)); |
736 Bytecode_invoke call(m, last_frame.bci()); |
728 Symbol* signature = call.signature(); |
737 Symbol* signature = call.signature(); |
729 receiver = Handle(thread, |
738 receiver = Handle(thread, last_frame.callee_receiver(signature)); |
730 thread->last_frame().interpreter_callee_receiver(signature)); |
739 |
731 assert(Universe::heap()->is_in_reserved_or_null(receiver()), |
740 assert(Universe::heap()->is_in_reserved_or_null(receiver()), |
732 "sanity check"); |
741 "sanity check"); |
733 assert(receiver.is_null() || |
742 assert(receiver.is_null() || |
734 !Universe::heap()->is_in_reserved(receiver->klass()), |
743 !Universe::heap()->is_in_reserved(receiver->klass()), |
735 "sanity check"); |
744 "sanity check"); |
736 } |
745 } |
737 |
746 |
738 // resolve method |
747 // resolve method |
739 CallInfo info; |
748 CallInfo info; |
740 constantPoolHandle pool(thread, method(thread)->constants()); |
749 constantPoolHandle pool(thread, last_frame.method()->constants()); |
741 |
750 |
742 { |
751 { |
743 JvmtiHideSingleStepping jhss(thread); |
752 JvmtiHideSingleStepping jhss(thread); |
744 LinkResolver::resolve_invoke(info, receiver, pool, |
753 LinkResolver::resolve_invoke(info, receiver, pool, |
745 get_index_u2_cpcache(thread, bytecode), bytecode, |
754 last_frame.get_index_u2_cpcache(bytecode), bytecode, |
746 CHECK); |
755 CHECK); |
747 if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
756 if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
748 int retry_count = 0; |
757 int retry_count = 0; |
749 while (info.resolved_method()->is_old()) { |
758 while (info.resolved_method()->is_old()) { |
750 // It is very unlikely that method is redefined more than 100 times |
759 // It is very unlikely that method is redefined more than 100 times |
752 // means then there could be a bug here. |
761 // means then there could be a bug here. |
753 guarantee((retry_count++ < 100), |
762 guarantee((retry_count++ < 100), |
754 "Could not resolve to latest version of redefined method"); |
763 "Could not resolve to latest version of redefined method"); |
755 // method is redefined in the middle of resolve so re-try. |
764 // method is redefined in the middle of resolve so re-try. |
756 LinkResolver::resolve_invoke(info, receiver, pool, |
765 LinkResolver::resolve_invoke(info, receiver, pool, |
757 get_index_u2_cpcache(thread, bytecode), bytecode, |
766 last_frame.get_index_u2_cpcache(bytecode), bytecode, |
758 CHECK); |
767 CHECK); |
759 } |
768 } |
760 } |
769 } |
761 } // end JvmtiHideSingleStepping |
770 } // end JvmtiHideSingleStepping |
762 |
771 |
763 // check if link resolution caused cpCache to be updated |
772 // check if link resolution caused cpCache to be updated |
764 ConstantPoolCacheEntry* cp_cache_entry = cache_entry(thread); |
773 ConstantPoolCacheEntry* cp_cache_entry = last_frame.cache_entry(); |
765 if (cp_cache_entry->is_resolved(bytecode)) return; |
774 if (cp_cache_entry->is_resolved(bytecode)) return; |
766 |
775 |
767 #ifdef ASSERT |
776 #ifdef ASSERT |
768 if (bytecode == Bytecodes::_invokeinterface) { |
777 if (bytecode == Bytecodes::_invokeinterface) { |
769 if (info.resolved_method()->method_holder() == |
778 if (info.resolved_method()->method_holder() == |
823 |
832 |
824 // First time execution: Resolve symbols, create a permanent MethodType object. |
833 // First time execution: Resolve symbols, create a permanent MethodType object. |
825 void InterpreterRuntime::resolve_invokehandle(JavaThread* thread) { |
834 void InterpreterRuntime::resolve_invokehandle(JavaThread* thread) { |
826 Thread* THREAD = thread; |
835 Thread* THREAD = thread; |
827 const Bytecodes::Code bytecode = Bytecodes::_invokehandle; |
836 const Bytecodes::Code bytecode = Bytecodes::_invokehandle; |
|
837 LastFrameAccessor last_frame(thread); |
828 |
838 |
829 // resolve method |
839 // resolve method |
830 CallInfo info; |
840 CallInfo info; |
831 constantPoolHandle pool(thread, method(thread)->constants()); |
841 constantPoolHandle pool(thread, last_frame.method()->constants()); |
832 { |
842 { |
833 JvmtiHideSingleStepping jhss(thread); |
843 JvmtiHideSingleStepping jhss(thread); |
834 LinkResolver::resolve_invoke(info, Handle(), pool, |
844 LinkResolver::resolve_invoke(info, Handle(), pool, |
835 get_index_u2_cpcache(thread, bytecode), bytecode, |
845 last_frame.get_index_u2_cpcache(bytecode), bytecode, |
836 CHECK); |
846 CHECK); |
837 } // end JvmtiHideSingleStepping |
847 } // end JvmtiHideSingleStepping |
838 |
848 |
839 ConstantPoolCacheEntry* cp_cache_entry = cache_entry(thread); |
849 ConstantPoolCacheEntry* cp_cache_entry = last_frame.cache_entry(); |
840 cp_cache_entry->set_method_handle(pool, info); |
850 cp_cache_entry->set_method_handle(pool, info); |
841 } |
851 } |
842 |
852 |
843 // First time execution: Resolve symbols, create a permanent CallSite object. |
853 // First time execution: Resolve symbols, create a permanent CallSite object. |
844 void InterpreterRuntime::resolve_invokedynamic(JavaThread* thread) { |
854 void InterpreterRuntime::resolve_invokedynamic(JavaThread* thread) { |
845 Thread* THREAD = thread; |
855 Thread* THREAD = thread; |
|
856 LastFrameAccessor last_frame(thread); |
846 const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; |
857 const Bytecodes::Code bytecode = Bytecodes::_invokedynamic; |
847 |
858 |
848 //TO DO: consider passing BCI to Java. |
859 //TO DO: consider passing BCI to Java. |
849 // int caller_bci = method(thread)->bci_from(bcp(thread)); |
860 // int caller_bci = last_frame.method()->bci_from(last_frame.bcp()); |
850 |
861 |
851 // resolve method |
862 // resolve method |
852 CallInfo info; |
863 CallInfo info; |
853 constantPoolHandle pool(thread, method(thread)->constants()); |
864 constantPoolHandle pool(thread, last_frame.method()->constants()); |
854 int index = get_index_u4(thread, bytecode); |
865 int index = last_frame.get_index_u4(bytecode); |
855 { |
866 { |
856 JvmtiHideSingleStepping jhss(thread); |
867 JvmtiHideSingleStepping jhss(thread); |
857 LinkResolver::resolve_invoke(info, Handle(), pool, |
868 LinkResolver::resolve_invoke(info, Handle(), pool, |
858 index, bytecode, CHECK); |
869 index, bytecode, CHECK); |
859 } // end JvmtiHideSingleStepping |
870 } // end JvmtiHideSingleStepping |
903 // This was a successful request for an OSR nmethod. Because |
914 // This was a successful request for an OSR nmethod. Because |
904 // frequency_counter_overflow_inner ends with a safepoint check, |
915 // frequency_counter_overflow_inner ends with a safepoint check, |
905 // nm could have been unloaded so look it up again. It's unsafe |
916 // nm could have been unloaded so look it up again. It's unsafe |
906 // to examine nm directly since it might have been freed and used |
917 // to examine nm directly since it might have been freed and used |
907 // for something else. |
918 // for something else. |
908 frame fr = thread->last_frame(); |
919 LastFrameAccessor last_frame(thread); |
909 Method* method = fr.interpreter_frame_method(); |
920 Method* method = last_frame.method(); |
910 int bci = method->bci_from(fr.interpreter_frame_bcp()); |
921 int bci = method->bci_from(last_frame.bcp()); |
911 nm = method->lookup_osr_nmethod_for(bci, CompLevel_none, false); |
922 nm = method->lookup_osr_nmethod_for(bci, CompLevel_none, false); |
912 } |
923 } |
913 #ifndef PRODUCT |
924 #ifndef PRODUCT |
914 if (TraceOnStackReplacement) { |
925 if (TraceOnStackReplacement) { |
915 if (nm != NULL) { |
926 if (nm != NULL) { |
925 InterpreterRuntime::frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp)) |
936 InterpreterRuntime::frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp)) |
926 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
937 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
927 // flag, in case this method triggers classloading which will call into Java. |
938 // flag, in case this method triggers classloading which will call into Java. |
928 UnlockFlagSaver fs(thread); |
939 UnlockFlagSaver fs(thread); |
929 |
940 |
930 frame fr = thread->last_frame(); |
941 LastFrameAccessor last_frame(thread); |
931 assert(fr.is_interpreted_frame(), "must come from interpreter"); |
942 assert(last_frame.is_interpreted_frame(), "must come from interpreter"); |
932 methodHandle method(thread, fr.interpreter_frame_method()); |
943 methodHandle method(thread, last_frame.method()); |
933 const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; |
944 const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; |
934 const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci; |
945 const int bci = branch_bcp != NULL ? method->bci_from(last_frame.bcp()) : InvocationEntryBci; |
935 |
946 |
936 assert(!HAS_PENDING_EXCEPTION, "Should not have any exceptions pending"); |
947 assert(!HAS_PENDING_EXCEPTION, "Should not have any exceptions pending"); |
937 nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread); |
948 nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread); |
938 assert(!HAS_PENDING_EXCEPTION, "Event handler should not throw any exceptions"); |
949 assert(!HAS_PENDING_EXCEPTION, "Event handler should not throw any exceptions"); |
939 |
950 |
945 // the OSR nmethod might be invalidated) because we don't have a |
956 // the OSR nmethod might be invalidated) because we don't have a |
946 // safepoint opportunity later once the migration begins. |
957 // safepoint opportunity later once the migration begins. |
947 if (UseBiasedLocking) { |
958 if (UseBiasedLocking) { |
948 ResourceMark rm; |
959 ResourceMark rm; |
949 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); |
960 GrowableArray<Handle>* objects_to_revoke = new GrowableArray<Handle>(); |
950 for( BasicObjectLock *kptr = fr.interpreter_frame_monitor_end(); |
961 for( BasicObjectLock *kptr = last_frame.monitor_end(); |
951 kptr < fr.interpreter_frame_monitor_begin(); |
962 kptr < last_frame.monitor_begin(); |
952 kptr = fr.next_monitor_in_interpreter_frame(kptr) ) { |
963 kptr = last_frame.next_monitor(kptr) ) { |
953 if( kptr->obj() != NULL ) { |
964 if( kptr->obj() != NULL ) { |
954 objects_to_revoke->append(Handle(THREAD, kptr->obj())); |
965 objects_to_revoke->append(Handle(THREAD, kptr->obj())); |
955 } |
966 } |
956 } |
967 } |
957 BiasedLocking::revoke(objects_to_revoke); |
968 BiasedLocking::revoke(objects_to_revoke); |
972 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
983 // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized |
973 // flag, in case this method triggers classloading which will call into Java. |
984 // flag, in case this method triggers classloading which will call into Java. |
974 UnlockFlagSaver fs(thread); |
985 UnlockFlagSaver fs(thread); |
975 |
986 |
976 assert(ProfileInterpreter, "must be profiling interpreter"); |
987 assert(ProfileInterpreter, "must be profiling interpreter"); |
977 frame fr = thread->last_frame(); |
988 LastFrameAccessor last_frame(thread); |
978 assert(fr.is_interpreted_frame(), "must come from interpreter"); |
989 assert(last_frame.is_interpreted_frame(), "must come from interpreter"); |
979 methodHandle method(thread, fr.interpreter_frame_method()); |
990 methodHandle method(thread, last_frame.method()); |
980 Method::build_interpreter_method_data(method, THREAD); |
991 Method::build_interpreter_method_data(method, THREAD); |
981 if (HAS_PENDING_EXCEPTION) { |
992 if (HAS_PENDING_EXCEPTION) { |
982 assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); |
993 assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); |
983 CLEAR_PENDING_EXCEPTION; |
994 CLEAR_PENDING_EXCEPTION; |
984 // and fall through... |
995 // and fall through... |
1019 |
1030 |
1020 IRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci)) |
1031 IRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci)) |
1021 assert(ProfileInterpreter, "must be profiling interpreter"); |
1032 assert(ProfileInterpreter, "must be profiling interpreter"); |
1022 ResourceMark rm(thread); |
1033 ResourceMark rm(thread); |
1023 HandleMark hm(thread); |
1034 HandleMark hm(thread); |
1024 frame fr = thread->last_frame(); |
1035 LastFrameAccessor last_frame(thread); |
1025 assert(fr.is_interpreted_frame(), "must come from interpreter"); |
1036 assert(last_frame.is_interpreted_frame(), "must come from interpreter"); |
1026 MethodData* h_mdo = fr.interpreter_frame_method()->method_data(); |
1037 MethodData* h_mdo = last_frame.method()->method_data(); |
1027 |
1038 |
1028 // Grab a lock to ensure atomic access to setting the return bci and |
1039 // Grab a lock to ensure atomic access to setting the return bci and |
1029 // the displacement. This can block and GC, invalidating all naked oops. |
1040 // the displacement. This can block and GC, invalidating all naked oops. |
1030 MutexLocker ml(RetData_lock); |
1041 MutexLocker ml(RetData_lock); |
1031 |
1042 |
1032 // ProfileData is essentially a wrapper around a derived oop, so we |
1043 // ProfileData is essentially a wrapper around a derived oop, so we |
1033 // need to take the lock before making any ProfileData structures. |
1044 // need to take the lock before making any ProfileData structures. |
1034 ProfileData* data = h_mdo->data_at(h_mdo->dp_to_di(fr.interpreter_frame_mdp())); |
1045 ProfileData* data = h_mdo->data_at(h_mdo->dp_to_di(last_frame.mdp())); |
1035 guarantee(data != NULL, "profile data must be valid"); |
1046 guarantee(data != NULL, "profile data must be valid"); |
1036 RetData* rdata = data->as_RetData(); |
1047 RetData* rdata = data->as_RetData(); |
1037 address new_mdp = rdata->fixup_ret(return_bci, h_mdo); |
1048 address new_mdp = rdata->fixup_ret(return_bci, h_mdo); |
1038 fr.interpreter_frame_set_mdp(new_mdp); |
1049 last_frame.set_mdp(new_mdp); |
1039 IRT_END |
1050 IRT_END |
1040 |
1051 |
1041 IRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* thread, Method* m)) |
1052 IRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* thread, Method* m)) |
1042 MethodCounters* mcs = Method::build_method_counters(m, thread); |
1053 MethodCounters* mcs = Method::build_method_counters(m, thread); |
1043 if (HAS_PENDING_EXCEPTION) { |
1054 if (HAS_PENDING_EXCEPTION) { |
1058 |
1069 |
1059 if (JvmtiExport::should_post_single_step()) { |
1070 if (JvmtiExport::should_post_single_step()) { |
1060 // We are called during regular safepoints and when the VM is |
1071 // We are called during regular safepoints and when the VM is |
1061 // single stepping. If any thread is marked for single stepping, |
1072 // single stepping. If any thread is marked for single stepping, |
1062 // then we may have JVMTI work to do. |
1073 // then we may have JVMTI work to do. |
1063 JvmtiExport::at_single_stepping_point(thread, method(thread), bcp(thread)); |
1074 LastFrameAccessor last_frame(thread); |
|
1075 JvmtiExport::at_single_stepping_point(thread, last_frame.method(), last_frame.bcp()); |
1064 } |
1076 } |
1065 IRT_END |
1077 IRT_END |
1066 |
1078 |
1067 IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, |
1079 IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj, |
1068 ConstantPoolCacheEntry *cp_entry)) |
1080 ConstantPoolCacheEntry *cp_entry)) |
1081 // non-static field accessors have an object, but we need a handle |
1093 // non-static field accessors have an object, but we need a handle |
1082 h_obj = Handle(thread, obj); |
1094 h_obj = Handle(thread, obj); |
1083 } |
1095 } |
1084 InstanceKlass* cp_entry_f1 = InstanceKlass::cast(cp_entry->f1_as_klass()); |
1096 InstanceKlass* cp_entry_f1 = InstanceKlass::cast(cp_entry->f1_as_klass()); |
1085 jfieldID fid = jfieldIDWorkaround::to_jfieldID(cp_entry_f1, cp_entry->f2_as_index(), is_static); |
1097 jfieldID fid = jfieldIDWorkaround::to_jfieldID(cp_entry_f1, cp_entry->f2_as_index(), is_static); |
1086 JvmtiExport::post_field_access(thread, method(thread), bcp(thread), cp_entry_f1, h_obj, fid); |
1098 LastFrameAccessor last_frame(thread); |
|
1099 JvmtiExport::post_field_access(thread, last_frame.method(), last_frame.bcp(), cp_entry_f1, h_obj, fid); |
1087 IRT_END |
1100 IRT_END |
1088 |
1101 |
1089 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, |
1102 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread, |
1090 oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) |
1103 oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value)) |
1091 |
1104 |
1136 if (!is_static) { |
1149 if (!is_static) { |
1137 // non-static field accessors have an object, but we need a handle |
1150 // non-static field accessors have an object, but we need a handle |
1138 h_obj = Handle(thread, obj); |
1151 h_obj = Handle(thread, obj); |
1139 } |
1152 } |
1140 |
1153 |
1141 JvmtiExport::post_raw_field_modification(thread, method(thread), bcp(thread), ik, h_obj, |
1154 LastFrameAccessor last_frame(thread); |
|
1155 JvmtiExport::post_raw_field_modification(thread, last_frame.method(), last_frame.bcp(), ik, h_obj, |
1142 fid, sig_type, &fvalue); |
1156 fid, sig_type, &fvalue); |
1143 IRT_END |
1157 IRT_END |
1144 |
1158 |
1145 IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) |
1159 IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread)) |
1146 JvmtiExport::post_method_entry(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); |
1160 LastFrameAccessor last_frame(thread); |
|
1161 JvmtiExport::post_method_entry(thread, last_frame.method(), last_frame.get_frame()); |
1147 IRT_END |
1162 IRT_END |
1148 |
1163 |
1149 |
1164 |
1150 IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) |
1165 IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread)) |
1151 JvmtiExport::post_method_exit(thread, InterpreterRuntime::method(thread), InterpreterRuntime::last_frame(thread)); |
1166 LastFrameAccessor last_frame(thread); |
|
1167 JvmtiExport::post_method_exit(thread, last_frame.method(), last_frame.get_frame()); |
1152 IRT_END |
1168 IRT_END |
1153 |
1169 |
1154 IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) |
1170 IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc)) |
1155 { |
1171 { |
1156 return (Interpreter::contains(pc) ? 1 : 0); |
1172 return (Interpreter::contains(pc) ? 1 : 0); |
1370 return; |
1386 return; |
1371 } |
1387 } |
1372 ResetNoHandleMark rnm; // In a LEAF entry. |
1388 ResetNoHandleMark rnm; // In a LEAF entry. |
1373 HandleMark hm; |
1389 HandleMark hm; |
1374 ResourceMark rm; |
1390 ResourceMark rm; |
1375 frame fr = thread->last_frame(); |
1391 LastFrameAccessor last_frame(thread); |
1376 assert(fr.is_interpreted_frame(), ""); |
1392 assert(last_frame.is_interpreted_frame(), ""); |
1377 jint bci = fr.interpreter_frame_bci(); |
1393 jint bci = last_frame.bci(); |
1378 methodHandle mh(thread, fr.interpreter_frame_method()); |
1394 methodHandle mh(thread, last_frame.method()); |
1379 Bytecode_invoke invoke(mh, bci); |
1395 Bytecode_invoke invoke(mh, bci); |
1380 ArgumentSizeComputer asc(invoke.signature()); |
1396 ArgumentSizeComputer asc(invoke.signature()); |
1381 int size_of_arguments = (asc.size() + (invoke.has_receiver() ? 1 : 0)); // receiver |
1397 int size_of_arguments = (asc.size() + (invoke.has_receiver() ? 1 : 0)); // receiver |
1382 Copy::conjoint_jbytes(src_address, dest_address, |
1398 Copy::conjoint_jbytes(src_address, dest_address, |
1383 size_of_arguments * Interpreter::stackElementSize); |
1399 size_of_arguments * Interpreter::stackElementSize); |
1419 // This must be a IRT_LEAF function because the interpreter must save registers on x86 to |
1435 // This must be a IRT_LEAF function because the interpreter must save registers on x86 to |
1420 // call this, which changes rsp and makes the interpreter's expression stack not walkable. |
1436 // call this, which changes rsp and makes the interpreter's expression stack not walkable. |
1421 // The generated code still uses call_VM because that will set up the frame pointer for |
1437 // The generated code still uses call_VM because that will set up the frame pointer for |
1422 // bcp and method. |
1438 // bcp and method. |
1423 IRT_LEAF(intptr_t, InterpreterRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2)) |
1439 IRT_LEAF(intptr_t, InterpreterRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2)) |
1424 const frame f = thread->last_frame(); |
1440 LastFrameAccessor last_frame(thread); |
1425 assert(f.is_interpreted_frame(), "must be an interpreted frame"); |
1441 assert(last_frame.is_interpreted_frame(), "must be an interpreted frame"); |
1426 methodHandle mh(thread, f.interpreter_frame_method()); |
1442 methodHandle mh(thread, last_frame.method()); |
1427 BytecodeTracer::trace(mh, f.interpreter_frame_bcp(), tos, tos2); |
1443 BytecodeTracer::trace(mh, last_frame.bcp(), tos, tos2); |
1428 return preserve_this_value; |
1444 return preserve_this_value; |
1429 IRT_END |
1445 IRT_END |
1430 #endif // !PRODUCT |
1446 #endif // !PRODUCT |