src/share/vm/ci/ciInstanceKlass.cpp

changeset 548
ba764ed4b6f2
parent 479
52fed2ec0afb
child 600
437d03ea40b1
     1.1 --- a/src/share/vm/ci/ciInstanceKlass.cpp	Fri Apr 11 09:56:35 2008 -0400
     1.2 +++ b/src/share/vm/ci/ciInstanceKlass.cpp	Sun Apr 13 17:43:42 2008 -0400
     1.3 @@ -48,6 +48,7 @@
     1.4    // Next line must follow and use the result of the previous line:
     1.5    _is_linked = _is_initialized || ik->is_linked();
     1.6    _nonstatic_field_size = ik->nonstatic_field_size();
     1.7 +  _has_nonstatic_fields = ik->has_nonstatic_fields();
     1.8    _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
     1.9  
    1.10    _nof_implementors = ik->nof_implementors();
    1.11 @@ -93,6 +94,7 @@
    1.12    _is_initialized = false;
    1.13    _is_linked = false;
    1.14    _nonstatic_field_size = -1;
    1.15 +  _has_nonstatic_fields = false;
    1.16    _nonstatic_fields = NULL;
    1.17    _nof_implementors = -1;
    1.18    _loader = loader;
    1.19 @@ -201,7 +203,7 @@
    1.20    assert(offset >= 0 && offset < layout_helper(), "offset must be tame");
    1.21    #endif
    1.22  
    1.23 -  if (offset < (instanceOopDesc::header_size() * wordSize)) {
    1.24 +  if (offset < instanceOopDesc::base_offset_in_bytes()) {
    1.25      // All header offsets belong properly to java/lang/Object.
    1.26      return CURRENT_ENV->Object_klass();
    1.27    }
    1.28 @@ -210,7 +212,8 @@
    1.29    for (;;) {
    1.30      assert(self->is_loaded(), "must be loaded to have size");
    1.31      ciInstanceKlass* super = self->super();
    1.32 -    if (super == NULL || !super->contains_field_offset(offset)) {
    1.33 +    if (super == NULL || super->nof_nonstatic_fields() == 0 ||
    1.34 +        !super->contains_field_offset(offset)) {
    1.35        return self;
    1.36      } else {
    1.37        self = super;  // return super->get_canonical_holder(offset)
    1.38 @@ -381,31 +384,28 @@
    1.39    if (_nonstatic_fields != NULL)
    1.40      return _nonstatic_fields->length();
    1.41  
    1.42 -  // Size in bytes of my fields, including inherited fields.
    1.43 -  // About equal to size_helper() - sizeof(oopDesc).
    1.44 -  int fsize = nonstatic_field_size() * wordSize;
    1.45 -  if (fsize == 0) {     // easy shortcut
    1.46 +  if (!has_nonstatic_fields()) {
    1.47      Arena* arena = CURRENT_ENV->arena();
    1.48      _nonstatic_fields = new (arena) GrowableArray<ciField*>(arena, 0, 0, NULL);
    1.49      return 0;
    1.50    }
    1.51    assert(!is_java_lang_Object(), "bootstrap OK");
    1.52  
    1.53 +  // Size in bytes of my fields, including inherited fields.
    1.54 +  int fsize = nonstatic_field_size() * wordSize;
    1.55 +
    1.56    ciInstanceKlass* super = this->super();
    1.57 -  int      super_fsize = 0;
    1.58 -  int      super_flen  = 0;
    1.59    GrowableArray<ciField*>* super_fields = NULL;
    1.60 -  if (super != NULL) {
    1.61 -    super_fsize  = super->nonstatic_field_size() * wordSize;
    1.62 -    super_flen   = super->nof_nonstatic_fields();
    1.63 +  if (super != NULL && super->has_nonstatic_fields()) {
    1.64 +    int super_fsize  = super->nonstatic_field_size() * wordSize;
    1.65 +    int super_flen   = super->nof_nonstatic_fields();
    1.66      super_fields = super->_nonstatic_fields;
    1.67      assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
    1.68 -  }
    1.69 -
    1.70 -  // See if I am no larger than my super; if so, I can use his fields.
    1.71 -  if (fsize == super_fsize) {
    1.72 -    _nonstatic_fields = super_fields;
    1.73 -    return super_fields->length();
    1.74 +    // See if I am no larger than my super; if so, I can use his fields.
    1.75 +    if (fsize == super_fsize) {
    1.76 +      _nonstatic_fields = super_fields;
    1.77 +      return super_fields->length();
    1.78 +    }
    1.79    }
    1.80  
    1.81    GrowableArray<ciField*>* fields = NULL;
    1.82 @@ -425,11 +425,11 @@
    1.83    // (In principle, they could mix with superclass fields.)
    1.84    fields->sort(sort_field_by_offset);
    1.85  #ifdef ASSERT
    1.86 -  int last_offset = sizeof(oopDesc);
    1.87 +  int last_offset = instanceOopDesc::base_offset_in_bytes();
    1.88    for (int i = 0; i < fields->length(); i++) {
    1.89      ciField* field = fields->at(i);
    1.90      int offset = field->offset_in_bytes();
    1.91 -    int size   = (field->_type == NULL) ? oopSize : field->size_in_bytes();
    1.92 +    int size   = (field->_type == NULL) ? heapOopSize : field->size_in_bytes();
    1.93      assert(last_offset <= offset, "no field overlap");
    1.94      if (last_offset > (int)sizeof(oopDesc))
    1.95        assert((offset - last_offset) < BytesPerLong, "no big holes");

mercurial