< prev index next >

src/share/vm/oops/objArrayOop.hpp

Print this page




  45 
  46 private:
  47   // Give size of objArrayOop in HeapWords minus the header
  48   static int array_size(int length) {
  49     const uint OopsPerHeapWord = HeapWordSize/heapOopSize;
  50     assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),
  51            "Else the following (new) computation would be in error");
  52     uint res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord;
  53 #ifdef ASSERT
  54     // The old code is left in for sanity-checking; it'll
  55     // go away pretty soon. XXX
  56     // Without UseCompressedOops, this is simply:
  57     // oop->length() * HeapWordsPerOop;
  58     // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
  59     // The oop elements are aligned up to wordSize
  60     const uint HeapWordsPerOop = heapOopSize/HeapWordSize;
  61     uint old_res;
  62     if (HeapWordsPerOop > 0) {
  63       old_res = length * HeapWordsPerOop;
  64     } else {
  65       old_res = align_size_up((uint)length, OopsPerHeapWord)/OopsPerHeapWord;
  66     }
  67     assert(res == old_res, "Inconsistency between old and new.");
  68 #endif  // ASSERT
  69     return res;
  70   }
  71 
  72  public:
  73   // Returns the offset of the first element.
  74   static int base_offset_in_bytes() {
  75     return arrayOopDesc::base_offset_in_bytes(T_OBJECT);
  76   }
  77 
  78   // base is the address following the header.
  79   HeapWord* base() const      { return (HeapWord*) arrayOopDesc::base(T_OBJECT); }
  80 
  81   // Accessing
  82   oop obj_at(int index) const;
  83 
  84   void inline obj_at_put(int index, oop value);
  85 




  45 
  46 private:
  47   // Give size of objArrayOop in HeapWords minus the header
  48   static int array_size(int length) {
  49     const uint OopsPerHeapWord = HeapWordSize/heapOopSize;
  50     assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),
  51            "Else the following (new) computation would be in error");
  52     uint res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord;
  53 #ifdef ASSERT
  54     // The old code is left in for sanity-checking; it'll
  55     // go away pretty soon. XXX
  56     // Without UseCompressedOops, this is simply:
  57     // oop->length() * HeapWordsPerOop;
  58     // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
  59     // The oop elements are aligned up to wordSize
  60     const uint HeapWordsPerOop = heapOopSize/HeapWordSize;
  61     uint old_res;
  62     if (HeapWordsPerOop > 0) {
  63       old_res = length * HeapWordsPerOop;
  64     } else {
  65       old_res = align_up((uint)length, OopsPerHeapWord)/OopsPerHeapWord;
  66     }
  67     assert(res == old_res, "Inconsistency between old and new.");
  68 #endif  // ASSERT
  69     return res;
  70   }
  71 
  72  public:
  73   // Returns the offset of the first element.
  74   static int base_offset_in_bytes() {
  75     return arrayOopDesc::base_offset_in_bytes(T_OBJECT);
  76   }
  77 
  78   // base is the address following the header.
  79   HeapWord* base() const      { return (HeapWord*) arrayOopDesc::base(T_OBJECT); }
  80 
  81   // Accessing
  82   oop obj_at(int index) const;
  83 
  84   void inline obj_at_put(int index, oop value);
  85 


< prev index next >