36 #include "interpreter/templateTable.hpp" 37 #include "logging/log.hpp" 38 #include "memory/oopFactory.hpp" 39 #include "memory/resourceArea.hpp" 40 #include "memory/universe.hpp" 41 #include "oops/constantPool.hpp" 42 #include "oops/cpCache.inline.hpp" 43 #include "oops/instanceKlass.hpp" 44 #include "oops/methodData.hpp" 45 #include "oops/objArrayKlass.hpp" 46 #include "oops/objArrayOop.inline.hpp" 47 #include "oops/oop.inline.hpp" 48 #include "oops/symbol.hpp" 49 #include "prims/jvmtiExport.hpp" 50 #include "prims/nativeLookup.hpp" 51 #include "runtime/atomic.hpp" 52 #include "runtime/biasedLocking.hpp" 53 #include "runtime/compilationPolicy.hpp" 54 #include "runtime/deoptimization.hpp" 55 #include "runtime/fieldDescriptor.hpp" 56 #include "runtime/handles.inline.hpp" 57 #include "runtime/icache.hpp" 58 #include "runtime/interfaceSupport.inline.hpp" 59 #include "runtime/java.hpp" 60 #include "runtime/jfieldIDWorkaround.hpp" 61 #include "runtime/osThread.hpp" 62 #include "runtime/sharedRuntime.hpp" 63 #include "runtime/stubRoutines.hpp" 64 #include "runtime/synchronizer.hpp" 65 #include "runtime/threadCritical.hpp" 66 #include "utilities/align.hpp" 67 #include "utilities/events.hpp" 68 #ifdef COMPILER2 69 #include "opto/runtime.hpp" 70 #endif 71 72 class UnlockFlagSaver { 73 private: 74 JavaThread* _thread; 75 bool _do_not_unlock; 76 public: 77 UnlockFlagSaver(JavaThread* t) { 78 _thread = t; 79 _do_not_unlock = t->do_not_unlock_if_synchronized(); 80 t->set_do_not_unlock_if_synchronized(false); 81 } 82 ~UnlockFlagSaver() { 83 _thread->set_do_not_unlock_if_synchronized(_do_not_unlock); 84 } 85 }; 86 87 //------------------------------------------------------------------------------------------------------------------------ 88 // State accessors 89 90 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { 91 LastFrameAccessor last_frame(thread); 92 last_frame.set_bcp(bcp); 93 if (ProfileInterpreter) { 94 // ProfileTraps uses MDOs independently of ProfileInterpreter. 95 // That is why we must check both ProfileInterpreter and mdo != NULL. 96 MethodData* mdo = last_frame.method()->method_data(); 97 if (mdo != NULL) { 98 NEEDS_CLEANUP; 99 last_frame.set_mdp(mdo->bci_to_dp(last_frame.bci())); 100 } 101 } 102 } 103 104 //------------------------------------------------------------------------------------------------------------------------ 105 // Constants | 36 #include "interpreter/templateTable.hpp" 37 #include "logging/log.hpp" 38 #include "memory/oopFactory.hpp" 39 #include "memory/resourceArea.hpp" 40 #include "memory/universe.hpp" 41 #include "oops/constantPool.hpp" 42 #include "oops/cpCache.inline.hpp" 43 #include "oops/instanceKlass.hpp" 44 #include "oops/methodData.hpp" 45 #include "oops/objArrayKlass.hpp" 46 #include "oops/objArrayOop.inline.hpp" 47 #include "oops/oop.inline.hpp" 48 #include "oops/symbol.hpp" 49 #include "prims/jvmtiExport.hpp" 50 #include "prims/nativeLookup.hpp" 51 #include "runtime/atomic.hpp" 52 #include "runtime/biasedLocking.hpp" 53 #include "runtime/compilationPolicy.hpp" 54 #include "runtime/deoptimization.hpp" 55 #include "runtime/fieldDescriptor.hpp" 56 #include "runtime/frame.inline.hpp" 57 #include "runtime/handles.inline.hpp" 58 #include "runtime/icache.hpp" 59 #include "runtime/interfaceSupport.inline.hpp" 60 #include "runtime/java.hpp" 61 #include "runtime/jfieldIDWorkaround.hpp" 62 #include "runtime/osThread.hpp" 63 #include "runtime/sharedRuntime.hpp" 64 #include "runtime/stubRoutines.hpp" 65 #include "runtime/synchronizer.hpp" 66 #include "runtime/threadCritical.hpp" 67 #include "utilities/align.hpp" 68 #include "utilities/events.hpp" 69 #ifdef COMPILER2 70 #include "opto/runtime.hpp" 71 #endif 72 73 class UnlockFlagSaver { 74 private: 75 JavaThread* _thread; 76 bool _do_not_unlock; 77 public: 78 UnlockFlagSaver(JavaThread* t) { 79 _thread = t; 80 _do_not_unlock = t->do_not_unlock_if_synchronized(); 81 t->set_do_not_unlock_if_synchronized(false); 82 } 83 ~UnlockFlagSaver() { 84 _thread->set_do_not_unlock_if_synchronized(_do_not_unlock); 85 } 86 }; 87 88 // Helper class to access current interpreter state 89 class LastFrameAccessor : public StackObj { 90 frame _last_frame; 91 public: 92 LastFrameAccessor(JavaThread* thread) { 93 assert(thread == Thread::current(), "sanity"); 94 _last_frame = thread->last_frame(); 95 } 96 bool is_interpreted_frame() const { return _last_frame.is_interpreted_frame(); } 97 Method* method() const { return _last_frame.interpreter_frame_method(); } 98 address bcp() const { return _last_frame.interpreter_frame_bcp(); } 99 int bci() const { return _last_frame.interpreter_frame_bci(); } 100 address mdp() const { return _last_frame.interpreter_frame_mdp(); } 101 102 void set_bcp(address bcp) { _last_frame.interpreter_frame_set_bcp(bcp); } 103 void set_mdp(address dp) { _last_frame.interpreter_frame_set_mdp(dp); } 104 105 // pass method to avoid calling unsafe bcp_to_method (partial fix 4926272) 106 Bytecodes::Code code() const { return Bytecodes::code_at(method(), bcp()); } 107 108 Bytecode bytecode() const { return Bytecode(method(), bcp()); } 109 int get_index_u1(Bytecodes::Code bc) const { return bytecode().get_index_u1(bc); } 110 int get_index_u2(Bytecodes::Code bc) const { return bytecode().get_index_u2(bc); } 111 int get_index_u2_cpcache(Bytecodes::Code bc) const 112 { return bytecode().get_index_u2_cpcache(bc); } 113 int get_index_u4(Bytecodes::Code bc) const { return bytecode().get_index_u4(bc); } 114 int number_of_dimensions() const { return bcp()[3]; } 115 ConstantPoolCacheEntry* cache_entry_at(int i) const 116 { return method()->constants()->cache()->entry_at(i); } 117 ConstantPoolCacheEntry* cache_entry() const { return cache_entry_at(Bytes::get_native_u2(bcp() + 1)); } 118 119 oop callee_receiver(Symbol* signature) { 120 return _last_frame.interpreter_callee_receiver(signature); 121 } 122 BasicObjectLock* monitor_begin() const { 123 return _last_frame.interpreter_frame_monitor_begin(); 124 } 125 BasicObjectLock* monitor_end() const { 126 return _last_frame.interpreter_frame_monitor_end(); 127 } 128 BasicObjectLock* next_monitor(BasicObjectLock* current) const { 129 return _last_frame.next_monitor_in_interpreter_frame(current); 130 } 131 132 frame& get_frame() { return _last_frame; } 133 }; 134 135 136 bool InterpreterRuntime::is_breakpoint(JavaThread *thread) { 137 return Bytecodes::code_or_bp_at(LastFrameAccessor(thread).bcp()) == Bytecodes::_breakpoint; 138 } 139 140 //------------------------------------------------------------------------------------------------------------------------ 141 // State accessors 142 143 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) { 144 LastFrameAccessor last_frame(thread); 145 last_frame.set_bcp(bcp); 146 if (ProfileInterpreter) { 147 // ProfileTraps uses MDOs independently of ProfileInterpreter. 148 // That is why we must check both ProfileInterpreter and mdo != NULL. 149 MethodData* mdo = last_frame.method()->method_data(); 150 if (mdo != NULL) { 151 NEEDS_CLEANUP; 152 last_frame.set_mdp(mdo->bci_to_dp(last_frame.bci())); 153 } 154 } 155 } 156 157 //------------------------------------------------------------------------------------------------------------------------ 158 // Constants |