--- old/src/share/vm/gc/g1/dirtyCardQueue.cpp 2016-03-04 02:58:09.667960683 -0500 +++ new/src/share/vm/gc/g1/dirtyCardQueue.cpp 2016-03-04 02:58:09.575960226 -0500 @@ -125,26 +125,27 @@ } bool DirtyCardQueue::apply_closure_to_buffer(CardTableEntryClosure* cl, - BufferNode* node, size_t sz, + BufferNode* node, + size_t buffer_size, bool consume, uint worker_i) { if (cl == NULL) return true; void** buf = BufferNode::make_buffer_from_node(node); - size_t limit = byte_index_to_index(sz); + size_t limit = byte_index_to_index(buffer_size); for (size_t i = byte_index_to_index(node->index()); i < limit; ++i) { jbyte* card_ptr = static_cast(buf[i]); assert(card_ptr != NULL, "invariant"); if (!cl->do_card_ptr(card_ptr, worker_i)) { if (consume) { size_t new_index = index_to_byte_index(i + 1); - assert(new_index <= sz, "invariant"); + assert(new_index <= buffer_size, "invariant"); node->set_index(new_index); } return false; } } if (consume) { - node->set_index(sz); + node->set_index(buffer_size); } return true; } --- old/src/share/vm/gc/g1/dirtyCardQueue.hpp 2016-03-04 02:58:10.191963281 -0500 +++ new/src/share/vm/gc/g1/dirtyCardQueue.hpp 2016-03-04 02:58:10.099962825 -0500 @@ -52,22 +52,24 @@ // Process queue entries and release resources. void flush() { flush_impl(); } - // Apply the closure to all active elements, from index to size. If - // all closure applications return true, then returns true. Stops - // processing after the first false closure application and returns - // false. If "consume" is true, index is updated to follow the last - // processed element. + // Apply the closure to the elements from _index to _sz. If all + // closure applications return true, then returns true. Stops + // processing after the first closure application that returns + // false, and returns false from this function. If "consume" is + // true, _index is updated to follow the last processed element. bool apply_closure(CardTableEntryClosure* cl, bool consume = true, uint worker_i = 0); - // Apply the closure to all active elements of "node", from it's - // index to sz. If all closure applications return true, then - // returns true. Stops processing after the first false closure - // application and returns false. If "consume" is true, the node's - // index is updated to follow the last processed element. + // Apply the closure to the elements of "node" from it's index to + // buffer_size. If all closure applications return true, then + // returns true. Stops processing after the first closure + // application that returns false, and returns false from this + // function. If "consume" is true, the node's index is updated to + // follow the last processed element. static bool apply_closure_to_buffer(CardTableEntryClosure* cl, - BufferNode* node, size_t sz, + BufferNode* node, + size_t buffer_size, bool consume = true, uint worker_i = 0); void **get_buf() { return _buf;} @@ -95,7 +97,6 @@ DirtyCardQueue _shared_dirty_card_queue; - // Override. bool mut_process_buffer(BufferNode* node); // Protected by the _cbl_mon. @@ -135,7 +136,7 @@ // returns false. If a completed buffer exists, but is only // partially completed before a "yield" happens, the partially // completed buffer (with its index updated to exclude the processed - // eleemnts) is returned to the completed buffer set, and this call + // elements) is returned to the completed buffer set, and this call // returns false. bool apply_closure_to_completed_buffer(CardTableEntryClosure* cl, uint worker_i, --- old/src/share/vm/gc/g1/ptrQueue.cpp 2016-03-04 02:58:10.723965919 -0500 +++ new/src/share/vm/gc/g1/ptrQueue.cpp 2016-03-04 02:58:10.627965443 -0500 @@ -44,7 +44,7 @@ void PtrQueue::flush_impl() { if (!_permanent && _buf != NULL) { BufferNode* node = BufferNode::make_node_from_buffer(_buf, _index); - if (_index == _sz) { + if (is_empty()) { // No work to do. qset()->deallocate_buffer(node); } else { --- old/src/share/vm/gc/g1/satbMarkQueue.cpp 2016-03-04 02:58:11.251968537 -0500 +++ new/src/share/vm/gc/g1/satbMarkQueue.cpp 2016-03-04 02:58:11.155968061 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -128,12 +128,17 @@ void* entry = *src; if (retain_entry(entry, g1h)) { // Found keeper. Search high to low for an entry to discard. - while ((src < --dst) && retain_entry(*dst, g1h)) { } - if (src >= dst) break; // Done if no discard found. - *dst = entry; // Replace discard with keeper. + while (src < --dst) { + if (!retain_entry(*dst, g1h)) { + *dst = entry; // Replace discard with keeper. + break; + } + } + // If discard search failed (src == dst), the outer loop will also end. } } - assert(src == dst, "invariant"); + // dst points to the lowest retained entry, or the end of the buffer + // if all the entries were filtered out. _index = pointer_delta(dst, buf, 1); }