Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/jvm.cpp @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | ccfcb502af3f |
children | d70fe6ab4436 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
122 JavaThread* jthread = JavaThread::current(); | 122 JavaThread* jthread = JavaThread::current(); |
123 if (jthread->has_last_Java_frame()) { | 123 if (jthread->has_last_Java_frame()) { |
124 vframeStream vfst(jthread); | 124 vframeStream vfst(jthread); |
125 | 125 |
126 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames | 126 // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames |
127 symbolHandle access_controller = oopFactory::new_symbol_handle("java/security/AccessController", CHECK); | 127 TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK); |
128 klassOop access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); | 128 klassOop access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK); |
129 symbolHandle privileged_action = oopFactory::new_symbol_handle("java/security/PrivilegedAction", CHECK); | 129 TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK); |
130 klassOop privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); | 130 klassOop privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK); |
131 | 131 |
132 methodOop last_caller = NULL; | 132 methodOop last_caller = NULL; |
133 | 133 |
134 while (!vfst.at_end()) { | 134 while (!vfst.at_end()) { |
173 line_number = vfst.method()->line_number_from_bci(vfst.bci()); | 173 line_number = vfst.method()->line_number_from_bci(vfst.bci()); |
174 if (line_number == -1) { | 174 if (line_number == -1) { |
175 // show method name if it's a native method | 175 // show method name if it's a native method |
176 trace = vfst.method()->name_and_sig_as_C_string(); | 176 trace = vfst.method()->name_and_sig_as_C_string(); |
177 } | 177 } |
178 symbolOop s = instanceKlass::cast(caller)->source_file_name(); | 178 Symbol* s = instanceKlass::cast(caller)->source_file_name(); |
179 if (s != NULL) { | 179 if (s != NULL) { |
180 source_file = s->as_C_string(); | 180 source_file = s->as_C_string(); |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
309 Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); | 309 Handle key_str = java_lang_String::create_from_platform_dependent_str(key, CHECK); |
310 Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); | 310 Handle value_str = java_lang_String::create_from_platform_dependent_str((value != NULL ? value : ""), CHECK); |
311 JavaCalls::call_virtual(&r, | 311 JavaCalls::call_virtual(&r, |
312 props, | 312 props, |
313 KlassHandle(THREAD, SystemDictionary::Properties_klass()), | 313 KlassHandle(THREAD, SystemDictionary::Properties_klass()), |
314 vmSymbolHandles::put_name(), | 314 vmSymbols::put_name(), |
315 vmSymbolHandles::object_object_object_signature(), | 315 vmSymbols::object_object_object_signature(), |
316 key_str, | 316 key_str, |
317 value_str, | 317 value_str, |
318 THREAD); | 318 THREAD); |
319 } | 319 } |
320 | 320 |
714 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, | 714 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, |
715 const char* name)) | 715 const char* name)) |
716 JVMWrapper2("JVM_FindClassFromBootLoader %s", name); | 716 JVMWrapper2("JVM_FindClassFromBootLoader %s", name); |
717 | 717 |
718 // Java libraries should ensure that name is never null... | 718 // Java libraries should ensure that name is never null... |
719 if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) { | 719 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
720 // It's impossible to create this class; the name cannot fit | 720 // It's impossible to create this class; the name cannot fit |
721 // into the constant pool. | 721 // into the constant pool. |
722 return NULL; | 722 return NULL; |
723 } | 723 } |
724 | 724 |
725 symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL); | 725 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
726 klassOop k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); | 726 klassOop k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL); |
727 if (k == NULL) { | 727 if (k == NULL) { |
728 return NULL; | 728 return NULL; |
729 } | 729 } |
730 | 730 |
738 jboolean init, jobject loader, | 738 jboolean init, jobject loader, |
739 jboolean throwError)) | 739 jboolean throwError)) |
740 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, | 740 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, |
741 throwError ? "error" : "exception"); | 741 throwError ? "error" : "exception"); |
742 // Java libraries should ensure that name is never null... | 742 // Java libraries should ensure that name is never null... |
743 if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) { | 743 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
744 // It's impossible to create this class; the name cannot fit | 744 // It's impossible to create this class; the name cannot fit |
745 // into the constant pool. | 745 // into the constant pool. |
746 if (throwError) { | 746 if (throwError) { |
747 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 747 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
748 } else { | 748 } else { |
749 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); | 749 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); |
750 } | 750 } |
751 } | 751 } |
752 symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL); | 752 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
753 Handle h_loader(THREAD, JNIHandles::resolve(loader)); | 753 Handle h_loader(THREAD, JNIHandles::resolve(loader)); |
754 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, | 754 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, |
755 Handle(), throwError, THREAD); | 755 Handle(), throwError, THREAD); |
756 | 756 |
757 if (TraceClassResolution && result != NULL) { | 757 if (TraceClassResolution && result != NULL) { |
762 | 762 |
763 | 763 |
764 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, | 764 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, |
765 jboolean init, jclass from)) | 765 jboolean init, jclass from)) |
766 JVMWrapper2("JVM_FindClassFromClass %s", name); | 766 JVMWrapper2("JVM_FindClassFromClass %s", name); |
767 if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) { | 767 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
768 // It's impossible to create this class; the name cannot fit | 768 // It's impossible to create this class; the name cannot fit |
769 // into the constant pool. | 769 // into the constant pool. |
770 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 770 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
771 } | 771 } |
772 symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL); | 772 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); |
773 oop from_class_oop = JNIHandles::resolve(from); | 773 oop from_class_oop = JNIHandles::resolve(from); |
774 klassOop from_class = (from_class_oop == NULL) | 774 klassOop from_class = (from_class_oop == NULL) |
775 ? (klassOop)NULL | 775 ? (klassOop)NULL |
776 : java_lang_Class::as_klassOop(from_class_oop); | 776 : java_lang_Class::as_klassOop(from_class_oop); |
777 oop class_loader = NULL; | 777 oop class_loader = NULL; |
836 ClassLoader::perf_app_classfile_bytes_read()->inc(len); | 836 ClassLoader::perf_app_classfile_bytes_read()->inc(len); |
837 } | 837 } |
838 | 838 |
839 // Since exceptions can be thrown, class initialization can take place | 839 // Since exceptions can be thrown, class initialization can take place |
840 // if name is NULL no check for class name in .class stream has to be made. | 840 // if name is NULL no check for class name in .class stream has to be made. |
841 symbolHandle class_name; | 841 TempNewSymbol class_name = NULL; |
842 if (name != NULL) { | 842 if (name != NULL) { |
843 const int str_len = (int)strlen(name); | 843 const int str_len = (int)strlen(name); |
844 if (str_len > symbolOopDesc::max_length()) { | 844 if (str_len > Symbol::max_length()) { |
845 // It's impossible to create this class; the name cannot fit | 845 // It's impossible to create this class; the name cannot fit |
846 // into the constant pool. | 846 // into the constant pool. |
847 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 847 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
848 } | 848 } |
849 class_name = oopFactory::new_symbol_handle(name, str_len, CHECK_NULL); | 849 class_name = SymbolTable::new_symbol(name, str_len, CHECK_NULL); |
850 } | 850 } |
851 | 851 |
852 ResourceMark rm(THREAD); | 852 ResourceMark rm(THREAD); |
853 ClassFileStream st((u1*) buf, len, (char *)source); | 853 ClassFileStream st((u1*) buf, len, (char *)source); |
854 Handle class_loader (THREAD, JNIHandles::resolve(loader)); | 854 Handle class_loader (THREAD, JNIHandles::resolve(loader)); |
903 const char* str = java_lang_String::as_utf8_string(string()); | 903 const char* str = java_lang_String::as_utf8_string(string()); |
904 // Sanity check, don't expect null | 904 // Sanity check, don't expect null |
905 if (str == NULL) return NULL; | 905 if (str == NULL) return NULL; |
906 | 906 |
907 const int str_len = (int)strlen(str); | 907 const int str_len = (int)strlen(str); |
908 if (str_len > symbolOopDesc::max_length()) { | 908 if (str_len > Symbol::max_length()) { |
909 // It's impossible to create this class; the name cannot fit | 909 // It's impossible to create this class; the name cannot fit |
910 // into the constant pool. | 910 // into the constant pool. |
911 return NULL; | 911 return NULL; |
912 } | 912 } |
913 symbolHandle klass_name = oopFactory::new_symbol_handle(str, str_len,CHECK_NULL); | 913 TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL); |
914 | 914 |
915 // Security Note: | 915 // Security Note: |
916 // The Java level wrapper will perform the necessary security check allowing | 916 // The Java level wrapper will perform the necessary security check allowing |
917 // us to pass the NULL as the initiating class loader. | 917 // us to pass the NULL as the initiating class loader. |
918 Handle h_loader(THREAD, JNIHandles::resolve(loader)); | 918 Handle h_loader(THREAD, JNIHandles::resolve(loader)); |
1153 | 1153 |
1154 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && | 1154 if ( pending_exception->is_a(SystemDictionary::Exception_klass()) && |
1155 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { | 1155 !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) { |
1156 // Throw a java.security.PrivilegedActionException(Exception e) exception | 1156 // Throw a java.security.PrivilegedActionException(Exception e) exception |
1157 JavaCallArguments args(pending_exception); | 1157 JavaCallArguments args(pending_exception); |
1158 THROW_ARG_0(vmSymbolHandles::java_security_PrivilegedActionException(), | 1158 THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(), |
1159 vmSymbolHandles::exception_void_signature(), | 1159 vmSymbols::exception_void_signature(), |
1160 &args); | 1160 &args); |
1161 } | 1161 } |
1162 } | 1162 } |
1163 | 1163 |
1164 if (pending_exception.not_null()) THROW_OOP_0(pending_exception()); | 1164 if (pending_exception.not_null()) THROW_OOP_0(pending_exception()); |
1450 ResourceMark rm(THREAD); | 1450 ResourceMark rm(THREAD); |
1451 // Return null for arrays and primatives | 1451 // Return null for arrays and primatives |
1452 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { | 1452 if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) { |
1453 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); | 1453 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls)); |
1454 if (Klass::cast(k)->oop_is_instance()) { | 1454 if (Klass::cast(k)->oop_is_instance()) { |
1455 symbolHandle sym = symbolHandle(THREAD, instanceKlass::cast(k)->generic_signature()); | 1455 Symbol* sym = instanceKlass::cast(k)->generic_signature(); |
1456 if (sym.is_null()) return NULL; | 1456 if (sym == NULL) return NULL; |
1457 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | 1457 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
1458 return (jstring) JNIHandles::make_local(env, str()); | 1458 return (jstring) JNIHandles::make_local(env, str()); |
1459 } | 1459 } |
1460 } | 1460 } |
1461 return NULL; | 1461 return NULL; |
1840 } else { | 1840 } else { |
1841 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); | 1841 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); |
1842 if (k_o == NULL) return NULL; | 1842 if (k_o == NULL) return NULL; |
1843 } | 1843 } |
1844 instanceKlassHandle k(THREAD, k_o); | 1844 instanceKlassHandle k(THREAD, k_o); |
1845 symbolOop name = cp->uncached_name_ref_at(index); | 1845 Symbol* name = cp->uncached_name_ref_at(index); |
1846 symbolOop sig = cp->uncached_signature_ref_at(index); | 1846 Symbol* sig = cp->uncached_signature_ref_at(index); |
1847 methodHandle m (THREAD, k->find_method(name, sig)); | 1847 methodHandle m (THREAD, k->find_method(name, sig)); |
1848 if (m.is_null()) { | 1848 if (m.is_null()) { |
1849 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); | 1849 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class"); |
1850 } | 1850 } |
1851 oop method; | 1851 oop method; |
1891 } else { | 1891 } else { |
1892 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); | 1892 k_o = constantPoolOopDesc::klass_at_if_loaded(cp, klass_ref); |
1893 if (k_o == NULL) return NULL; | 1893 if (k_o == NULL) return NULL; |
1894 } | 1894 } |
1895 instanceKlassHandle k(THREAD, k_o); | 1895 instanceKlassHandle k(THREAD, k_o); |
1896 symbolOop name = cp->uncached_name_ref_at(index); | 1896 Symbol* name = cp->uncached_name_ref_at(index); |
1897 symbolOop sig = cp->uncached_signature_ref_at(index); | 1897 Symbol* sig = cp->uncached_signature_ref_at(index); |
1898 fieldDescriptor fd; | 1898 fieldDescriptor fd; |
1899 klassOop target_klass = k->find_field(name, sig, &fd); | 1899 klassOop target_klass = k->find_field(name, sig, &fd); |
1900 if (target_klass == NULL) { | 1900 if (target_klass == NULL) { |
1901 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); | 1901 THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up field in target class"); |
1902 } | 1902 } |
1935 constantTag tag = cp->tag_at(index); | 1935 constantTag tag = cp->tag_at(index); |
1936 if (!tag.is_field_or_method()) { | 1936 if (!tag.is_field_or_method()) { |
1937 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | 1937 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
1938 } | 1938 } |
1939 int klass_ref = cp->uncached_klass_ref_index_at(index); | 1939 int klass_ref = cp->uncached_klass_ref_index_at(index); |
1940 symbolHandle klass_name (THREAD, cp->klass_name_at(klass_ref)); | 1940 Symbol* klass_name = cp->klass_name_at(klass_ref); |
1941 symbolHandle member_name(THREAD, cp->uncached_name_ref_at(index)); | 1941 Symbol* member_name = cp->uncached_name_ref_at(index); |
1942 symbolHandle member_sig (THREAD, cp->uncached_signature_ref_at(index)); | 1942 Symbol* member_sig = cp->uncached_signature_ref_at(index); |
1943 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 3, CHECK_NULL); | 1943 objArrayOop dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 3, CHECK_NULL); |
1944 objArrayHandle dest(THREAD, dest_o); | 1944 objArrayHandle dest(THREAD, dest_o); |
1945 Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL); | 1945 Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL); |
1946 dest->obj_at_put(0, str()); | 1946 dest->obj_at_put(0, str()); |
1947 str = java_lang_String::create_from_symbol(member_name, CHECK_NULL); | 1947 str = java_lang_String::create_from_symbol(member_name, CHECK_NULL); |
2026 bounds_check(cp, index, CHECK_NULL); | 2026 bounds_check(cp, index, CHECK_NULL); |
2027 constantTag tag = cp->tag_at(index); | 2027 constantTag tag = cp->tag_at(index); |
2028 if (!tag.is_symbol()) { | 2028 if (!tag.is_symbol()) { |
2029 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); | 2029 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index"); |
2030 } | 2030 } |
2031 symbolOop sym_o = cp->symbol_at(index); | 2031 Symbol* sym = cp->symbol_at(index); |
2032 symbolHandle sym(THREAD, sym_o); | |
2033 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | 2032 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
2034 return (jstring) JNIHandles::make_local(str()); | 2033 return (jstring) JNIHandles::make_local(str()); |
2035 } | 2034 } |
2036 JVM_END | 2035 JVM_END |
2037 | 2036 |
2354 JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | 2353 JVM_ENTRY(const char*, JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2355 JVMWrapper("JVM_GetCPClassNameUTF"); | 2354 JVMWrapper("JVM_GetCPClassNameUTF"); |
2356 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); | 2355 klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls)); |
2357 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); | 2356 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2358 constantPoolOop cp = instanceKlass::cast(k)->constants(); | 2357 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2359 symbolOop classname = cp->klass_name_at(cp_index); | 2358 Symbol* classname = cp->klass_name_at(cp_index); |
2360 return classname->as_utf8(); | 2359 return classname->as_utf8(); |
2361 JVM_END | 2360 JVM_END |
2362 | 2361 |
2363 | 2362 |
2364 JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) | 2363 JVM_ENTRY(const char*, JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index)) |
2367 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); | 2366 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2368 constantPoolOop cp = instanceKlass::cast(k)->constants(); | 2367 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2369 switch (cp->tag_at(cp_index).value()) { | 2368 switch (cp->tag_at(cp_index).value()) { |
2370 case JVM_CONSTANT_Fieldref: { | 2369 case JVM_CONSTANT_Fieldref: { |
2371 int class_index = cp->uncached_klass_ref_index_at(cp_index); | 2370 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2372 symbolOop classname = cp->klass_name_at(class_index); | 2371 Symbol* classname = cp->klass_name_at(class_index); |
2373 return classname->as_utf8(); | 2372 return classname->as_utf8(); |
2374 } | 2373 } |
2375 default: | 2374 default: |
2376 fatal("JVM_GetCPFieldClassNameUTF: illegal constant"); | 2375 fatal("JVM_GetCPFieldClassNameUTF: illegal constant"); |
2377 } | 2376 } |
2387 constantPoolOop cp = instanceKlass::cast(k)->constants(); | 2386 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2388 switch (cp->tag_at(cp_index).value()) { | 2387 switch (cp->tag_at(cp_index).value()) { |
2389 case JVM_CONSTANT_Methodref: | 2388 case JVM_CONSTANT_Methodref: |
2390 case JVM_CONSTANT_InterfaceMethodref: { | 2389 case JVM_CONSTANT_InterfaceMethodref: { |
2391 int class_index = cp->uncached_klass_ref_index_at(cp_index); | 2390 int class_index = cp->uncached_klass_ref_index_at(cp_index); |
2392 symbolOop classname = cp->klass_name_at(class_index); | 2391 Symbol* classname = cp->klass_name_at(class_index); |
2393 return classname->as_utf8(); | 2392 return classname->as_utf8(); |
2394 } | 2393 } |
2395 default: | 2394 default: |
2396 fatal("JVM_GetCPMethodClassNameUTF: illegal constant"); | 2395 fatal("JVM_GetCPMethodClassNameUTF: illegal constant"); |
2397 } | 2396 } |
2408 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); | 2407 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2409 constantPoolOop cp = instanceKlass::cast(k)->constants(); | 2408 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2410 constantPoolOop cp_called = instanceKlass::cast(k_called)->constants(); | 2409 constantPoolOop cp_called = instanceKlass::cast(k_called)->constants(); |
2411 switch (cp->tag_at(cp_index).value()) { | 2410 switch (cp->tag_at(cp_index).value()) { |
2412 case JVM_CONSTANT_Fieldref: { | 2411 case JVM_CONSTANT_Fieldref: { |
2413 symbolOop name = cp->uncached_name_ref_at(cp_index); | 2412 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2414 symbolOop signature = cp->uncached_signature_ref_at(cp_index); | 2413 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2415 typeArrayOop fields = instanceKlass::cast(k_called)->fields(); | 2414 typeArrayOop fields = instanceKlass::cast(k_called)->fields(); |
2416 int fields_count = fields->length(); | 2415 int fields_count = fields->length(); |
2417 for (int i = 0; i < fields_count; i += instanceKlass::next_offset) { | 2416 for (int i = 0; i < fields_count; i += instanceKlass::next_offset) { |
2418 if (cp_called->symbol_at(fields->ushort_at(i + instanceKlass::name_index_offset)) == name && | 2417 if (cp_called->symbol_at(fields->ushort_at(i + instanceKlass::name_index_offset)) == name && |
2419 cp_called->symbol_at(fields->ushort_at(i + instanceKlass::signature_index_offset)) == signature) { | 2418 cp_called->symbol_at(fields->ushort_at(i + instanceKlass::signature_index_offset)) == signature) { |
2438 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); | 2437 k_called = JvmtiThreadState::class_to_verify_considering_redefinition(k_called, thread); |
2439 constantPoolOop cp = instanceKlass::cast(k)->constants(); | 2438 constantPoolOop cp = instanceKlass::cast(k)->constants(); |
2440 switch (cp->tag_at(cp_index).value()) { | 2439 switch (cp->tag_at(cp_index).value()) { |
2441 case JVM_CONSTANT_Methodref: | 2440 case JVM_CONSTANT_Methodref: |
2442 case JVM_CONSTANT_InterfaceMethodref: { | 2441 case JVM_CONSTANT_InterfaceMethodref: { |
2443 symbolOop name = cp->uncached_name_ref_at(cp_index); | 2442 Symbol* name = cp->uncached_name_ref_at(cp_index); |
2444 symbolOop signature = cp->uncached_signature_ref_at(cp_index); | 2443 Symbol* signature = cp->uncached_signature_ref_at(cp_index); |
2445 objArrayOop methods = instanceKlass::cast(k_called)->methods(); | 2444 objArrayOop methods = instanceKlass::cast(k_called)->methods(); |
2446 int methods_count = methods->length(); | 2445 int methods_count = methods->length(); |
2447 for (int i = 0; i < methods_count; i++) { | 2446 for (int i = 0; i < methods_count; i++) { |
2448 methodOop method = methodOop(methods->obj_at(i)); | 2447 methodOop method = methodOop(methods->obj_at(i)); |
2449 if (method->name() == name && method->signature() == signature) { | 2448 if (method->name() == name && method->signature() == signature) { |
2627 Handle obj(THREAD, thread->threadObj()); | 2626 Handle obj(THREAD, thread->threadObj()); |
2628 JavaValue result(T_VOID); | 2627 JavaValue result(T_VOID); |
2629 JavaCalls::call_virtual(&result, | 2628 JavaCalls::call_virtual(&result, |
2630 obj, | 2629 obj, |
2631 KlassHandle(THREAD, SystemDictionary::Thread_klass()), | 2630 KlassHandle(THREAD, SystemDictionary::Thread_klass()), |
2632 vmSymbolHandles::run_method_name(), | 2631 vmSymbols::run_method_name(), |
2633 vmSymbolHandles::void_method_signature(), | 2632 vmSymbols::void_method_signature(), |
2634 THREAD); | 2633 THREAD); |
2635 } | 2634 } |
2636 | 2635 |
2637 | 2636 |
2638 JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) | 2637 JVM_ENTRY(void, JVM_StartThread(JNIEnv* env, jobject jthread)) |
3111 ResourceMark rm(THREAD); | 3110 ResourceMark rm(THREAD); |
3112 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); | 3111 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); |
3113 Handle class_name_str = java_lang_String::internalize_classname(h_name, CHECK_0); | 3112 Handle class_name_str = java_lang_String::internalize_classname(h_name, CHECK_0); |
3114 | 3113 |
3115 const char* str = java_lang_String::as_utf8_string(class_name_str()); | 3114 const char* str = java_lang_String::as_utf8_string(class_name_str()); |
3116 symbolHandle class_name_sym = | 3115 TempNewSymbol class_name_sym = SymbolTable::probe(str, (int)strlen(str)); |
3117 symbolHandle(THREAD, SymbolTable::probe(str, (int)strlen(str))); | 3116 if (class_name_sym == NULL) { |
3118 if (class_name_sym.is_null()) { | |
3119 return -1; | 3117 return -1; |
3120 } | 3118 } |
3121 | 3119 |
3122 int depth = 0; | 3120 int depth = 0; |
3123 | 3121 |
3124 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { | 3122 for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) { |
3125 if (!vfst.method()->is_native()) { | 3123 if (!vfst.method()->is_native()) { |
3126 klassOop holder = vfst.method()->method_holder(); | 3124 klassOop holder = vfst.method()->method_holder(); |
3127 assert(holder->is_klass(), "just checking"); | 3125 assert(holder->is_klass(), "just checking"); |
3128 if (instanceKlass::cast(holder)->name() == class_name_sym()) { | 3126 if (instanceKlass::cast(holder)->name() == class_name_sym) { |
3129 return depth; | 3127 return depth; |
3130 } | 3128 } |
3131 depth++; | 3129 depth++; |
3132 } | 3130 } |
3133 } | 3131 } |
3322 Handle classname (THREAD, JNIHandles::resolve_non_null(currClassName)); | 3320 Handle classname (THREAD, JNIHandles::resolve_non_null(currClassName)); |
3323 Handle string = java_lang_String::internalize_classname(classname, CHECK_NULL); | 3321 Handle string = java_lang_String::internalize_classname(classname, CHECK_NULL); |
3324 | 3322 |
3325 const char* str = java_lang_String::as_utf8_string(string()); | 3323 const char* str = java_lang_String::as_utf8_string(string()); |
3326 | 3324 |
3327 if (str == NULL || (int)strlen(str) > symbolOopDesc::max_length()) { | 3325 if (str == NULL || (int)strlen(str) > Symbol::max_length()) { |
3328 // It's impossible to create this class; the name cannot fit | 3326 // It's impossible to create this class; the name cannot fit |
3329 // into the constant pool. | 3327 // into the constant pool. |
3330 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), str); | 3328 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), str); |
3331 } | 3329 } |
3332 | 3330 |
3333 symbolHandle name = oopFactory::new_symbol_handle(str, CHECK_NULL); | 3331 TempNewSymbol name = SymbolTable::new_symbol(str, CHECK_NULL); |
3334 Handle curr_klass (THREAD, JNIHandles::resolve(currClass)); | 3332 Handle curr_klass (THREAD, JNIHandles::resolve(currClass)); |
3335 // Find the most recent class on the stack with a non-null classloader | 3333 // Find the most recent class on the stack with a non-null classloader |
3336 oop loader = NULL; | 3334 oop loader = NULL; |
3337 oop protection_domain = NULL; | 3335 oop protection_domain = NULL; |
3338 if (curr_klass.is_null()) { | 3336 if (curr_klass.is_null()) { |
3971 JVM_END | 3969 JVM_END |
3972 | 3970 |
3973 | 3971 |
3974 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// | 3972 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3975 | 3973 |
3976 jclass find_class_from_class_loader(JNIEnv* env, symbolHandle name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { | 3974 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { |
3977 // Security Note: | 3975 // Security Note: |
3978 // The Java level wrapper will perform the necessary security check allowing | 3976 // The Java level wrapper will perform the necessary security check allowing |
3979 // us to pass the NULL as the initiating class loader. | 3977 // us to pass the NULL as the initiating class loader. |
3980 klassOop klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); | 3978 klassOop klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3981 | 3979 |
4067 JvmtiVMObjectAllocEventCollector oam; | 4065 JvmtiVMObjectAllocEventCollector oam; |
4068 if (name == NULL) return NULL; | 4066 if (name == NULL) return NULL; |
4069 Handle str (THREAD, JNIHandles::resolve_non_null(name)); | 4067 Handle str (THREAD, JNIHandles::resolve_non_null(name)); |
4070 | 4068 |
4071 const char* cstr = java_lang_String::as_utf8_string(str()); | 4069 const char* cstr = java_lang_String::as_utf8_string(str()); |
4072 symbolHandle field_name = | 4070 TempNewSymbol field_name = SymbolTable::probe(cstr, (int)strlen(cstr)); |
4073 symbolHandle(THREAD, SymbolTable::probe(cstr, (int)strlen(cstr))); | 4071 if (field_name == NULL) { |
4074 if (field_name.is_null()) { | |
4075 THROW_0(vmSymbols::java_lang_NoSuchFieldException()); | 4072 THROW_0(vmSymbols::java_lang_NoSuchFieldException()); |
4076 } | 4073 } |
4077 | 4074 |
4078 oop mirror = JNIHandles::resolve_non_null(cls); | 4075 oop mirror = JNIHandles::resolve_non_null(cls); |
4079 oop result = Reflection::reflect_field(mirror, field_name(), which, CHECK_NULL); | 4076 oop result = Reflection::reflect_field(mirror, field_name, which, CHECK_NULL); |
4080 if (result == NULL) { | 4077 if (result == NULL) { |
4081 THROW_0(vmSymbols::java_lang_NoSuchFieldException()); | 4078 THROW_0(vmSymbols::java_lang_NoSuchFieldException()); |
4082 } | 4079 } |
4083 return JNIHandles::make_local(env, result); | 4080 return JNIHandles::make_local(env, result); |
4084 JVM_END | 4081 JVM_END |
4091 THROW_0(vmSymbols::java_lang_NullPointerException()); | 4088 THROW_0(vmSymbols::java_lang_NullPointerException()); |
4092 } | 4089 } |
4093 Handle str (THREAD, JNIHandles::resolve_non_null(name)); | 4090 Handle str (THREAD, JNIHandles::resolve_non_null(name)); |
4094 | 4091 |
4095 const char* cstr = java_lang_String::as_utf8_string(str()); | 4092 const char* cstr = java_lang_String::as_utf8_string(str()); |
4096 symbolHandle method_name = | 4093 TempNewSymbol method_name = SymbolTable::probe(cstr, (int)strlen(cstr)); |
4097 symbolHandle(THREAD, SymbolTable::probe(cstr, (int)strlen(cstr))); | 4094 if (method_name == NULL) { |
4098 if (method_name.is_null()) { | |
4099 THROW_0(vmSymbols::java_lang_NoSuchMethodException()); | 4095 THROW_0(vmSymbols::java_lang_NoSuchMethodException()); |
4100 } | 4096 } |
4101 | 4097 |
4102 oop mirror = JNIHandles::resolve_non_null(cls); | 4098 oop mirror = JNIHandles::resolve_non_null(cls); |
4103 objArrayHandle tarray (THREAD, objArrayOop(JNIHandles::resolve(types))); | 4099 objArrayHandle tarray (THREAD, objArrayOop(JNIHandles::resolve(types))); |
4466 objArrayHandle dest(THREAD, dest_o); | 4462 objArrayHandle dest(THREAD, dest_o); |
4467 klassOop enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); | 4463 klassOop enc_k = ik_h->constants()->klass_at(encl_method_class_idx, CHECK_NULL); |
4468 dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror()); | 4464 dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror()); |
4469 int encl_method_method_idx = ik_h->enclosing_method_method_index(); | 4465 int encl_method_method_idx = ik_h->enclosing_method_method_index(); |
4470 if (encl_method_method_idx != 0) { | 4466 if (encl_method_method_idx != 0) { |
4471 symbolOop sym_o = ik_h->constants()->symbol_at( | 4467 Symbol* sym = ik_h->constants()->symbol_at( |
4472 extract_low_short_from_int( | 4468 extract_low_short_from_int( |
4473 ik_h->constants()->name_and_type_at(encl_method_method_idx))); | 4469 ik_h->constants()->name_and_type_at(encl_method_method_idx))); |
4474 symbolHandle sym(THREAD, sym_o); | |
4475 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | 4470 Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
4476 dest->obj_at_put(1, str()); | 4471 dest->obj_at_put(1, str()); |
4477 sym_o = ik_h->constants()->symbol_at( | 4472 sym = ik_h->constants()->symbol_at( |
4478 extract_high_short_from_int( | 4473 extract_high_short_from_int( |
4479 ik_h->constants()->name_and_type_at(encl_method_method_idx))); | 4474 ik_h->constants()->name_and_type_at(encl_method_method_idx))); |
4480 sym = symbolHandle(THREAD, sym_o); | |
4481 str = java_lang_String::create_from_symbol(sym, CHECK_NULL); | 4475 str = java_lang_String::create_from_symbol(sym, CHECK_NULL); |
4482 dest->obj_at_put(2, str()); | 4476 dest->obj_at_put(2, str()); |
4483 } | 4477 } |
4484 return (jobjectArray) JNIHandles::make_local(dest()); | 4478 return (jobjectArray) JNIHandles::make_local(dest()); |
4485 } | 4479 } |