< prev index next >

src/hotspot/share/runtime/sharedRuntime.hpp

Print this page




 355   static address clean_static_call_entry();
 356 
 357 #if defined(X86) && defined(COMPILER1)
 358   // For Object.hashCode, System.identityHashCode try to pull hashCode from object header if available.
 359   static void inline_check_hashcode_from_object_header(MacroAssembler* masm, const methodHandle& method, Register obj_reg, Register result);
 360 #endif // X86 && COMPILER1
 361 
 362  public:
 363 
 364   // Read the array of BasicTypes from a Java signature, and compute where
 365   // compiled Java code would like to put the results.  Values in reg_lo and
 366   // reg_hi refer to 4-byte quantities.  Values less than SharedInfo::stack0 are
 367   // registers, those above refer to 4-byte stack slots.  All stack slots are
 368   // based off of the window top.  SharedInfo::stack0 refers to the first usable
 369   // slot in the bottom of the frame. SharedInfo::stack0+1 refers to the memory word
 370   // 4-bytes higher. So for sparc because the register window save area is at
 371   // the bottom of the frame the first 16 words will be skipped and SharedInfo::stack0
 372   // will be just above it. (
 373   // return value is the maximum number of VMReg stack slots the convention will use.
 374   static int java_calling_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed, int is_outgoing);





 375   static int java_return_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed);
 376   static const uint java_return_convention_max_int;
 377   static const uint java_return_convention_max_float;
 378 
 379   static void check_member_name_argument_is_last_argument(const methodHandle& method,
 380                                                           const BasicType* sig_bt,
 381                                                           const VMRegPair* regs) NOT_DEBUG_RETURN;
 382 
 383   // Ditto except for calling C
 384   //
 385   // C argument in register AND stack slot.
 386   // Some architectures require that an argument must be passed in a register
 387   // AND in a stack slot. These architectures provide a second VMRegPair array
 388   // to be filled by the c_calling_convention method. On other architectures,
 389   // NULL is being passed as the second VMRegPair array, so arguments are either
 390   // passed in a register OR in a stack slot.
 391   static int c_calling_convention(const BasicType *sig_bt, VMRegPair *regs, VMRegPair *regs2,
 392                                   int total_args_passed);
 393 
 394   static size_t trampoline_size();


 407   // location for the interpreter to record. This is used by the frame code
 408   // to correct the sender code to match up with the stack pointer when the
 409   // thread left the compiled code. In addition it allows the interpreter
 410   // to remove the space the c2i adapter allocated to do its argument conversion.
 411 
 412   // Although a c2i blob will always run interpreted even if compiled code is
 413   // present if we see that compiled code is present the compiled call site
 414   // will be patched/re-resolved so that later calls will run compiled.
 415 
 416   // Additionally a c2i blob need to have a unverified entry because it can be reached
 417   // in situations where the call site is an inlined cache site and may go megamorphic.
 418 
 419   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 420   // that the interpreter before it does any call dispatch will record the current
 421   // stack pointer in the interpreter frame. On return it will restore the stack
 422   // pointer as needed. This means the i2c adapter code doesn't need any special
 423   // handshaking path with compiled code to keep the stack walking correct.
 424 
 425   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *masm,
 426                                                       int comp_args_on_stack,
 427                                                       const GrowableArray<SigEntry>& sig_extended,
 428                                                       const VMRegPair *regs,



 429                                                       AdapterFingerPrint* fingerprint,
 430                                                       AdapterBlob*& new_adapter);
 431 
 432   static void gen_i2c_adapter(MacroAssembler *_masm,
 433                               int comp_args_on_stack,
 434                               const GrowableArray<SigEntry>& sig_extended,
 435                               const VMRegPair *regs);
 436 
 437   // OSR support
 438 
 439   // OSR_migration_begin will extract the jvm state from an interpreter
 440   // frame (locals, monitors) and store the data in a piece of C heap
 441   // storage. This then allows the interpreter frame to be removed from the
 442   // stack and the OSR nmethod to be called. That method is called with a
 443   // pointer to the C heap storage. This pointer is the return value from
 444   // OSR_migration_begin.
 445 
 446   static intptr_t* OSR_migration_begin(JavaThread *thread);
 447 
 448   // OSR_migration_end is a trivial routine. It is called after the compiled
 449   // method has extracted the jvm state from the C heap that OSR_migration_begin
 450   // created. It's entire job is to simply free this storage.
 451   static void OSR_migration_end(intptr_t* buf);
 452 
 453   // Convert a sig into a calling convention register layout
 454   // and find interesting things about it.


 623 // Rmethod->_i2i_entry.  On entry, the interpreted frame has not yet been
 624 // setup.  Compiled frames are fixed-size and the args are likely not in the
 625 // right place.  Hence all the args will likely be copied into the
 626 // interpreter's frame, forcing that frame to grow.  The compiled frame's
 627 // outgoing stack args will be dead after the copy.
 628 //
 629 // Native wrappers, like adapters, marshal arguments.  Unlike adapters they
 630 // also perform an official frame push & pop.  They have a call to the native
 631 // routine in their middles and end in a return (instead of ending in a jump).
 632 // The native wrappers are stored in real nmethods instead of the BufferBlobs
 633 // used by the adapters.  The code generation happens here because it's very
 634 // similar to what the adapters have to do.
 635 
 636 class AdapterHandlerEntry : public BasicHashtableEntry<mtCode> {
 637   friend class AdapterHandlerTable;
 638 
 639  private:
 640   AdapterFingerPrint* _fingerprint;
 641   address _i2c_entry;
 642   address _c2i_entry;

 643   address _c2i_unverified_entry;
 644   Symbol* _sig_extended;



 645 
 646 #ifdef ASSERT
 647   // Captures code and signature used to generate this adapter when
 648   // verifying adapter equivalence.
 649   unsigned char* _saved_code;
 650   int            _saved_code_length;
 651 #endif
 652 
 653   void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry, Symbol* sig_extended) {
 654     _fingerprint = fingerprint;
 655     _i2c_entry = i2c_entry;
 656     _c2i_entry = c2i_entry;

 657     _c2i_unverified_entry = c2i_unverified_entry;
 658     _sig_extended = sig_extended;

 659 #ifdef ASSERT
 660     _saved_code = NULL;
 661     _saved_code_length = 0;
 662 #endif
 663   }
 664 
 665   void deallocate();
 666 
 667   // should never be used
 668   AdapterHandlerEntry();
 669 
 670  public:
 671   address get_i2c_entry()            const { return _i2c_entry; }
 672   address get_c2i_entry()            const { return _c2i_entry; }

 673   address get_c2i_unverified_entry() const { return _c2i_unverified_entry; }
 674   Symbol* get_sig_extended()         const { return _sig_extended; }
 675   address base_address();
 676   void relocate(address new_base);
 677 






 678   AdapterFingerPrint* fingerprint() const { return _fingerprint; }
 679 
 680   AdapterHandlerEntry* next() {
 681     return (AdapterHandlerEntry*)BasicHashtableEntry<mtCode>::next();
 682   }
 683 
 684 #ifdef ASSERT
 685   // Used to verify that code generated for shared adapters is equivalent
 686   void save_code   (unsigned char* code, int length);
 687   bool compare_code(unsigned char* code, int length);
 688 #endif
 689 
 690   //virtual void print_on(outputStream* st) const;  DO NOT USE
 691   void print_adapter_on(outputStream* st) const;
 692 };
 693 
 694 // This class is used only with DumpSharedSpaces==true. It holds extra information
 695 // that's used only during CDS dump time.
 696 // For details, see comments around Method::link_method()
 697 class CDSAdapterHandlerEntry: public AdapterHandlerEntry {
 698   address               _c2i_entry_trampoline;   // allocated from shared spaces "MC" region
 699   AdapterHandlerEntry** _adapter_trampoline;     // allocated from shared spaces "MD" region
 700 
 701 public:
 702   address get_c2i_entry_trampoline()             const { return _c2i_entry_trampoline; }
 703   AdapterHandlerEntry** get_adapter_trampoline() const { return _adapter_trampoline; }
 704   void init() NOT_CDS_RETURN;
 705 };
 706 
 707 
 708 class AdapterHandlerLibrary: public AllStatic {
 709  private:
 710   static BufferBlob* _buffer; // the temporary code buffer in CodeCache
 711   static AdapterHandlerTable* _adapters;
 712   static AdapterHandlerEntry* _abstract_method_handler;
 713   static BufferBlob* buffer_blob();
 714   static void initialize();
 715   static AdapterHandlerEntry* get_adapter0(const methodHandle& method, TRAPS);
 716 
 717  public:
 718 
 719   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
 720                                         address i2c_entry, address c2i_entry, address c2i_unverified_entry,
 721                                         Symbol* sig_extended = NULL);
 722   static void create_native_wrapper(const methodHandle& method);
 723   static AdapterHandlerEntry* get_adapter(const methodHandle& method, TRAPS);
 724 
 725   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
 726   static void print_handler_on(outputStream* st, const CodeBlob* b);
 727   static bool contains(const CodeBlob* b);
 728 #ifndef PRODUCT
 729   static void print_statistics();
 730 #endif // PRODUCT
 731 
 732 };
 733 
 734 #endif // SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP


 355   static address clean_static_call_entry();
 356 
 357 #if defined(X86) && defined(COMPILER1)
 358   // For Object.hashCode, System.identityHashCode try to pull hashCode from object header if available.
 359   static void inline_check_hashcode_from_object_header(MacroAssembler* masm, const methodHandle& method, Register obj_reg, Register result);
 360 #endif // X86 && COMPILER1
 361 
 362  public:
 363 
 364   // Read the array of BasicTypes from a Java signature, and compute where
 365   // compiled Java code would like to put the results.  Values in reg_lo and
 366   // reg_hi refer to 4-byte quantities.  Values less than SharedInfo::stack0 are
 367   // registers, those above refer to 4-byte stack slots.  All stack slots are
 368   // based off of the window top.  SharedInfo::stack0 refers to the first usable
 369   // slot in the bottom of the frame. SharedInfo::stack0+1 refers to the memory word
 370   // 4-bytes higher. So for sparc because the register window save area is at
 371   // the bottom of the frame the first 16 words will be skipped and SharedInfo::stack0
 372   // will be just above it. (
 373   // return value is the maximum number of VMReg stack slots the convention will use.
 374   static int java_calling_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed, int is_outgoing);
 375   static int java_calling_convention(const GrowableArray<SigEntry>* sig, VMRegPair* regs) {
 376     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sig->length());
 377     int total_args_passed = SigEntry::fill_sig_bt(sig, sig_bt);
 378     return java_calling_convention(sig_bt, regs, total_args_passed, false);
 379   }
 380   static int java_return_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed);
 381   static const uint java_return_convention_max_int;
 382   static const uint java_return_convention_max_float;
 383 
 384   static void check_member_name_argument_is_last_argument(const methodHandle& method,
 385                                                           const BasicType* sig_bt,
 386                                                           const VMRegPair* regs) NOT_DEBUG_RETURN;
 387 
 388   // Ditto except for calling C
 389   //
 390   // C argument in register AND stack slot.
 391   // Some architectures require that an argument must be passed in a register
 392   // AND in a stack slot. These architectures provide a second VMRegPair array
 393   // to be filled by the c_calling_convention method. On other architectures,
 394   // NULL is being passed as the second VMRegPair array, so arguments are either
 395   // passed in a register OR in a stack slot.
 396   static int c_calling_convention(const BasicType *sig_bt, VMRegPair *regs, VMRegPair *regs2,
 397                                   int total_args_passed);
 398 
 399   static size_t trampoline_size();


 412   // location for the interpreter to record. This is used by the frame code
 413   // to correct the sender code to match up with the stack pointer when the
 414   // thread left the compiled code. In addition it allows the interpreter
 415   // to remove the space the c2i adapter allocated to do its argument conversion.
 416 
 417   // Although a c2i blob will always run interpreted even if compiled code is
 418   // present if we see that compiled code is present the compiled call site
 419   // will be patched/re-resolved so that later calls will run compiled.
 420 
 421   // Additionally a c2i blob need to have a unverified entry because it can be reached
 422   // in situations where the call site is an inlined cache site and may go megamorphic.
 423 
 424   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 425   // that the interpreter before it does any call dispatch will record the current
 426   // stack pointer in the interpreter frame. On return it will restore the stack
 427   // pointer as needed. This means the i2c adapter code doesn't need any special
 428   // handshaking path with compiled code to keep the stack walking correct.
 429 
 430   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *masm,
 431                                                       int comp_args_on_stack,
 432                                                       int comp_args_on_stack_cc,
 433                                                       const GrowableArray<SigEntry>* sig,
 434                                                       const VMRegPair* regs,
 435                                                       const GrowableArray<SigEntry>* sig_cc,
 436                                                       const VMRegPair* regs_cc,
 437                                                       AdapterFingerPrint* fingerprint,
 438                                                       AdapterBlob*& new_adapter);
 439 
 440   static void gen_i2c_adapter(MacroAssembler *_masm,
 441                               int comp_args_on_stack,
 442                               const GrowableArray<SigEntry>* sig,
 443                               const VMRegPair *regs);
 444 
 445   // OSR support
 446 
 447   // OSR_migration_begin will extract the jvm state from an interpreter
 448   // frame (locals, monitors) and store the data in a piece of C heap
 449   // storage. This then allows the interpreter frame to be removed from the
 450   // stack and the OSR nmethod to be called. That method is called with a
 451   // pointer to the C heap storage. This pointer is the return value from
 452   // OSR_migration_begin.
 453 
 454   static intptr_t* OSR_migration_begin(JavaThread *thread);
 455 
 456   // OSR_migration_end is a trivial routine. It is called after the compiled
 457   // method has extracted the jvm state from the C heap that OSR_migration_begin
 458   // created. It's entire job is to simply free this storage.
 459   static void OSR_migration_end(intptr_t* buf);
 460 
 461   // Convert a sig into a calling convention register layout
 462   // and find interesting things about it.


 631 // Rmethod->_i2i_entry.  On entry, the interpreted frame has not yet been
 632 // setup.  Compiled frames are fixed-size and the args are likely not in the
 633 // right place.  Hence all the args will likely be copied into the
 634 // interpreter's frame, forcing that frame to grow.  The compiled frame's
 635 // outgoing stack args will be dead after the copy.
 636 //
 637 // Native wrappers, like adapters, marshal arguments.  Unlike adapters they
 638 // also perform an official frame push & pop.  They have a call to the native
 639 // routine in their middles and end in a return (instead of ending in a jump).
 640 // The native wrappers are stored in real nmethods instead of the BufferBlobs
 641 // used by the adapters.  The code generation happens here because it's very
 642 // similar to what the adapters have to do.
 643 
 644 class AdapterHandlerEntry : public BasicHashtableEntry<mtCode> {
 645   friend class AdapterHandlerTable;
 646 
 647  private:
 648   AdapterFingerPrint* _fingerprint;
 649   address _i2c_entry;
 650   address _c2i_entry;
 651   address _c2i_value_entry;
 652   address _c2i_unverified_entry;
 653 
 654   // Support for scalarized value type calling convention
 655   const GrowableArray<SigEntry>* _sig_cc;
 656   SigEntry _res_sig_entry;
 657 
 658 #ifdef ASSERT
 659   // Captures code and signature used to generate this adapter when
 660   // verifying adapter equivalence.
 661   unsigned char* _saved_code;
 662   int            _saved_code_length;
 663 #endif
 664 
 665   void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_value_entry, address c2i_unverified_entry) {
 666     _fingerprint = fingerprint;
 667     _i2c_entry = i2c_entry;
 668     _c2i_entry = c2i_entry;
 669     _c2i_value_entry = c2i_value_entry;
 670     _c2i_unverified_entry = c2i_unverified_entry;
 671     _sig_cc = NULL;
 672     _res_sig_entry = SigEntry();
 673 #ifdef ASSERT
 674     _saved_code = NULL;
 675     _saved_code_length = 0;
 676 #endif
 677   }
 678 
 679   void deallocate();
 680 
 681   // should never be used
 682   AdapterHandlerEntry();
 683 
 684  public:
 685   address get_i2c_entry()            const { return _i2c_entry; }
 686   address get_c2i_entry()            const { return _c2i_entry; }
 687   address get_c2i_value_entry()      const { return _c2i_value_entry; }
 688   address get_c2i_unverified_entry() const { return _c2i_unverified_entry; }

 689   address base_address();
 690   void relocate(address new_base);
 691 
 692   // Support for scalarized value type calling convention
 693   void set_sig_cc(const GrowableArray<SigEntry>* sig)  { _sig_cc = sig; }
 694   const GrowableArray<SigEntry>* get_sig_cc()    const { return _sig_cc; }
 695   void     set_res_entry(SigEntry res_sig_entry)       { _res_sig_entry = res_sig_entry; }
 696   SigEntry get_res_entry()                       const { return _res_sig_entry; }
 697 
 698   AdapterFingerPrint* fingerprint() const { return _fingerprint; }
 699 
 700   AdapterHandlerEntry* next() {
 701     return (AdapterHandlerEntry*)BasicHashtableEntry<mtCode>::next();
 702   }
 703 
 704 #ifdef ASSERT
 705   // Used to verify that code generated for shared adapters is equivalent
 706   void save_code   (unsigned char* code, int length);
 707   bool compare_code(unsigned char* code, int length);
 708 #endif
 709 
 710   //virtual void print_on(outputStream* st) const;  DO NOT USE
 711   void print_adapter_on(outputStream* st) const;
 712 };
 713 
 714 // This class is used only with DumpSharedSpaces==true. It holds extra information
 715 // that's used only during CDS dump time.
 716 // For details, see comments around Method::link_method()
 717 class CDSAdapterHandlerEntry: public AdapterHandlerEntry {
 718   address               _c2i_entry_trampoline;   // allocated from shared spaces "MC" region
 719   AdapterHandlerEntry** _adapter_trampoline;     // allocated from shared spaces "MD" region
 720 
 721 public:
 722   address get_c2i_entry_trampoline()             const { return _c2i_entry_trampoline; }
 723   AdapterHandlerEntry** get_adapter_trampoline() const { return _adapter_trampoline; }
 724   void init() NOT_CDS_RETURN;
 725 };
 726 
 727 
 728 class AdapterHandlerLibrary: public AllStatic {
 729  private:
 730   static BufferBlob* _buffer; // the temporary code buffer in CodeCache
 731   static AdapterHandlerTable* _adapters;
 732   static AdapterHandlerEntry* _abstract_method_handler;
 733   static BufferBlob* buffer_blob();
 734   static void initialize();
 735   static AdapterHandlerEntry* get_adapter0(const methodHandle& method);
 736 
 737  public:
 738 
 739   static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
 740                                         address i2c_entry, address c2i_entry, address c2i_value_entry, address c2i_unverified_entry);

 741   static void create_native_wrapper(const methodHandle& method);
 742   static AdapterHandlerEntry* get_adapter(const methodHandle& method);
 743 
 744   static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
 745   static void print_handler_on(outputStream* st, const CodeBlob* b);
 746   static bool contains(const CodeBlob* b);
 747 #ifndef PRODUCT
 748   static void print_statistics();
 749 #endif // PRODUCT
 750 
 751 };
 752 
 753 #endif // SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
< prev index next >