< prev index next >

src/share/vm/runtime/sharedRuntime.hpp

Print this page




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
  26 #define SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
  27 
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeTracer.hpp"
  30 #include "interpreter/linkResolver.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "utilities/hashtable.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 class AdapterHandlerEntry;
  37 class AdapterHandlerTable;
  38 class AdapterFingerPrint;
  39 class vframeStream;
  40 










































  41 // Runtime is the base class for various runtime interfaces
  42 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
  43 // shared functionality such as exception forwarding (C++ to
  44 // Java exceptions), locking/unlocking mechanisms, statistical
  45 // information, etc.
  46 
  47 class SharedRuntime: AllStatic {
  48   friend class VMStructs;
  49 
  50  private:
  51   static methodHandle resolve_sub_helper(JavaThread *thread,
  52                                          bool is_virtual,
  53                                          bool is_optimized, TRAPS);
  54 
  55   // Shared stub locations
  56 
  57   static RuntimeStub*        _wrong_method_blob;
  58   static RuntimeStub*        _wrong_method_abstract_blob;
  59   static RuntimeStub*        _ic_miss_blob;
  60   static RuntimeStub*        _resolve_opt_virtual_call_blob;


 414   // the blob to pass the incoming stack pointer (the sender sp) in a known
 415   // location for the interpreter to record. This is used by the frame code
 416   // to correct the sender code to match up with the stack pointer when the
 417   // thread left the compiled code. In addition it allows the interpreter
 418   // to remove the space the c2i adapter allocated to do its argument conversion.
 419 
 420   // Although a c2i blob will always run interpreted even if compiled code is
 421   // present if we see that compiled code is present the compiled call site
 422   // will be patched/re-resolved so that later calls will run compiled.
 423 
 424   // Additionally a c2i blob need to have a unverified entry because it can be reached
 425   // in situations where the call site is an inlined cache site and may go megamorphic.
 426 
 427   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 428   // that the interpreter before it does any call dispatch will record the current
 429   // stack pointer in the interpreter frame. On return it will restore the stack
 430   // pointer as needed. This means the i2c adapter code doesn't need any special
 431   // handshaking path with compiled code to keep the stack walking correct.
 432 
 433   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
 434                                                       int total_args_passed,
 435                                                       int max_arg,
 436                                                       const BasicType *sig_bt,
 437                                                       const VMRegPair *regs,
 438                                                       AdapterFingerPrint* fingerprint);

 439 
 440   static void gen_i2c_adapter(MacroAssembler *_masm,
 441                               int total_args_passed,
 442                               int comp_args_on_stack,
 443                               const BasicType *sig_bt,
 444                               const VMRegPair *regs);
 445 
 446   // OSR support
 447 
 448   // OSR_migration_begin will extract the jvm state from an interpreter
 449   // frame (locals, monitors) and store the data in a piece of C heap
 450   // storage. This then allows the interpreter frame to be removed from the
 451   // stack and the OSR nmethod to be called. That method is called with a
 452   // pointer to the C heap storage. This pointer is the return value from
 453   // OSR_migration_begin.
 454 
 455   static intptr_t* OSR_migration_begin(JavaThread *thread);
 456 
 457   // OSR_migration_end is a trivial routine. It is called after the compiled
 458   // method has extracted the jvm state from the C heap that OSR_migration_begin
 459   // created. It's entire job is to simply free this storage.
 460   static void OSR_migration_end(intptr_t* buf);
 461 
 462   // Convert a sig into a calling convention register layout
 463   // and find interesting things about it.


 505 
 506   // Slow-path Locking and Unlocking
 507   static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 508   static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 509 
 510   // Resolving of calls
 511   static address resolve_static_call_C     (JavaThread *thread);
 512   static address resolve_virtual_call_C    (JavaThread *thread);
 513   static address resolve_opt_virtual_call_C(JavaThread *thread);
 514 
 515   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
 516   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
 517                                oopDesc* dest, jint dest_pos,
 518                                jint length, JavaThread* thread);
 519 
 520   // handle ic miss with caller being compiled code
 521   // wrong method handling (inline cache misses, zombie methods)
 522   static address handle_wrong_method(JavaThread* thread);
 523   static address handle_wrong_method_abstract(JavaThread* thread);
 524   static address handle_wrong_method_ic_miss(JavaThread* thread);

 525 
 526 #ifndef PRODUCT
 527 
 528   // Collect and print inline cache miss statistics
 529  private:
 530   enum { maxICmiss_count = 100 };
 531   static int     _ICmiss_index;                  // length of IC miss histogram
 532   static int     _ICmiss_count[maxICmiss_count]; // miss counts
 533   static address _ICmiss_at[maxICmiss_count];    // miss addresses
 534   static void trace_ic_miss(address at);
 535 
 536  public:
 537   static int _throw_null_ctr;                    // throwing a null-pointer exception
 538   static int _ic_miss_ctr;                       // total # of IC misses
 539   static int _wrong_method_ctr;
 540   static int _resolve_static_ctr;
 541   static int _resolve_virtual_ctr;
 542   static int _resolve_opt_virtual_ctr;
 543   static int _implicit_null_throws;
 544   static int _implicit_div0_throws;




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
  26 #define SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
  27 
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/bytecodeTracer.hpp"
  30 #include "interpreter/linkResolver.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "utilities/hashtable.hpp"
  34 #include "utilities/macros.hpp"
  35 
  36 class AdapterHandlerEntry;
  37 class AdapterHandlerTable;
  38 class AdapterFingerPrint;
  39 class vframeStream;
  40 
  41 // Used for adapter generation. One SigEntry is used per element of
  42 // the signature of the method. Value type arguments are treated
  43 // specially. See comment for collect_fields().
  44 class SigEntry VALUE_OBJ_CLASS_SPEC {
  45  public:
  46   BasicType _bt;
  47   int _offset;
  48     
  49   SigEntry()
  50     : _bt(T_ILLEGAL), _offset(-1) {
  51   }
  52   SigEntry(BasicType bt, int offset)
  53     : _bt(bt), _offset(offset) {}
  54 
  55   SigEntry(BasicType bt)
  56     : _bt(bt), _offset(-1) {}
  57   
  58   static int compare(SigEntry* e1, SigEntry* e2) {
  59     if (e1->_offset != e2->_offset) {
  60       return e1->_offset - e2->_offset;
  61     }
  62     assert((e1->_bt == T_LONG && (e2->_bt == T_LONG || e2->_bt == T_VOID)) ||
  63            (e1->_bt == T_DOUBLE && (e2->_bt == T_DOUBLE || e2->_bt == T_VOID)) ||
  64            e1->_bt == T_VALUETYPE || e2->_bt == T_VALUETYPE || e1->_bt == T_VOID || e2->_bt == T_VOID, "bad bt");
  65     if (e1->_bt == e2->_bt) {
  66       assert(e1->_bt == T_VALUETYPE || e1->_bt == T_VOID, "");
  67       return 0;
  68     }
  69     if (e1->_bt == T_VOID ||
  70         e2->_bt == T_VALUETYPE) {
  71       return 1;
  72     }
  73     if (e1->_bt == T_VALUETYPE ||
  74         e2->_bt == T_VOID) {
  75       return -1;
  76     }
  77     ShouldNotReachHere();
  78     return 0;
  79   }
  80 };
  81 
  82 
  83 // Runtime is the base class for various runtime interfaces
  84 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
  85 // shared functionality such as exception forwarding (C++ to
  86 // Java exceptions), locking/unlocking mechanisms, statistical
  87 // information, etc.
  88 
  89 class SharedRuntime: AllStatic {
  90   friend class VMStructs;
  91 
  92  private:
  93   static methodHandle resolve_sub_helper(JavaThread *thread,
  94                                          bool is_virtual,
  95                                          bool is_optimized, TRAPS);
  96 
  97   // Shared stub locations
  98 
  99   static RuntimeStub*        _wrong_method_blob;
 100   static RuntimeStub*        _wrong_method_abstract_blob;
 101   static RuntimeStub*        _ic_miss_blob;
 102   static RuntimeStub*        _resolve_opt_virtual_call_blob;


 456   // the blob to pass the incoming stack pointer (the sender sp) in a known
 457   // location for the interpreter to record. This is used by the frame code
 458   // to correct the sender code to match up with the stack pointer when the
 459   // thread left the compiled code. In addition it allows the interpreter
 460   // to remove the space the c2i adapter allocated to do its argument conversion.
 461 
 462   // Although a c2i blob will always run interpreted even if compiled code is
 463   // present if we see that compiled code is present the compiled call site
 464   // will be patched/re-resolved so that later calls will run compiled.
 465 
 466   // Additionally a c2i blob need to have a unverified entry because it can be reached
 467   // in situations where the call site is an inlined cache site and may go megamorphic.
 468 
 469   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 470   // that the interpreter before it does any call dispatch will record the current
 471   // stack pointer in the interpreter frame. On return it will restore the stack
 472   // pointer as needed. This means the i2c adapter code doesn't need any special
 473   // handshaking path with compiled code to keep the stack walking correct.
 474 
 475   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
 476                                                       int comp_args_on_stack,
 477                                                       const GrowableArray<SigEntry>& sig,

 478                                                       const VMRegPair *regs,
 479                                                       AdapterFingerPrint* fingerprint,
 480                                                       AdapterBlob*& new_adapter);
 481 
 482   static void gen_i2c_adapter(MacroAssembler *_masm,

 483                               int comp_args_on_stack,
 484                               const GrowableArray<SigEntry>& sig,
 485                               const VMRegPair *regs);
 486 
 487   // OSR support
 488 
 489   // OSR_migration_begin will extract the jvm state from an interpreter
 490   // frame (locals, monitors) and store the data in a piece of C heap
 491   // storage. This then allows the interpreter frame to be removed from the
 492   // stack and the OSR nmethod to be called. That method is called with a
 493   // pointer to the C heap storage. This pointer is the return value from
 494   // OSR_migration_begin.
 495 
 496   static intptr_t* OSR_migration_begin(JavaThread *thread);
 497 
 498   // OSR_migration_end is a trivial routine. It is called after the compiled
 499   // method has extracted the jvm state from the C heap that OSR_migration_begin
 500   // created. It's entire job is to simply free this storage.
 501   static void OSR_migration_end(intptr_t* buf);
 502 
 503   // Convert a sig into a calling convention register layout
 504   // and find interesting things about it.


 546 
 547   // Slow-path Locking and Unlocking
 548   static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 549   static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
 550 
 551   // Resolving of calls
 552   static address resolve_static_call_C     (JavaThread *thread);
 553   static address resolve_virtual_call_C    (JavaThread *thread);
 554   static address resolve_opt_virtual_call_C(JavaThread *thread);
 555 
 556   // arraycopy, the non-leaf version.  (See StubRoutines for all the leaf calls.)
 557   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
 558                                oopDesc* dest, jint dest_pos,
 559                                jint length, JavaThread* thread);
 560 
 561   // handle ic miss with caller being compiled code
 562   // wrong method handling (inline cache misses, zombie methods)
 563   static address handle_wrong_method(JavaThread* thread);
 564   static address handle_wrong_method_abstract(JavaThread* thread);
 565   static address handle_wrong_method_ic_miss(JavaThread* thread);
 566   static void allocate_value_types(JavaThread* thread);
 567 
 568 #ifndef PRODUCT
 569 
 570   // Collect and print inline cache miss statistics
 571  private:
 572   enum { maxICmiss_count = 100 };
 573   static int     _ICmiss_index;                  // length of IC miss histogram
 574   static int     _ICmiss_count[maxICmiss_count]; // miss counts
 575   static address _ICmiss_at[maxICmiss_count];    // miss addresses
 576   static void trace_ic_miss(address at);
 577 
 578  public:
 579   static int _throw_null_ctr;                    // throwing a null-pointer exception
 580   static int _ic_miss_ctr;                       // total # of IC misses
 581   static int _wrong_method_ctr;
 582   static int _resolve_static_ctr;
 583   static int _resolve_virtual_ctr;
 584   static int _resolve_opt_virtual_ctr;
 585   static int _implicit_null_throws;
 586   static int _implicit_div0_throws;


< prev index next >