1.1 --- a/src/share/vm/oops/instanceKlass.cpp Sat Sep 10 00:11:04 2011 -0700 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Sat Sep 10 17:29:02 2011 -0700 1.3 @@ -36,6 +36,7 @@ 1.4 #include "memory/genOopClosures.inline.hpp" 1.5 #include "memory/oopFactory.hpp" 1.6 #include "memory/permGen.hpp" 1.7 +#include "oops/fieldStreams.hpp" 1.8 #include "oops/instanceKlass.hpp" 1.9 #include "oops/instanceMirrorKlass.hpp" 1.10 #include "oops/instanceOop.hpp" 1.11 @@ -782,14 +783,11 @@ 1.12 1.13 1.14 bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const { 1.15 - const int n = fields()->length(); 1.16 - for (int i = 0; i < n; i += next_offset ) { 1.17 - int name_index = fields()->ushort_at(i + name_index_offset); 1.18 - int sig_index = fields()->ushort_at(i + signature_index_offset); 1.19 - Symbol* f_name = constants()->symbol_at(name_index); 1.20 - Symbol* f_sig = constants()->symbol_at(sig_index); 1.21 + for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { 1.22 + Symbol* f_name = fs.name(); 1.23 + Symbol* f_sig = fs.signature(); 1.24 if (f_name == name && f_sig == sig) { 1.25 - fd->initialize(as_klassOop(), i); 1.26 + fd->initialize(as_klassOop(), fs.index()); 1.27 return true; 1.28 } 1.29 } 1.30 @@ -803,11 +801,10 @@ 1.31 closure->do_symbol(&_source_file_name); 1.32 closure->do_symbol(&_source_debug_extension); 1.33 1.34 - const int n = fields()->length(); 1.35 - for (int i = 0; i < n; i += next_offset ) { 1.36 - int name_index = fields()->ushort_at(i + name_index_offset); 1.37 + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.38 + int name_index = fs.name_index(); 1.39 closure->do_symbol(constants()->symbol_at_addr(name_index)); 1.40 - int sig_index = fields()->ushort_at(i + signature_index_offset); 1.41 + int sig_index = fs.signature_index(); 1.42 closure->do_symbol(constants()->symbol_at_addr(sig_index)); 1.43 } 1.44 } 1.45 @@ -872,10 +869,9 @@ 1.46 1.47 1.48 bool instanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const { 1.49 - int length = fields()->length(); 1.50 - for (int i = 0; i < length; i += next_offset) { 1.51 - if (offset_from_fields( i ) == offset) { 1.52 - fd->initialize(as_klassOop(), i); 1.53 + for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) { 1.54 + if (fs.offset() == offset) { 1.55 + fd->initialize(as_klassOop(), fs.index()); 1.56 if (fd->is_static() == is_static) return true; 1.57 } 1.58 } 1.59 @@ -906,11 +902,12 @@ 1.60 1.61 1.62 void instanceKlass::do_local_static_fields(FieldClosure* cl) { 1.63 - fieldDescriptor fd; 1.64 - int length = fields()->length(); 1.65 - for (int i = 0; i < length; i += next_offset) { 1.66 - fd.initialize(as_klassOop(), i); 1.67 - if (fd.is_static()) cl->do_field(&fd); 1.68 + for (JavaFieldStream fs(this); !fs.done(); fs.next()) { 1.69 + if (fs.access_flags().is_static()) { 1.70 + fieldDescriptor fd; 1.71 + fd.initialize(as_klassOop(), fs.index()); 1.72 + cl->do_field(&fd); 1.73 + } 1.74 } 1.75 } 1.76 1.77 @@ -922,11 +919,12 @@ 1.78 1.79 1.80 void instanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) { 1.81 - fieldDescriptor fd; 1.82 - int length = this_oop->fields()->length(); 1.83 - for (int i = 0; i < length; i += next_offset) { 1.84 - fd.initialize(this_oop(), i); 1.85 - if (fd.is_static()) { f(&fd, CHECK); } // Do NOT remove {}! (CHECK macro expands into several statements) 1.86 + for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) { 1.87 + if (fs.access_flags().is_static()) { 1.88 + fieldDescriptor fd; 1.89 + fd.initialize(this_oop(), fs.index()); 1.90 + f(&fd, CHECK); 1.91 + } 1.92 } 1.93 } 1.94 1.95 @@ -941,11 +939,11 @@ 1.96 super->do_nonstatic_fields(cl); 1.97 } 1.98 fieldDescriptor fd; 1.99 - int length = fields()->length(); 1.100 + int length = java_fields_count(); 1.101 // In DebugInfo nonstatic fields are sorted by offset. 1.102 int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1)); 1.103 int j = 0; 1.104 - for (int i = 0; i < length; i += next_offset) { 1.105 + for (int i = 0; i < length; i += 1) { 1.106 fd.initialize(as_klassOop(), i); 1.107 if (!fd.is_static()) { 1.108 fields_sorted[j + 0] = fd.offset(); 1.109 @@ -2411,43 +2409,6 @@ 1.110 oop_oop_iterate(obj, &blk); 1.111 } 1.112 1.113 -#ifndef PRODUCT 1.114 - 1.115 -void instanceKlass::verify_class_klass_nonstatic_oop_maps(klassOop k) { 1.116 - // This verification code is disabled. JDK_Version::is_gte_jdk14x_version() 1.117 - // cannot be called since this function is called before the VM is 1.118 - // able to determine what JDK version is running with. 1.119 - // The check below always is false since 1.4. 1.120 - return; 1.121 - 1.122 - // This verification code temporarily disabled for the 1.4 1.123 - // reflection implementation since java.lang.Class now has 1.124 - // Java-level instance fields. Should rewrite this to handle this 1.125 - // case. 1.126 - if (!(JDK_Version::is_gte_jdk14x_version() && UseNewReflection)) { 1.127 - // Verify that java.lang.Class instances have a fake oop field added. 1.128 - instanceKlass* ik = instanceKlass::cast(k); 1.129 - 1.130 - // Check that we have the right class 1.131 - static bool first_time = true; 1.132 - guarantee(k == SystemDictionary::Class_klass() && first_time, "Invalid verify of maps"); 1.133 - first_time = false; 1.134 - const int extra = java_lang_Class::number_of_fake_oop_fields; 1.135 - guarantee(ik->nonstatic_field_size() == extra, "just checking"); 1.136 - guarantee(ik->nonstatic_oop_map_count() == 1, "just checking"); 1.137 - guarantee(ik->size_helper() == align_object_size(instanceOopDesc::header_size() + extra), "just checking"); 1.138 - 1.139 - // Check that the map is (2,extra) 1.140 - int offset = java_lang_Class::klass_offset; 1.141 - 1.142 - OopMapBlock* map = ik->start_of_nonstatic_oop_maps(); 1.143 - guarantee(map->offset() == offset && map->count() == (unsigned int) extra, 1.144 - "sanity"); 1.145 - } 1.146 -} 1.147 - 1.148 -#endif // ndef PRODUCT 1.149 - 1.150 // JNIid class for jfieldIDs only 1.151 // Note to reviewers: 1.152 // These JNI functions are just moved over to column 1 and not changed