comparison src/share/vm/runtime/sharedRuntime.cpp @ 1299:9eba43136cb5

6934494: JSR 292 MethodHandles adapters should be generated into their own CodeBlob Summary: Passing a null pointer to an InvokeDynamic function call should lead to a NullPointerException. Reviewed-by: kvn, never
author twisti
date Tue, 16 Mar 2010 11:52:17 +0100
parents 3cf667df43ef
children 93767e6a2dfd
comparison
equal deleted inserted replaced
1298:da06d1795d84 1299:9eba43136cb5
580 // 1. Inline-cache check in C2I handler blob, 580 // 1. Inline-cache check in C2I handler blob,
581 // 2. Inline-cache check in nmethod, or 581 // 2. Inline-cache check in nmethod, or
582 // 3. Implict null exception in nmethod 582 // 3. Implict null exception in nmethod
583 583
584 if (!cb->is_nmethod()) { 584 if (!cb->is_nmethod()) {
585 guarantee(cb->is_adapter_blob(), 585 guarantee(cb->is_adapter_blob() || cb->is_method_handles_adapter_blob(),
586 "exception happened outside interpreter, nmethods and vtable stubs (1)"); 586 "exception happened outside interpreter, nmethods and vtable stubs (1)");
587 // There is no handler here, so we will simply unwind. 587 // There is no handler here, so we will simply unwind.
588 return StubRoutines::throw_NullPointerException_at_call_entry(); 588 return StubRoutines::throw_NullPointerException_at_call_entry();
589 } 589 }
590 590
2077 #endif 2077 #endif
2078 2078
2079 2079
2080 // --------------------------------------------------------------------------- 2080 // ---------------------------------------------------------------------------
2081 // Implementation of AdapterHandlerLibrary 2081 // Implementation of AdapterHandlerLibrary
2082 const char* AdapterHandlerEntry::name = "I2C/C2I adapters";
2083 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL; 2082 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL;
2084 AdapterHandlerEntry* AdapterHandlerLibrary::_abstract_method_handler = NULL; 2083 AdapterHandlerEntry* AdapterHandlerLibrary::_abstract_method_handler = NULL;
2085 const int AdapterHandlerLibrary_size = 16*K; 2084 const int AdapterHandlerLibrary_size = 16*K;
2086 BufferBlob* AdapterHandlerLibrary::_buffer = NULL; 2085 BufferBlob* AdapterHandlerLibrary::_buffer = NULL;
2087 2086
2129 assert(ic_miss != NULL, "must have handler"); 2128 assert(ic_miss != NULL, "must have handler");
2130 2129
2131 ResourceMark rm; 2130 ResourceMark rm;
2132 2131
2133 NOT_PRODUCT(int code_size); 2132 NOT_PRODUCT(int code_size);
2134 BufferBlob *B = NULL; 2133 AdapterBlob* B = NULL;
2135 AdapterHandlerEntry* entry = NULL; 2134 AdapterHandlerEntry* entry = NULL;
2136 AdapterFingerPrint* fingerprint = NULL; 2135 AdapterFingerPrint* fingerprint = NULL;
2137 { 2136 {
2138 MutexLocker mu(AdapterHandlerLibrary_lock); 2137 MutexLocker mu(AdapterHandlerLibrary_lock);
2139 // make sure data structure is initialized 2138 // make sure data structure is initialized
2179 // Make a C heap allocated version of the fingerprint to store in the adapter 2178 // Make a C heap allocated version of the fingerprint to store in the adapter
2180 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); 2179 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt);
2181 2180
2182 // Create I2C & C2I handlers 2181 // Create I2C & C2I handlers
2183 2182
2184 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache 2183 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache
2185 if (buf != NULL) { 2184 if (buf != NULL) {
2186 CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); 2185 CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
2187 short buffer_locs[20]; 2186 short buffer_locs[20];
2188 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, 2187 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
2189 sizeof(buffer_locs)/sizeof(relocInfo)); 2188 sizeof(buffer_locs)/sizeof(relocInfo));
2208 entry->save_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt); 2207 entry->save_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt);
2209 } 2208 }
2210 } 2209 }
2211 #endif 2210 #endif
2212 2211
2213 B = BufferBlob::create(AdapterHandlerEntry::name, &buffer); 2212 B = AdapterBlob::create(&buffer);
2214 NOT_PRODUCT(code_size = buffer.code_size()); 2213 NOT_PRODUCT(code_size = buffer.code_size());
2215 } 2214 }
2216 if (B == NULL) { 2215 if (B == NULL) {
2217 // CodeCache is full, disable compilation 2216 // CodeCache is full, disable compilation
2218 // Ought to log this but compile log is only per compile thread 2217 // Ought to log this but compile log is only per compile thread
2240 if (B != NULL) { 2239 if (B != NULL) {
2241 char blob_id[256]; 2240 char blob_id[256];
2242 jio_snprintf(blob_id, 2241 jio_snprintf(blob_id,
2243 sizeof(blob_id), 2242 sizeof(blob_id),
2244 "%s(%s)@" PTR_FORMAT, 2243 "%s(%s)@" PTR_FORMAT,
2245 AdapterHandlerEntry::name, 2244 B->name(),
2246 fingerprint->as_string(), 2245 fingerprint->as_string(),
2247 B->instructions_begin()); 2246 B->instructions_begin());
2248 VTune::register_stub(blob_id, B->instructions_begin(), B->instructions_end()); 2247 VTune::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2249 Forte::register_stub(blob_id, B->instructions_begin(), B->instructions_end()); 2248 Forte::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2250 2249