equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
27 |
27 |
28 #include "gc/shared/specialized_oop_closures.hpp" |
28 #include "gc/shared/specialized_oop_closures.hpp" |
29 #include "oops/arrayOop.hpp" |
29 #include "oops/arrayOop.hpp" |
30 #include "utilities/align.hpp" |
30 #include "utilities/align.hpp" |
31 |
31 |
|
32 class Klass; |
|
33 |
32 // An objArrayOop is an array containing oops. |
34 // An objArrayOop is an array containing oops. |
33 // Evaluating "String arg[10]" will create an objArrayOop. |
35 // Evaluating "String arg[10]" will create an objArrayOop. |
34 |
36 |
35 class objArrayOopDesc : public arrayOopDesc { |
37 class objArrayOopDesc : public arrayOopDesc { |
36 friend class ObjArrayKlass; |
38 friend class ObjArrayKlass; |
40 friend class G1ParScanPartialArrayClosure; |
42 friend class G1ParScanPartialArrayClosure; |
41 |
43 |
42 template <class T> T* obj_at_addr(int index) const { |
44 template <class T> T* obj_at_addr(int index) const { |
43 assert(is_within_bounds(index), "index out of bounds"); |
45 assert(is_within_bounds(index), "index out of bounds"); |
44 return &((T*)base())[index]; |
46 return &((T*)base())[index]; |
|
47 } |
|
48 |
|
49 template <class T> |
|
50 static ptrdiff_t obj_at_offset(int index) { |
|
51 return base_offset_in_bytes() + sizeof(T) * index; |
45 } |
52 } |
46 |
53 |
47 private: |
54 private: |
48 // Give size of objArrayOop in HeapWords minus the header |
55 // Give size of objArrayOop in HeapWords minus the header |
49 static int array_size(int length) { |
56 static int array_size(int length) { |
80 HeapWord* base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); } |
87 HeapWord* base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); } |
81 |
88 |
82 // Accessing |
89 // Accessing |
83 oop obj_at(int index) const; |
90 oop obj_at(int index) const; |
84 |
91 |
85 void inline obj_at_put(int index, oop value); |
92 void obj_at_put(int index, oop value); |
86 |
93 |
87 oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value); |
94 oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value); |
88 |
95 |
89 // Sizing |
96 // Sizing |
90 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } |
97 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } |
97 assert(osz >= asz, "no overflow"); |
104 assert(osz >= asz, "no overflow"); |
98 assert((int)osz > 0, "no overflow"); |
105 assert((int)osz > 0, "no overflow"); |
99 return (int)osz; |
106 return (int)osz; |
100 } |
107 } |
101 |
108 |
|
109 Klass* element_klass(); |
|
110 |
102 // special iterators for index ranges, returns size of object |
111 // special iterators for index ranges, returns size of object |
103 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ |
112 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \ |
104 void oop_iterate_range(OopClosureType* blk, int start, int end); |
113 void oop_iterate_range(OopClosureType* blk, int start, int end); |
105 |
114 |
106 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL) |
115 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL) |