annotate src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp @ 6862:8a5ea0a9ccc4

7127708: G1: change task num types from int to uint in concurrent mark Summary: Change the type of various task num fields, parameters etc to unsigned and rename them to be more consistent with the other collectors. Code changes were also reviewed by Vitaly Davidovich. Reviewed-by: johnc Contributed-by: Kaushik Srenevasan <kaushik@twitter.com>
author johnc
date Sat, 06 Oct 2012 01:17:44 -0700
parents da91efe96a93
children 746b070f5022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/java.hpp"
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
31 #include "services/memTracker.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 void ObjectStartArray::initialize(MemRegion reserved_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // We're based on the assumption that we use the same
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // size blocks as the card table.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 assert((int)block_size == (int)CardTableModRefBS::card_size, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
37 assert((int)block_size <= 512, "block_size must be less than or equal to 512");
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // Calculate how much space must be reserved
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _reserved_region = reserved_region;
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 size_t bytes_to_reserve = reserved_region.word_size() / block_size_in_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 assert(bytes_to_reserve > 0, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bytes_to_reserve =
a61af66fc99e Initial load
duke
parents:
diff changeset
46 align_size_up(bytes_to_reserve, os::vm_allocation_granularity());
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Do not use large-pages for the backing store. The one large page region
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // will be used for the heap proper.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 ReservedSpace backing_store(bytes_to_reserve);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (!backing_store.is_reserved()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 vm_exit_during_initialization("Could not reserve space for ObjectStartArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
54 MemTracker::record_virtual_memory_type((address)backing_store.base(), mtGC);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // We do not commit any memory initially
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (!_virtual_space.initialize(backing_store, 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 vm_exit_during_initialization("Could not commit space for ObjectStartArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _raw_base = (jbyte*)_virtual_space.low_boundary();
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
62
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63 if (_raw_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 vm_exit_during_initialization("Could not get raw_base address");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
67 MemTracker::record_virtual_memory_type((address)_raw_base, mtGC);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
68
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
69
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _offset_base = _raw_base - (size_t(reserved_region.start()) >> block_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _covered_region.set_start(reserved_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _covered_region.set_word_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _blocks_region.set_start((HeapWord*)_raw_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _blocks_region.set_word_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void ObjectStartArray::set_covered_region(MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert(_reserved_region.contains(mr), "MemRegion outside of reserved space");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert(_reserved_region.start() == mr.start(), "Attempt to move covered region");
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 HeapWord* low_bound = mr.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 HeapWord* high_bound = mr.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert((uintptr_t(low_bound) & (block_size - 1)) == 0, "heap must start at block boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert((uintptr_t(high_bound) & (block_size - 1)) == 0, "heap must end at block boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 size_t requested_blocks_size_in_bytes = mr.word_size() / block_size_in_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Only commit memory in page sized chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
91 requested_blocks_size_in_bytes =
a61af66fc99e Initial load
duke
parents:
diff changeset
92 align_size_up(requested_blocks_size_in_bytes, os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _covered_region = mr;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 size_t current_blocks_size_in_bytes = _blocks_region.byte_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if (requested_blocks_size_in_bytes > current_blocks_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Expand
a61af66fc99e Initial load
duke
parents:
diff changeset
100 size_t expand_by = requested_blocks_size_in_bytes - current_blocks_size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (!_virtual_space.expand_by(expand_by)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 vm_exit_out_of_memory(expand_by, "object start array expansion");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Clear *only* the newly allocated region
a61af66fc99e Initial load
duke
parents:
diff changeset
105 memset(_blocks_region.end(), clean_block, expand_by);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (requested_blocks_size_in_bytes < current_blocks_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Shrink
a61af66fc99e Initial load
duke
parents:
diff changeset
110 size_t shrink_by = current_blocks_size_in_bytes - requested_blocks_size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _virtual_space.shrink_by(shrink_by);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _blocks_region.set_word_size(requested_blocks_size_in_bytes / sizeof(HeapWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 assert(requested_blocks_size_in_bytes % sizeof(HeapWord) == 0, "Block table not expanded in word sized increment");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 assert(requested_blocks_size_in_bytes == _blocks_region.byte_size(), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
118 assert(block_for_addr(low_bound) == &_raw_base[0], "Checking start of map");
a61af66fc99e Initial load
duke
parents:
diff changeset
119 assert(block_for_addr(high_bound-1) <= &_raw_base[_blocks_region.byte_size()-1], "Checking end of map");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void ObjectStartArray::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 memset(_blocks_region.start(), clean_block, _blocks_region.byte_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 HeapWord* end_addr) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 assert(start_addr <= end_addr, "range is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (start_addr > end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 jbyte* start_block = block_for_addr(start_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 jbyte* end_block = block_for_addr(end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 for (jbyte* block = start_block; block <= end_block; block++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (*block != clean_block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // No object starts in this slice; verify this using
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
143 // more traditional methods: Note that no object can
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
144 // start before the start_addr.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
145 assert(end_addr == start_addr ||
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
146 object_start(end_addr - 1) <= start_addr,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 "Oops an object does start in this slice?");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }