Mercurial > hg > truffle
diff src/share/vm/oops/instanceKlass.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | f198b24093f3 436b4a3231bf |
children | 33df1aeaebbf |
line wrap: on
line diff
--- a/src/share/vm/oops/instanceKlass.cpp Sat Dec 17 20:50:09 2011 +0100 +++ b/src/share/vm/oops/instanceKlass.cpp Sat Dec 17 21:40:27 2011 +0100 @@ -36,6 +36,7 @@ #include "memory/genOopClosures.inline.hpp" #include "memory/oopFactory.hpp" #include "memory/permGen.hpp" +#include "oops/fieldStreams.hpp" #include "oops/instanceKlass.hpp" #include "oops/instanceMirrorKlass.hpp" #include "oops/instanceOop.hpp" @@ -60,6 +61,9 @@ #ifdef TARGET_OS_FAMILY_windows # include "thread_windows.inline.hpp" #endif +#ifdef TARGET_OS_FAMILY_bsd +# include "thread_bsd.inline.hpp" +#endif #ifndef SERIALGC #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #include "gc_implementation/g1/g1OopClosures.inline.hpp" @@ -76,6 +80,8 @@ #ifdef DTRACE_ENABLED +#ifndef USDT2 + HS_DTRACE_PROBE_DECL4(hotspot, class__initialization__required, char*, intptr_t, oop, intptr_t); HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__recursive, @@ -118,6 +124,42 @@ HS_DTRACE_PROBE5(hotspot, class__initialization__##type, \ data, len, (clss)->class_loader(), thread_type, wait); \ } +#else /* USDT2 */ + +#define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED +#define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE +#define HOTSPOT_CLASS_INITIALIZATION_concurrent HOTSPOT_CLASS_INITIALIZATION_CONCURRENT +#define HOTSPOT_CLASS_INITIALIZATION_erroneous HOTSPOT_CLASS_INITIALIZATION_ERRONEOUS +#define HOTSPOT_CLASS_INITIALIZATION_super__failed HOTSPOT_CLASS_INITIALIZATION_SUPER_FAILED +#define HOTSPOT_CLASS_INITIALIZATION_clinit HOTSPOT_CLASS_INITIALIZATION_CLINIT +#define HOTSPOT_CLASS_INITIALIZATION_error HOTSPOT_CLASS_INITIALIZATION_ERROR +#define HOTSPOT_CLASS_INITIALIZATION_end HOTSPOT_CLASS_INITIALIZATION_END +#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) \ + { \ + char* data = NULL; \ + int len = 0; \ + Symbol* name = (clss)->name(); \ + if (name != NULL) { \ + data = (char*)name->bytes(); \ + len = name->utf8_length(); \ + } \ + HOTSPOT_CLASS_INITIALIZATION_##type( \ + data, len, (clss)->class_loader(), thread_type); \ + } + +#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \ + { \ + char* data = NULL; \ + int len = 0; \ + Symbol* name = (clss)->name(); \ + if (name != NULL) { \ + data = (char*)name->bytes(); \ + len = name->utf8_length(); \ + } \ + HOTSPOT_CLASS_INITIALIZATION_##type( \ + data, len, (clss)->class_loader(), thread_type, wait); \ + } +#endif /* USDT2 */ #else // ndef DTRACE_ENABLED @@ -782,14 +824,11 @@ bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { - const int n = fields()->length(); - for (int i = 0; i < n; i += next_offset ) { - int name_index = fields()->ushort_at(i + name_index_offset); - int sig_index = fields()->ushort_at(i + signature_index_offset); - Symbol* f_name = constants()->symbol_at(name_index); - Symbol* f_sig = constants()->symbol_at(sig_index); + for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { + Symbol* f_name = fs.name(); + Symbol* f_sig = fs.signature(); if (f_name == name && f_sig == sig) { - fd->initialize(as_klassOop(), i); + fd->initialize(as_klassOop(), fs.index()); return true; } } @@ -803,11 +842,10 @@ closure->do_symbol(&_source_file_name); closure->do_symbol(&_source_debug_extension); - const int n = fields()->length(); - for (int i = 0; i < n; i += next_offset ) { - int name_index = fields()->ushort_at(i + name_index_offset); + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { + int name_index = fs.name_index(); closure->do_symbol(constants()->symbol_at_addr(name_index)); - int sig_index = fields()->ushort_at(i + signature_index_offset); + int sig_index = fs.signature_index(); closure->do_symbol(constants()->symbol_at_addr(sig_index)); } } @@ -872,10 +910,9 @@ bool instanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { - int length = fields()->length(); - for (int i = 0; i < length; i += next_offset) { - if (offset_from_fields( i ) == offset) { - fd->initialize(as_klassOop(), i); + for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { + if (fs.offset() == offset) { + fd->initialize(as_klassOop(), fs.index()); if (fd->is_static() == is_static) return true; } } @@ -906,11 +943,12 @@ void instanceKlass::do_local_static_fields(FieldClosure* cl) { - fieldDescriptor fd; - int length = fields()->length(); - for (int i = 0; i < length; i += next_offset) { - fd.initialize(as_klassOop(), i); - if (fd.is_static()) cl->do_field(&fd); + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) { + fieldDescriptor fd; + fd.initialize(as_klassOop(), fs.index()); + cl->do_field(&fd); + } } } @@ -922,11 +960,12 @@ void instanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { - fieldDescriptor fd; - int length = this_oop->fields()->length(); - for (int i = 0; i < length; i += next_offset) { - fd.initialize(this_oop(), i); - if (fd.is_static()) { f(&fd, CHECK); } // Do NOT remove {}! (CHECK macro expands into several statements) + for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) { + fieldDescriptor fd; + fd.initialize(this_oop(), fs.index()); + f(&fd, CHECK); + } } } @@ -941,11 +980,11 @@ super->do_nonstatic_fields(cl); } fieldDescriptor fd; - int length = fields()->length(); + int length = java_fields_count(); // In DebugInfo nonstatic fields are sorted by offset. int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1)); int j = 0; - for (int i = 0; i < length; i += next_offset) { + for (int i = 0; i < length; i += 1) { fd.initialize(as_klassOop(), i); if (!fd.is_static()) { fields_sorted[j + 0] = fd.offset(); @@ -1374,39 +1413,8 @@ // -// nmethodBucket is used to record dependent nmethods for -// deoptimization. nmethod dependencies are actually <klass, method> -// pairs but we really only care about the klass part for purposes of -// finding nmethods which might need to be deoptimized. Instead of -// recording the method, a count of how many times a particular nmethod -// was recorded is kept. This ensures that any recording errors are -// noticed since an nmethod should be removed as many times are it's -// added. -// -class nmethodBucket { - private: - nmethod* _nmethod; - int _count; - nmethodBucket* _next; - - public: - nmethodBucket(nmethod* nmethod, nmethodBucket* next) { - _nmethod = nmethod; - _next = next; - _count = 1; - } - int count() { return _count; } - int increment() { _count += 1; return _count; } - int decrement() { _count -= 1; assert(_count >= 0, "don't underflow"); return _count; } - nmethodBucket* next() { return _next; } - void set_next(nmethodBucket* b) { _next = b; } - nmethod* get_nmethod() { return _nmethod; } -}; - - -// // Walk the list of dependent nmethods searching for nmethods which -// are dependent on the klassOop that was passed in and mark them for +// are dependent on the changes that were passed in and mark them for // deoptimization. Returns the number of nmethods found. // int instanceKlass::mark_dependent_nmethods(DepChange& changes) { @@ -2411,43 +2419,6 @@ oop_oop_iterate(obj, &blk); } -#ifndef PRODUCT - -void instanceKlass::verify_class_klass_nonstatic_oop_maps(klassOop k) { - // This verification code is disabled. JDK_Version::is_gte_jdk14x_version() - // cannot be called since this function is called before the VM is - // able to determine what JDK version is running with. - // The check below always is false since 1.4. - return; - - // This verification code temporarily disabled for the 1.4 - // reflection implementation since java.lang.Class now has - // Java-level instance fields. Should rewrite this to handle this - // case. - if (!(JDK_Version::is_gte_jdk14x_version() && UseNewReflection)) { - // Verify that java.lang.Class instances have a fake oop field added. - instanceKlass* ik = instanceKlass::cast(k); - - // Check that we have the right class - static bool first_time = true; - guarantee(k == SystemDictionary::Class_klass() && first_time, "Invalid verify of maps"); - first_time = false; - const int extra = java_lang_Class::number_of_fake_oop_fields; - guarantee(ik->nonstatic_field_size() == extra, "just checking"); - guarantee(ik->nonstatic_oop_map_count() == 1, "just checking"); - guarantee(ik->size_helper() == align_object_size(instanceOopDesc::header_size() + extra), "just checking"); - - // Check that the map is (2,extra) - int offset = java_lang_Class::klass_offset; - - OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); - guarantee(map->offset() == offset && map->count() == (unsigned int) extra, - "sanity"); - } -} - -#endif // ndef PRODUCT - // JNIid class for jfieldIDs only // Note to reviewers: // These JNI functions are just moved over to column 1 and not changed