annotate src/share/vm/gc_implementation/g1/g1BiasedArray.hpp @ 12305:a19bea467577

7163191: G1: introduce a "heap spanning table" abstraction Summary: Add G1BiasedArray<T> that is an array where each element represents a fixed-sized subdivision of the heap. Use this abstraction to refactor the HeapRegionSeq class. Reviewed-by: brutisso
author tschatzl
date Wed, 25 Sep 2013 13:25:24 +0200
parents
children e9fc29d2e8ae 5479cb006184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12305
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
1 /*
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
4 *
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
7 * published by the Free Software Foundation.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
8 *
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
13 * accompanied this code).
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
14 *
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
18 *
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
21 * questions.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
22 *
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
23 */
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
24
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
27
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
28 #include "utilities/debug.hpp"
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
29 #include "memory/allocation.inline.hpp"
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
30
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
31 // Implements the common base functionality for arrays that contain provisions
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
32 // for accessing its elements using a biased index.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
33 // The element type is defined by the instantiating the template.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
34 class G1BiasedMappedArrayBase VALUE_OBJ_CLASS_SPEC {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
35 friend class VMStructs;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
36 public:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
37 typedef size_t idx_t;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
38 protected:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
39 address _base; // the real base address
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
40 size_t _length; // the length of the array
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
41 address _biased_base; // base address biased by "bias" elements
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
42 size_t _bias; // the bias, i.e. the offset biased_base is located to the right in elements
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
43 uint _shift_by; // the amount of bits to shift right when mapping to an index of the array.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
44
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
45 protected:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
46
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
47 G1BiasedMappedArrayBase() : _base(NULL), _length(0), _biased_base(NULL),
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
48 _bias(0), _shift_by(0) { }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
49
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
50 // Allocate a new array, generic version.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
51 static address create_new_base_array(size_t length, size_t elem_size) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
52 assert(length > 0, "just checking");
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
53 assert(elem_size > 0, "just checking");
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
54 return NEW_C_HEAP_ARRAY(u_char, length * elem_size, mtGC);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
55 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
56
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
57 // Initialize the members of this class. The biased start address of this array
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
58 // is the bias (in elements) multiplied by the element size.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
59 void initialize_base(address base, size_t length, size_t bias, size_t elem_size, uint shift_by) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
60 assert(base != NULL, "just checking");
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
61 assert(length > 0, "just checking");
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
62 assert(shift_by < sizeof(uintptr_t) * 8, err_msg("Shifting by %zd, larger than word size?", shift_by));
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
63 _base = base;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
64 _length = length;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
65 _biased_base = base - (bias * elem_size);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
66 _bias = bias;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
67 _shift_by = shift_by;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
68 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
69
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
70 // Allocate and initialize this array to cover the heap addresses in the range
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
71 // of [bottom, end).
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
72 void initialize(HeapWord* bottom, HeapWord* end, size_t target_elem_size_in_bytes, size_t mapping_granularity_in_bytes) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
73 assert(mapping_granularity_in_bytes > 0, "just checking");
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
74 assert(is_power_of_2(mapping_granularity_in_bytes),
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
75 err_msg("mapping granularity must be power of 2, is %zd", mapping_granularity_in_bytes));
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
76 assert((uintptr_t)bottom % mapping_granularity_in_bytes == 0,
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
77 err_msg("bottom mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
78 mapping_granularity_in_bytes, bottom));
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
79 assert((uintptr_t)end % mapping_granularity_in_bytes == 0,
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
80 err_msg("end mapping area address must be a multiple of mapping granularity %zd, is "PTR_FORMAT,
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
81 mapping_granularity_in_bytes, end));
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
82 size_t num_target_elems = (end - bottom) / (mapping_granularity_in_bytes / HeapWordSize);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
83 idx_t bias = (uintptr_t)bottom / mapping_granularity_in_bytes;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
84 address base = create_new_base_array(num_target_elems, target_elem_size_in_bytes);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
85 initialize_base(base, num_target_elems, bias, target_elem_size_in_bytes, log2_intptr(mapping_granularity_in_bytes));
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
86 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
87
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
88 size_t bias() const { return _bias; }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
89 uint shift_by() const { return _shift_by; }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
90
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
91 void verify_index(idx_t index) const PRODUCT_RETURN;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
92 void verify_biased_index(idx_t biased_index) const PRODUCT_RETURN;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
93 void verify_biased_index_inclusive_end(idx_t biased_index) const PRODUCT_RETURN;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
94
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
95 public:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
96 // Return the length of the array in elements.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
97 size_t length() const { return _length; }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
98 };
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
99
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
100 // Array that provides biased access and mapping from (valid) addresses in the
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
101 // heap into this array.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
102 template<class T>
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
103 class G1BiasedMappedArray : public G1BiasedMappedArrayBase {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
104 public:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
105 typedef G1BiasedMappedArrayBase::idx_t idx_t;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
106
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
107 T* base() const { return (T*)G1BiasedMappedArrayBase::_base; }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
108 // Return the element of the given array at the given index. Assume
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
109 // the index is valid. This is a convenience method that does sanity
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
110 // checking on the index.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
111 T get_by_index(idx_t index) const {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
112 verify_index(index);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
113 return this->base()[index];
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
114 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
115
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
116 // Set the element of the given array at the given index to the
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
117 // given value. Assume the index is valid. This is a convenience
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
118 // method that does sanity checking on the index.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
119 void set_by_index(idx_t index, T value) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
120 verify_index(index);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
121 this->base()[index] = value;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
122 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
123
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
124 // The raw biased base pointer.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
125 T* biased_base() const { return (T*)G1BiasedMappedArrayBase::_biased_base; }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
126
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
127 // Return the element of the given array that covers the given word in the
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
128 // heap. Assumes the index is valid.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
129 T get_by_address(HeapWord* value) const {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
130 idx_t biased_index = ((uintptr_t)value) >> this->shift_by();
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
131 this->verify_biased_index(biased_index);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
132 return biased_base()[biased_index];
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
133 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
134
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
135 // Set the value of the array entry that corresponds to the given array.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
136 void set_by_address(HeapWord * address, T value) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
137 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
138 this->verify_biased_index(biased_index);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
139 biased_base()[biased_index] = value;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
140 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
141
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
142 protected:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
143 // Returns the address of the element the given address maps to
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
144 T* address_mapped_to(HeapWord* address) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
145 idx_t biased_index = ((uintptr_t)address) >> this->shift_by();
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
146 this->verify_biased_index_inclusive_end(biased_index);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
147 return biased_base() + biased_index;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
148 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
149
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
150 public:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
151 // Return the smallest address (inclusive) in the heap that this array covers.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
152 HeapWord* bottom_address_mapped() const {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
153 return (HeapWord*) ((uintptr_t)this->bias() << this->shift_by());
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
154 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
155
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
156 // Return the highest address (exclusive) in the heap that this array covers.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
157 HeapWord* end_address_mapped() const {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
158 return (HeapWord*) ((uintptr_t)(this->bias() + this->length()) << this->shift_by());
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
159 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
160
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
161 protected:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
162 virtual T default_value() const = 0;
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
163 // Set all elements of the given array to the given value.
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
164 void clear() {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
165 T value = default_value();
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
166 for (idx_t i = 0; i < length(); i++) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
167 set_by_index(i, value);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
168 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
169 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
170 public:
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
171 G1BiasedMappedArray() {}
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
172
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
173 // Allocate and initialize this array to cover the heap addresses in the range
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
174 // of [bottom, end).
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
175 void initialize(HeapWord* bottom, HeapWord* end, size_t mapping_granularity) {
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
176 G1BiasedMappedArrayBase::initialize(bottom, end, sizeof(T), mapping_granularity);
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
177 this->clear();
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
178 }
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
179 };
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
180
a19bea467577 7163191: G1: introduce a "heap spanning table" abstraction
tschatzl
parents:
diff changeset
181 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BIASEDARRAY_HPP