Mercurial > hg > graal-compiler
comparison src/share/vm/oops/instanceKlass.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 8762b6b8fbb6 |
children | 5e6f29f287d6 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
47 #include "oops/oop.inline.hpp" | 47 #include "oops/oop.inline.hpp" |
48 #include "oops/symbol.hpp" | 48 #include "oops/symbol.hpp" |
49 #include "prims/jvmtiExport.hpp" | 49 #include "prims/jvmtiExport.hpp" |
50 #include "prims/jvmtiRedefineClassesTrace.hpp" | 50 #include "prims/jvmtiRedefineClassesTrace.hpp" |
51 #include "prims/jvmtiRedefineClasses.hpp" | 51 #include "prims/jvmtiRedefineClasses.hpp" |
52 #include "prims/jvmtiThreadState.hpp" | |
53 #include "prims/methodComparator.hpp" | 52 #include "prims/methodComparator.hpp" |
54 #include "runtime/fieldDescriptor.hpp" | 53 #include "runtime/fieldDescriptor.hpp" |
55 #include "runtime/handles.inline.hpp" | 54 #include "runtime/handles.inline.hpp" |
56 #include "runtime/javaCalls.hpp" | 55 #include "runtime/javaCalls.hpp" |
57 #include "runtime/mutexLocker.hpp" | 56 #include "runtime/mutexLocker.hpp" |
76 #include "c1/c1_Compiler.hpp" | 75 #include "c1/c1_Compiler.hpp" |
77 #endif | 76 #endif |
78 | 77 |
79 #ifdef DTRACE_ENABLED | 78 #ifdef DTRACE_ENABLED |
80 | 79 |
80 #ifndef USDT2 | |
81 | |
82 HS_DTRACE_PROBE_DECL4(hotspot, class__initialization__required, | |
83 char*, intptr_t, oop, intptr_t); | |
84 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__recursive, | |
85 char*, intptr_t, oop, intptr_t, int); | |
86 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__concurrent, | |
87 char*, intptr_t, oop, intptr_t, int); | |
88 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__erroneous, | |
89 char*, intptr_t, oop, intptr_t, int); | |
90 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__super__failed, | |
91 char*, intptr_t, oop, intptr_t, int); | |
92 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__clinit, | |
93 char*, intptr_t, oop, intptr_t, int); | |
94 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__error, | |
95 char*, intptr_t, oop, intptr_t, int); | |
96 HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__end, | |
97 char*, intptr_t, oop, intptr_t, int); | |
98 | |
99 #define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) \ | |
100 { \ | |
101 char* data = NULL; \ | |
102 int len = 0; \ | |
103 Symbol* name = (clss)->name(); \ | |
104 if (name != NULL) { \ | |
105 data = (char*)name->bytes(); \ | |
106 len = name->utf8_length(); \ | |
107 } \ | |
108 HS_DTRACE_PROBE4(hotspot, class__initialization__##type, \ | |
109 data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type); \ | |
110 } | |
111 | |
112 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \ | |
113 { \ | |
114 char* data = NULL; \ | |
115 int len = 0; \ | |
116 Symbol* name = (clss)->name(); \ | |
117 if (name != NULL) { \ | |
118 data = (char*)name->bytes(); \ | |
119 len = name->utf8_length(); \ | |
120 } \ | |
121 HS_DTRACE_PROBE5(hotspot, class__initialization__##type, \ | |
122 data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type, wait); \ | |
123 } | |
124 #else /* USDT2 */ | |
81 | 125 |
82 #define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED | 126 #define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED |
83 #define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE | 127 #define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE |
84 #define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT | 128 #define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT |
85 #define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS | 129 #define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS |
110 len = name->utf8_length(); \ | 154 len = name->utf8_length(); \ |
111 } \ | 155 } \ |
112 HOTSPOT_CLASS_INITIALIZATION_##type( \ | 156 HOTSPOT_CLASS_INITIALIZATION_##type( \ |
113 data, len, (clss)->class_loader(), thread_type, wait); \ | 157 data, len, (clss)->class_loader(), thread_type, wait); \ |
114 } | 158 } |
159 #endif /* USDT2 */ | |
115 | 160 |
116 #else // ndef DTRACE_ENABLED | 161 #else // ndef DTRACE_ENABLED |
117 | 162 |
118 #define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) | 163 #define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) |
119 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) | 164 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) |
861 } | 906 } |
862 else { | 907 else { |
863 // Step 10 and 11 | 908 // Step 10 and 11 |
864 Handle e(THREAD, PENDING_EXCEPTION); | 909 Handle e(THREAD, PENDING_EXCEPTION); |
865 CLEAR_PENDING_EXCEPTION; | 910 CLEAR_PENDING_EXCEPTION; |
866 // JVMTI has already reported the pending exception | |
867 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError | |
868 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); | |
869 { | 911 { |
870 EXCEPTION_MARK; | 912 EXCEPTION_MARK; |
871 this_oop->set_initialization_state_and_notify(initialization_error, THREAD); | 913 this_oop->set_initialization_state_and_notify(initialization_error, THREAD); |
872 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below | 914 CLEAR_PENDING_EXCEPTION; // ignore any exception thrown, class initialization error is thrown below |
873 // JVMTI has already reported the pending exception | |
874 // JVMTI internal flag reset is needed in order to report ExceptionInInitializerError | |
875 JvmtiExport::clear_detected_exception((JavaThread*)THREAD); | |
876 } | 915 } |
877 DTRACE_CLASSINIT_PROBE_WAIT(error, InstanceKlass::cast(this_oop()), -1,wait); | 916 DTRACE_CLASSINIT_PROBE_WAIT(error, InstanceKlass::cast(this_oop()), -1,wait); |
878 if (e->is_a(SystemDictionary::Error_klass())) { | 917 if (e->is_a(SystemDictionary::Error_klass())) { |
879 THROW_OOP(e()); | 918 THROW_OOP(e()); |
880 } else { | 919 } else { |
1162 if (_oop_map_cache == NULL) { | 1201 if (_oop_map_cache == NULL) { |
1163 // Otherwise, allocate a new one. | 1202 // Otherwise, allocate a new one. |
1164 MutexLocker x(OopMapCacheAlloc_lock); | 1203 MutexLocker x(OopMapCacheAlloc_lock); |
1165 // First time use. Allocate a cache in C heap | 1204 // First time use. Allocate a cache in C heap |
1166 if (_oop_map_cache == NULL) { | 1205 if (_oop_map_cache == NULL) { |
1167 // Release stores from OopMapCache constructor before assignment | 1206 _oop_map_cache = new OopMapCache(); |
1168 // to _oop_map_cache. C++ compilers on ppc do not emit the | |
1169 // required memory barrier only because of the volatile | |
1170 // qualifier of _oop_map_cache. | |
1171 OrderAccess::release_store_ptr(&_oop_map_cache, new OopMapCache()); | |
1172 } | 1207 } |
1173 } | 1208 } |
1174 // _oop_map_cache is constant after init; lookup below does is own locking. | 1209 // _oop_map_cache is constant after init; lookup below does is own locking. |
1175 _oop_map_cache->lookup(method, bci, entry_for); | 1210 _oop_map_cache->lookup(method, bci, entry_for); |
1176 } | 1211 } |
1461 return start; | 1496 return start; |
1462 } | 1497 } |
1463 return -1; | 1498 return -1; |
1464 } | 1499 } |
1465 | 1500 |
1466 // uncached_lookup_method searches both the local class methods array and all | 1501 // lookup_method searches both the local methods array and all superclasses methods arrays |
1467 // superclasses methods arrays, skipping any overpass methods in superclasses. | |
1468 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { | 1502 Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const { |
1469 Klass* klass = const_cast<InstanceKlass*>(this); | 1503 Klass* klass = const_cast<InstanceKlass*>(this); |
1470 bool dont_ignore_overpasses = true; // For the class being searched, find its overpasses. | |
1471 while (klass != NULL) { | 1504 while (klass != NULL) { |
1472 Method* method = InstanceKlass::cast(klass)->find_method(name, signature); | 1505 Method* method = InstanceKlass::cast(klass)->find_method(name, signature); |
1473 if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) { | 1506 if (method != NULL) return method; |
1474 return method; | |
1475 } | |
1476 klass = InstanceKlass::cast(klass)->super(); | 1507 klass = InstanceKlass::cast(klass)->super(); |
1477 dont_ignore_overpasses = false; // Ignore overpass methods in all superclasses. | |
1478 } | 1508 } |
1479 return NULL; | 1509 return NULL; |
1480 } | 1510 } |
1481 | 1511 |
1482 // lookup a method in the default methods list then in all transitive interfaces | 1512 // lookup a method in the default methods list then in all transitive interfaces |
1487 if (default_methods() != NULL) { | 1517 if (default_methods() != NULL) { |
1488 m = find_method(default_methods(), name, signature); | 1518 m = find_method(default_methods(), name, signature); |
1489 } | 1519 } |
1490 // Look up interfaces | 1520 // Look up interfaces |
1491 if (m == NULL) { | 1521 if (m == NULL) { |
1492 m = lookup_method_in_all_interfaces(name, signature, false); | 1522 m = lookup_method_in_all_interfaces(name, signature); |
1493 } | 1523 } |
1494 return m; | 1524 return m; |
1495 } | 1525 } |
1496 | 1526 |
1497 // lookup a method in all the interfaces that this class implements | 1527 // lookup a method in all the interfaces that this class implements |
1498 // Do NOT return private or static methods, new in JDK8 which are not externally visible | 1528 // Do NOT return private or static methods, new in JDK8 which are not externally visible |
1499 // They should only be found in the initial InterfaceMethodRef | 1529 // They should only be found in the initial InterfaceMethodRef |
1500 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, | 1530 Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, |
1501 Symbol* signature, | 1531 Symbol* signature) const { |
1502 bool skip_default_methods) const { | |
1503 Array<Klass*>* all_ifs = transitive_interfaces(); | 1532 Array<Klass*>* all_ifs = transitive_interfaces(); |
1504 int num_ifs = all_ifs->length(); | 1533 int num_ifs = all_ifs->length(); |
1505 InstanceKlass *ik = NULL; | 1534 InstanceKlass *ik = NULL; |
1506 for (int i = 0; i < num_ifs; i++) { | 1535 for (int i = 0; i < num_ifs; i++) { |
1507 ik = InstanceKlass::cast(all_ifs->at(i)); | 1536 ik = InstanceKlass::cast(all_ifs->at(i)); |
1508 Method* m = ik->lookup_method(name, signature); | 1537 Method* m = ik->lookup_method(name, signature); |
1509 if (m != NULL && m->is_public() && !m->is_static() && | 1538 if (m != NULL && m->is_public() && !m->is_static()) { |
1510 (!skip_default_methods || !m->is_default_method())) { | |
1511 return m; | 1539 return m; |
1512 } | 1540 } |
1513 } | 1541 } |
1514 return NULL; | 1542 return NULL; |
1515 } | 1543 } |
2197 | 2225 |
2198 void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { | 2226 void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { |
2199 for (int m = 0; m < methods()->length(); m++) { | 2227 for (int m = 0; m < methods()->length(); m++) { |
2200 MethodData* mdo = methods()->at(m)->method_data(); | 2228 MethodData* mdo = methods()->at(m)->method_data(); |
2201 if (mdo != NULL) { | 2229 if (mdo != NULL) { |
2202 mdo->clean_method_data(is_alive); | 2230 for (ProfileData* data = mdo->first_data(); |
2231 mdo->is_valid(data); | |
2232 data = mdo->next_data(data)) { | |
2233 data->clean_weak_klass_links(is_alive); | |
2234 } | |
2235 ParametersTypeData* parameters = mdo->parameters_type_data(); | |
2236 if (parameters != NULL) { | |
2237 parameters->clean_weak_klass_links(is_alive); | |
2238 } | |
2203 } | 2239 } |
2204 } | 2240 } |
2205 } | 2241 } |
2206 | 2242 |
2207 | 2243 |
2716 nmethod* cur = osr_nmethods_head(); | 2752 nmethod* cur = osr_nmethods_head(); |
2717 int max_level = CompLevel_none; // Find the max comp level excluding n | 2753 int max_level = CompLevel_none; // Find the max comp level excluding n |
2718 Method* m = n->method(); | 2754 Method* m = n->method(); |
2719 // Search for match | 2755 // Search for match |
2720 while(cur != NULL && cur != n) { | 2756 while(cur != NULL && cur != n) { |
2721 if (TieredCompilation && m == cur->method()) { | 2757 if (TieredCompilation) { |
2722 // Find max level before n | 2758 // Find max level before n |
2723 max_level = MAX2(max_level, cur->comp_level()); | 2759 max_level = MAX2(max_level, cur->comp_level()); |
2724 } | 2760 } |
2725 last = cur; | 2761 last = cur; |
2726 cur = cur->osr_link(); | 2762 cur = cur->osr_link(); |
2738 n->set_osr_link(NULL); | 2774 n->set_osr_link(NULL); |
2739 if (TieredCompilation) { | 2775 if (TieredCompilation) { |
2740 cur = next; | 2776 cur = next; |
2741 while (cur != NULL) { | 2777 while (cur != NULL) { |
2742 // Find max level after n | 2778 // Find max level after n |
2743 if (m == cur->method()) { | 2779 max_level = MAX2(max_level, cur->comp_level()); |
2744 max_level = MAX2(max_level, cur->comp_level()); | |
2745 } | |
2746 cur = cur->osr_link(); | 2780 cur = cur->osr_link(); |
2747 } | 2781 } |
2748 m->set_highest_osr_comp_level(max_level); | 2782 m->set_highest_osr_comp_level(max_level); |
2749 } | 2783 } |
2750 // Remember to unlock again | 2784 // Remember to unlock again |
2986 juint length = java_lang_String::length(obj); | 3020 juint length = java_lang_String::length(obj); |
2987 if (value->is_typeArray() && | 3021 if (value->is_typeArray() && |
2988 offset <= (juint) value->length() && | 3022 offset <= (juint) value->length() && |
2989 offset + length <= (juint) value->length()) { | 3023 offset + length <= (juint) value->length()) { |
2990 st->print(BULLET"string: "); | 3024 st->print(BULLET"string: "); |
2991 java_lang_String::print(obj, st); | 3025 Handle h_obj(obj); |
3026 java_lang_String::print(h_obj, st); | |
2992 st->cr(); | 3027 st->cr(); |
2993 if (!WizardMode) return; // that is enough | 3028 if (!WizardMode) return; // that is enough |
2994 } | 3029 } |
2995 } | 3030 } |
2996 } | 3031 } |
3137 public: | 3172 public: |
3138 virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); } | 3173 virtual void do_oop(oop* p) { VerifyFieldClosure::do_oop_work(p); } |
3139 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } | 3174 virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } |
3140 }; | 3175 }; |
3141 | 3176 |
3142 void InstanceKlass::verify_on(outputStream* st) { | 3177 void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) { |
3143 #ifndef PRODUCT | 3178 #ifndef PRODUCT |
3144 // Avoid redundant verifies, this really should be in product. | 3179 // Avoid redundant verifies, this really should be in product. |
3145 if (_verify_count == Universe::verify_count()) return; | 3180 if (_verify_count == Universe::verify_count()) return; |
3146 _verify_count = Universe::verify_count(); | 3181 _verify_count = Universe::verify_count(); |
3147 #endif | 3182 #endif |
3148 | 3183 |
3149 // Verify Klass | 3184 // Verify Klass |
3150 Klass::verify_on(st); | 3185 Klass::verify_on(st, check_dictionary); |
3151 | 3186 |
3152 // Verify that klass is present in ClassLoaderData | 3187 // Verify that klass is present in SystemDictionary if not already |
3153 guarantee(class_loader_data()->contains_klass(this), | 3188 // verifying the SystemDictionary. |
3154 "this class isn't found in class loader data"); | 3189 if (is_loaded() && !is_anonymous() && check_dictionary) { |
3190 Symbol* h_name = name(); | |
3191 SystemDictionary::verify_obj_klass_present(h_name, class_loader_data()); | |
3192 } | |
3155 | 3193 |
3156 // Verify vtables | 3194 // Verify vtables |
3157 if (is_linked()) { | 3195 if (is_linked()) { |
3158 ResourceMark rm; | 3196 ResourceMark rm; |
3159 // $$$ This used to be done only for m/s collections. Doing it | 3197 // $$$ This used to be done only for m/s collections. Doing it |