src/hotspot/share/interpreter/interpreterRuntime.cpp
changeset 49480 d7df2dd501ce
parent 49449 ef5d5d343e2a
child 49593 4dd58ecc9912
equal deleted inserted replaced
49479:5865398439d4 49480:d7df2dd501ce
    51 #include "runtime/atomic.hpp"
    51 #include "runtime/atomic.hpp"
    52 #include "runtime/biasedLocking.hpp"
    52 #include "runtime/biasedLocking.hpp"
    53 #include "runtime/compilationPolicy.hpp"
    53 #include "runtime/compilationPolicy.hpp"
    54 #include "runtime/deoptimization.hpp"
    54 #include "runtime/deoptimization.hpp"
    55 #include "runtime/fieldDescriptor.hpp"
    55 #include "runtime/fieldDescriptor.hpp"
       
    56 #include "runtime/frame.inline.hpp"
    56 #include "runtime/handles.inline.hpp"
    57 #include "runtime/handles.inline.hpp"
    57 #include "runtime/icache.hpp"
    58 #include "runtime/icache.hpp"
    58 #include "runtime/interfaceSupport.inline.hpp"
    59 #include "runtime/interfaceSupport.inline.hpp"
    59 #include "runtime/java.hpp"
    60 #include "runtime/java.hpp"
    60 #include "runtime/jfieldIDWorkaround.hpp"
    61 #include "runtime/jfieldIDWorkaround.hpp"
    81     }
    82     }
    82     ~UnlockFlagSaver() {
    83     ~UnlockFlagSaver() {
    83       _thread->set_do_not_unlock_if_synchronized(_do_not_unlock);
    84       _thread->set_do_not_unlock_if_synchronized(_do_not_unlock);
    84     }
    85     }
    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 }
    86 
   139 
    87 //------------------------------------------------------------------------------------------------------------------------
   140 //------------------------------------------------------------------------------------------------------------------------
    88 // State accessors
   141 // State accessors
    89 
   142 
    90 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) {
   143 void InterpreterRuntime::set_bcp_and_mdp(address bcp, JavaThread *thread) {