Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/systemDictionary.cpp @ 2460:ed69575596ac
6981791: remove experimental code for JSR 292
Reviewed-by: twisti
author | jrose |
---|---|
date | Thu, 07 Apr 2011 17:02:30 -0700 |
parents | 38fea01eb669 |
children | 0654ee04b214 8ce625481709 |
comparison
equal
deleted
inserted
replaced
2459:55973726c600 | 2460:ed69575596ac |
---|---|
1885 WK_KLASSES_DO(WK_KLASS_INIT_INFO) | 1885 WK_KLASSES_DO(WK_KLASS_INIT_INFO) |
1886 #undef WK_KLASS_INIT_INFO | 1886 #undef WK_KLASS_INIT_INFO |
1887 0 | 1887 0 |
1888 }; | 1888 }; |
1889 | 1889 |
1890 Symbol* SystemDictionary::find_backup_symbol(Symbol* symbol, | |
1891 const char* from_prefix, | |
1892 const char* to_prefix) { | |
1893 assert(AllowTransitionalJSR292, ""); // delete this subroutine | |
1894 Symbol* backup_symbol = NULL; | |
1895 size_t from_len = strlen(from_prefix); | |
1896 if (strncmp((const char*) symbol->base(), from_prefix, from_len) != 0) | |
1897 return NULL; | |
1898 char buf[100]; | |
1899 size_t to_len = strlen(to_prefix); | |
1900 size_t tail_len = symbol->utf8_length() - from_len; | |
1901 size_t new_len = to_len + tail_len; | |
1902 guarantee(new_len < sizeof(buf), "buf too small"); | |
1903 memcpy(buf, to_prefix, to_len); | |
1904 memcpy(buf + to_len, symbol->base() + from_len, tail_len); | |
1905 buf[new_len] = '\0'; | |
1906 vmSymbols::SID backup_sid = vmSymbols::find_sid(buf); | |
1907 if (backup_sid != vmSymbols::NO_SID) { | |
1908 backup_symbol = vmSymbols::symbol_at(backup_sid); | |
1909 } | |
1910 return backup_symbol; | |
1911 } | |
1912 | |
1913 Symbol* SystemDictionary::find_backup_class_name(Symbol* symbol) { | |
1914 assert(AllowTransitionalJSR292, ""); // delete this subroutine | |
1915 if (symbol == NULL) return NULL; | |
1916 Symbol* backup_symbol = find_backup_symbol(symbol, "java/lang/invoke/", "java/dyn/"); // AllowTransitionalJSR292 ONLY | |
1917 if (backup_symbol == NULL) | |
1918 backup_symbol = find_backup_symbol(symbol, "java/dyn/", "sun/dyn/"); // AllowTransitionalJSR292 ONLY | |
1919 return backup_symbol; | |
1920 } | |
1921 | |
1922 Symbol* SystemDictionary::find_backup_signature(Symbol* symbol) { | |
1923 assert(AllowTransitionalJSR292, ""); // delete this subroutine | |
1924 if (symbol == NULL) return NULL; | |
1925 return find_backup_symbol(symbol, "Ljava/lang/invoke/", "Ljava/dyn/"); | |
1926 } | |
1927 | |
1928 bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) { | 1890 bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) { |
1929 assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); | 1891 assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob"); |
1930 int info = wk_init_info[id - FIRST_WKID]; | 1892 int info = wk_init_info[id - FIRST_WKID]; |
1931 int sid = (info >> CEIL_LG_OPTION_LIMIT); | 1893 int sid = (info >> CEIL_LG_OPTION_LIMIT); |
1932 Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid); | 1894 Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid); |
1933 klassOop* klassp = &_well_known_klasses[id]; | 1895 klassOop* klassp = &_well_known_klasses[id]; |
1934 bool pre_load = (init_opt < SystemDictionary::Opt); | 1896 bool must_load = (init_opt < SystemDictionary::Opt); |
1935 bool try_load = true; | 1897 bool try_load = true; |
1936 if (init_opt == SystemDictionary::Opt_Kernel) { | 1898 if (init_opt == SystemDictionary::Opt_Kernel) { |
1937 #ifndef KERNEL | 1899 #ifndef KERNEL |
1938 try_load = false; | 1900 try_load = false; |
1939 #endif //KERNEL | 1901 #endif //KERNEL |
1940 } | 1902 } |
1941 Symbol* backup_symbol = NULL; // symbol to try if the current symbol fails | 1903 if ((*klassp) == NULL && try_load) { |
1942 if (init_opt == SystemDictionary::Pre_JSR292) { | |
1943 if (!EnableInvokeDynamic) try_load = false; // do not bother to load such classes | |
1944 if (AllowTransitionalJSR292) { | |
1945 backup_symbol = find_backup_class_name(symbol); | |
1946 if (try_load && PreferTransitionalJSR292) { | |
1947 while (backup_symbol != NULL) { | |
1948 (*klassp) = resolve_or_null(backup_symbol, CHECK_0); // try backup early | |
1949 if (TraceMethodHandles) { | |
1950 ResourceMark rm; | |
1951 tty->print_cr("MethodHandles: try backup first for %s => %s (%s)", | |
1952 symbol->as_C_string(), backup_symbol->as_C_string(), | |
1953 ((*klassp) == NULL) ? "no such class" : "backup load succeeded"); | |
1954 } | |
1955 if ((*klassp) != NULL) return true; | |
1956 backup_symbol = find_backup_class_name(backup_symbol); // find next backup | |
1957 } | |
1958 } | |
1959 } | |
1960 } | |
1961 if ((*klassp) != NULL) return true; | |
1962 if (!try_load) return false; | |
1963 while (symbol != NULL) { | |
1964 bool must_load = (pre_load && (backup_symbol == NULL)); | |
1965 if (must_load) { | 1904 if (must_load) { |
1966 (*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class | 1905 (*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class |
1967 } else { | 1906 } else { |
1968 (*klassp) = resolve_or_null(symbol, CHECK_0); // load optional klass | 1907 (*klassp) = resolve_or_null(symbol, CHECK_0); // load optional klass |
1969 } | 1908 } |
1970 if ((*klassp) != NULL) return true; | 1909 } |
1971 // Go around again. Example of long backup sequence: | 1910 return ((*klassp) != NULL); |
1972 // java.lang.invoke.MemberName, java.dyn.MemberName, sun.dyn.MemberName, ONLY if AllowTransitionalJSR292 | |
1973 if (TraceMethodHandles && (backup_symbol != NULL)) { | |
1974 ResourceMark rm; | |
1975 tty->print_cr("MethodHandles: backup for %s => %s", | |
1976 symbol->as_C_string(), backup_symbol->as_C_string()); | |
1977 } | |
1978 symbol = backup_symbol; | |
1979 if (AllowTransitionalJSR292) | |
1980 backup_symbol = find_backup_class_name(symbol); | |
1981 } | |
1982 return false; | |
1983 } | 1911 } |
1984 | 1912 |
1985 void SystemDictionary::initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) { | 1913 void SystemDictionary::initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) { |
1986 assert((int)start_id <= (int)limit_id, "IDs are out of order!"); | 1914 assert((int)start_id <= (int)limit_id, "IDs are out of order!"); |
1987 for (int id = (int)start_id; id < (int)limit_id; id++) { | 1915 for (int id = (int)start_id; id < (int)limit_id; id++) { |
2407 if (spe == NULL || spe->property_oop() == NULL) { | 2335 if (spe == NULL || spe->property_oop() == NULL) { |
2408 spe = NULL; | 2336 spe = NULL; |
2409 // Must create lots of stuff here, but outside of the SystemDictionary lock. | 2337 // Must create lots of stuff here, but outside of the SystemDictionary lock. |
2410 if (THREAD->is_Compiler_thread()) | 2338 if (THREAD->is_Compiler_thread()) |
2411 return NULL; // do not attempt from within compiler | 2339 return NULL; // do not attempt from within compiler |
2412 bool for_invokeGeneric = (name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name)); | 2340 bool for_invokeGeneric = (name_id != vmSymbols::VM_SYMBOL_ENUM_NAME(invokeExact_name)); |
2413 if (AllowInvokeForInvokeGeneric && name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name)) | |
2414 for_invokeGeneric = true; | |
2415 bool found_on_bcp = false; | 2341 bool found_on_bcp = false; |
2416 Handle mt = find_method_handle_type(signature, accessing_klass, | 2342 Handle mt = find_method_handle_type(signature, accessing_klass, |
2417 for_invokeGeneric, | 2343 for_invokeGeneric, |
2418 found_on_bcp, CHECK_NULL); | 2344 found_on_bcp, CHECK_NULL); |
2419 KlassHandle mh_klass = SystemDictionaryHandles::MethodHandle_klass(); | 2345 KlassHandle mh_klass = SystemDictionaryHandles::MethodHandle_klass(); |
2496 | 2422 |
2497 // call java.lang.invoke.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType | 2423 // call java.lang.invoke.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType |
2498 JavaCallArguments args(Handle(THREAD, rt())); | 2424 JavaCallArguments args(Handle(THREAD, rt())); |
2499 args.push_oop(pts()); | 2425 args.push_oop(pts()); |
2500 JavaValue result(T_OBJECT); | 2426 JavaValue result(T_OBJECT); |
2501 Symbol* findMethodHandleType_signature = vmSymbols::findMethodHandleType_signature(); | |
2502 if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) { | |
2503 findMethodHandleType_signature = vmSymbols::findMethodHandleType_TRANS_signature(); | |
2504 } | |
2505 JavaCalls::call_static(&result, | 2427 JavaCalls::call_static(&result, |
2506 SystemDictionary::MethodHandleNatives_klass(), | 2428 SystemDictionary::MethodHandleNatives_klass(), |
2507 vmSymbols::findMethodHandleType_name(), | 2429 vmSymbols::findMethodHandleType_name(), |
2508 findMethodHandleType_signature, | 2430 vmSymbols::findMethodHandleType_signature(), |
2509 &args, CHECK_(empty)); | 2431 &args, CHECK_(empty)); |
2510 Handle method_type(THREAD, (oop) result.get_jobject()); | 2432 Handle method_type(THREAD, (oop) result.get_jobject()); |
2511 | 2433 |
2512 if (for_invokeGeneric) { | 2434 if (for_invokeGeneric) { |
2513 // call java.lang.invoke.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void | 2435 // call java.lang.invoke.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void |
2514 JavaCallArguments args(Handle(THREAD, method_type())); | 2436 JavaCallArguments args(Handle(THREAD, method_type())); |
2515 JavaValue no_result(T_VOID); | 2437 JavaValue no_result(T_VOID); |
2516 Symbol* notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_signature(); | |
2517 if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) { | |
2518 notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_TRANS_signature(); | |
2519 } | |
2520 JavaCalls::call_static(&no_result, | 2438 JavaCalls::call_static(&no_result, |
2521 SystemDictionary::MethodHandleNatives_klass(), | 2439 SystemDictionary::MethodHandleNatives_klass(), |
2522 vmSymbols::notifyGenericMethodType_name(), | 2440 vmSymbols::notifyGenericMethodType_name(), |
2523 notifyGenericMethodType_signature, | 2441 vmSymbols::notifyGenericMethodType_signature(), |
2524 &args, THREAD); | 2442 &args, THREAD); |
2525 if (HAS_PENDING_EXCEPTION) { | 2443 if (HAS_PENDING_EXCEPTION) { |
2526 // If the notification fails, just kill it. | 2444 // If the notification fails, just kill it. |
2527 CLEAR_PENDING_EXCEPTION; | 2445 CLEAR_PENDING_EXCEPTION; |
2528 } | 2446 } |
2567 args.push_int(ref_kind); | 2485 args.push_int(ref_kind); |
2568 args.push_oop(callee->java_mirror()); // the target class | 2486 args.push_oop(callee->java_mirror()); // the target class |
2569 args.push_oop(name()); | 2487 args.push_oop(name()); |
2570 args.push_oop(type()); | 2488 args.push_oop(type()); |
2571 JavaValue result(T_OBJECT); | 2489 JavaValue result(T_OBJECT); |
2572 Symbol* linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_signature(); | |
2573 if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandle_klass()->name() == vmSymbols::java_dyn_MethodHandle()) { | |
2574 linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_TRANS_signature(); | |
2575 } | |
2576 JavaCalls::call_static(&result, | 2490 JavaCalls::call_static(&result, |
2577 SystemDictionary::MethodHandleNatives_klass(), | 2491 SystemDictionary::MethodHandleNatives_klass(), |
2578 vmSymbols::linkMethodHandleConstant_name(), | 2492 vmSymbols::linkMethodHandleConstant_name(), |
2579 linkMethodHandleConstant_signature, | 2493 vmSymbols::linkMethodHandleConstant_signature(), |
2580 &args, CHECK_(empty)); | 2494 &args, CHECK_(empty)); |
2581 return Handle(THREAD, (oop) result.get_jobject()); | 2495 return Handle(THREAD, (oop) result.get_jobject()); |
2582 } | 2496 } |
2583 | 2497 |
2584 // Ask Java code to find or construct a java.lang.invoke.CallSite for the given | 2498 // Ask Java code to find or construct a java.lang.invoke.CallSite for the given |
2605 args.push_oop(signature_invoker->method_handle_type()); | 2519 args.push_oop(signature_invoker->method_handle_type()); |
2606 args.push_oop(info()); | 2520 args.push_oop(info()); |
2607 args.push_oop(caller_mname()); | 2521 args.push_oop(caller_mname()); |
2608 args.push_int(caller_bci); | 2522 args.push_int(caller_bci); |
2609 JavaValue result(T_OBJECT); | 2523 JavaValue result(T_OBJECT); |
2610 Symbol* makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_signature(); | |
2611 if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::sun_dyn_MethodHandleNatives()) { | |
2612 makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS_signature(); | |
2613 } | |
2614 if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::java_dyn_MethodHandleNatives()) { | |
2615 makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS2_signature(); | |
2616 } | |
2617 JavaCalls::call_static(&result, | 2524 JavaCalls::call_static(&result, |
2618 SystemDictionary::MethodHandleNatives_klass(), | 2525 SystemDictionary::MethodHandleNatives_klass(), |
2619 vmSymbols::makeDynamicCallSite_name(), | 2526 vmSymbols::makeDynamicCallSite_name(), |
2620 makeDynamicCallSite_signature, | 2527 vmSymbols::makeDynamicCallSite_signature(), |
2621 &args, CHECK_(empty)); | 2528 &args, CHECK_(empty)); |
2622 oop call_site_oop = (oop) result.get_jobject(); | 2529 oop call_site_oop = (oop) result.get_jobject(); |
2623 assert(call_site_oop->is_oop() | 2530 assert(call_site_oop->is_oop() |
2624 /*&& java_lang_invoke_CallSite::is_instance(call_site_oop)*/, "must be sane"); | 2531 /*&& java_lang_invoke_CallSite::is_instance(call_site_oop)*/, "must be sane"); |
2625 if (TraceMethodHandles) { | 2532 if (TraceMethodHandles) { |
2696 } | 2603 } |
2697 | 2604 |
2698 argument_info_result = argument_info; // return argument_info to caller | 2605 argument_info_result = argument_info; // return argument_info to caller |
2699 return bsm; | 2606 return bsm; |
2700 } | 2607 } |
2701 // else null BSM; fall through | |
2702 } else if (tag.is_name_and_type()) { | |
2703 // JSR 292 EDR does not have JVM_CONSTANT_InvokeDynamic | |
2704 // a bare name&type defaults its BSM to null, so fall through... | |
2705 } else { | 2608 } else { |
2706 ShouldNotReachHere(); // verifier does not allow this | 2609 ShouldNotReachHere(); // verifier does not allow this |
2707 } | |
2708 | |
2709 // Fall through to pick up the per-class bootstrap method. | |
2710 // This mechanism may go away in the PFD. | |
2711 assert(AllowTransitionalJSR292, "else the verifier should have stopped us already"); | |
2712 argument_info_result = empty; // return no argument_info to caller | |
2713 oop bsm_oop = instanceKlass::cast(caller_method->method_holder())->bootstrap_method(); | |
2714 if (bsm_oop != NULL) { | |
2715 if (TraceMethodHandles) { | |
2716 tty->print_cr("bootstrap method for "PTR_FORMAT" registered as "PTR_FORMAT":", | |
2717 (intptr_t) caller_method(), (intptr_t) bsm_oop); | |
2718 } | |
2719 assert(bsm_oop->is_oop(), "must be sane"); | |
2720 return Handle(THREAD, bsm_oop); | |
2721 } | 2610 } |
2722 | 2611 |
2723 return empty; | 2612 return empty; |
2724 } | 2613 } |
2725 | 2614 |