< prev index next >

src/hotspot/share/oops/objArrayOop.inline.hpp

Print this page

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_OOPS_OBJARRAYOOP_INLINE_HPP
26 #define SHARE_OOPS_OBJARRAYOOP_INLINE_HPP
27 
28 #include "oops/objArrayOop.hpp"
29 
30 #include "oops/access.hpp"
31 #include "oops/arrayOop.hpp"

32 #include "oops/oop.inline.hpp"

33 #include "runtime/globals.hpp"
34 
35 inline HeapWord* objArrayOopDesc::base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); }
36 





37 template <class T> T* objArrayOopDesc::obj_at_addr(int index) const {
38   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
39   return &((T*)base())[index];
40 }
41 
42 inline oop objArrayOopDesc::obj_at(int index) const {
43   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
44   ptrdiff_t offset = UseCompressedOops ? obj_at_offset<narrowOop>(index) : obj_at_offset<oop>(index);
45   return HeapAccess<IS_ARRAY>::oop_load_at(as_oop(), offset);












46 }
47 
48 inline void objArrayOopDesc::obj_at_put(int index, oop value) {
49   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
50   ptrdiff_t offset = UseCompressedOops ? obj_at_offset<narrowOop>(index) : obj_at_offset<oop>(index);
51   HeapAccess<IS_ARRAY>::oop_store_at(as_oop(), offset, value);












52 }
53 
54 #endif // SHARE_OOPS_OBJARRAYOOP_INLINE_HPP

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_OOPS_OBJARRAYOOP_INLINE_HPP
26 #define SHARE_OOPS_OBJARRAYOOP_INLINE_HPP
27 
28 #include "oops/objArrayOop.hpp"
29 
30 #include "oops/access.hpp"
31 #include "oops/arrayOop.hpp"
32 #include "oops/flatArrayOop.inline.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "oops/refArrayKlass.inline.hpp"
35 #include "runtime/globals.hpp"
36 
37 inline HeapWord* objArrayOopDesc::base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); }
38 
39 inline objArrayOop objArrayOopDesc::cast(oop o) {
40   assert(o->is_objArray(), "Must be a refArray");
41   return (objArrayOop)o;
42 }
43 
44 template <class T> T* objArrayOopDesc::obj_at_addr(int index) const {
45   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
46   return &((T*)base())[index];
47 }
48 
49 inline oop objArrayOopDesc::obj_at(int index) const {
50   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
51   if (is_flatArray()) {
52     return ((const flatArrayOopDesc* )this)->obj_at(index);
53   } else {
54     return ((const refArrayOopDesc* )this)->obj_at(index);
55   }
56 }
57 
58 inline oop objArrayOopDesc::obj_at(int index, TRAPS) const {
59   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
60   if (is_flatArray()) {
61     return ((const flatArrayOopDesc* )this)->obj_at(index, CHECK_NULL);
62   } else {
63     return ((const refArrayOopDesc* )this)->obj_at(index, CHECK_NULL);
64   }
65 }
66 
67 inline void objArrayOopDesc::obj_at_put(int index, oop value) {
68   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
69   if (is_flatArray()) {
70     ((flatArrayOopDesc* )this)->obj_at_put(index, value);
71   } else {
72     ((refArrayOopDesc* )this)->obj_at_put(index, value);
73   }
74 }
75 
76 inline void objArrayOopDesc::obj_at_put(int index, oop value, TRAPS) {
77   assert(is_within_bounds(index), "index %d out of bounds %d", index, length());
78   if (is_flatArray()) {
79     ((flatArrayOopDesc* )this)->obj_at_put(index, value, CHECK);
80   } else {
81     ((refArrayOopDesc* )this)->obj_at_put(index, value, CHECK);
82   }
83 }
84 
85 #endif // SHARE_OOPS_OBJARRAYOOP_INLINE_HPP
< prev index next >