Mercurial > hg > graal-compiler
comparison src/share/vm/oops/instanceKlass.cpp @ 7482:989155e2d07a
Merge with hs25-b15.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 16 Jan 2013 01:34:24 +0100 |
parents | 291ffc492eb6 37a3e8b7a1e9 |
children | 3ac7d10a6572 |
comparison
equal
deleted
inserted
replaced
7381:6761a8f854a4 | 7482:989155e2d07a |
---|---|
45 #include "oops/method.hpp" | 45 #include "oops/method.hpp" |
46 #include "oops/oop.inline.hpp" | 46 #include "oops/oop.inline.hpp" |
47 #include "oops/symbol.hpp" | 47 #include "oops/symbol.hpp" |
48 #include "prims/jvmtiExport.hpp" | 48 #include "prims/jvmtiExport.hpp" |
49 #include "prims/jvmtiRedefineClassesTrace.hpp" | 49 #include "prims/jvmtiRedefineClassesTrace.hpp" |
50 #include "prims/methodComparator.hpp" | |
50 #include "runtime/fieldDescriptor.hpp" | 51 #include "runtime/fieldDescriptor.hpp" |
51 #include "runtime/handles.inline.hpp" | 52 #include "runtime/handles.inline.hpp" |
52 #include "runtime/javaCalls.hpp" | 53 #include "runtime/javaCalls.hpp" |
53 #include "runtime/mutexLocker.hpp" | 54 #include "runtime/mutexLocker.hpp" |
54 #include "runtime/thread.inline.hpp" | 55 #include "runtime/thread.inline.hpp" |
158 #define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) | 159 #define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) |
159 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) | 160 #define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) |
160 | 161 |
161 #endif // ndef DTRACE_ENABLED | 162 #endif // ndef DTRACE_ENABLED |
162 | 163 |
164 volatile int InstanceKlass::_total_instanceKlass_count = 0; | |
165 | |
163 Klass* InstanceKlass::allocate_instance_klass(ClassLoaderData* loader_data, | 166 Klass* InstanceKlass::allocate_instance_klass(ClassLoaderData* loader_data, |
164 int vtable_len, | 167 int vtable_len, |
165 int itable_len, | 168 int itable_len, |
166 int static_field_size, | 169 int static_field_size, |
167 int nonstatic_oop_map_size, | 170 int nonstatic_oop_map_size, |
201 ik = new (loader_data, size, THREAD) InstanceRefKlass( | 204 ik = new (loader_data, size, THREAD) InstanceRefKlass( |
202 vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, | 205 vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, |
203 access_flags, !host_klass.is_null()); | 206 access_flags, !host_klass.is_null()); |
204 } | 207 } |
205 | 208 |
209 Atomic::inc(&_total_instanceKlass_count); | |
206 return ik; | 210 return ik; |
207 } | 211 } |
208 | 212 |
209 InstanceKlass::InstanceKlass(int vtable_len, | 213 InstanceKlass::InstanceKlass(int vtable_len, |
210 int itable_len, | 214 int itable_len, |
359 // Null out Java heap objects, although these won't be walked to keep | 363 // Null out Java heap objects, although these won't be walked to keep |
360 // alive once this InstanceKlass is deallocated. | 364 // alive once this InstanceKlass is deallocated. |
361 set_protection_domain(NULL); | 365 set_protection_domain(NULL); |
362 set_signers(NULL); | 366 set_signers(NULL); |
363 set_init_lock(NULL); | 367 set_init_lock(NULL); |
368 | |
369 // We should deallocate the Annotations instance | |
370 MetadataFactory::free_metadata(loader_data, annotations()); | |
364 set_annotations(NULL); | 371 set_annotations(NULL); |
365 } | 372 } |
366 | 373 |
367 volatile oop InstanceKlass::init_lock() const { | 374 volatile oop InstanceKlass::init_lock() const { |
368 volatile oop lock = _init_lock; // read once | 375 volatile oop lock = _init_lock; // read once |
597 // also sets rewritten | 604 // also sets rewritten |
598 this_oop->rewrite_class(CHECK_false); | 605 this_oop->rewrite_class(CHECK_false); |
599 } | 606 } |
600 | 607 |
601 // relocate jsrs and link methods after they are all rewritten | 608 // relocate jsrs and link methods after they are all rewritten |
602 this_oop->relocate_and_link_methods(CHECK_false); | 609 this_oop->link_methods(CHECK_false); |
603 | 610 |
604 // Initialize the vtable and interface table after | 611 // Initialize the vtable and interface table after |
605 // methods have been rewritten since rewrite may | 612 // methods have been rewritten since rewrite may |
606 // fabricate new Method*s. | 613 // fabricate new Method*s. |
607 // also does loader constraint checking | 614 // also does loader constraint checking |
645 } | 652 } |
646 | 653 |
647 // Now relocate and link method entry points after class is rewritten. | 654 // Now relocate and link method entry points after class is rewritten. |
648 // This is outside is_rewritten flag. In case of an exception, it can be | 655 // This is outside is_rewritten flag. In case of an exception, it can be |
649 // executed more than once. | 656 // executed more than once. |
650 void InstanceKlass::relocate_and_link_methods(TRAPS) { | 657 void InstanceKlass::link_methods(TRAPS) { |
651 assert(is_loaded(), "must be loaded"); | 658 int len = methods()->length(); |
652 instanceKlassHandle this_oop(THREAD, this); | 659 for (int i = len-1; i >= 0; i--) { |
653 Rewriter::relocate_and_link(this_oop, CHECK); | 660 methodHandle m(THREAD, methods()->at(i)); |
661 | |
662 // Set up method entry points for compiler and interpreter . | |
663 m->link_method(m, CHECK); | |
664 | |
665 // This is for JVMTI and unrelated to relocator but the last thing we do | |
666 #ifdef ASSERT | |
667 if (StressMethodComparator) { | |
668 ResourceMark rm(THREAD); | |
669 static int nmc = 0; | |
670 for (int j = i; j >= 0 && j >= i-4; j--) { | |
671 if ((++nmc % 1000) == 0) tty->print_cr("Have run MethodComparator %d times...", nmc); | |
672 bool z = MethodComparator::methods_EMCP(m(), | |
673 methods()->at(j)); | |
674 if (j == i && !z) { | |
675 tty->print("MethodComparator FAIL: "); m->print(); m->print_codes(); | |
676 assert(z, "method must compare equal to itself"); | |
677 } | |
678 } | |
679 } | |
680 #endif //ASSERT | |
681 } | |
654 } | 682 } |
655 | 683 |
656 | 684 |
657 void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { | 685 void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { |
658 // Make sure klass is linked (verified) before initialization | 686 // Make sure klass is linked (verified) before initialization |
2304 // unreference array name derived from this class name (arrays of an unloaded | 2332 // unreference array name derived from this class name (arrays of an unloaded |
2305 // class can't be referenced anymore). | 2333 // class can't be referenced anymore). |
2306 if (_array_name != NULL) _array_name->decrement_refcount(); | 2334 if (_array_name != NULL) _array_name->decrement_refcount(); |
2307 if (_source_file_name != NULL) _source_file_name->decrement_refcount(); | 2335 if (_source_file_name != NULL) _source_file_name->decrement_refcount(); |
2308 if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass); | 2336 if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension, mtClass); |
2337 | |
2338 assert(_total_instanceKlass_count >= 1, "Sanity check"); | |
2339 Atomic::dec(&_total_instanceKlass_count); | |
2309 } | 2340 } |
2310 | 2341 |
2311 void InstanceKlass::set_source_file_name(Symbol* n) { | 2342 void InstanceKlass::set_source_file_name(Symbol* n) { |
2312 _source_file_name = n; | 2343 _source_file_name = n; |
2313 if (_source_file_name != NULL) _source_file_name->increment_refcount(); | 2344 if (_source_file_name != NULL) _source_file_name->increment_refcount(); |