src/share/vm/oops/objArrayOop.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 





  25 // An objArrayOop is an array containing oops.
  26 // Evaluating "String arg[10]" will create an objArrayOop.
  27 
  28 class objArrayOopDesc : public arrayOopDesc {
  29   friend class objArrayKlass;
  30   friend class Runtime1;
  31   friend class psPromotionManager;
  32   friend class CSMarkOopClosure;
  33   friend class G1ParScanPartialArrayClosure;
  34 
  35   template <class T> T* obj_at_addr(int index) const {
  36     assert(is_within_bounds(index), "index out of bounds");
  37     return &((T*)base())[index];
  38   }
  39 
  40 private:
  41   // Give size of objArrayOop in HeapWords minus the header
  42   static int array_size(int length) {
  43     const int OopsPerHeapWord = HeapWordSize/heapOopSize;
  44     assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),


  93   // Sizing
  94   static int header_size()    { return arrayOopDesc::header_size(T_OBJECT); }
  95   int object_size()           { return object_size(length()); }
  96 
  97   static int object_size(int length) {
  98     // This returns the object size in HeapWords.
  99     uint asz = array_size(length);
 100     uint osz = align_object_size(header_size() + asz);
 101     assert(osz >= asz,   "no overflow");
 102     assert((int)osz > 0, "no overflow");
 103     return (int)osz;
 104   }
 105 
 106   // special iterators for index ranges, returns size of object
 107 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix)     \
 108   int oop_iterate_range(OopClosureType* blk, int start, int end);
 109 
 110   ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL)
 111   ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayOop_OOP_ITERATE_DECL)
 112 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_OBJARRAYOOP_HPP
  26 #define SHARE_VM_OOPS_OBJARRAYOOP_HPP
  27 
  28 #include "oops/arrayOop.hpp"
  29 
  30 // An objArrayOop is an array containing oops.
  31 // Evaluating "String arg[10]" will create an objArrayOop.
  32 
  33 class objArrayOopDesc : public arrayOopDesc {
  34   friend class objArrayKlass;
  35   friend class Runtime1;
  36   friend class psPromotionManager;
  37   friend class CSMarkOopClosure;
  38   friend class G1ParScanPartialArrayClosure;
  39 
  40   template <class T> T* obj_at_addr(int index) const {
  41     assert(is_within_bounds(index), "index out of bounds");
  42     return &((T*)base())[index];
  43   }
  44 
  45 private:
  46   // Give size of objArrayOop in HeapWords minus the header
  47   static int array_size(int length) {
  48     const int OopsPerHeapWord = HeapWordSize/heapOopSize;
  49     assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0),


  98   // Sizing
  99   static int header_size()    { return arrayOopDesc::header_size(T_OBJECT); }
 100   int object_size()           { return object_size(length()); }
 101 
 102   static int object_size(int length) {
 103     // This returns the object size in HeapWords.
 104     uint asz = array_size(length);
 105     uint osz = align_object_size(header_size() + asz);
 106     assert(osz >= asz,   "no overflow");
 107     assert((int)osz > 0, "no overflow");
 108     return (int)osz;
 109   }
 110 
 111   // special iterators for index ranges, returns size of object
 112 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix)     \
 113   int oop_iterate_range(OopClosureType* blk, int start, int end);
 114 
 115   ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL)
 116   ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayOop_OOP_ITERATE_DECL)
 117 };
 118 
 119 #endif // SHARE_VM_OOPS_OBJARRAYOOP_HPP