121 // The nmethod will be gone when we get here. |
122 // The nmethod will be gone when we get here. |
122 if (code() != NULL) _code = NULL; |
123 if (code() != NULL) _code = NULL; |
123 } |
124 } |
124 |
125 |
125 address Method::get_i2c_entry() { |
126 address Method::get_i2c_entry() { |
126 assert(_adapter != NULL, "must have"); |
127 assert(adapter() != NULL, "must have"); |
127 return _adapter->get_i2c_entry(); |
128 return adapter()->get_i2c_entry(); |
128 } |
129 } |
129 |
130 |
130 address Method::get_c2i_entry() { |
131 address Method::get_c2i_entry() { |
131 assert(_adapter != NULL, "must have"); |
132 assert(adapter() != NULL, "must have"); |
132 return _adapter->get_c2i_entry(); |
133 return adapter()->get_c2i_entry(); |
133 } |
134 } |
134 |
135 |
135 address Method::get_c2i_unverified_entry() { |
136 address Method::get_c2i_unverified_entry() { |
136 assert(_adapter != NULL, "must have"); |
137 assert(adapter() != NULL, "must have"); |
137 return _adapter->get_c2i_unverified_entry(); |
138 return adapter()->get_c2i_unverified_entry(); |
138 } |
139 } |
139 |
140 |
140 char* Method::name_and_sig_as_C_string() const { |
141 char* Method::name_and_sig_as_C_string() const { |
141 return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature()); |
142 return name_and_sig_as_C_string(constants()->pool_holder(), name(), signature()); |
142 } |
143 } |
890 // Revert to using the interpreter and clear out the nmethod |
891 // Revert to using the interpreter and clear out the nmethod |
891 void Method::clear_code() { |
892 void Method::clear_code() { |
892 |
893 |
893 // this may be NULL if c2i adapters have not been made yet |
894 // this may be NULL if c2i adapters have not been made yet |
894 // Only should happen at allocate time. |
895 // Only should happen at allocate time. |
895 if (_adapter == NULL) { |
896 if (adapter() == NULL) { |
896 _from_compiled_entry = NULL; |
897 _from_compiled_entry = NULL; |
897 } else { |
898 } else { |
898 _from_compiled_entry = _adapter->get_c2i_entry(); |
899 _from_compiled_entry = adapter()->get_c2i_entry(); |
899 } |
900 } |
900 OrderAccess::storestore(); |
901 OrderAccess::storestore(); |
901 _from_interpreted_entry = _i2i_entry; |
902 _from_interpreted_entry = _i2i_entry; |
902 OrderAccess::storestore(); |
903 OrderAccess::storestore(); |
903 _code = NULL; |
904 _code = NULL; |
904 } |
905 } |
905 |
906 |
|
907 #if INCLUDE_CDS |
906 // Called by class data sharing to remove any entry points (which are not shared) |
908 // Called by class data sharing to remove any entry points (which are not shared) |
907 void Method::unlink_method() { |
909 void Method::unlink_method() { |
908 _code = NULL; |
910 _code = NULL; |
909 _i2i_entry = NULL; |
911 |
910 _from_interpreted_entry = NULL; |
912 assert(DumpSharedSpaces, "dump time only"); |
|
913 // Set the values to what they should be at run time. Note that |
|
914 // this Method can no longer be executed during dump time. |
|
915 _i2i_entry = Interpreter::entry_for_cds_method(this); |
|
916 _from_interpreted_entry = _i2i_entry; |
|
917 |
911 if (is_native()) { |
918 if (is_native()) { |
912 *native_function_addr() = NULL; |
919 *native_function_addr() = NULL; |
913 set_signature_handler(NULL); |
920 set_signature_handler(NULL); |
914 } |
921 } |
915 NOT_PRODUCT(set_compiled_invocation_count(0);) |
922 NOT_PRODUCT(set_compiled_invocation_count(0);) |
916 _adapter = NULL; |
923 |
917 _from_compiled_entry = NULL; |
924 CDSAdapterHandlerEntry* cds_adapter = (CDSAdapterHandlerEntry*)adapter(); |
|
925 constMethod()->set_adapter_trampoline(cds_adapter->get_adapter_trampoline()); |
|
926 _from_compiled_entry = cds_adapter->get_c2i_entry_trampoline(); |
|
927 assert(*((int*)_from_compiled_entry) == 0, "must be NULL during dump time, to be initialized at run time"); |
|
928 |
918 |
929 |
919 // In case of DumpSharedSpaces, _method_data should always be NULL. |
930 // In case of DumpSharedSpaces, _method_data should always be NULL. |
920 // |
931 assert(_method_data == NULL, "unexpected method data?"); |
921 // During runtime (!DumpSharedSpaces), when we are cleaning a |
|
922 // shared class that failed to load, this->link_method() may |
|
923 // have already been called (before an exception happened), so |
|
924 // this->_method_data may not be NULL. |
|
925 assert(!DumpSharedSpaces || _method_data == NULL, "unexpected method data?"); |
|
926 |
932 |
927 set_method_data(NULL); |
933 set_method_data(NULL); |
928 clear_method_counters(); |
934 clear_method_counters(); |
929 } |
935 } |
|
936 #endif |
930 |
937 |
931 // Called when the method_holder is getting linked. Setup entrypoints so the method |
938 // Called when the method_holder is getting linked. Setup entrypoints so the method |
932 // is ready to be called from interpreter, compiler, and vtables. |
939 // is ready to be called from interpreter, compiler, and vtables. |
933 void Method::link_method(const methodHandle& h_method, TRAPS) { |
940 void Method::link_method(const methodHandle& h_method, TRAPS) { |
934 // If the code cache is full, we may reenter this function for the |
941 // If the code cache is full, we may reenter this function for the |
935 // leftover methods that weren't linked. |
942 // leftover methods that weren't linked. |
936 if (_i2i_entry != NULL) return; |
943 if (is_shared()) { |
937 |
944 if (adapter() != NULL) return; |
938 assert(_adapter == NULL, "init'd to NULL" ); |
945 } else { |
|
946 if (_i2i_entry != NULL) return; |
|
947 |
|
948 assert(adapter() == NULL, "init'd to NULL" ); |
|
949 } |
939 assert( _code == NULL, "nothing compiled yet" ); |
950 assert( _code == NULL, "nothing compiled yet" ); |
940 |
951 |
941 // Setup interpreter entrypoint |
952 // Setup interpreter entrypoint |
942 assert(this == h_method(), "wrong h_method()" ); |
953 assert(this == h_method(), "wrong h_method()" ); |
943 address entry = Interpreter::entry_for_method(h_method); |
954 address entry; |
|
955 |
|
956 if (this->is_shared()) { |
|
957 entry = Interpreter::entry_for_cds_method(h_method); |
|
958 } else { |
|
959 entry = Interpreter::entry_for_method(h_method); |
|
960 } |
944 assert(entry != NULL, "interpreter entry must be non-null"); |
961 assert(entry != NULL, "interpreter entry must be non-null"); |
945 // Sets both _i2i_entry and _from_interpreted_entry |
962 if (is_shared()) { |
946 set_interpreter_entry(entry); |
963 assert(entry == _i2i_entry && entry == _from_interpreted_entry, |
|
964 "should be correctly set during dump time"); |
|
965 } else { |
|
966 // Sets both _i2i_entry and _from_interpreted_entry |
|
967 set_interpreter_entry(entry); |
|
968 } |
947 |
969 |
948 // Don't overwrite already registered native entries. |
970 // Don't overwrite already registered native entries. |
949 if (is_native() && !has_native_function()) { |
971 if (is_native() && !has_native_function()) { |
950 set_native_function( |
972 set_native_function( |
951 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), |
973 SharedRuntime::native_method_throw_unsatisfied_link_error_entry(), |
973 AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh); |
995 AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh); |
974 if (adapter == NULL ) { |
996 if (adapter == NULL ) { |
975 THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters"); |
997 THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters"); |
976 } |
998 } |
977 |
999 |
978 mh->set_adapter_entry(adapter); |
1000 if (mh->is_shared()) { |
979 mh->_from_compiled_entry = adapter->get_c2i_entry(); |
1001 assert(mh->adapter() == adapter, "must be"); |
|
1002 assert(mh->_from_compiled_entry != NULL, "must be"); // FIXME, the instructions also not NULL |
|
1003 } else { |
|
1004 mh->set_adapter_entry(adapter); |
|
1005 mh->_from_compiled_entry = adapter->get_c2i_entry(); |
|
1006 } |
980 return adapter->get_c2i_entry(); |
1007 return adapter->get_c2i_entry(); |
981 } |
1008 } |
982 |
1009 |
983 void Method::restore_unshareable_info(TRAPS) { |
1010 void Method::restore_unshareable_info(TRAPS) { |
984 // Since restore_unshareable_info can be called more than once for a method, don't |
1011 // Since restore_unshareable_info can be called more than once for a method, don't |