653 // interpreter's frame, forcing that frame to grow. The compiled frame's
654 // outgoing stack args will be dead after the copy.
655 //
656 // Native wrappers, like adapters, marshal arguments. Unlike adapters they
657 // also perform an official frame push & pop. They have a call to the native
658 // routine in their middles and end in a return (instead of ending in a jump).
659 // The native wrappers are stored in real nmethods instead of the BufferBlobs
660 // used by the adapters. The code generation happens here because it's very
661 // similar to what the adapters have to do.
662
663 class AdapterHandlerEntry : public BasicHashtableEntry<mtCode> {
664 friend class AdapterHandlerTable;
665
666 private:
667 AdapterFingerPrint* _fingerprint;
668 address _i2c_entry;
669 address _c2i_entry;
670 address _c2i_value_entry;
671 address _c2i_value_ro_entry;
672 address _c2i_unverified_entry;
673
674 // Support for scalarized value type calling convention
675 const GrowableArray<SigEntry>* _sig_cc;
676
677 #ifdef ASSERT
678 // Captures code and signature used to generate this adapter when
679 // verifying adapter equivalence.
680 unsigned char* _saved_code;
681 int _saved_code_length;
682 #endif
683
684 void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_value_entry, address c2i_value_ro_entry, address c2i_unverified_entry) {
685 _fingerprint = fingerprint;
686 _i2c_entry = i2c_entry;
687 _c2i_entry = c2i_entry;
688 _c2i_value_entry = c2i_value_entry;
689 _c2i_value_ro_entry = c2i_value_ro_entry;
690 _c2i_unverified_entry = c2i_unverified_entry;
691 _sig_cc = NULL;
692 #ifdef ASSERT
693 _saved_code = NULL;
694 _saved_code_length = 0;
695 #endif
696 }
697
698 void deallocate();
699
700 // should never be used
701 AdapterHandlerEntry();
702
703 public:
704 address get_i2c_entry() const { return _i2c_entry; }
705 address get_c2i_entry() const { return _c2i_entry; }
706 address get_c2i_value_entry() const { return _c2i_value_entry; }
707 address get_c2i_value_ro_entry() const { return _c2i_value_ro_entry; }
708 address get_c2i_unverified_entry() const { return _c2i_unverified_entry; }
709 address base_address();
710 void relocate(address new_base);
711
712 // Support for scalarized value type calling convention
713 void set_sig_cc(const GrowableArray<SigEntry>* sig) { _sig_cc = sig; }
714 const GrowableArray<SigEntry>* get_sig_cc() const { return _sig_cc; }
715
716 AdapterFingerPrint* fingerprint() const { return _fingerprint; }
717
718 AdapterHandlerEntry* next() {
719 return (AdapterHandlerEntry*)BasicHashtableEntry<mtCode>::next();
720 }
721
722 #ifdef ASSERT
723 // Used to verify that code generated for shared adapters is equivalent
724 void save_code (unsigned char* code, int length);
725 bool compare_code(unsigned char* code, int length);
726 #endif
727
728 //virtual void print_on(outputStream* st) const; DO NOT USE
738
739 public:
740 address get_c2i_entry_trampoline() const { return _c2i_entry_trampoline; }
741 AdapterHandlerEntry** get_adapter_trampoline() const { return _adapter_trampoline; }
742 void init() NOT_CDS_RETURN;
743 };
744
745
746 class AdapterHandlerLibrary: public AllStatic {
747 private:
748 static BufferBlob* _buffer; // the temporary code buffer in CodeCache
749 static AdapterHandlerTable* _adapters;
750 static AdapterHandlerEntry* _abstract_method_handler;
751 static BufferBlob* buffer_blob();
752 static void initialize();
753 static AdapterHandlerEntry* get_adapter0(const methodHandle& method);
754
755 public:
756
757 static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
758 address i2c_entry, address c2i_entry, address c2i_value_entry, address c2i_value_ro_entry, address c2i_unverified_entry);
759 static void create_native_wrapper(const methodHandle& method);
760 static AdapterHandlerEntry* get_adapter(const methodHandle& method);
761
762 static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
763 static void print_handler_on(outputStream* st, const CodeBlob* b);
764 static bool contains(const CodeBlob* b);
765 #ifndef PRODUCT
766 static void print_statistics();
767 #endif // PRODUCT
768
769 };
770
771 // Utility class for computing the calling convention of the 3 types
772 // of compiled method entries:
773 // Method::_from_compiled_entry - sig_cc
774 // Method::_from_compiled_value_ro_entry - sig_cc_ro
775 // Method::_from_compiled_value_entry - sig
776 class CompiledEntrySignature : public StackObj {
777 Method* _method;
778 int _num_value_args;
|
653 // interpreter's frame, forcing that frame to grow. The compiled frame's
654 // outgoing stack args will be dead after the copy.
655 //
656 // Native wrappers, like adapters, marshal arguments. Unlike adapters they
657 // also perform an official frame push & pop. They have a call to the native
658 // routine in their middles and end in a return (instead of ending in a jump).
659 // The native wrappers are stored in real nmethods instead of the BufferBlobs
660 // used by the adapters. The code generation happens here because it's very
661 // similar to what the adapters have to do.
662
663 class AdapterHandlerEntry : public BasicHashtableEntry<mtCode> {
664 friend class AdapterHandlerTable;
665
666 private:
667 AdapterFingerPrint* _fingerprint;
668 address _i2c_entry;
669 address _c2i_entry;
670 address _c2i_value_entry;
671 address _c2i_value_ro_entry;
672 address _c2i_unverified_entry;
673 address _c2i_unverified_value_entry;
674
675 // Support for scalarized value type calling convention
676 const GrowableArray<SigEntry>* _sig_cc;
677
678 #ifdef ASSERT
679 // Captures code and signature used to generate this adapter when
680 // verifying adapter equivalence.
681 unsigned char* _saved_code;
682 int _saved_code_length;
683 #endif
684
685 void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_value_entry,
686 address c2i_value_ro_entry, address c2i_unverified_entry, address c2i_unverified_value_entry) {
687 _fingerprint = fingerprint;
688 _i2c_entry = i2c_entry;
689 _c2i_entry = c2i_entry;
690 _c2i_value_entry = c2i_value_entry;
691 _c2i_value_ro_entry = c2i_value_ro_entry;
692 _c2i_unverified_entry = c2i_unverified_entry;
693 _c2i_unverified_value_entry = c2i_unverified_value_entry;
694 _sig_cc = NULL;
695 #ifdef ASSERT
696 _saved_code = NULL;
697 _saved_code_length = 0;
698 #endif
699 }
700
701 void deallocate();
702
703 // should never be used
704 AdapterHandlerEntry();
705
706 public:
707 address get_i2c_entry() const { return _i2c_entry; }
708 address get_c2i_entry() const { return _c2i_entry; }
709 address get_c2i_value_entry() const { return _c2i_value_entry; }
710 address get_c2i_value_ro_entry() const { return _c2i_value_ro_entry; }
711 address get_c2i_unverified_entry() const { return _c2i_unverified_entry; }
712 address get_c2i_unverified_value_entry() const { return _c2i_unverified_value_entry; }
713 address base_address();
714 void relocate(address new_base);
715
716 // Support for scalarized value type calling convention
717 void set_sig_cc(const GrowableArray<SigEntry>* sig) { _sig_cc = sig; }
718 const GrowableArray<SigEntry>* get_sig_cc() const { return _sig_cc; }
719
720 AdapterFingerPrint* fingerprint() const { return _fingerprint; }
721
722 AdapterHandlerEntry* next() {
723 return (AdapterHandlerEntry*)BasicHashtableEntry<mtCode>::next();
724 }
725
726 #ifdef ASSERT
727 // Used to verify that code generated for shared adapters is equivalent
728 void save_code (unsigned char* code, int length);
729 bool compare_code(unsigned char* code, int length);
730 #endif
731
732 //virtual void print_on(outputStream* st) const; DO NOT USE
742
743 public:
744 address get_c2i_entry_trampoline() const { return _c2i_entry_trampoline; }
745 AdapterHandlerEntry** get_adapter_trampoline() const { return _adapter_trampoline; }
746 void init() NOT_CDS_RETURN;
747 };
748
749
750 class AdapterHandlerLibrary: public AllStatic {
751 private:
752 static BufferBlob* _buffer; // the temporary code buffer in CodeCache
753 static AdapterHandlerTable* _adapters;
754 static AdapterHandlerEntry* _abstract_method_handler;
755 static BufferBlob* buffer_blob();
756 static void initialize();
757 static AdapterHandlerEntry* get_adapter0(const methodHandle& method);
758
759 public:
760
761 static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
762 address i2c_entry, address c2i_entry, address c2i_value_entry, address c2i_value_ro_entry,
763 address c2i_unverified_entry, address c2i_unverified_value_entry);
764 static void create_native_wrapper(const methodHandle& method);
765 static AdapterHandlerEntry* get_adapter(const methodHandle& method);
766
767 static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
768 static void print_handler_on(outputStream* st, const CodeBlob* b);
769 static bool contains(const CodeBlob* b);
770 #ifndef PRODUCT
771 static void print_statistics();
772 #endif // PRODUCT
773
774 };
775
776 // Utility class for computing the calling convention of the 3 types
777 // of compiled method entries:
778 // Method::_from_compiled_entry - sig_cc
779 // Method::_from_compiled_value_ro_entry - sig_cc_ro
780 // Method::_from_compiled_value_entry - sig
781 class CompiledEntrySignature : public StackObj {
782 Method* _method;
783 int _num_value_args;
|