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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_BLOCKOFFSETTABLE_HPP
26 #define SHARE_VM_GC_SHARED_BLOCKOFFSETTABLE_HPP
27
28 #include "gc/shared/memset_with_concurrent_readers.hpp"
29 #include "memory/memRegion.hpp"
30 #include "memory/virtualspace.hpp"
31 #include "runtime/globals.hpp"
32 #include "utilities/globalDefinitions.hpp"
33 #include "utilities/macros.hpp"
34
35 // The CollectedHeap type requires subtypes to implement a method
36 // "block_start". For some subtypes, notably generational
37 // systems using card-table-based write barriers, the efficiency of this
38 // operation may be important. Implementations of the "BlockOffsetArray"
39 // class may be useful in providing such efficient implementations.
40 //
41 // BlockOffsetTable (abstract)
42 // - BlockOffsetArray (abstract)
43 // - BlockOffsetArrayNonContigSpace
44 // - BlockOffsetArrayContigSpace
45 //
46
47 class ContiguousSpace;
48
60
61 static size_t power_to_cards_back(uint i) {
62 return (size_t)1 << (LogBase * i);
63 }
64 static size_t power_to_words_back(uint i) {
65 return power_to_cards_back(i) * N_words;
66 }
67 static size_t entry_to_cards_back(u_char entry) {
68 assert(entry >= N_words, "Precondition");
69 return power_to_cards_back(entry - N_words);
70 }
71 static size_t entry_to_words_back(u_char entry) {
72 assert(entry >= N_words, "Precondition");
73 return power_to_words_back(entry - N_words);
74 }
75 };
76
77 //////////////////////////////////////////////////////////////////////////
78 // The BlockOffsetTable "interface"
79 //////////////////////////////////////////////////////////////////////////
80 class BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
81 friend class VMStructs;
82 protected:
83 // These members describe the region covered by the table.
84
85 // The space this table is covering.
86 HeapWord* _bottom; // == reserved.start
87 HeapWord* _end; // End of currently allocated region.
88
89 public:
90 // Initialize the table to cover the given space.
91 // The contents of the initial table are undefined.
92 BlockOffsetTable(HeapWord* bottom, HeapWord* end):
93 _bottom(bottom), _end(end) {
94 assert(_bottom <= _end, "arguments out of order");
95 }
96
97 // Note that the committed size of the covered space may have changed,
98 // so the table size might also wish to change.
99 virtual void resize(size_t new_word_size) = 0;
100
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_BLOCKOFFSETTABLE_HPP
26 #define SHARE_VM_GC_SHARED_BLOCKOFFSETTABLE_HPP
27
28 #include "gc/shared/memset_with_concurrent_readers.hpp"
29 #include "memory/allocation.hpp"
30 #include "memory/memRegion.hpp"
31 #include "memory/virtualspace.hpp"
32 #include "runtime/globals.hpp"
33 #include "utilities/globalDefinitions.hpp"
34 #include "utilities/macros.hpp"
35
36 // The CollectedHeap type requires subtypes to implement a method
37 // "block_start". For some subtypes, notably generational
38 // systems using card-table-based write barriers, the efficiency of this
39 // operation may be important. Implementations of the "BlockOffsetArray"
40 // class may be useful in providing such efficient implementations.
41 //
42 // BlockOffsetTable (abstract)
43 // - BlockOffsetArray (abstract)
44 // - BlockOffsetArrayNonContigSpace
45 // - BlockOffsetArrayContigSpace
46 //
47
48 class ContiguousSpace;
49
61
62 static size_t power_to_cards_back(uint i) {
63 return (size_t)1 << (LogBase * i);
64 }
65 static size_t power_to_words_back(uint i) {
66 return power_to_cards_back(i) * N_words;
67 }
68 static size_t entry_to_cards_back(u_char entry) {
69 assert(entry >= N_words, "Precondition");
70 return power_to_cards_back(entry - N_words);
71 }
72 static size_t entry_to_words_back(u_char entry) {
73 assert(entry >= N_words, "Precondition");
74 return power_to_words_back(entry - N_words);
75 }
76 };
77
78 //////////////////////////////////////////////////////////////////////////
79 // The BlockOffsetTable "interface"
80 //////////////////////////////////////////////////////////////////////////
81 class BlockOffsetTable {
82 friend class VMStructs;
83 protected:
84 // These members describe the region covered by the table.
85
86 // The space this table is covering.
87 HeapWord* _bottom; // == reserved.start
88 HeapWord* _end; // End of currently allocated region.
89
90 public:
91 // Initialize the table to cover the given space.
92 // The contents of the initial table are undefined.
93 BlockOffsetTable(HeapWord* bottom, HeapWord* end):
94 _bottom(bottom), _end(end) {
95 assert(_bottom <= _end, "arguments out of order");
96 }
97
98 // Note that the committed size of the covered space may have changed,
99 // so the table size might also wish to change.
100 virtual void resize(size_t new_word_size) = 0;
101
|