Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/g1/satbQueue.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4ca6dc0799b6 78bbf4d43a14 |
children | 7848fc12602b |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
30 #include "oops/oop.inline.hpp" | 30 #include "oops/oop.inline.hpp" |
31 #include "runtime/mutexLocker.hpp" | 31 #include "runtime/mutexLocker.hpp" |
32 #include "runtime/thread.hpp" | 32 #include "runtime/thread.hpp" |
33 #include "runtime/vmThread.hpp" | 33 #include "runtime/vmThread.hpp" |
34 | 34 |
35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC | |
36 | |
35 void ObjPtrQueue::flush() { | 37 void ObjPtrQueue::flush() { |
36 // The buffer might contain refs into the CSet. We have to filter it | 38 // The buffer might contain refs into the CSet. We have to filter it |
37 // first before we flush it, otherwise we might end up with an | 39 // first before we flush it, otherwise we might end up with an |
38 // enqueued buffer with refs into the CSet which breaks our invariants. | 40 // enqueued buffer with refs into the CSet which breaks our invariants. |
39 filter(); | 41 filter(); |
217 DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();) | 219 DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();) |
218 t->satb_mark_queue().handle_zero_index(); | 220 t->satb_mark_queue().handle_zero_index(); |
219 } | 221 } |
220 | 222 |
221 #ifdef ASSERT | 223 #ifdef ASSERT |
222 void SATBMarkQueueSet::dump_active_values(JavaThread* first, | 224 void SATBMarkQueueSet::dump_active_states(bool expected_active) { |
223 bool expected_active) { | 225 gclog_or_tty->print_cr("Expected SATB active state: %s", |
224 gclog_or_tty->print_cr("SATB queue active values for Java Threads"); | 226 expected_active ? "ACTIVE" : "INACTIVE"); |
225 gclog_or_tty->print_cr(" SATB queue set: active is %s", | 227 gclog_or_tty->print_cr("Actual SATB active states:"); |
226 (is_active()) ? "TRUE" : "FALSE"); | 228 gclog_or_tty->print_cr(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE"); |
227 gclog_or_tty->print_cr(" expected_active is %s", | 229 for (JavaThread* t = Threads::first(); t; t = t->next()) { |
228 (expected_active) ? "TRUE" : "FALSE"); | 230 gclog_or_tty->print_cr(" Thread \"%s\" queue: %s", t->name(), |
229 for (JavaThread* t = first; t; t = t->next()) { | 231 t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE"); |
230 bool active = t->satb_mark_queue().is_active(); | 232 } |
231 gclog_or_tty->print_cr(" thread %s, active is %s", | 233 gclog_or_tty->print_cr(" Shared queue: %s", |
232 t->name(), (active) ? "TRUE" : "FALSE"); | 234 shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE"); |
235 } | |
236 | |
237 void SATBMarkQueueSet::verify_active_states(bool expected_active) { | |
238 // Verify queue set state | |
239 if (is_active() != expected_active) { | |
240 dump_active_states(expected_active); | |
241 guarantee(false, "SATB queue set has an unexpected active state"); | |
242 } | |
243 | |
244 // Verify thread queue states | |
245 for (JavaThread* t = Threads::first(); t; t = t->next()) { | |
246 if (t->satb_mark_queue().is_active() != expected_active) { | |
247 dump_active_states(expected_active); | |
248 guarantee(false, "Thread SATB queue has an unexpected active state"); | |
249 } | |
250 } | |
251 | |
252 // Verify shared queue state | |
253 if (shared_satb_queue()->is_active() != expected_active) { | |
254 dump_active_states(expected_active); | |
255 guarantee(false, "Shared SATB queue has an unexpected active state"); | |
233 } | 256 } |
234 } | 257 } |
235 #endif // ASSERT | 258 #endif // ASSERT |
236 | 259 |
237 void SATBMarkQueueSet::set_active_all_threads(bool b, | 260 void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) { |
238 bool expected_active) { | |
239 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); | 261 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
240 JavaThread* first = Threads::first(); | |
241 | |
242 #ifdef ASSERT | 262 #ifdef ASSERT |
243 if (_all_active != expected_active) { | 263 verify_active_states(expected_active); |
244 dump_active_values(first, expected_active); | |
245 | |
246 // I leave this here as a guarantee, instead of an assert, so | |
247 // that it will still be compiled in if we choose to uncomment | |
248 // the #ifdef ASSERT in a product build. The whole block is | |
249 // within an #ifdef ASSERT so the guarantee will not be compiled | |
250 // in a product build anyway. | |
251 guarantee(false, | |
252 "SATB queue set has an unexpected active value"); | |
253 } | |
254 #endif // ASSERT | 264 #endif // ASSERT |
255 _all_active = b; | 265 _all_active = active; |
256 | 266 for (JavaThread* t = Threads::first(); t; t = t->next()) { |
257 for (JavaThread* t = first; t; t = t->next()) { | 267 t->satb_mark_queue().set_active(active); |
258 #ifdef ASSERT | 268 } |
259 bool active = t->satb_mark_queue().is_active(); | 269 shared_satb_queue()->set_active(active); |
260 if (active != expected_active) { | |
261 dump_active_values(first, expected_active); | |
262 | |
263 // I leave this here as a guarantee, instead of an assert, so | |
264 // that it will still be compiled in if we choose to uncomment | |
265 // the #ifdef ASSERT in a product build. The whole block is | |
266 // within an #ifdef ASSERT so the guarantee will not be compiled | |
267 // in a product build anyway. | |
268 guarantee(false, | |
269 "thread has an unexpected active value in its SATB queue"); | |
270 } | |
271 #endif // ASSERT | |
272 t->satb_mark_queue().set_active(b); | |
273 } | |
274 } | 270 } |
275 | 271 |
276 void SATBMarkQueueSet::filter_thread_buffers() { | 272 void SATBMarkQueueSet::filter_thread_buffers() { |
277 for(JavaThread* t = Threads::first(); t; t = t->next()) { | 273 for(JavaThread* t = Threads::first(); t; t = t->next()) { |
278 t->satb_mark_queue().filter(); | 274 t->satb_mark_queue().filter(); |
294 t->satb_mark_queue().apply_closure_and_empty(_closure); | 290 t->satb_mark_queue().apply_closure_and_empty(_closure); |
295 } | 291 } |
296 shared_satb_queue()->apply_closure_and_empty(_closure); | 292 shared_satb_queue()->apply_closure_and_empty(_closure); |
297 } | 293 } |
298 | 294 |
299 void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) { | 295 void SATBMarkQueueSet::par_iterate_closure_all_threads(uint worker) { |
300 SharedHeap* sh = SharedHeap::heap(); | 296 SharedHeap* sh = SharedHeap::heap(); |
301 int parity = sh->strong_roots_parity(); | 297 int parity = sh->strong_roots_parity(); |
302 | 298 |
303 for(JavaThread* t = Threads::first(); t; t = t->next()) { | 299 for(JavaThread* t = Threads::first(); t; t = t->next()) { |
304 if (t->claim_oops_do(true, parity)) { | 300 if (t->claim_oops_do(true, parity)) { |
319 shared_satb_queue()->apply_closure_and_empty(_par_closures[worker]); | 315 shared_satb_queue()->apply_closure_and_empty(_par_closures[worker]); |
320 } | 316 } |
321 } | 317 } |
322 | 318 |
323 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, | 319 bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
324 int worker) { | 320 uint worker) { |
325 BufferNode* nd = NULL; | 321 BufferNode* nd = NULL; |
326 { | 322 { |
327 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); | 323 MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
328 if (_completed_buffers_head != NULL) { | 324 if (_completed_buffers_head != NULL) { |
329 nd = _completed_buffers_head; | 325 nd = _completed_buffers_head; |