src/share/vm/oops/objArrayOop.hpp

changeset 1526
6aa7255741f3
parent 1383
89e0543e1737
child 1530
7bfd295ec074
     1.1 --- a/src/share/vm/oops/objArrayOop.hpp	Tue Nov 24 15:19:30 2009 -0800
     1.2 +++ b/src/share/vm/oops/objArrayOop.hpp	Thu Dec 03 15:01:57 2009 -0800
     1.3 @@ -37,6 +37,32 @@
     1.4      return &((T*)base())[index];
     1.5    }
     1.6  
     1.7 +private:
     1.8 +  // Give size of objArrayOop in HeapWords minus the header
     1.9 +  static int array_size(int length) {
    1.10 +    const int OopsPerHeapWord = HeapWordSize/heapOopSize;
    1.11 +    assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),
    1.12 +           "Else the following (new) computation would be in error");
    1.13 +#ifdef ASSERT
    1.14 +    // The old code is left in for sanity-checking; it'll
    1.15 +    // go away pretty soon. XXX
    1.16 +    // Without UseCompressedOops, this is simply:
    1.17 +    // oop->length() * HeapWordsPerOop;
    1.18 +    // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
    1.19 +    // The oop elements are aligned up to wordSize
    1.20 +    const int HeapWordsPerOop = heapOopSize/HeapWordSize;
    1.21 +    int old_res;
    1.22 +    if (HeapWordsPerOop > 0) {
    1.23 +      old_res = length * HeapWordsPerOop;
    1.24 +    } else {
    1.25 +      old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
    1.26 +    }
    1.27 +#endif  // ASSERT
    1.28 +    int res = (length + OopsPerHeapWord - 1)/OopsPerHeapWord;
    1.29 +    assert(res == old_res, "Inconsistency between old and new.");
    1.30 +    return res;
    1.31 +  }
    1.32 +
    1.33   public:
    1.34    // Returns the offset of the first element.
    1.35    static int base_offset_in_bytes() {
    1.36 @@ -67,29 +93,12 @@
    1.37    // Sizing
    1.38    static int header_size()    { return arrayOopDesc::header_size(T_OBJECT); }
    1.39    int object_size()           { return object_size(length()); }
    1.40 -  int array_size()            { return array_size(length()); }
    1.41  
    1.42    static int object_size(int length) {
    1.43      // This returns the object size in HeapWords.
    1.44      return align_object_size(header_size() + array_size(length));
    1.45    }
    1.46  
    1.47 -  // Give size of objArrayOop in HeapWords minus the header
    1.48 -  static int array_size(int length) {
    1.49 -    // Without UseCompressedOops, this is simply:
    1.50 -    // oop->length() * HeapWordsPerOop;
    1.51 -    // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
    1.52 -    // The oop elements are aligned up to wordSize
    1.53 -    const int HeapWordsPerOop = heapOopSize/HeapWordSize;
    1.54 -    if (HeapWordsPerOop > 0) {
    1.55 -      return length * HeapWordsPerOop;
    1.56 -    } else {
    1.57 -      const int OopsPerHeapWord = HeapWordSize/heapOopSize;
    1.58 -      int word_len = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
    1.59 -      return word_len;
    1.60 -    }
    1.61 -  }
    1.62 -
    1.63    // special iterators for index ranges, returns size of object
    1.64  #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix)     \
    1.65    int oop_iterate_range(OopClosureType* blk, int start, int end);

mercurial