Mercurial > hg > truffle
diff src/share/vm/ci/ciInstanceKlass.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | 46f211fe010c e6b1331a51d2 |
children | 716a2c5c0656 |
line wrap: on
line diff
--- a/src/share/vm/ci/ciInstanceKlass.cpp Sat Dec 17 20:50:09 2011 +0100 +++ b/src/share/vm/ci/ciInstanceKlass.cpp Sat Dec 17 21:40:27 2011 +0100 @@ -31,6 +31,7 @@ #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" #include "oops/oop.inline.hpp" +#include "oops/fieldStreams.hpp" #include "runtime/fieldDescriptor.hpp" // ciInstanceKlass @@ -411,7 +412,7 @@ VM_ENTRY_MARK; ciEnv* curEnv = ciEnv::current(); instanceKlass* ik = get_instanceKlass(); - int max_n_fields = ik->fields()->length()/instanceKlass::next_offset; + int max_n_fields = ik->java_fields_count(); Arena* arena = curEnv->arena(); _non_static_fields = @@ -475,23 +476,6 @@ // Now sort them by offset, ascending. // (In principle, they could mix with superclass fields.) fields->sort(sort_field_by_offset); -#ifdef ASSERT - int last_offset = instanceOopDesc::base_offset_in_bytes(); - for (int i = 0; i < fields->length(); i++) { - ciField* field = fields->at(i); - int offset = field->offset_in_bytes(); - int size = (field->_type == NULL) ? heapOopSize : field->size_in_bytes(); - assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset)); - if (last_offset > (int)sizeof(oopDesc)) - assert((offset - last_offset) < BytesPerLong, "no big holes"); - // Note: Two consecutive T_BYTE fields will be separated by wordSize-1 - // padding bytes if one of them is declared by a superclass. - // This is a minor inefficiency classFileParser.cpp. - last_offset = offset + size; - } - assert(last_offset <= (int)instanceOopDesc::base_offset_in_bytes() + fsize, "no overflow"); -#endif - _nonstatic_fields = fields; return flen; } @@ -504,33 +488,29 @@ int flen = 0; GrowableArray<ciField*>* fields = NULL; instanceKlass* k = get_instanceKlass(); - typeArrayOop fields_array = k->fields(); - for (int pass = 0; pass <= 1; pass++) { - for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) { - fieldDescriptor fd; - fd.initialize(k->as_klassOop(), i); - if (fd.is_static()) continue; - if (pass == 0) { - flen += 1; - } else { - ciField* field = new (arena) ciField(&fd); - fields->append(field); - } - } + for (JavaFieldStream fs(k); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) continue; + flen += 1; + } - // Between passes, allocate the array: - if (pass == 0) { - if (flen == 0) { - return NULL; // return nothing if none are locally declared - } - if (super_fields != NULL) { - flen += super_fields->length(); - } - fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); - if (super_fields != NULL) { - fields->appendAll(super_fields); - } - } + // allocate the array: + if (flen == 0) { + return NULL; // return nothing if none are locally declared + } + if (super_fields != NULL) { + flen += super_fields->length(); + } + fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL); + if (super_fields != NULL) { + fields->appendAll(super_fields); + } + + for (JavaFieldStream fs(k); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) continue; + fieldDescriptor fd; + fd.initialize(k->as_klassOop(), fs.index()); + ciField* field = new (arena) ciField(&fd); + fields->append(field); } assert(fields->length() == flen, "sanity"); return fields;