src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/share/vm/runtime/sharedRuntime.cpp	Wed Apr 29 11:01:11 2009
--- new/src/share/vm/runtime/sharedRuntime.cpp	Wed Apr 29 11:01:11 2009

*** 1774,1785 **** --- 1774,1792 ---- // Implementation of AdapterHandlerLibrary const char* AdapterHandlerEntry::name = "I2C/C2I adapters"; GrowableArray<uint64_t>* AdapterHandlerLibrary::_fingerprints = NULL; GrowableArray<AdapterHandlerEntry* >* AdapterHandlerLibrary::_handlers = NULL; const int AdapterHandlerLibrary_size = 16*K; ! u_char AdapterHandlerLibrary::_buffer[AdapterHandlerLibrary_size + 32]; ! BufferBlob* AdapterHandlerLibrary::_buffer = NULL; + BufferBlob* AdapterHandlerLibrary::buffer_blob() { + // Should be called only when AdapterHandlerLibrary_lock is active. + if (_buffer == NULL) // Initialize lazily + _buffer = BufferBlob::create("adapters", AdapterHandlerLibrary_size); + return _buffer; + } + void AdapterHandlerLibrary::initialize() { if (_fingerprints != NULL) return; _fingerprints = new(ResourceObj::C_HEAP)GrowableArray<uint64_t>(32, true); _handlers = new(ResourceObj::C_HEAP)GrowableArray<AdapterHandlerEntry*>(32, true); // Index 0 reserved for the slow path handler
*** 1810,1820 **** --- 1817,1829 ---- // earlier. address ic_miss = SharedRuntime::get_ic_miss_stub(); assert(ic_miss != NULL, "must have handler"); int result; + NOT_PRODUCT(int code_size); BufferBlob *B = NULL; + AdapterHandlerEntry* entry = NULL; uint64_t fingerprint; { MutexLocker mu(AdapterHandlerLibrary_lock); // make sure data structure is initialized initialize();
*** 1848,1860 **** --- 1857,1870 ---- // adapters). } // Create I2C & C2I handlers ResourceMark rm; // Improve alignment slightly u_char *buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1)); CodeBuffer buffer(buf, AdapterHandlerLibrary_size); + + BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache + if (buf != NULL) { + CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); short buffer_locs[20]; buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, sizeof(buffer_locs)/sizeof(relocInfo)); MacroAssembler _masm(&buffer);
*** 1877,1893 **** --- 1887,1905 ---- int comp_args_on_stack; // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); ! AdapterHandlerEntry* entry = SharedRuntime::generate_i2c2i_adapters(&_masm, ! entry = SharedRuntime::generate_i2c2i_adapters(&_masm, total_args_passed, comp_args_on_stack, sig_bt, regs); B = BufferBlob::create(AdapterHandlerEntry::name, &buffer); + NOT_PRODUCT(code_size = buffer.code_size()); + } if (B == NULL) { // CodeCache is full, disable compilation // Ought to log this but compile log is only per compile thread // and we're some non descript Java thread. UseInterpreter = true;
*** 1910,1922 **** --- 1922,1934 ---- // debugging suppport if (PrintAdapterHandlers) { tty->cr(); tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = 0x%llx, %d bytes generated)", _handlers->length(), (method->is_static() ? "static" : "receiver"), ! method->signature()->as_C_string(), fingerprint, buffer.code_size() ); tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); ! Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + buffer.code_size()); } #endif // add handlers to library _fingerprints->append(fingerprint);
*** 1980,2002 **** --- 1992,2010 ---- nm = method->code(); if (nm) { return nm; } // Improve alignment slightly u_char* buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1)); CodeBuffer buffer(buf, AdapterHandlerLibrary_size); // Need a few relocation entries double locs_buf[20]; buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); MacroAssembler _masm(&buffer); + ResourceMark rm; + BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache + if (buf != NULL) { // Fill in the signature array, for the calling-convention call. int total_args_passed = method->size_of_parameters(); BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed); ! VMRegPair * regs = NEW_RESOURCE_ARRAY(VMRegPair ,total_args_passed); ! VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair,total_args_passed); int i=0; if( !method->is_static() ) // Pass in receiver first sig_bt[i++] = T_OBJECT; SignatureStream ss(method->signature()); for( ; !ss.at_return_type(); ss.next()) {
*** 2009,2026 **** --- 2017,2040 ---- // Now get the compiled-Java layout as input arguments int comp_args_on_stack; comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); + CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); + double locs_buf[20]; + buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); + MacroAssembler _masm(&buffer); + // Generate the compiled-to-native wrapper code nm = SharedRuntime::generate_native_wrapper(&_masm, method, total_args_passed, comp_args_on_stack, sig_bt,regs, ret_type); } + } // Must unlock before calling set_code // Install the generated code. if (nm != NULL) { method->set_code(method, nm);
*** 2075,2097 **** --- 2089,2113 ---- nm = method->code(); if (nm) { return nm; } // Improve alignment slightly u_char* buf = (u_char*) (((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1)); CodeBuffer buffer(buf, AdapterHandlerLibrary_size); + ResourceMark rm; + + BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache + if (buf != NULL) { + CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); // Need a few relocation entries double locs_buf[20]; buffer.insts()->initialize_shared_locs( (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); MacroAssembler _masm(&buffer); // Generate the compiled-to-native wrapper code nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method); } + } return nm; } // the dtrace method needs to convert java lang string to utf8 string. void SharedRuntime::get_utf(oopDesc* src, address dst) {

src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File