author | coleenp |
Wed, 24 Jul 2019 10:22:11 -0400 | |
changeset 57511 | 00ae3b739184 |
parent 53244 | 9807daeb47c4 |
child 57777 | 90ead0febf56 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50752
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4465
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4465
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4465
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50752
diff
changeset
|
25 |
#ifndef SHARE_OOPS_OBJARRAYOOP_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50752
diff
changeset
|
26 |
#define SHARE_OOPS_OBJARRAYOOP_HPP |
7397 | 27 |
|
28 |
#include "oops/arrayOop.hpp" |
|
46625 | 29 |
#include "utilities/align.hpp" |
7397 | 30 |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
31 |
class Klass; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
32 |
|
1 | 33 |
// An objArrayOop is an array containing oops. |
34 |
// Evaluating "String arg[10]" will create an objArrayOop. |
|
35 |
||
36 |
class objArrayOopDesc : public arrayOopDesc { |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
11176
diff
changeset
|
37 |
friend class ObjArrayKlass; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
38 |
friend class Runtime1; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
39 |
friend class psPromotionManager; |
11176
9bb1ddd8da51
7112743: G1: Reduce overhead of marking closure during evacuation pauses
johnc
parents:
7397
diff
changeset
|
40 |
friend class CSetMarkOopClosure; |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
41 |
friend class G1ParScanPartialArrayClosure; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
42 |
|
49041
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
47998
diff
changeset
|
43 |
template <class T> T* obj_at_addr(int index) const; |
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
47998
diff
changeset
|
44 |
template <class T> T* obj_at_addr_raw(int index) const; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
45 |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
46 |
template <class T> |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
47 |
static ptrdiff_t obj_at_offset(int index) { |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
48 |
return base_offset_in_bytes() + sizeof(T) * index; |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
49 |
} |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
50 |
|
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
51 |
private: |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
52 |
// Give size of objArrayOop in HeapWords minus the header |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
53 |
static int array_size(int length) { |
27427
5c3f72c4c703
8054530: C2: assert(res == old_res) failed: Inconsistency between old and new
morris
parents:
25325
diff
changeset
|
54 |
const uint OopsPerHeapWord = HeapWordSize/heapOopSize; |
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
55 |
assert(OopsPerHeapWord >= 1 && (HeapWordSize % heapOopSize == 0), |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
56 |
"Else the following (new) computation would be in error"); |
27427
5c3f72c4c703
8054530: C2: assert(res == old_res) failed: Inconsistency between old and new
morris
parents:
25325
diff
changeset
|
57 |
uint res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord; |
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
58 |
#ifdef ASSERT |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
59 |
// The old code is left in for sanity-checking; it'll |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
60 |
// go away pretty soon. XXX |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
61 |
// Without UseCompressedOops, this is simply: |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
62 |
// oop->length() * HeapWordsPerOop; |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
63 |
// With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer. |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
64 |
// The oop elements are aligned up to wordSize |
27427
5c3f72c4c703
8054530: C2: assert(res == old_res) failed: Inconsistency between old and new
morris
parents:
25325
diff
changeset
|
65 |
const uint HeapWordsPerOop = heapOopSize/HeapWordSize; |
5c3f72c4c703
8054530: C2: assert(res == old_res) failed: Inconsistency between old and new
morris
parents:
25325
diff
changeset
|
66 |
uint old_res; |
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
67 |
if (HeapWordsPerOop > 0) { |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
68 |
old_res = length * HeapWordsPerOop; |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
69 |
} else { |
46619
a3919f5e8d2b
8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents:
35862
diff
changeset
|
70 |
old_res = align_up((uint)length, OopsPerHeapWord)/OopsPerHeapWord; |
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
71 |
} |
27427
5c3f72c4c703
8054530: C2: assert(res == old_res) failed: Inconsistency between old and new
morris
parents:
25325
diff
changeset
|
72 |
assert(res == old_res, "Inconsistency between old and new."); |
4461
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
73 |
#endif // ASSERT |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
74 |
return res; |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
75 |
} |
c17c526d36ef
6906727: UseCompressedOops: some card-marking fixes related to object arrays
ysr
parents:
3795
diff
changeset
|
76 |
|
1 | 77 |
public: |
3595
d67c151b72a5
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
1388
diff
changeset
|
78 |
// Returns the offset of the first element. |
d67c151b72a5
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
1388
diff
changeset
|
79 |
static int base_offset_in_bytes() { |
d67c151b72a5
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
1388
diff
changeset
|
80 |
return arrayOopDesc::base_offset_in_bytes(T_OBJECT); |
d67c151b72a5
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
1388
diff
changeset
|
81 |
} |
d67c151b72a5
6860920: serialize.cpp shouldn't use objArrayOopDesc::base_offset_in_bytes(T_BYTE)
twisti
parents:
1388
diff
changeset
|
82 |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
83 |
// base is the address following the header. |
49041
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
47998
diff
changeset
|
84 |
HeapWord* base() const; |
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
47998
diff
changeset
|
85 |
HeapWord* base_raw() const; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
86 |
|
1 | 87 |
// Accessing |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27427
diff
changeset
|
88 |
oop obj_at(int index) const; |
1 | 89 |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
90 |
void obj_at_put(int index, oop value); |
25325 | 91 |
|
92 |
oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value); |
|
93 |
||
1 | 94 |
// Sizing |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
95 |
static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
96 |
int object_size() { return object_size(length()); } |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
97 |
|
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
98 |
static int object_size(int length) { |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
99 |
// This returns the object size in HeapWords. |
4465
7b73e0380188
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
4461
diff
changeset
|
100 |
uint asz = array_size(length); |
7b73e0380188
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
4461
diff
changeset
|
101 |
uint osz = align_object_size(header_size() + asz); |
7b73e0380188
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
4461
diff
changeset
|
102 |
assert(osz >= asz, "no overflow"); |
7b73e0380188
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
4461
diff
changeset
|
103 |
assert((int)osz > 0, "no overflow"); |
7b73e0380188
6908208: UseCompressedOops: array_size() returns incorrect size for MAX_INT object array following 6906727
ysr
parents:
4461
diff
changeset
|
104 |
return (int)osz; |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
105 |
} |
1 | 106 |
|
47998
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
107 |
Klass* element_klass(); |
fb0275c320a0
8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents:
47216
diff
changeset
|
108 |
|
50752 | 109 |
public: |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
110 |
// special iterators for index ranges, returns size of object |
50752 | 111 |
template <typename OopClosureType> |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30764
diff
changeset
|
112 |
void oop_iterate_range(OopClosureType* blk, int start, int end); |
1 | 113 |
}; |
7397 | 114 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50752
diff
changeset
|
115 |
#endif // SHARE_OOPS_OBJARRAYOOP_HPP |