author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 52421 | 3021c1ad958b |
child 57550 | 278795ad438a |
permissions | -rw-r--r-- |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52421
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
4 |
* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
8 |
* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
13 |
* accompanied this code). |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
14 |
* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
18 |
* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
21 |
* questions. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
22 |
* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
23 |
*/ |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
24 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
25 |
#ifndef SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
26 |
#define SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
27 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
28 |
#include "gc/shared/oopStorage.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
29 |
#include "metaprogramming/conditional.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
30 |
#include "metaprogramming/isConst.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
31 |
#include "oops/oop.hpp" |
49333
489f1dd40582
8196876: OopStorage::assert_at_safepoint clashes with assert_at_safepoint macros in g1CollectedHeap.hpp
kbarrett
parents:
48886
diff
changeset
|
32 |
#include "runtime/safepoint.hpp" |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
33 |
#include "utilities/align.hpp" |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
34 |
#include "utilities/count_trailing_zeros.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
35 |
#include "utilities/debug.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
36 |
#include "utilities/globalDefinitions.hpp" |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
37 |
|
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
38 |
// Array of all active blocks. Refcounted for lock-free reclaim of |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
39 |
// old array when a new array is allocated for expansion. |
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
40 |
class OopStorage::ActiveArray { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
41 |
friend class OopStorage::TestAccess; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
42 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
43 |
size_t _size; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
44 |
volatile size_t _block_count; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
45 |
mutable volatile int _refcount; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
46 |
// Block* _blocks[1]; // Pseudo flexible array member. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
47 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
48 |
ActiveArray(size_t size); |
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
49 |
~ActiveArray(); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
50 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
51 |
// Noncopyable |
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
52 |
ActiveArray(const ActiveArray&); |
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
53 |
ActiveArray& operator=(const ActiveArray&); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
54 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
55 |
static size_t blocks_offset(); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
56 |
Block* const* base_ptr() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
57 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
58 |
Block* const* block_ptr(size_t index) const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
59 |
Block** block_ptr(size_t index); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
60 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
61 |
public: |
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
62 |
static ActiveArray* create(size_t size, AllocFailType alloc_fail = AllocFailStrategy::EXIT_OOM); |
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
63 |
static void destroy(ActiveArray* ba); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
64 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
65 |
inline Block* at(size_t i) const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
66 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
67 |
size_t size() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
68 |
size_t block_count() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
69 |
size_t block_count_acquire() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
70 |
void increment_refcount() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
71 |
bool decrement_refcount() const; // Return true if zero, otherwise false |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
72 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
73 |
// Support for OopStorage::allocate. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
74 |
// Add block to the end of the array. Updates block count at the |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
75 |
// end of the operation, with a release_store. Returns true if the |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
76 |
// block was added, false if there was no room available. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
77 |
// precondition: owner's _allocation_mutex is locked, or at safepoint. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
78 |
bool push(Block* block); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
79 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
80 |
// Support OopStorage::delete_empty_blocks_xxx operations. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
81 |
// Remove block from the array. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
82 |
// precondition: block must be present at its active_index element. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
83 |
void remove(Block* block); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
84 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
85 |
void copy_from(const ActiveArray* from); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
86 |
}; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
87 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
88 |
inline size_t OopStorage::ActiveArray::blocks_offset() { |
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
89 |
return align_up(sizeof(ActiveArray), sizeof(Block*)); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
90 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
91 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
92 |
inline OopStorage::Block* const* OopStorage::ActiveArray::base_ptr() const { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
93 |
const void* ptr = reinterpret_cast<const char*>(this) + blocks_offset(); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
94 |
return reinterpret_cast<Block* const*>(ptr); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
95 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
96 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
97 |
inline OopStorage::Block* const* OopStorage::ActiveArray::block_ptr(size_t index) const { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
98 |
return base_ptr() + index; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
99 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
100 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
101 |
inline OopStorage::Block** OopStorage::ActiveArray::block_ptr(size_t index) { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
102 |
return const_cast<Block**>(base_ptr() + index); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
103 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
104 |
|
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
105 |
inline OopStorage::Block* OopStorage::ActiveArray::at(size_t index) const { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
106 |
assert(index < _block_count, "precondition"); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
107 |
return *block_ptr(index); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
108 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
109 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
110 |
// A Block has an embedded AllocationListEntry to provide the links between |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
111 |
// Blocks in an AllocationList. |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
112 |
class OopStorage::AllocationListEntry { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
113 |
friend class OopStorage::AllocationList; |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
114 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
115 |
// Members are mutable, and we deal exclusively with pointers to |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
116 |
// const, to make const blocks easier to use; a block being const |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
117 |
// doesn't prevent modifying its list state. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
118 |
mutable const Block* _prev; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
119 |
mutable const Block* _next; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
120 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
121 |
// Noncopyable. |
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
122 |
AllocationListEntry(const AllocationListEntry&); |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
123 |
AllocationListEntry& operator=(const AllocationListEntry&); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
124 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
125 |
public: |
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
126 |
AllocationListEntry(); |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
127 |
~AllocationListEntry(); |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
128 |
}; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
129 |
|
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
130 |
// Fixed-sized array of oops, plus bookkeeping data. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
131 |
// All blocks are in the storage's _active_array, at the block's _active_index. |
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
132 |
// Non-full blocks are in the storage's _allocation_list, linked through the |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
133 |
// block's _allocation_list_entry. Empty blocks are at the end of that list. |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
134 |
class OopStorage::Block /* No base class, to avoid messing up alignment. */ { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
135 |
// _data must be the first non-static data member, for alignment. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
136 |
oop _data[BitsPerWord]; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
137 |
static const unsigned _data_pos = 0; // Position of _data. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
138 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
139 |
volatile uintx _allocated_bitmask; // One bit per _data element. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
140 |
const OopStorage* _owner; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
141 |
void* _memory; // Unaligned storage containing block. |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
142 |
size_t _active_index; |
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
143 |
AllocationListEntry _allocation_list_entry; |
48886 | 144 |
Block* volatile _deferred_updates_next; |
145 |
volatile uintx _release_refcount; |
|
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
146 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
147 |
Block(const OopStorage* owner, void* memory); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
148 |
~Block(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
149 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
150 |
void check_index(unsigned index) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
151 |
unsigned get_index(const oop* ptr) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
152 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
153 |
template<typename F, typename BlockPtr> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
154 |
static bool iterate_impl(F f, BlockPtr b); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
155 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
156 |
// Noncopyable. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
157 |
Block(const Block&); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
158 |
Block& operator=(const Block&); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
159 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
160 |
public: |
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
161 |
const AllocationListEntry& allocation_list_entry() const; |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
162 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
163 |
static size_t allocation_size(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
164 |
static size_t allocation_alignment_shift(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
165 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
166 |
oop* get_pointer(unsigned index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
167 |
const oop* get_pointer(unsigned index) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
168 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
169 |
uintx bitmask_for_index(unsigned index) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
170 |
uintx bitmask_for_entry(const oop* ptr) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
171 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
172 |
// Allocation bitmask accessors are racy. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
173 |
bool is_full() const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
174 |
bool is_empty() const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
175 |
uintx allocated_bitmask() const; |
52421
3021c1ad958b
8210986: Add OopStorage cleanup to ServiceThread
kbarrett
parents:
50954
diff
changeset
|
176 |
|
3021c1ad958b
8210986: Add OopStorage cleanup to ServiceThread
kbarrett
parents:
50954
diff
changeset
|
177 |
bool is_safe_to_delete() const; |
48886 | 178 |
|
179 |
Block* deferred_updates_next() const; |
|
180 |
void set_deferred_updates_next(Block* new_next); |
|
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
181 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
182 |
bool contains(const oop* ptr) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
183 |
|
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
184 |
size_t active_index() const; |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
185 |
void set_active_index(size_t index); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
186 |
static size_t active_index_safe(const Block* block); // Returns 0 if access fails. |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
187 |
|
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
188 |
// Returns NULL if ptr is not in a block or not allocated in that block. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
189 |
static Block* block_for_ptr(const OopStorage* owner, const oop* ptr); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
190 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
191 |
oop* allocate(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
192 |
static Block* new_block(const OopStorage* owner); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
193 |
static void delete_block(const Block& block); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
194 |
|
52421
3021c1ad958b
8210986: Add OopStorage cleanup to ServiceThread
kbarrett
parents:
50954
diff
changeset
|
195 |
void release_entries(uintx releasing, OopStorage* owner); |
48886 | 196 |
|
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
197 |
template<typename F> bool iterate(F f); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
198 |
template<typename F> bool iterate(F f) const; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
199 |
}; // class Block |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
200 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
201 |
inline OopStorage::Block* OopStorage::AllocationList::head() { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
202 |
return const_cast<Block*>(_head); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
203 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
204 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
205 |
inline OopStorage::Block* OopStorage::AllocationList::tail() { |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
206 |
return const_cast<Block*>(_tail); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
207 |
} |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
208 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
209 |
inline const OopStorage::Block* OopStorage::AllocationList::chead() const { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
210 |
return _head; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
211 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
212 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
213 |
inline const OopStorage::Block* OopStorage::AllocationList::ctail() const { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
214 |
return _tail; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
215 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
216 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
217 |
inline OopStorage::Block* OopStorage::AllocationList::prev(Block& block) { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
218 |
return const_cast<Block*>(block.allocation_list_entry()._prev); |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
219 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
220 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
221 |
inline OopStorage::Block* OopStorage::AllocationList::next(Block& block) { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
222 |
return const_cast<Block*>(block.allocation_list_entry()._next); |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
223 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
224 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
225 |
inline const OopStorage::Block* OopStorage::AllocationList::prev(const Block& block) const { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
226 |
return block.allocation_list_entry()._prev; |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
227 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
228 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
229 |
inline const OopStorage::Block* OopStorage::AllocationList::next(const Block& block) const { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
230 |
return block.allocation_list_entry()._next; |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
231 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
232 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
233 |
template<typename Closure> |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
49333
diff
changeset
|
234 |
class OopStorage::OopFn { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
235 |
public: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
236 |
explicit OopFn(Closure* cl) : _cl(cl) {} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
237 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
238 |
template<typename OopPtr> // [const] oop* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
239 |
bool operator()(OopPtr ptr) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
240 |
_cl->do_oop(ptr); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
241 |
return true; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
242 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
243 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
244 |
private: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
245 |
Closure* _cl; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
246 |
}; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
247 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
248 |
template<typename Closure> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
249 |
inline OopStorage::OopFn<Closure> OopStorage::oop_fn(Closure* cl) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
250 |
return OopFn<Closure>(cl); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
251 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
252 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
253 |
template<typename IsAlive, typename F> |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
49333
diff
changeset
|
254 |
class OopStorage::IfAliveFn { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
255 |
public: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
256 |
IfAliveFn(IsAlive* is_alive, F f) : _is_alive(is_alive), _f(f) {} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
257 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
258 |
bool operator()(oop* ptr) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
259 |
bool result = true; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
260 |
oop v = *ptr; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
261 |
if (v != NULL) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
262 |
if (_is_alive->do_object_b(v)) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
263 |
result = _f(ptr); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
264 |
} else { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
265 |
*ptr = NULL; // Clear dead value. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
266 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
267 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
268 |
return result; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
269 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
270 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
271 |
private: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
272 |
IsAlive* _is_alive; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
273 |
F _f; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
274 |
}; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
275 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
276 |
template<typename IsAlive, typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
277 |
inline OopStorage::IfAliveFn<IsAlive, F> OopStorage::if_alive_fn(IsAlive* is_alive, F f) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
278 |
return IfAliveFn<IsAlive, F>(is_alive, f); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
279 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
280 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
281 |
template<typename F> |
49392
2956d0ece7a9
8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents:
49333
diff
changeset
|
282 |
class OopStorage::SkipNullFn { |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
283 |
public: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
284 |
SkipNullFn(F f) : _f(f) {} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
285 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
286 |
template<typename OopPtr> // [const] oop* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
287 |
bool operator()(OopPtr ptr) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
288 |
return (*ptr != NULL) ? _f(ptr) : true; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
289 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
290 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
291 |
private: |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
292 |
F _f; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
293 |
}; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
294 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
295 |
template<typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
296 |
inline OopStorage::SkipNullFn<F> OopStorage::skip_null_fn(F f) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
297 |
return SkipNullFn<F>(f); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
298 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
299 |
|
50513
7f166e010af4
8204097: Simplify OopStorage::AllocateList block entry access
kbarrett
parents:
50209
diff
changeset
|
300 |
// Inline Block accesses for use in iteration loops. |
7f166e010af4
8204097: Simplify OopStorage::AllocateList block entry access
kbarrett
parents:
50209
diff
changeset
|
301 |
|
50954
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
302 |
inline const OopStorage::AllocationListEntry& OopStorage::Block::allocation_list_entry() const { |
f85092465b0c
8204834: Fix confusing "allocate" naming in OopStorage
kbarrett
parents:
50513
diff
changeset
|
303 |
return _allocation_list_entry; |
50513
7f166e010af4
8204097: Simplify OopStorage::AllocateList block entry access
kbarrett
parents:
50209
diff
changeset
|
304 |
} |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
305 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
306 |
inline void OopStorage::Block::check_index(unsigned index) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
307 |
assert(index < ARRAY_SIZE(_data), "Index out of bounds: %u", index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
308 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
309 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
310 |
inline oop* OopStorage::Block::get_pointer(unsigned index) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
311 |
check_index(index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
312 |
return &_data[index]; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
313 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
314 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
315 |
inline const oop* OopStorage::Block::get_pointer(unsigned index) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
316 |
check_index(index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
317 |
return &_data[index]; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
318 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
319 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
320 |
inline uintx OopStorage::Block::allocated_bitmask() const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
321 |
return _allocated_bitmask; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
322 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
323 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
324 |
inline uintx OopStorage::Block::bitmask_for_index(unsigned index) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
325 |
check_index(index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
326 |
return uintx(1) << index; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
327 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
328 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
329 |
// Provide const or non-const iteration, depending on whether BlockPtr |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
330 |
// is const Block* or Block*, respectively. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
331 |
template<typename F, typename BlockPtr> // BlockPtr := [const] Block* |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
332 |
inline bool OopStorage::Block::iterate_impl(F f, BlockPtr block) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
333 |
uintx bitmask = block->allocated_bitmask(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
334 |
while (bitmask != 0) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
335 |
unsigned index = count_trailing_zeros(bitmask); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
336 |
bitmask ^= block->bitmask_for_index(index); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
337 |
if (!f(block->get_pointer(index))) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
338 |
return false; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
339 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
340 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
341 |
return true; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
342 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
343 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
344 |
template<typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
345 |
inline bool OopStorage::Block::iterate(F f) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
346 |
return iterate_impl(f, this); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
347 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
348 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
349 |
template<typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
350 |
inline bool OopStorage::Block::iterate(F f) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
351 |
return iterate_impl(f, this); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
352 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
353 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
354 |
////////////////////////////////////////////////////////////////////////////// |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
355 |
// Support for serial iteration, always at a safepoint. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
356 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
357 |
// Provide const or non-const iteration, depending on whether Storage is |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
358 |
// const OopStorage* or OopStorage*, respectively. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
359 |
template<typename F, typename Storage> // Storage := [const] OopStorage |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
360 |
inline bool OopStorage::iterate_impl(F f, Storage* storage) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
361 |
assert_at_safepoint(); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
362 |
// Propagate const/non-const iteration to the block layer, by using |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
363 |
// const or non-const blocks as corresponding to Storage. |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
364 |
typedef typename Conditional<IsConst<Storage>::value, const Block*, Block*>::type BlockPtr; |
50209
2fdce199fcb9
8202863: Rename OopStorage inner collection classes
kbarrett
parents:
49977
diff
changeset
|
365 |
ActiveArray* blocks = storage->_active_array; |
49977
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
366 |
size_t limit = blocks->block_count(); |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
367 |
for (size_t i = 0; i < limit; ++i) { |
9f758f0bb058
8200557: OopStorage parallel iteration scales poorly
kbarrett
parents:
49392
diff
changeset
|
368 |
BlockPtr block = blocks->at(i); |
48816
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
369 |
if (!block->iterate(f)) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
370 |
return false; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
371 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
372 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
373 |
return true; |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
374 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
375 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
376 |
template<typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
377 |
inline bool OopStorage::iterate_safepoint(F f) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
378 |
return iterate_impl(f, this); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
379 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
380 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
381 |
template<typename F> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
382 |
inline bool OopStorage::iterate_safepoint(F f) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
383 |
return iterate_impl(f, this); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
384 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
385 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
386 |
template<typename Closure> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
387 |
inline void OopStorage::oops_do(Closure* cl) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
388 |
iterate_safepoint(oop_fn(cl)); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
389 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
390 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
391 |
template<typename Closure> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
392 |
inline void OopStorage::oops_do(Closure* cl) const { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
393 |
iterate_safepoint(oop_fn(cl)); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
394 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
395 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
396 |
template<typename Closure> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
397 |
inline void OopStorage::weak_oops_do(Closure* cl) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
398 |
iterate_safepoint(skip_null_fn(oop_fn(cl))); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
399 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
400 |
|
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
401 |
template<typename IsAliveClosure, typename Closure> |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
402 |
inline void OopStorage::weak_oops_do(IsAliveClosure* is_alive, Closure* cl) { |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
403 |
iterate_safepoint(if_alive_fn(is_alive, oop_fn(cl))); |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
404 |
} |
3495d6050efe
8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff
changeset
|
405 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52421
diff
changeset
|
406 |
#endif // SHARE_GC_SHARED_OOPSTORAGE_INLINE_HPP |