Mercurial > hg > graal-jvmci-8
annotate src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp @ 1779:6eddcbe17c83
6981746: G1: SEGV with -XX:+TraceGen0Time
Summary: Pass correct value for length to NumberSeq constructor. Guard dereferences of "body_summary" pointer with a NULL check.
Reviewed-by: tonyp, ysr
author | johnc |
---|---|
date | Mon, 13 Sep 2010 10:00:24 -0700 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
342 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1317
diff
changeset
|
2 * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved. |
342 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1317
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1317
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:
1317
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_g1SATBCardTableModRefBS.cpp.incl" | |
27 | |
28 G1SATBCardTableModRefBS::G1SATBCardTableModRefBS(MemRegion whole_heap, | |
29 int max_covered_regions) : | |
30 CardTableModRefBSForCTRS(whole_heap, max_covered_regions) | |
31 { | |
32 _kind = G1SATBCT; | |
33 } | |
34 | |
35 | |
36 void G1SATBCardTableModRefBS::enqueue(oop pre_val) { | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
37 assert(pre_val->is_oop_or_null(true), "Error"); |
1317
d4197f8d516a
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
845
diff
changeset
|
38 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
342 | 39 Thread* thr = Thread::current(); |
40 if (thr->is_Java_thread()) { | |
41 JavaThread* jt = (JavaThread*)thr; | |
42 jt->satb_mark_queue().enqueue(pre_val); | |
43 } else { | |
44 MutexLocker x(Shared_SATB_Q_lock); | |
45 JavaThread::satb_mark_queue_set().shared_satb_queue()->enqueue(pre_val); | |
46 } | |
47 } | |
48 | |
49 // When we know the current java thread: | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
50 template <class T> void |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
51 G1SATBCardTableModRefBS::write_ref_field_pre_static(T* field, |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
52 oop new_val, |
342 | 53 JavaThread* jt) { |
1317
d4197f8d516a
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
845
diff
changeset
|
54 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
55 T heap_oop = oopDesc::load_heap_oop(field); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
56 if (!oopDesc::is_null(heap_oop)) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
57 oop pre_val = oopDesc::decode_heap_oop_not_null(heap_oop); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
58 assert(pre_val->is_oop(true /* ignore mark word */), "Error"); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
59 jt->satb_mark_queue().enqueue(pre_val); |
342 | 60 } |
61 } | |
62 | |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
63 template <class T> void |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
64 G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) { |
1317
d4197f8d516a
6935821: G1: threads created during marking do not active their SATB queues
tonyp
parents:
845
diff
changeset
|
65 if (!JavaThread::satb_mark_queue_set().is_active()) return; |
845
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
66 T* elem_ptr = dst; |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
67 for (int i = 0; i < count; i++, elem_ptr++) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
68 T heap_oop = oopDesc::load_heap_oop(elem_ptr); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
69 if (!oopDesc::is_null(heap_oop)) { |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
70 enqueue(oopDesc::decode_heap_oop_not_null(heap_oop)); |
df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents:
342
diff
changeset
|
71 } |
342 | 72 } |
73 } | |
74 | |
75 G1SATBCardTableLoggingModRefBS:: | |
76 G1SATBCardTableLoggingModRefBS(MemRegion whole_heap, | |
77 int max_covered_regions) : | |
78 G1SATBCardTableModRefBS(whole_heap, max_covered_regions), | |
79 _dcqs(JavaThread::dirty_card_queue_set()) | |
80 { | |
81 _kind = G1SATBCTLogging; | |
82 } | |
83 | |
84 void | |
85 G1SATBCardTableLoggingModRefBS::write_ref_field_work(void* field, | |
86 oop new_val) { | |
87 jbyte* byte = byte_for(field); | |
88 if (*byte != dirty_card) { | |
89 *byte = dirty_card; | |
90 Thread* thr = Thread::current(); | |
91 if (thr->is_Java_thread()) { | |
92 JavaThread* jt = (JavaThread*)thr; | |
93 jt->dirty_card_queue().enqueue(byte); | |
94 } else { | |
95 MutexLockerEx x(Shared_DirtyCardQ_lock, | |
96 Mutex::_no_safepoint_check_flag); | |
97 _dcqs.shared_dirty_card_queue()->enqueue(byte); | |
98 } | |
99 } | |
100 } | |
101 | |
102 void | |
103 G1SATBCardTableLoggingModRefBS::write_ref_field_static(void* field, | |
104 oop new_val) { | |
105 uintptr_t field_uint = (uintptr_t)field; | |
106 uintptr_t new_val_uint = (uintptr_t)new_val; | |
107 uintptr_t comb = field_uint ^ new_val_uint; | |
108 comb = comb >> HeapRegion::LogOfHRGrainBytes; | |
109 if (comb == 0) return; | |
110 if (new_val == NULL) return; | |
111 // Otherwise, log it. | |
112 G1SATBCardTableLoggingModRefBS* g1_bs = | |
113 (G1SATBCardTableLoggingModRefBS*)Universe::heap()->barrier_set(); | |
114 g1_bs->write_ref_field_work(field, new_val); | |
115 } | |
116 | |
117 void | |
118 G1SATBCardTableLoggingModRefBS::invalidate(MemRegion mr, bool whole_heap) { | |
119 jbyte* byte = byte_for(mr.start()); | |
120 jbyte* last_byte = byte_for(mr.last()); | |
121 Thread* thr = Thread::current(); | |
122 if (whole_heap) { | |
123 while (byte <= last_byte) { | |
124 *byte = dirty_card; | |
125 byte++; | |
126 } | |
127 } else { | |
128 // Enqueue if necessary. | |
129 if (thr->is_Java_thread()) { | |
130 JavaThread* jt = (JavaThread*)thr; | |
131 while (byte <= last_byte) { | |
132 if (*byte != dirty_card) { | |
133 *byte = dirty_card; | |
134 jt->dirty_card_queue().enqueue(byte); | |
135 } | |
136 byte++; | |
137 } | |
138 } else { | |
139 MutexLockerEx x(Shared_DirtyCardQ_lock, | |
140 Mutex::_no_safepoint_check_flag); | |
141 while (byte <= last_byte) { | |
142 if (*byte != dirty_card) { | |
143 *byte = dirty_card; | |
144 _dcqs.shared_dirty_card_queue()->enqueue(byte); | |
145 } | |
146 byte++; | |
147 } | |
148 } | |
149 } | |
150 } |