2255 }
2256
2257
2258 methodHandle SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid,
2259 Symbol* signature,
2260 TRAPS) {
2261 methodHandle empty;
2262 assert(MethodHandles::is_signature_polymorphic(iid) &&
2263 MethodHandles::is_signature_polymorphic_intrinsic(iid) &&
2264 iid != vmIntrinsics::_invokeGeneric,
2265 err_msg("must be a known MH intrinsic iid=%d: %s", iid, vmIntrinsics::name_at(iid)));
2266
2267 unsigned int hash = invoke_method_table()->compute_hash(signature, iid);
2268 int index = invoke_method_table()->hash_to_index(hash);
2269 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature, iid);
2270 methodHandle m;
2271 if (spe == NULL || spe->method() == NULL) {
2272 spe = NULL;
2273 // Must create lots of stuff here, but outside of the SystemDictionary lock.
2274 m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty));
2275 if (!Arguments::is_interpreter_only()) {
2276 // Generate a compiled form of the MH intrinsic.
2277 AdapterHandlerLibrary::create_native_wrapper(m);
2278 // Check if have the compiled code.
2279 if (!m->has_compiled_code()) {
2280 THROW_MSG_(vmSymbols::java_lang_VirtualMachineError(),
2281 "out of space in CodeCache for method handle intrinsic", empty);
2282 }
2283 }
2284 // Now grab the lock. We might have to throw away the new method,
2285 // if a racing thread has managed to install one at the same time.
2286 {
2287 MutexLocker ml(SystemDictionary_lock, THREAD);
2288 spe = invoke_method_table()->find_entry(index, hash, signature, iid);
2289 if (spe == NULL)
2290 spe = invoke_method_table()->add_entry(index, hash, signature, iid);
2291 if (spe->method() == NULL)
2292 spe->set_method(m());
2293 }
2294 }
2295
2296 assert(spe != NULL && spe->method() != NULL, "");
2297 assert(Arguments::is_interpreter_only() || (spe->method()->has_compiled_code() &&
2298 spe->method()->code()->entry_point() == spe->method()->from_compiled_entry()),
2299 "MH intrinsic invariant");
2300 return spe->method();
2301 }
2302
2303 // Helper for unpacking the return value from linkMethod and linkCallSite.
2304 static methodHandle unpack_method_and_appendix(Handle mname,
2305 KlassHandle accessing_klass,
2306 objArrayHandle appendix_box,
2307 Handle* appendix_result,
2308 TRAPS) {
2309 methodHandle empty;
2310 if (mname.not_null()) {
2311 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(mname());
2312 if (vmtarget != NULL && vmtarget->is_method()) {
2313 Method* m = (Method*)vmtarget;
2314 oop appendix = appendix_box->obj_at(0);
2315 if (TraceMethodHandles) {
2316 #ifndef PRODUCT
2317 tty->print("Linked method=" INTPTR_FORMAT ": ", p2i(m));
2318 m->print();
2319 if (appendix != NULL) { tty->print("appendix = "); appendix->print(); }
|
2255 }
2256
2257
2258 methodHandle SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid,
2259 Symbol* signature,
2260 TRAPS) {
2261 methodHandle empty;
2262 assert(MethodHandles::is_signature_polymorphic(iid) &&
2263 MethodHandles::is_signature_polymorphic_intrinsic(iid) &&
2264 iid != vmIntrinsics::_invokeGeneric,
2265 err_msg("must be a known MH intrinsic iid=%d: %s", iid, vmIntrinsics::name_at(iid)));
2266
2267 unsigned int hash = invoke_method_table()->compute_hash(signature, iid);
2268 int index = invoke_method_table()->hash_to_index(hash);
2269 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature, iid);
2270 methodHandle m;
2271 if (spe == NULL || spe->method() == NULL) {
2272 spe = NULL;
2273 // Must create lots of stuff here, but outside of the SystemDictionary lock.
2274 m = Method::make_method_handle_intrinsic(iid, signature, CHECK_(empty));
2275 #ifndef SHARK
2276 if (!Arguments::is_interpreter_only()) {
2277 // Generate a compiled form of the MH intrinsic.
2278 AdapterHandlerLibrary::create_native_wrapper(m);
2279 // Check if have the compiled code.
2280 if (!m->has_compiled_code()) {
2281 THROW_MSG_(vmSymbols::java_lang_VirtualMachineError(),
2282 "out of space in CodeCache for method handle intrinsic", empty);
2283 }
2284 }
2285 #endif // SHARK
2286 // Now grab the lock. We might have to throw away the new method,
2287 // if a racing thread has managed to install one at the same time.
2288 {
2289 MutexLocker ml(SystemDictionary_lock, THREAD);
2290 spe = invoke_method_table()->find_entry(index, hash, signature, iid);
2291 if (spe == NULL)
2292 spe = invoke_method_table()->add_entry(index, hash, signature, iid);
2293 if (spe->method() == NULL)
2294 spe->set_method(m());
2295 }
2296 }
2297
2298 assert(spe != NULL && spe->method() != NULL, "");
2299 #ifndef SHARK
2300 assert(Arguments::is_interpreter_only() || (spe->method()->has_compiled_code() &&
2301 spe->method()->code()->entry_point() == spe->method()->from_compiled_entry()),
2302 "MH intrinsic invariant");
2303 #endif // SHARK
2304 return spe->method();
2305 }
2306
2307 // Helper for unpacking the return value from linkMethod and linkCallSite.
2308 static methodHandle unpack_method_and_appendix(Handle mname,
2309 KlassHandle accessing_klass,
2310 objArrayHandle appendix_box,
2311 Handle* appendix_result,
2312 TRAPS) {
2313 methodHandle empty;
2314 if (mname.not_null()) {
2315 Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(mname());
2316 if (vmtarget != NULL && vmtarget->is_method()) {
2317 Method* m = (Method*)vmtarget;
2318 oop appendix = appendix_box->obj_at(0);
2319 if (TraceMethodHandles) {
2320 #ifndef PRODUCT
2321 tty->print("Linked method=" INTPTR_FORMAT ": ", p2i(m));
2322 m->print();
2323 if (appendix != NULL) { tty->print("appendix = "); appendix->print(); }
|