3067N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 342N/A * This code is free software; you can redistribute it and/or modify it 342N/A * under the terms of the GNU General Public License version 2 only, as 342N/A * published by the Free Software Foundation. 342N/A * This code is distributed in the hope that it will be useful, but WITHOUT 342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 342N/A * version 2 for more details (a copy is included in the LICENSE file that 342N/A * accompanied this code). 342N/A * You should have received a copy of the GNU General Public License version 342N/A * 2 along with this work; if not, write to the Free Software Foundation, 342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3067N/A // The buffer might contain refs into the CSet. We have to filter it 3067N/A // first before we flush it, otherwise we might end up with an 3067N/A // enqueued buffer with refs into the CSet which breaks our invariants. 2034N/A// This method removes entries from an SATB buffer that will not be 2034N/A// useful to the concurrent marking threads. An entry is removed if it 2034N/A// satisfies one of the following conditions: 2034N/A// * it points to an object outside the G1 heap (G1's concurrent 2034N/A// marking only visits objects inside the G1 heap), 2034N/A// * it points to an object that has been allocated since marking 2034N/A// started (according to SATB those objects do not need to be 2034N/A// visited during marking), or 2034N/A// * it points to an object that has already been marked (no need to 2034N/A// The rest of the entries will be retained and are compacted towards 3067N/A// the top of the buffer. Note that, because we do not allow old 3067N/A// regions in the CSet during marking, all objects on the CSet regions 3067N/A// are young (eden or survivors) and therefore implicitly live. So any 3067N/A// references into the CSet will be removed during filtering. 2034N/A // Used for sanity checking at the end of the loop. 2034N/A assert(i > 0,
"we should have at least one more entry to process");
2034N/A // NULL the entry so that unused parts of the buffer contain NULLs 2034N/A // at the end. If we are going to retain it we will copy it to its 2034N/A // final place. If we have retained all entries we have visited so 2034N/A // far, we'll just end up copying it to the same place. 2034N/A "new_index should never be below i, as we alwaysr compact 'up'");
2034N/A "the source as we always compact 'up'");
2034N/A "we should have already cleared the destination location");
2034N/A "should match the number of entries we calculated");
2034N/A "should match the number of retained entries we calculated");
3067N/A// This method will first apply the above filtering to the buffer. If 3067N/A// post-filtering a large enough chunk of the buffer has been cleared 3067N/A// we can re-use the buffer (instead of enqueueing it) and we can just 3067N/A// allow the mutator to carry on executing using the same buffer 3067N/A "we should have taken the lock before calling this");
3067N/A // Even if G1SATBBufferEnqueueingThresholdPercent == 0 we have to 3067N/A // filter the buffer given that this will remove any references into 3067N/A // the CSet as we currently assume that no such refs will appear in 3067N/A // This method should only be called if there is a non-NULL buffer 342N/A // There can be NULL entries because of destructors. 342N/A#
ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away 1317N/A // I leave this here as a guarantee, instead of an assert, so 1317N/A // that it will still be compiled in if we choose to uncomment 1317N/A // the #ifdef ASSERT in a product build. The whole block is 1317N/A // within an #ifdef ASSERT so the guarantee will not be compiled 1317N/A // in a product build anyway. 1317N/A "SATB queue set has an unexpected active value");
1317N/A // I leave this here as a guarantee, instead of an assert, so 1317N/A // that it will still be compiled in if we choose to uncomment 1317N/A // the #ifdef ASSERT in a product build. The whole block is 1317N/A // within an #ifdef ASSERT so the guarantee will not be compiled 1317N/A // in a product build anyway. 1317N/A "thread has an unexpected active value in its SATB queue");
2815N/A // We also need to claim the VMThread so that its parity is updated 2815N/A // otherwise the next call to Thread::possibly_parallel_oops_do inside 2815N/A // a StrongRootsScope might skip the VMThread because it has a stale 2815N/A // parity that matches the parity set by the StrongRootsScope 2815N/A // Whichever worker succeeds in claiming the VMThread gets to do 342N/A // So we can safely manipulate these queues.