annotate src/share/vm/gc_implementation/parallelScavenge/objectStartArray.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children d2a62e0f25eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, 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"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 void ObjectStartArray::initialize(MemRegion reserved_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // We're based on the assumption that we use the same
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // size blocks as the card table.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert((int)block_size == (int)CardTableModRefBS::card_size, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
36 assert((int)block_size <= 512, "block_size must be less than or equal to 512");
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Calculate how much space must be reserved
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _reserved_region = reserved_region;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 size_t bytes_to_reserve = reserved_region.word_size() / block_size_in_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 assert(bytes_to_reserve > 0, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 bytes_to_reserve =
a61af66fc99e Initial load
duke
parents:
diff changeset
45 align_size_up(bytes_to_reserve, os::vm_allocation_granularity());
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Do not use large-pages for the backing store. The one large page region
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // will be used for the heap proper.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 ReservedSpace backing_store(bytes_to_reserve);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (!backing_store.is_reserved()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 vm_exit_during_initialization("Could not reserve space for ObjectStartArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // We do not commit any memory initially
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (!_virtual_space.initialize(backing_store, 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 vm_exit_during_initialization("Could not commit space for ObjectStartArray");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _raw_base = (jbyte*)_virtual_space.low_boundary();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 if (_raw_base == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 vm_exit_during_initialization("Could not get raw_base address");
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _offset_base = _raw_base - (size_t(reserved_region.start()) >> block_shift);
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _covered_region.set_start(reserved_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _covered_region.set_word_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _blocks_region.set_start((HeapWord*)_raw_base);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _blocks_region.set_word_size(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void ObjectStartArray::set_covered_region(MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 assert(_reserved_region.contains(mr), "MemRegion outside of reserved space");
a61af66fc99e Initial load
duke
parents:
diff changeset
75 assert(_reserved_region.start() == mr.start(), "Attempt to move covered region");
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 HeapWord* low_bound = mr.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 HeapWord* high_bound = mr.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 assert((uintptr_t(low_bound) & (block_size - 1)) == 0, "heap must start at block boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert((uintptr_t(high_bound) & (block_size - 1)) == 0, "heap must end at block boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 size_t requested_blocks_size_in_bytes = mr.word_size() / block_size_in_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Only commit memory in page sized chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
85 requested_blocks_size_in_bytes =
a61af66fc99e Initial load
duke
parents:
diff changeset
86 align_size_up(requested_blocks_size_in_bytes, os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _covered_region = mr;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 size_t current_blocks_size_in_bytes = _blocks_region.byte_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (requested_blocks_size_in_bytes > current_blocks_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Expand
a61af66fc99e Initial load
duke
parents:
diff changeset
94 size_t expand_by = requested_blocks_size_in_bytes - current_blocks_size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (!_virtual_space.expand_by(expand_by)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 vm_exit_out_of_memory(expand_by, "object start array expansion");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Clear *only* the newly allocated region
a61af66fc99e Initial load
duke
parents:
diff changeset
99 memset(_blocks_region.end(), clean_block, expand_by);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (requested_blocks_size_in_bytes < current_blocks_size_in_bytes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Shrink
a61af66fc99e Initial load
duke
parents:
diff changeset
104 size_t shrink_by = current_blocks_size_in_bytes - requested_blocks_size_in_bytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _virtual_space.shrink_by(shrink_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 _blocks_region.set_word_size(requested_blocks_size_in_bytes / sizeof(HeapWord));
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert(requested_blocks_size_in_bytes % sizeof(HeapWord) == 0, "Block table not expanded in word sized increment");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 assert(requested_blocks_size_in_bytes == _blocks_region.byte_size(), "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
112 assert(block_for_addr(low_bound) == &_raw_base[0], "Checking start of map");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 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
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void ObjectStartArray::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 memset(_blocks_region.start(), clean_block, _blocks_region.byte_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 bool ObjectStartArray::object_starts_in_range(HeapWord* start_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
122 HeapWord* end_addr) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert(start_addr <= end_addr, "range is wrong");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (start_addr > end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 jbyte* start_block = block_for_addr(start_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 jbyte* end_block = block_for_addr(end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 for (jbyte* block = start_block; block <= end_block; block++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 if (*block != clean_block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // No object starts in this slice; verify this using
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // more traditional methods:
a61af66fc99e Initial load
duke
parents:
diff changeset
138 assert(object_start(end_addr - 1) <= start_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
139 "Oops an object does start in this slice?");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }