Thu, 12 Oct 2017 21:27:07 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
aoqi@0 | 27 | #include "gc_implementation/g1/satbQueue.hpp" |
aoqi@0 | 28 | #include "memory/allocation.inline.hpp" |
aoqi@0 | 29 | #include "memory/sharedHeap.hpp" |
aoqi@0 | 30 | #include "oops/oop.inline.hpp" |
aoqi@0 | 31 | #include "runtime/mutexLocker.hpp" |
aoqi@0 | 32 | #include "runtime/thread.hpp" |
aoqi@0 | 33 | #include "runtime/vmThread.hpp" |
aoqi@0 | 34 | |
aoqi@0 | 35 | PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
aoqi@0 | 36 | |
aoqi@0 | 37 | void ObjPtrQueue::flush() { |
aoqi@0 | 38 | // The buffer might contain refs into the CSet. We have to filter it |
aoqi@0 | 39 | // first before we flush it, otherwise we might end up with an |
aoqi@0 | 40 | // enqueued buffer with refs into the CSet which breaks our invariants. |
aoqi@0 | 41 | filter(); |
tschatzl@7445 | 42 | flush_impl(); |
aoqi@0 | 43 | } |
aoqi@0 | 44 | |
aoqi@0 | 45 | // This method removes entries from an SATB buffer that will not be |
aoqi@0 | 46 | // useful to the concurrent marking threads. An entry is removed if it |
aoqi@0 | 47 | // satisfies one of the following conditions: |
aoqi@0 | 48 | // |
aoqi@0 | 49 | // * it points to an object outside the G1 heap (G1's concurrent |
aoqi@0 | 50 | // marking only visits objects inside the G1 heap), |
aoqi@0 | 51 | // * it points to an object that has been allocated since marking |
aoqi@0 | 52 | // started (according to SATB those objects do not need to be |
aoqi@0 | 53 | // visited during marking), or |
aoqi@0 | 54 | // * it points to an object that has already been marked (no need to |
aoqi@0 | 55 | // process it again). |
aoqi@0 | 56 | // |
aoqi@0 | 57 | // The rest of the entries will be retained and are compacted towards |
aoqi@0 | 58 | // the top of the buffer. Note that, because we do not allow old |
aoqi@0 | 59 | // regions in the CSet during marking, all objects on the CSet regions |
aoqi@0 | 60 | // are young (eden or survivors) and therefore implicitly live. So any |
aoqi@0 | 61 | // references into the CSet will be removed during filtering. |
aoqi@0 | 62 | |
aoqi@0 | 63 | void ObjPtrQueue::filter() { |
aoqi@0 | 64 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); |
aoqi@0 | 65 | void** buf = _buf; |
aoqi@0 | 66 | size_t sz = _sz; |
aoqi@0 | 67 | |
aoqi@0 | 68 | if (buf == NULL) { |
aoqi@0 | 69 | // nothing to do |
aoqi@0 | 70 | return; |
aoqi@0 | 71 | } |
aoqi@0 | 72 | |
aoqi@0 | 73 | // Used for sanity checking at the end of the loop. |
aoqi@0 | 74 | debug_only(size_t entries = 0; size_t retained = 0;) |
aoqi@0 | 75 | |
aoqi@0 | 76 | size_t i = sz; |
aoqi@0 | 77 | size_t new_index = sz; |
aoqi@0 | 78 | |
aoqi@0 | 79 | while (i > _index) { |
aoqi@0 | 80 | assert(i > 0, "we should have at least one more entry to process"); |
aoqi@0 | 81 | i -= oopSize; |
aoqi@0 | 82 | debug_only(entries += 1;) |
aoqi@0 | 83 | oop* p = (oop*) &buf[byte_index_to_index((int) i)]; |
aoqi@0 | 84 | oop obj = *p; |
aoqi@0 | 85 | // NULL the entry so that unused parts of the buffer contain NULLs |
aoqi@0 | 86 | // at the end. If we are going to retain it we will copy it to its |
aoqi@0 | 87 | // final place. If we have retained all entries we have visited so |
aoqi@0 | 88 | // far, we'll just end up copying it to the same place. |
aoqi@0 | 89 | *p = NULL; |
aoqi@0 | 90 | |
aoqi@0 | 91 | bool retain = g1h->is_obj_ill(obj); |
aoqi@0 | 92 | if (retain) { |
aoqi@0 | 93 | assert(new_index > 0, "we should not have already filled up the buffer"); |
aoqi@0 | 94 | new_index -= oopSize; |
aoqi@0 | 95 | assert(new_index >= i, |
aoqi@0 | 96 | "new_index should never be below i, as we alwaysr compact 'up'"); |
aoqi@0 | 97 | oop* new_p = (oop*) &buf[byte_index_to_index((int) new_index)]; |
aoqi@0 | 98 | assert(new_p >= p, "the destination location should never be below " |
aoqi@0 | 99 | "the source as we always compact 'up'"); |
aoqi@0 | 100 | assert(*new_p == NULL, |
aoqi@0 | 101 | "we should have already cleared the destination location"); |
aoqi@0 | 102 | *new_p = obj; |
aoqi@0 | 103 | debug_only(retained += 1;) |
aoqi@0 | 104 | } |
aoqi@0 | 105 | } |
aoqi@0 | 106 | |
aoqi@0 | 107 | #ifdef ASSERT |
aoqi@0 | 108 | size_t entries_calc = (sz - _index) / oopSize; |
aoqi@0 | 109 | assert(entries == entries_calc, "the number of entries we counted " |
aoqi@0 | 110 | "should match the number of entries we calculated"); |
aoqi@0 | 111 | size_t retained_calc = (sz - new_index) / oopSize; |
aoqi@0 | 112 | assert(retained == retained_calc, "the number of retained entries we counted " |
aoqi@0 | 113 | "should match the number of retained entries we calculated"); |
aoqi@0 | 114 | #endif // ASSERT |
aoqi@0 | 115 | |
aoqi@0 | 116 | _index = new_index; |
aoqi@0 | 117 | } |
aoqi@0 | 118 | |
aoqi@0 | 119 | // This method will first apply the above filtering to the buffer. If |
aoqi@0 | 120 | // post-filtering a large enough chunk of the buffer has been cleared |
aoqi@0 | 121 | // we can re-use the buffer (instead of enqueueing it) and we can just |
aoqi@0 | 122 | // allow the mutator to carry on executing using the same buffer |
aoqi@0 | 123 | // instead of replacing it. |
aoqi@0 | 124 | |
aoqi@0 | 125 | bool ObjPtrQueue::should_enqueue_buffer() { |
aoqi@0 | 126 | assert(_lock == NULL || _lock->owned_by_self(), |
aoqi@0 | 127 | "we should have taken the lock before calling this"); |
aoqi@0 | 128 | |
aoqi@0 | 129 | // Even if G1SATBBufferEnqueueingThresholdPercent == 0 we have to |
aoqi@0 | 130 | // filter the buffer given that this will remove any references into |
aoqi@0 | 131 | // the CSet as we currently assume that no such refs will appear in |
aoqi@0 | 132 | // enqueued buffers. |
aoqi@0 | 133 | |
aoqi@0 | 134 | // This method should only be called if there is a non-NULL buffer |
aoqi@0 | 135 | // that is full. |
aoqi@0 | 136 | assert(_index == 0, "pre-condition"); |
aoqi@0 | 137 | assert(_buf != NULL, "pre-condition"); |
aoqi@0 | 138 | |
aoqi@0 | 139 | filter(); |
aoqi@0 | 140 | |
aoqi@0 | 141 | size_t sz = _sz; |
aoqi@0 | 142 | size_t all_entries = sz / oopSize; |
aoqi@0 | 143 | size_t retained_entries = (sz - _index) / oopSize; |
aoqi@0 | 144 | size_t perc = retained_entries * 100 / all_entries; |
aoqi@0 | 145 | bool should_enqueue = perc > (size_t) G1SATBBufferEnqueueingThresholdPercent; |
aoqi@0 | 146 | return should_enqueue; |
aoqi@0 | 147 | } |
aoqi@0 | 148 | |
aoqi@0 | 149 | void ObjPtrQueue::apply_closure(ObjectClosure* cl) { |
aoqi@0 | 150 | if (_buf != NULL) { |
aoqi@0 | 151 | apply_closure_to_buffer(cl, _buf, _index, _sz); |
aoqi@0 | 152 | } |
aoqi@0 | 153 | } |
aoqi@0 | 154 | |
aoqi@0 | 155 | void ObjPtrQueue::apply_closure_and_empty(ObjectClosure* cl) { |
aoqi@0 | 156 | if (_buf != NULL) { |
aoqi@0 | 157 | apply_closure_to_buffer(cl, _buf, _index, _sz); |
aoqi@0 | 158 | _index = _sz; |
aoqi@0 | 159 | } |
aoqi@0 | 160 | } |
aoqi@0 | 161 | |
aoqi@0 | 162 | void ObjPtrQueue::apply_closure_to_buffer(ObjectClosure* cl, |
aoqi@0 | 163 | void** buf, size_t index, size_t sz) { |
aoqi@0 | 164 | if (cl == NULL) return; |
aoqi@0 | 165 | for (size_t i = index; i < sz; i += oopSize) { |
aoqi@0 | 166 | oop obj = (oop)buf[byte_index_to_index((int)i)]; |
aoqi@0 | 167 | // There can be NULL entries because of destructors. |
aoqi@0 | 168 | if (obj != NULL) { |
aoqi@0 | 169 | cl->do_object(obj); |
aoqi@0 | 170 | } |
aoqi@0 | 171 | } |
aoqi@0 | 172 | } |
aoqi@0 | 173 | |
aoqi@0 | 174 | #ifndef PRODUCT |
aoqi@0 | 175 | // Helpful for debugging |
aoqi@0 | 176 | |
aoqi@0 | 177 | void ObjPtrQueue::print(const char* name) { |
aoqi@0 | 178 | print(name, _buf, _index, _sz); |
aoqi@0 | 179 | } |
aoqi@0 | 180 | |
aoqi@0 | 181 | void ObjPtrQueue::print(const char* name, |
aoqi@0 | 182 | void** buf, size_t index, size_t sz) { |
aoqi@0 | 183 | gclog_or_tty->print_cr(" SATB BUFFER [%s] buf: "PTR_FORMAT" " |
aoqi@0 | 184 | "index: "SIZE_FORMAT" sz: "SIZE_FORMAT, |
aoqi@0 | 185 | name, buf, index, sz); |
aoqi@0 | 186 | } |
aoqi@0 | 187 | #endif // PRODUCT |
aoqi@0 | 188 | |
aoqi@0 | 189 | #ifdef ASSERT |
aoqi@0 | 190 | void ObjPtrQueue::verify_oops_in_buffer() { |
aoqi@0 | 191 | if (_buf == NULL) return; |
aoqi@0 | 192 | for (size_t i = _index; i < _sz; i += oopSize) { |
aoqi@0 | 193 | oop obj = (oop)_buf[byte_index_to_index((int)i)]; |
aoqi@0 | 194 | assert(obj != NULL && obj->is_oop(true /* ignore mark word */), |
aoqi@0 | 195 | "Not an oop"); |
aoqi@0 | 196 | } |
aoqi@0 | 197 | } |
aoqi@0 | 198 | #endif |
aoqi@0 | 199 | |
aoqi@0 | 200 | #ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away |
aoqi@0 | 201 | #pragma warning( disable:4355 ) // 'this' : used in base member initializer list |
aoqi@0 | 202 | #endif // _MSC_VER |
aoqi@0 | 203 | |
aoqi@0 | 204 | SATBMarkQueueSet::SATBMarkQueueSet() : |
aoqi@0 | 205 | PtrQueueSet(), _closure(NULL), _par_closures(NULL), |
aoqi@0 | 206 | _shared_satb_queue(this, true /*perm*/) { } |
aoqi@0 | 207 | |
aoqi@0 | 208 | void SATBMarkQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock, |
aoqi@0 | 209 | int process_completed_threshold, |
aoqi@0 | 210 | Mutex* lock) { |
aoqi@0 | 211 | PtrQueueSet::initialize(cbl_mon, fl_lock, process_completed_threshold, -1); |
aoqi@0 | 212 | _shared_satb_queue.set_lock(lock); |
aoqi@0 | 213 | if (ParallelGCThreads > 0) { |
aoqi@0 | 214 | _par_closures = NEW_C_HEAP_ARRAY(ObjectClosure*, ParallelGCThreads, mtGC); |
aoqi@0 | 215 | } |
aoqi@0 | 216 | } |
aoqi@0 | 217 | |
aoqi@0 | 218 | void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) { |
aoqi@0 | 219 | DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();) |
aoqi@0 | 220 | t->satb_mark_queue().handle_zero_index(); |
aoqi@0 | 221 | } |
aoqi@0 | 222 | |
aoqi@0 | 223 | #ifdef ASSERT |
aoqi@0 | 224 | void SATBMarkQueueSet::dump_active_states(bool expected_active) { |
aoqi@0 | 225 | gclog_or_tty->print_cr("Expected SATB active state: %s", |
aoqi@0 | 226 | expected_active ? "ACTIVE" : "INACTIVE"); |
aoqi@0 | 227 | gclog_or_tty->print_cr("Actual SATB active states:"); |
aoqi@0 | 228 | gclog_or_tty->print_cr(" Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE"); |
aoqi@0 | 229 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 230 | gclog_or_tty->print_cr(" Thread \"%s\" queue: %s", t->name(), |
aoqi@0 | 231 | t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE"); |
aoqi@0 | 232 | } |
aoqi@0 | 233 | gclog_or_tty->print_cr(" Shared queue: %s", |
aoqi@0 | 234 | shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE"); |
aoqi@0 | 235 | } |
aoqi@0 | 236 | |
aoqi@0 | 237 | void SATBMarkQueueSet::verify_active_states(bool expected_active) { |
aoqi@0 | 238 | // Verify queue set state |
aoqi@0 | 239 | if (is_active() != expected_active) { |
aoqi@0 | 240 | dump_active_states(expected_active); |
aoqi@0 | 241 | guarantee(false, "SATB queue set has an unexpected active state"); |
aoqi@0 | 242 | } |
aoqi@0 | 243 | |
aoqi@0 | 244 | // Verify thread queue states |
aoqi@0 | 245 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 246 | if (t->satb_mark_queue().is_active() != expected_active) { |
aoqi@0 | 247 | dump_active_states(expected_active); |
aoqi@0 | 248 | guarantee(false, "Thread SATB queue has an unexpected active state"); |
aoqi@0 | 249 | } |
aoqi@0 | 250 | } |
aoqi@0 | 251 | |
aoqi@0 | 252 | // Verify shared queue state |
aoqi@0 | 253 | if (shared_satb_queue()->is_active() != expected_active) { |
aoqi@0 | 254 | dump_active_states(expected_active); |
aoqi@0 | 255 | guarantee(false, "Shared SATB queue has an unexpected active state"); |
aoqi@0 | 256 | } |
aoqi@0 | 257 | } |
aoqi@0 | 258 | #endif // ASSERT |
aoqi@0 | 259 | |
aoqi@0 | 260 | void SATBMarkQueueSet::set_active_all_threads(bool active, bool expected_active) { |
aoqi@0 | 261 | assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
aoqi@0 | 262 | #ifdef ASSERT |
aoqi@0 | 263 | verify_active_states(expected_active); |
aoqi@0 | 264 | #endif // ASSERT |
aoqi@0 | 265 | _all_active = active; |
aoqi@0 | 266 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 267 | t->satb_mark_queue().set_active(active); |
aoqi@0 | 268 | } |
aoqi@0 | 269 | shared_satb_queue()->set_active(active); |
aoqi@0 | 270 | } |
aoqi@0 | 271 | |
aoqi@0 | 272 | void SATBMarkQueueSet::filter_thread_buffers() { |
aoqi@0 | 273 | for(JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 274 | t->satb_mark_queue().filter(); |
aoqi@0 | 275 | } |
aoqi@0 | 276 | shared_satb_queue()->filter(); |
aoqi@0 | 277 | } |
aoqi@0 | 278 | |
aoqi@0 | 279 | void SATBMarkQueueSet::set_closure(ObjectClosure* closure) { |
aoqi@0 | 280 | _closure = closure; |
aoqi@0 | 281 | } |
aoqi@0 | 282 | |
aoqi@0 | 283 | void SATBMarkQueueSet::set_par_closure(int i, ObjectClosure* par_closure) { |
aoqi@0 | 284 | assert(ParallelGCThreads > 0 && _par_closures != NULL, "Precondition"); |
aoqi@0 | 285 | _par_closures[i] = par_closure; |
aoqi@0 | 286 | } |
aoqi@0 | 287 | |
aoqi@0 | 288 | bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par, |
aoqi@0 | 289 | uint worker) { |
aoqi@0 | 290 | BufferNode* nd = NULL; |
aoqi@0 | 291 | { |
aoqi@0 | 292 | MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
aoqi@0 | 293 | if (_completed_buffers_head != NULL) { |
aoqi@0 | 294 | nd = _completed_buffers_head; |
aoqi@0 | 295 | _completed_buffers_head = nd->next(); |
aoqi@0 | 296 | if (_completed_buffers_head == NULL) _completed_buffers_tail = NULL; |
aoqi@0 | 297 | _n_completed_buffers--; |
aoqi@0 | 298 | if (_n_completed_buffers == 0) _process_completed = false; |
aoqi@0 | 299 | } |
aoqi@0 | 300 | } |
aoqi@0 | 301 | ObjectClosure* cl = (par ? _par_closures[worker] : _closure); |
aoqi@0 | 302 | if (nd != NULL) { |
aoqi@0 | 303 | void **buf = BufferNode::make_buffer_from_node(nd); |
aoqi@0 | 304 | ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); |
aoqi@0 | 305 | deallocate_buffer(buf); |
aoqi@0 | 306 | return true; |
aoqi@0 | 307 | } else { |
aoqi@0 | 308 | return false; |
aoqi@0 | 309 | } |
aoqi@0 | 310 | } |
aoqi@0 | 311 | |
aoqi@0 | 312 | void SATBMarkQueueSet::iterate_completed_buffers_read_only(ObjectClosure* cl) { |
aoqi@0 | 313 | assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
aoqi@0 | 314 | assert(cl != NULL, "pre-condition"); |
aoqi@0 | 315 | |
aoqi@0 | 316 | BufferNode* nd = _completed_buffers_head; |
aoqi@0 | 317 | while (nd != NULL) { |
aoqi@0 | 318 | void** buf = BufferNode::make_buffer_from_node(nd); |
aoqi@0 | 319 | ObjPtrQueue::apply_closure_to_buffer(cl, buf, 0, _sz); |
aoqi@0 | 320 | nd = nd->next(); |
aoqi@0 | 321 | } |
aoqi@0 | 322 | } |
aoqi@0 | 323 | |
aoqi@0 | 324 | void SATBMarkQueueSet::iterate_thread_buffers_read_only(ObjectClosure* cl) { |
aoqi@0 | 325 | assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
aoqi@0 | 326 | assert(cl != NULL, "pre-condition"); |
aoqi@0 | 327 | |
aoqi@0 | 328 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 329 | t->satb_mark_queue().apply_closure(cl); |
aoqi@0 | 330 | } |
aoqi@0 | 331 | shared_satb_queue()->apply_closure(cl); |
aoqi@0 | 332 | } |
aoqi@0 | 333 | |
aoqi@0 | 334 | #ifndef PRODUCT |
aoqi@0 | 335 | // Helpful for debugging |
aoqi@0 | 336 | |
aoqi@0 | 337 | #define SATB_PRINTER_BUFFER_SIZE 256 |
aoqi@0 | 338 | |
aoqi@0 | 339 | void SATBMarkQueueSet::print_all(const char* msg) { |
aoqi@0 | 340 | char buffer[SATB_PRINTER_BUFFER_SIZE]; |
aoqi@0 | 341 | assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
aoqi@0 | 342 | |
aoqi@0 | 343 | gclog_or_tty->cr(); |
aoqi@0 | 344 | gclog_or_tty->print_cr("SATB BUFFERS [%s]", msg); |
aoqi@0 | 345 | |
aoqi@0 | 346 | BufferNode* nd = _completed_buffers_head; |
aoqi@0 | 347 | int i = 0; |
aoqi@0 | 348 | while (nd != NULL) { |
aoqi@0 | 349 | void** buf = BufferNode::make_buffer_from_node(nd); |
aoqi@0 | 350 | jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Enqueued: %d", i); |
aoqi@0 | 351 | ObjPtrQueue::print(buffer, buf, 0, _sz); |
aoqi@0 | 352 | nd = nd->next(); |
aoqi@0 | 353 | i += 1; |
aoqi@0 | 354 | } |
aoqi@0 | 355 | |
aoqi@0 | 356 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 357 | jio_snprintf(buffer, SATB_PRINTER_BUFFER_SIZE, "Thread: %s", t->name()); |
aoqi@0 | 358 | t->satb_mark_queue().print(buffer); |
aoqi@0 | 359 | } |
aoqi@0 | 360 | |
aoqi@0 | 361 | shared_satb_queue()->print("Shared"); |
aoqi@0 | 362 | |
aoqi@0 | 363 | gclog_or_tty->cr(); |
aoqi@0 | 364 | } |
aoqi@0 | 365 | #endif // PRODUCT |
aoqi@0 | 366 | |
aoqi@0 | 367 | void SATBMarkQueueSet::abandon_partial_marking() { |
aoqi@0 | 368 | BufferNode* buffers_to_delete = NULL; |
aoqi@0 | 369 | { |
aoqi@0 | 370 | MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag); |
aoqi@0 | 371 | while (_completed_buffers_head != NULL) { |
aoqi@0 | 372 | BufferNode* nd = _completed_buffers_head; |
aoqi@0 | 373 | _completed_buffers_head = nd->next(); |
aoqi@0 | 374 | nd->set_next(buffers_to_delete); |
aoqi@0 | 375 | buffers_to_delete = nd; |
aoqi@0 | 376 | } |
aoqi@0 | 377 | _completed_buffers_tail = NULL; |
aoqi@0 | 378 | _n_completed_buffers = 0; |
aoqi@0 | 379 | DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked()); |
aoqi@0 | 380 | } |
aoqi@0 | 381 | while (buffers_to_delete != NULL) { |
aoqi@0 | 382 | BufferNode* nd = buffers_to_delete; |
aoqi@0 | 383 | buffers_to_delete = nd->next(); |
aoqi@0 | 384 | deallocate_buffer(BufferNode::make_buffer_from_node(nd)); |
aoqi@0 | 385 | } |
aoqi@0 | 386 | assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint."); |
aoqi@0 | 387 | // So we can safely manipulate these queues. |
aoqi@0 | 388 | for (JavaThread* t = Threads::first(); t; t = t->next()) { |
aoqi@0 | 389 | t->satb_mark_queue().reset(); |
aoqi@0 | 390 | } |
aoqi@0 | 391 | shared_satb_queue()->reset(); |
aoqi@0 | 392 | } |