src/share/vm/ci/ciInstanceKlass.cpp

changeset 3137
e6b1331a51d2
parent 2658
c7f3d0b4570f
child 3368
52b5d32fbfaf
     1.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Sat Sep 10 00:11:04 2011 -0700
     1.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Sat Sep 10 17:29:02 2011 -0700
     1.3 @@ -31,6 +31,7 @@
     1.4  #include "memory/allocation.hpp"
     1.5  #include "memory/allocation.inline.hpp"
     1.6  #include "oops/oop.inline.hpp"
     1.7 +#include "oops/fieldStreams.hpp"
     1.8  #include "runtime/fieldDescriptor.hpp"
     1.9  
    1.10  // ciInstanceKlass
    1.11 @@ -412,7 +413,7 @@
    1.12      VM_ENTRY_MARK;
    1.13      ciEnv* curEnv = ciEnv::current();
    1.14      instanceKlass* ik = get_instanceKlass();
    1.15 -    int max_n_fields = ik->fields()->length()/instanceKlass::next_offset;
    1.16 +    int max_n_fields = ik->java_fields_count();
    1.17  
    1.18      Arena* arena = curEnv->arena();
    1.19      _non_static_fields =
    1.20 @@ -476,23 +477,6 @@
    1.21    // Now sort them by offset, ascending.
    1.22    // (In principle, they could mix with superclass fields.)
    1.23    fields->sort(sort_field_by_offset);
    1.24 -#ifdef ASSERT
    1.25 -  int last_offset = instanceOopDesc::base_offset_in_bytes();
    1.26 -  for (int i = 0; i < fields->length(); i++) {
    1.27 -    ciField* field = fields->at(i);
    1.28 -    int offset = field->offset_in_bytes();
    1.29 -    int size   = (field->_type == NULL) ? heapOopSize : field->size_in_bytes();
    1.30 -    assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset));
    1.31 -    if (last_offset > (int)sizeof(oopDesc))
    1.32 -      assert((offset - last_offset) < BytesPerLong, "no big holes");
    1.33 -    // Note:  Two consecutive T_BYTE fields will be separated by wordSize-1
    1.34 -    // padding bytes if one of them is declared by a superclass.
    1.35 -    // This is a minor inefficiency classFileParser.cpp.
    1.36 -    last_offset = offset + size;
    1.37 -  }
    1.38 -  assert(last_offset <= (int)instanceOopDesc::base_offset_in_bytes() + fsize, "no overflow");
    1.39 -#endif
    1.40 -
    1.41    _nonstatic_fields = fields;
    1.42    return flen;
    1.43  }
    1.44 @@ -505,33 +489,29 @@
    1.45    int flen = 0;
    1.46    GrowableArray<ciField*>* fields = NULL;
    1.47    instanceKlass* k = get_instanceKlass();
    1.48 -  typeArrayOop fields_array = k->fields();
    1.49 -  for (int pass = 0; pass <= 1; pass++) {
    1.50 -    for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) {
    1.51 -      fieldDescriptor fd;
    1.52 -      fd.initialize(k->as_klassOop(), i);
    1.53 -      if (fd.is_static())  continue;
    1.54 -      if (pass == 0) {
    1.55 -        flen += 1;
    1.56 -      } else {
    1.57 -        ciField* field = new (arena) ciField(&fd);
    1.58 -        fields->append(field);
    1.59 -      }
    1.60 -    }
    1.61 +  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
    1.62 +    if (fs.access_flags().is_static())  continue;
    1.63 +    flen += 1;
    1.64 +  }
    1.65  
    1.66 -    // Between passes, allocate the array:
    1.67 -    if (pass == 0) {
    1.68 -      if (flen == 0) {
    1.69 -        return NULL;  // return nothing if none are locally declared
    1.70 -      }
    1.71 -      if (super_fields != NULL) {
    1.72 -        flen += super_fields->length();
    1.73 -      }
    1.74 -      fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
    1.75 -      if (super_fields != NULL) {
    1.76 -        fields->appendAll(super_fields);
    1.77 -      }
    1.78 -    }
    1.79 +  // allocate the array:
    1.80 +  if (flen == 0) {
    1.81 +    return NULL;  // return nothing if none are locally declared
    1.82 +  }
    1.83 +  if (super_fields != NULL) {
    1.84 +    flen += super_fields->length();
    1.85 +  }
    1.86 +  fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
    1.87 +  if (super_fields != NULL) {
    1.88 +    fields->appendAll(super_fields);
    1.89 +  }
    1.90 +
    1.91 +  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
    1.92 +    if (fs.access_flags().is_static())  continue;
    1.93 +    fieldDescriptor fd;
    1.94 +    fd.initialize(k->as_klassOop(), fs.index());
    1.95 +    ciField* field = new (arena) ciField(&fd);
    1.96 +    fields->append(field);
    1.97    }
    1.98    assert(fields->length() == flen, "sanity");
    1.99    return fields;

mercurial