--- old/src/share/vm/runtime/sharedRuntime.hpp 2013-10-16 08:00:14.159722207 +0200 +++ new/src/share/vm/runtime/sharedRuntime.hpp 2013-10-16 08:00:14.075722209 +0200 @@ -600,14 +600,13 @@ address _i2c_entry; address _c2i_entry; address _c2i_unverified_entry; + bool _contains_all_checks; #ifdef ASSERT // Captures code and signature used to generate this adapter when // verifing adapter equivalence. unsigned char* _saved_code; - int _code_length; - BasicType* _saved_sig; - int _total_args_passed; + int _saved_code_length; #endif void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) { @@ -615,11 +614,10 @@ _i2c_entry = i2c_entry; _c2i_entry = c2i_entry; _c2i_unverified_entry = c2i_unverified_entry; + _contains_all_checks = false; #ifdef ASSERT _saved_code = NULL; - _code_length = 0; - _saved_sig = NULL; - _total_args_passed = 0; + _saved_code_length = 0; #endif } @@ -632,6 +630,8 @@ address get_i2c_entry() const { return _i2c_entry; } address get_c2i_entry() const { return _c2i_entry; } address get_c2i_unverified_entry() const { return _c2i_unverified_entry; } + void set_contains_all_checks(bool val){ _contains_all_checks = val; } + bool contains_all_checks() { return _contains_all_checks; } address base_address(); void relocate(address new_base); @@ -644,8 +644,8 @@ #ifdef ASSERT // Used to verify that code generated for shared adapters is equivalent - void save_code(unsigned char* code, int length, int total_args_passed, BasicType* sig_bt); - bool compare_code(unsigned char* code, int length, int total_args_passed, BasicType* sig_bt); + void save_code (unsigned char* code, int length); + bool compare_code(unsigned char* code, int length); #endif //virtual void print_on(outputStream* st) const; DO NOT USE --- old/src/share/vm/runtime/sharedRuntime.cpp 2013-10-16 08:00:14.167722207 +0200 +++ new/src/share/vm/runtime/sharedRuntime.cpp 2013-10-16 08:00:14.079722208 +0200 @@ -2406,14 +2406,24 @@ #ifdef ASSERT AdapterHandlerEntry* shared_entry = NULL; - if (VerifyAdapterSharing && entry != NULL) { + // Start adapter sharing verification only after the VM is booted. + if (VerifyAdapterSharing && (entry != NULL) && entry->contains_all_checks()) { shared_entry = entry; entry = NULL; } #endif if (entry != NULL) { - return entry; + // Re-use generated adapter only if VM is booted (StubRoutines::code2() != NULL + // or VerifyAdapterCalls is false. The reason is that gen_i2c_adapter() generates + // code based on the existence of StubRoutines::code1() and StubRoutines::code2(). + // Since these fields can be initialized after adapters are generated, VerifyAdapterCalls + // potentially reports a false error and/or VerifyAdapterSharing will fail. + if (!entry->contains_all_checks()) { + _adapters->free_entry(entry); + } else { + return entry; + } } // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage @@ -2430,25 +2440,25 @@ short buffer_locs[20]; buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, sizeof(buffer_locs)/sizeof(relocInfo)); - MacroAssembler _masm(&buffer); + bool contains_all_checks = (StubRoutines::code2() != NULL) || !VerifyAdapterCalls; + MacroAssembler _masm(&buffer); entry = SharedRuntime::generate_i2c2i_adapters(&_masm, total_args_passed, comp_args_on_stack, sig_bt, regs, fingerprint); - + entry->set_contains_all_checks(contains_all_checks); #ifdef ASSERT if (VerifyAdapterSharing) { if (shared_entry != NULL) { - assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt), - "code must match"); + assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size()), "code must match"); // Release the one just created and return the original _adapters->free_entry(entry); return shared_entry; } else { - entry->save_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt); + entry->save_code(buf->code_begin(), buffer.insts_size()); } } #endif @@ -2530,7 +2540,6 @@ delete _fingerprint; #ifdef ASSERT if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); - if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig, mtCode); #endif } @@ -2539,26 +2548,19 @@ // Capture the code before relocation so that it can be compared // against other versions. If the code is captured after relocation // then relative instructions won't be equivalent. -void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { +void AdapterHandlerEntry::save_code(unsigned char* buffer, int length) { _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); - _code_length = length; + _saved_code_length = length; memcpy(_saved_code, buffer, length); - _total_args_passed = total_args_passed; - _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed, mtCode); - memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); } -bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { - if (length != _code_length) { +bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length) { + if (length != _saved_code_length) { return false; } - for (int i = 0; i < length; i++) { - if (buffer[i] != _saved_code[i]) { - return false; - } - } - return true; + + return (memcmp(buffer, _saved_code, length) == 0) ? true : false; } #endif