annotate src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 c49dcaf78a65
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
2 * Copyright (c) 2001, 2014, 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: 605
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
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: 605
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: 1706
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
26 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
27 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
28 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
29 #include "gc_implementation/parallelScavenge/psTasks.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
30 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
31 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
32 #include "oops/oop.psgc.inline.hpp"
20198
c49dcaf78a65 8042737: Introduce umbrella header prefetch.inline.hpp
goetz
parents: 17937
diff changeset
33 #include "runtime/prefetch.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Checks an individual oop for missing precise marks. Mark
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // may be either dirty or newgen.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class CheckForUnmarkedOops : public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
38 private:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
39 PSYoungGen* _young_gen;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 CardTableExtension* _card_table;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
41 HeapWord* _unmarked_addr;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
42 jbyte* _unmarked_card;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
44 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
45 template <class T> void do_oop_work(T* p) {
6009
dde53abda3d6 7160613: VerifyRememberedSets doesn't work with CompressedOops
stefank
parents: 4095
diff changeset
46 oop obj = oopDesc::load_decode_heap_oop(p);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
47 if (_young_gen->is_in_reserved(obj) &&
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 !_card_table->addr_is_marked_imprecise(p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Don't overwrite the first missing card mark
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (_unmarked_addr == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _unmarked_addr = (HeapWord*)p;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _unmarked_card = _card_table->byte_for(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
57 public:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
58 CheckForUnmarkedOops(PSYoungGen* young_gen, CardTableExtension* card_table) :
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
59 _young_gen(young_gen), _card_table(card_table), _unmarked_addr(NULL) { }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
60
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
61 virtual void do_oop(oop* p) { CheckForUnmarkedOops::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
62 virtual void do_oop(narrowOop* p) { CheckForUnmarkedOops::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
63
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64 bool has_unmarked_oop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return _unmarked_addr != NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Checks all objects for the existance of some type of mark,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // precise or imprecise, dirty or newgen.
a61af66fc99e Initial load
duke
parents:
diff changeset
71 class CheckForUnmarkedObjects : public ObjectClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
72 private:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
73 PSYoungGen* _young_gen;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74 CardTableExtension* _card_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 CheckForUnmarkedObjects() {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _young_gen = heap->young_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _card_table = (CardTableExtension*)heap->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // No point in asserting barrier set type here. Need to make CardTableExtension
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // a unique barrier set type.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Card marks are not precise. The current system can leave us with
605
98cb887364d3 6810672: Comment typos
twisti
parents: 269
diff changeset
88 // a mismash of precise marks and beginning of object marks. This means
0
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // we test for missing precise marks first. If any are found, we don't
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // fail unless the object head is also unmarked.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 virtual void do_object(oop obj) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
92 CheckForUnmarkedOops object_check(_young_gen, _card_table);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6009
diff changeset
93 obj->oop_iterate_no_header(&object_check);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if (object_check.has_unmarked_oop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 assert(_card_table->addr_is_marked_imprecise(obj), "Found unmarked young_gen object");
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 };
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Checks for precise marking of oops as newgen.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 class CheckForPreciseMarks : public OopClosure {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
102 private:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
103 PSYoungGen* _young_gen;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 CardTableExtension* _card_table;
a61af66fc99e Initial load
duke
parents:
diff changeset
105
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
106 protected:
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
107 template <class T> void do_oop_work(T* p) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
108 oop obj = oopDesc::load_decode_heap_oop_not_null(p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
109 if (_young_gen->is_in_reserved(obj)) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
110 assert(_card_table->addr_is_marked_precise(p), "Found unmarked precise oop");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
111 _card_table->set_card_newgen(p);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
112 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
113 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
114
0
a61af66fc99e Initial load
duke
parents:
diff changeset
115 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
116 CheckForPreciseMarks( PSYoungGen* young_gen, CardTableExtension* card_table ) :
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _young_gen(young_gen), _card_table(card_table) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
119 virtual void do_oop(oop* p) { CheckForPreciseMarks::do_oop_work(p); }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
120 virtual void do_oop(narrowOop* p) { CheckForPreciseMarks::do_oop_work(p); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // We get passed the space_top value to prevent us from traversing into
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // the old_gen promotion labs, which cannot be safely parsed.
a61af66fc99e Initial load
duke
parents:
diff changeset
125
6817
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
126 // Do not call this method if the space is empty.
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
127 // It is a waste to start tasks and get here only to
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
128 // do no work. If this method needs to be called
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
129 // when the space is empty, fix the calculation of
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
130 // end_card to allow sp_top == sp->bottom().
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void CardTableExtension::scavenge_contents_parallel(ObjectStartArray* start_array,
a61af66fc99e Initial load
duke
parents:
diff changeset
133 MutableSpace* sp,
a61af66fc99e Initial load
duke
parents:
diff changeset
134 HeapWord* space_top,
a61af66fc99e Initial load
duke
parents:
diff changeset
135 PSPromotionManager* pm,
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
136 uint stripe_number,
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
137 uint stripe_total) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int ssize = 128; // Naked constant! Work unit = 64k.
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int dirty_card_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
140
6817
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
141 // It is a waste to get here if empty.
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
142 assert(sp->bottom() < sp->top(), "Should not be called if empty");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 oop* sp_top = (oop*)space_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 jbyte* start_card = byte_for(sp->bottom());
6817
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
145 jbyte* end_card = byte_for(sp_top - 1) + 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 oop* last_scanned = NULL; // Prevent scanning objects more than once
4095
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
147 // The width of the stripe ssize*stripe_total must be
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
148 // consistent with the number of stripes so that the complete slice
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
149 // is covered.
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
150 size_t slice_width = ssize * stripe_total;
bca17e38de00 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 1972
diff changeset
151 for (jbyte* slice = start_card; slice < end_card; slice += slice_width) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
152 jbyte* worker_start_card = slice + stripe_number * ssize;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (worker_start_card >= end_card)
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return; // We're done.
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 jbyte* worker_end_card = worker_start_card + ssize;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (worker_end_card > end_card)
a61af66fc99e Initial load
duke
parents:
diff changeset
158 worker_end_card = end_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // We do not want to scan objects more than once. In order to accomplish
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // this, we assert that any object with an object head inside our 'slice'
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // belongs to us. We may need to extend the range of scanned cards if the
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // last object continues into the next 'slice'.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 //
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // Note! ending cards are exclusive!
a61af66fc99e Initial load
duke
parents:
diff changeset
166 HeapWord* slice_start = addr_for(worker_start_card);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 HeapWord* slice_end = MIN2((HeapWord*) sp_top, addr_for(worker_end_card));
a61af66fc99e Initial load
duke
parents:
diff changeset
168
6817
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
169 #ifdef ASSERT
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
170 if (GCWorkerDelayMillis > 0) {
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
171 // Delay 1 worker so that it proceeds after all the work
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
172 // has been completed.
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
173 if (stripe_number < 2) {
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
174 os::sleep(Thread::current(), GCWorkerDelayMillis, false);
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
175 }
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
176 }
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
177 #endif
f81a7c0c618d 7199349: NPG: PS: Crash seen in jprt
jmasa
parents: 6725
diff changeset
178
0
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // If there are not objects starting within the chunk, skip it.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if (!start_array->object_starts_in_range(slice_start, slice_end)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
605
98cb887364d3 6810672: Comment typos
twisti
parents: 269
diff changeset
183 // Update our beginning addr
0
a61af66fc99e Initial load
duke
parents:
diff changeset
184 HeapWord* first_object = start_array->object_start(slice_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 debug_only(oop* first_object_within_slice = (oop*) first_object;)
a61af66fc99e Initial load
duke
parents:
diff changeset
186 if (first_object < slice_start) {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 last_scanned = (oop*)(first_object + oop(first_object)->size());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 debug_only(first_object_within_slice = last_scanned;)
a61af66fc99e Initial load
duke
parents:
diff changeset
189 worker_start_card = byte_for(last_scanned);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Update the ending addr
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (slice_end < (HeapWord*)sp_top) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // The subtraction is important! An object may start precisely at slice_end.
a61af66fc99e Initial load
duke
parents:
diff changeset
195 HeapWord* last_object = start_array->object_start(slice_end - 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 slice_end = last_object + oop(last_object)->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // worker_end_card is exclusive, so bump it one past the end of last_object's
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // covered span.
a61af66fc99e Initial load
duke
parents:
diff changeset
199 worker_end_card = byte_for(slice_end) + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if (worker_end_card > end_card)
a61af66fc99e Initial load
duke
parents:
diff changeset
202 worker_end_card = end_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 assert(slice_end <= (HeapWord*)sp_top, "Last object in slice crosses space boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(is_valid_card_address(worker_start_card), "Invalid worker start card");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 assert(is_valid_card_address(worker_end_card), "Invalid worker end card");
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // Note that worker_start_card >= worker_end_card is legal, and happens when
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // an object spans an entire slice.
a61af66fc99e Initial load
duke
parents:
diff changeset
210 assert(worker_start_card <= end_card, "worker start card beyond end card");
a61af66fc99e Initial load
duke
parents:
diff changeset
211 assert(worker_end_card <= end_card, "worker end card beyond end card");
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 jbyte* current_card = worker_start_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
214 while (current_card < worker_end_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // Find an unclean card.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 while (current_card < worker_end_card && card_is_clean(*current_card)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 current_card++;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 jbyte* first_unclean_card = current_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // Find the end of a run of contiguous unclean cards
a61af66fc99e Initial load
duke
parents:
diff changeset
222 while (current_card < worker_end_card && !card_is_clean(*current_card)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 while (current_card < worker_end_card && !card_is_clean(*current_card)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 current_card++;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (current_card < worker_end_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // Some objects may be large enough to span several cards. If such
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // an object has more than one dirty card, separated by a clean card,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // we will attempt to scan it twice. The test against "last_scanned"
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // prevents the redundant object scan, but it does not prevent newly
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // marked cards from being cleaned.
a61af66fc99e Initial load
duke
parents:
diff changeset
233 HeapWord* last_object_in_dirty_region = start_array->object_start(addr_for(current_card)-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
234 size_t size_of_last_object = oop(last_object_in_dirty_region)->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 HeapWord* end_of_last_object = last_object_in_dirty_region + size_of_last_object;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 jbyte* ending_card_of_last_object = byte_for(end_of_last_object);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 assert(ending_card_of_last_object <= worker_end_card, "ending_card_of_last_object is greater than worker_end_card");
a61af66fc99e Initial load
duke
parents:
diff changeset
238 if (ending_card_of_last_object > current_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // This means the object spans the next complete card.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // We need to bump the current_card to ending_card_of_last_object
a61af66fc99e Initial load
duke
parents:
diff changeset
241 current_card = ending_card_of_last_object;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 jbyte* following_clean_card = current_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if (first_unclean_card < worker_end_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 oop* p = (oop*) start_array->object_start(addr_for(first_unclean_card));
a61af66fc99e Initial load
duke
parents:
diff changeset
249 assert((HeapWord*)p <= addr_for(first_unclean_card), "checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // "p" should always be >= "last_scanned" because newly GC dirtied
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // cards are no longer scanned again (see comment at end
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // of loop on the increment of "current_card"). Test that
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // hypothesis before removing this code.
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // If this code is removed, deal with the first time through
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // the loop when the last_scanned is the object starting in
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // the previous slice.
a61af66fc99e Initial load
duke
parents:
diff changeset
257 assert((p >= last_scanned) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
258 (last_scanned == first_object_within_slice),
a61af66fc99e Initial load
duke
parents:
diff changeset
259 "Should no longer be possible");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 if (p < last_scanned) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Avoid scanning more than once; this can happen because
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // newgen cards set by GC may a different set than the
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // originally dirty set
a61af66fc99e Initial load
duke
parents:
diff changeset
264 p = last_scanned;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 oop* to = (oop*)addr_for(following_clean_card);
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Test slice_end first!
a61af66fc99e Initial load
duke
parents:
diff changeset
269 if ((HeapWord*)to > slice_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 to = (oop*)slice_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 } else if (to > sp_top) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 to = sp_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // we know which cards to scan, now clear them
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (first_unclean_card <= worker_start_card+1)
a61af66fc99e Initial load
duke
parents:
diff changeset
277 first_unclean_card = worker_start_card+1;
a61af66fc99e Initial load
duke
parents:
diff changeset
278 if (following_clean_card >= worker_end_card-1)
a61af66fc99e Initial load
duke
parents:
diff changeset
279 following_clean_card = worker_end_card-1;
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 while (first_unclean_card < following_clean_card) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 *first_unclean_card++ = clean_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 const int interval = PrefetchScanIntervalInBytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 // scan all objects in the range
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (interval != 0) {
1706
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
288 while (p < to) {
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
289 Prefetch::write(p, interval);
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
290 oop m = oop(p);
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
291 assert(m->is_oop_or_null(), "check for header");
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
292 m->push_contents(pm);
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
293 p += m->size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
1706
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
295 pm->drain_stacks_cond_depth();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
296 } else {
1706
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
297 while (p < to) {
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
298 oop m = oop(p);
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
299 assert(m->is_oop_or_null(), "check for header");
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
300 m->push_contents(pm);
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
301 p += m->size();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
1706
9d7a8ab3736b 6962589: remove breadth first scanning code from parallel gc
tonyp
parents: 1612
diff changeset
303 pm->drain_stacks_cond_depth();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305 last_scanned = p;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // "current_card" is still the "following_clean_card" or
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // the current_card is >= the worker_end_card so the
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // loop will not execute again.
a61af66fc99e Initial load
duke
parents:
diff changeset
310 assert((current_card == following_clean_card) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
311 (current_card >= worker_end_card),
a61af66fc99e Initial load
duke
parents:
diff changeset
312 "current_card should only be incremented if it still equals "
a61af66fc99e Initial load
duke
parents:
diff changeset
313 "following_clean_card");
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // Increment current_card so that it is not processed again.
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // It may now be dirty because a old-to-young pointer was
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // found on it an updated. If it is now dirty, it cannot be
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // be safely cleaned in the next iteration.
a61af66fc99e Initial load
duke
parents:
diff changeset
318 current_card++;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // This should be called before a scavenge.
a61af66fc99e Initial load
duke
parents:
diff changeset
324 void CardTableExtension::verify_all_young_refs_imprecise() {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 CheckForUnmarkedObjects check;
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
328 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 PSOldGen* old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 old_gen->object_iterate(&check);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 }
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // This should be called immediately after a scavenge, before mutators resume.
a61af66fc99e Initial load
duke
parents:
diff changeset
336 void CardTableExtension::verify_all_young_refs_precise() {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 PSOldGen* old_gen = heap->old_gen();
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 CheckForPreciseMarks check(heap->young_gen(), (CardTableExtension*)heap->barrier_set());
a61af66fc99e Initial load
duke
parents:
diff changeset
343
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6009
diff changeset
344 old_gen->oop_iterate_no_header(&check);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 verify_all_young_refs_precise_helper(old_gen->object_space()->used_region());
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 void CardTableExtension::verify_all_young_refs_precise_helper(MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 CardTableExtension* card_table = (CardTableExtension*)Universe::heap()->barrier_set();
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // FIX ME ASSERT HERE
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 jbyte* bot = card_table->byte_for(mr.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
354 jbyte* top = card_table->byte_for(mr.end());
a61af66fc99e Initial load
duke
parents:
diff changeset
355 while(bot <= top) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 assert(*bot == clean_card || *bot == verify_card, "Found unwanted or unknown card mark");
a61af66fc99e Initial load
duke
parents:
diff changeset
357 if (*bot == verify_card)
a61af66fc99e Initial load
duke
parents:
diff changeset
358 *bot = youngergen_card;
a61af66fc99e Initial load
duke
parents:
diff changeset
359 bot++;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 bool CardTableExtension::addr_is_marked_imprecise(void *addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 jbyte* p = byte_for(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 jbyte val = *p;
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 if (card_is_dirty(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
368 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 if (card_is_newgen(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
371 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 if (card_is_clean(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
374 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 assert(false, "Found unhandled card mark type");
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // Also includes verify_card
a61af66fc99e Initial load
duke
parents:
diff changeset
382 bool CardTableExtension::addr_is_marked_precise(void *addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 jbyte* p = byte_for(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 jbyte val = *p;
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 if (card_is_newgen(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
387 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 if (card_is_verify(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
390 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 if (card_is_clean(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
393 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
394
a61af66fc99e Initial load
duke
parents:
diff changeset
395 if (card_is_dirty(val))
a61af66fc99e Initial load
duke
parents:
diff changeset
396 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 assert(false, "Found unhandled card mark type");
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Assumes that only the base or the end changes. This allows indentification
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // of the region that is being resized. The
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // CardTableModRefBS::resize_covered_region() is used for the normal case
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // where the covered regions are growing or shrinking at the high end.
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // The method resize_covered_region_by_end() is analogous to
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // CardTableModRefBS::resize_covered_region() but
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // for regions that grow or shrink at the low end.
a61af66fc99e Initial load
duke
parents:
diff changeset
410 void CardTableExtension::resize_covered_region(MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 for (int i = 0; i < _cur_covered_regions; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
413 if (_covered[i].start() == new_region.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // Found a covered region with the same start as the
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // new region. The region is growing or shrinking
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // from the start of the region.
a61af66fc99e Initial load
duke
parents:
diff changeset
417 resize_covered_region_by_start(new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
420 if (_covered[i].start() > new_region.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
421 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 int changed_region = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
426 for (int j = 0; j < _cur_covered_regions; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 if (_covered[j].end() == new_region.end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 changed_region = j;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // This is a case where the covered region is growing or shrinking
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // at the start of the region.
a61af66fc99e Initial load
duke
parents:
diff changeset
431 assert(changed_region != -1, "Don't expect to add a covered region");
a61af66fc99e Initial load
duke
parents:
diff changeset
432 assert(_covered[changed_region].byte_size() != new_region.byte_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
433 "The sizes should be different here");
a61af66fc99e Initial load
duke
parents:
diff changeset
434 resize_covered_region_by_end(changed_region, new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // This should only be a new covered region (where no existing
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // covered region matches at the start or the end).
a61af66fc99e Initial load
duke
parents:
diff changeset
440 assert(_cur_covered_regions < _max_covered_regions,
a61af66fc99e Initial load
duke
parents:
diff changeset
441 "An existing region should have been found");
a61af66fc99e Initial load
duke
parents:
diff changeset
442 resize_covered_region_by_start(new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 void CardTableExtension::resize_covered_region_by_start(MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 CardTableModRefBS::resize_covered_region(new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
447 debug_only(verify_guard();)
a61af66fc99e Initial load
duke
parents:
diff changeset
448 }
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 void CardTableExtension::resize_covered_region_by_end(int changed_region,
a61af66fc99e Initial load
duke
parents:
diff changeset
451 MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 assert(SafepointSynchronize::is_at_safepoint(),
a61af66fc99e Initial load
duke
parents:
diff changeset
453 "Only expect an expansion at the low end at a GC");
a61af66fc99e Initial load
duke
parents:
diff changeset
454 debug_only(verify_guard();)
a61af66fc99e Initial load
duke
parents:
diff changeset
455 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
456 for (int k = 0; k < _cur_covered_regions; k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
457 if (_covered[k].end() == new_region.end()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
458 assert(changed_region == k, "Changed region is incorrect");
a61af66fc99e Initial load
duke
parents:
diff changeset
459 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Commit new or uncommit old pages, if necessary.
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
465 if (resize_commit_uncommit(changed_region, new_region)) {
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
466 // Set the new start of the committed region
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
467 resize_update_committed_table(changed_region, new_region);
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
468 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // Update card table entries
a61af66fc99e Initial load
duke
parents:
diff changeset
471 resize_update_card_table_entries(changed_region, new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // Update the covered region
a61af66fc99e Initial load
duke
parents:
diff changeset
474 resize_update_covered_table(changed_region, new_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
475
a61af66fc99e Initial load
duke
parents:
diff changeset
476 if (TraceCardTableModRefBS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 int ind = changed_region;
a61af66fc99e Initial load
duke
parents:
diff changeset
478 gclog_or_tty->print_cr("CardTableModRefBS::resize_covered_region: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
479 gclog_or_tty->print_cr(" "
a61af66fc99e Initial load
duke
parents:
diff changeset
480 " _covered[%d].start(): " INTPTR_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
481 " _covered[%d].last(): " INTPTR_FORMAT,
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
482 ind, p2i(_covered[ind].start()),
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
483 ind, p2i(_covered[ind].last()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
484 gclog_or_tty->print_cr(" "
a61af66fc99e Initial load
duke
parents:
diff changeset
485 " _committed[%d].start(): " INTPTR_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
486 " _committed[%d].last(): " INTPTR_FORMAT,
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
487 ind, p2i(_committed[ind].start()),
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
488 ind, p2i(_committed[ind].last()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
489 gclog_or_tty->print_cr(" "
a61af66fc99e Initial load
duke
parents:
diff changeset
490 " byte_for(start): " INTPTR_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
491 " byte_for(last): " INTPTR_FORMAT,
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
492 p2i(byte_for(_covered[ind].start())),
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
493 p2i(byte_for(_covered[ind].last())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
494 gclog_or_tty->print_cr(" "
a61af66fc99e Initial load
duke
parents:
diff changeset
495 " addr_for(start): " INTPTR_FORMAT
a61af66fc99e Initial load
duke
parents:
diff changeset
496 " addr_for(last): " INTPTR_FORMAT,
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
497 p2i(addr_for((jbyte*) _committed[ind].start())),
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 10969
diff changeset
498 p2i(addr_for((jbyte*) _committed[ind].last())));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 debug_only(verify_guard();)
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
503 bool CardTableExtension::resize_commit_uncommit(int changed_region,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
504 MemRegion new_region) {
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
505 bool result = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // Commit new or uncommit old pages, if necessary.
a61af66fc99e Initial load
duke
parents:
diff changeset
507 MemRegion cur_committed = _committed[changed_region];
a61af66fc99e Initial load
duke
parents:
diff changeset
508 assert(_covered[changed_region].end() == new_region.end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
509 "The ends of the regions are expected to match");
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // Extend the start of this _committed region to
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // to cover the start of any previous _committed region.
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // This forms overlapping regions, but never interior regions.
a61af66fc99e Initial load
duke
parents:
diff changeset
513 HeapWord* min_prev_start = lowest_prev_committed_start(changed_region);
a61af66fc99e Initial load
duke
parents:
diff changeset
514 if (min_prev_start < cur_committed.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // Only really need to set start of "cur_committed" to
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // the new start (min_prev_start) but assertion checking code
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // below use cur_committed.end() so make it correct.
a61af66fc99e Initial load
duke
parents:
diff changeset
518 MemRegion new_committed =
a61af66fc99e Initial load
duke
parents:
diff changeset
519 MemRegion(min_prev_start, cur_committed.end());
a61af66fc99e Initial load
duke
parents:
diff changeset
520 cur_committed = new_committed;
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
523 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
524 assert(cur_committed.start() ==
a61af66fc99e Initial load
duke
parents:
diff changeset
525 (HeapWord*) align_size_up((uintptr_t) cur_committed.start(),
a61af66fc99e Initial load
duke
parents:
diff changeset
526 os::vm_page_size()),
a61af66fc99e Initial load
duke
parents:
diff changeset
527 "Starts should have proper alignment");
a61af66fc99e Initial load
duke
parents:
diff changeset
528 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 jbyte* new_start = byte_for(new_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
531 // Round down because this is for the start address
a61af66fc99e Initial load
duke
parents:
diff changeset
532 HeapWord* new_start_aligned =
a61af66fc99e Initial load
duke
parents:
diff changeset
533 (HeapWord*)align_size_down((uintptr_t)new_start, os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
534 // The guard page is always committed and should not be committed over.
a61af66fc99e Initial load
duke
parents:
diff changeset
535 // This method is used in cases where the generation is growing toward
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // lower addresses but the guard region is still at the end of the
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // card table. That still makes sense when looking for writes
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // off the end of the card table.
a61af66fc99e Initial load
duke
parents:
diff changeset
539 if (new_start_aligned < cur_committed.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // Expand the committed region
a61af66fc99e Initial load
duke
parents:
diff changeset
541 //
a61af66fc99e Initial load
duke
parents:
diff changeset
542 // Case A
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // |+ guard +|
a61af66fc99e Initial load
duke
parents:
diff changeset
544 // |+ cur committed +++++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // |+ new committed +++++++++++++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
546 //
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // Case B
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // |+ guard +|
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // |+ cur committed +|
a61af66fc99e Initial load
duke
parents:
diff changeset
550 // |+ new committed +++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
551 //
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // These are not expected because the calculation of the
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // cur committed region and the new committed region
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // share the same end for the covered region.
a61af66fc99e Initial load
duke
parents:
diff changeset
555 // Case C
a61af66fc99e Initial load
duke
parents:
diff changeset
556 // |+ guard +|
a61af66fc99e Initial load
duke
parents:
diff changeset
557 // |+ cur committed +|
a61af66fc99e Initial load
duke
parents:
diff changeset
558 // |+ new committed +++++++++++++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
559 // Case D
a61af66fc99e Initial load
duke
parents:
diff changeset
560 // |+ guard +|
a61af66fc99e Initial load
duke
parents:
diff changeset
561 // |+ cur committed +++++++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // |+ new committed +++++++|
a61af66fc99e Initial load
duke
parents:
diff changeset
563
a61af66fc99e Initial load
duke
parents:
diff changeset
564 HeapWord* new_end_for_commit =
a61af66fc99e Initial load
duke
parents:
diff changeset
565 MIN2(cur_committed.end(), _guard_region.start());
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
566 if(new_start_aligned < new_end_for_commit) {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
567 MemRegion new_committed =
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents: 113
diff changeset
568 MemRegion(new_start_aligned, new_end_for_commit);
10969
a837fa3d3f86 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 10161
diff changeset
569 os::commit_memory_or_exit((char*)new_committed.start(),
a837fa3d3f86 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 10161
diff changeset
570 new_committed.byte_size(), !ExecMem,
a837fa3d3f86 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 10161
diff changeset
571 "card table expansion");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
572 }
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
573 result = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
574 } else if (new_start_aligned > cur_committed.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
575 // Shrink the committed region
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
576 #if 0 // uncommitting space is currently unsafe because of the interactions
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
577 // of growing and shrinking regions. One region A can uncommit space
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
578 // that it owns but which is being used by another region B (maybe).
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
579 // Region B has not committed the space because it was already
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
580 // committed by region A.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
581 MemRegion uncommit_region = committed_unique_to_self(changed_region,
a61af66fc99e Initial load
duke
parents:
diff changeset
582 MemRegion(cur_committed.start(), new_start_aligned));
a61af66fc99e Initial load
duke
parents:
diff changeset
583 if (!uncommit_region.is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
584 if (!os::uncommit_memory((char*)uncommit_region.start(),
a61af66fc99e Initial load
duke
parents:
diff changeset
585 uncommit_region.byte_size())) {
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
586 // If the uncommit fails, ignore it. Let the
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
587 // committed table resizing go even though the committed
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
588 // table will over state the committed space.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590 }
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
591 #else
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
592 assert(!result, "Should be false with current workaround");
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
593 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
594 }
a61af66fc99e Initial load
duke
parents:
diff changeset
595 assert(_committed[changed_region].end() == cur_committed.end(),
a61af66fc99e Initial load
duke
parents:
diff changeset
596 "end should not change");
1612
fdde661c8e06 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 1552
diff changeset
597 return result;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 void CardTableExtension::resize_update_committed_table(int changed_region,
a61af66fc99e Initial load
duke
parents:
diff changeset
601 MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
602
a61af66fc99e Initial load
duke
parents:
diff changeset
603 jbyte* new_start = byte_for(new_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
604 // Set the new start of the committed region
a61af66fc99e Initial load
duke
parents:
diff changeset
605 HeapWord* new_start_aligned =
a61af66fc99e Initial load
duke
parents:
diff changeset
606 (HeapWord*)align_size_down((uintptr_t)new_start,
a61af66fc99e Initial load
duke
parents:
diff changeset
607 os::vm_page_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
608 MemRegion new_committed = MemRegion(new_start_aligned,
a61af66fc99e Initial load
duke
parents:
diff changeset
609 _committed[changed_region].end());
a61af66fc99e Initial load
duke
parents:
diff changeset
610 _committed[changed_region] = new_committed;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 _committed[changed_region].set_start(new_start_aligned);
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613
a61af66fc99e Initial load
duke
parents:
diff changeset
614 void CardTableExtension::resize_update_card_table_entries(int changed_region,
a61af66fc99e Initial load
duke
parents:
diff changeset
615 MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 debug_only(verify_guard();)
a61af66fc99e Initial load
duke
parents:
diff changeset
617 MemRegion original_covered = _covered[changed_region];
a61af66fc99e Initial load
duke
parents:
diff changeset
618 // Initialize the card entries. Only consider the
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // region covered by the card table (_whole_heap)
a61af66fc99e Initial load
duke
parents:
diff changeset
620 jbyte* entry;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 if (new_region.start() < _whole_heap.start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
622 entry = byte_for(_whole_heap.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
623 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 entry = byte_for(new_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626 jbyte* end = byte_for(original_covered.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
627 // If _whole_heap starts at the original covered regions start,
a61af66fc99e Initial load
duke
parents:
diff changeset
628 // this loop will not execute.
a61af66fc99e Initial load
duke
parents:
diff changeset
629 while (entry < end) { *entry++ = clean_card; }
a61af66fc99e Initial load
duke
parents:
diff changeset
630 }
a61af66fc99e Initial load
duke
parents:
diff changeset
631
a61af66fc99e Initial load
duke
parents:
diff changeset
632 void CardTableExtension::resize_update_covered_table(int changed_region,
a61af66fc99e Initial load
duke
parents:
diff changeset
633 MemRegion new_region) {
a61af66fc99e Initial load
duke
parents:
diff changeset
634 // Update the covered region
a61af66fc99e Initial load
duke
parents:
diff changeset
635 _covered[changed_region].set_start(new_region.start());
a61af66fc99e Initial load
duke
parents:
diff changeset
636 _covered[changed_region].set_word_size(new_region.word_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
637
a61af66fc99e Initial load
duke
parents:
diff changeset
638 // reorder regions. There should only be at most 1 out
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // of order.
a61af66fc99e Initial load
duke
parents:
diff changeset
640 for (int i = _cur_covered_regions-1 ; i > 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
641 if (_covered[i].start() < _covered[i-1].start()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
642 MemRegion covered_mr = _covered[i-1];
a61af66fc99e Initial load
duke
parents:
diff changeset
643 _covered[i-1] = _covered[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
644 _covered[i] = covered_mr;
a61af66fc99e Initial load
duke
parents:
diff changeset
645 MemRegion committed_mr = _committed[i-1];
a61af66fc99e Initial load
duke
parents:
diff changeset
646 _committed[i-1] = _committed[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
647 _committed[i] = committed_mr;
a61af66fc99e Initial load
duke
parents:
diff changeset
648 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
651 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
652 for (int m = 0; m < _cur_covered_regions-1; m++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
653 assert(_covered[m].start() <= _covered[m+1].start(),
a61af66fc99e Initial load
duke
parents:
diff changeset
654 "Covered regions out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
655 assert(_committed[m].start() <= _committed[m+1].start(),
a61af66fc99e Initial load
duke
parents:
diff changeset
656 "Committed regions out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
657 }
a61af66fc99e Initial load
duke
parents:
diff changeset
658 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
660
a61af66fc99e Initial load
duke
parents:
diff changeset
661 // Returns the start of any committed region that is lower than
a61af66fc99e Initial load
duke
parents:
diff changeset
662 // the target committed region (index ind) and that intersects the
a61af66fc99e Initial load
duke
parents:
diff changeset
663 // target region. If none, return start of target region.
a61af66fc99e Initial load
duke
parents:
diff changeset
664 //
a61af66fc99e Initial load
duke
parents:
diff changeset
665 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
666 // | |
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
668 // ------------
a61af66fc99e Initial load
duke
parents:
diff changeset
669 // | target |
a61af66fc99e Initial load
duke
parents:
diff changeset
670 // ------------
a61af66fc99e Initial load
duke
parents:
diff changeset
671 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // | |
a61af66fc99e Initial load
duke
parents:
diff changeset
673 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
674 // ^ returns this
a61af66fc99e Initial load
duke
parents:
diff changeset
675 //
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
677 // | |
a61af66fc99e Initial load
duke
parents:
diff changeset
678 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
679 // ------------
a61af66fc99e Initial load
duke
parents:
diff changeset
680 // | target |
a61af66fc99e Initial load
duke
parents:
diff changeset
681 // ------------
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
683 // | |
a61af66fc99e Initial load
duke
parents:
diff changeset
684 // -------------
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // ^ returns this
a61af66fc99e Initial load
duke
parents:
diff changeset
686
a61af66fc99e Initial load
duke
parents:
diff changeset
687 HeapWord* CardTableExtension::lowest_prev_committed_start(int ind) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
688 assert(_cur_covered_regions >= 0, "Expecting at least on region");
a61af66fc99e Initial load
duke
parents:
diff changeset
689 HeapWord* min_start = _committed[ind].start();
a61af66fc99e Initial load
duke
parents:
diff changeset
690 for (int j = 0; j < ind; j++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 HeapWord* this_start = _committed[j].start();
a61af66fc99e Initial load
duke
parents:
diff changeset
692 if ((this_start < min_start) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
693 !(_committed[j].intersection(_committed[ind])).is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 min_start = this_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
696 }
a61af66fc99e Initial load
duke
parents:
diff changeset
697 return min_start;
a61af66fc99e Initial load
duke
parents:
diff changeset
698 }