/* * Copyright (c) 2021, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// A helper class to encode a few card indexes within a ContainerPtr. // // The pointer value (either 32 or 64 bits) is split into two areas: // // - Header containing identifying tag and number of encoded cards. // - Data area containing the card indexes themselves // // The header starts (from LSB) with the identifying tag (two bits, // always 00), and three bits size. The size stores the number of // valid card indexes after the header. // // The data area makes up the remainder of the word, with card indexes // put one after another at increasing bit positions. The separate // card indexes use just enough space (bits) to represent the whole // range of cards needed for covering the whole range of values // (typically in a region). There may be unused space at the top of // the word. // // Example: // // 64 bit pointer size, with 8M-size regions (8M == 2^23) // -> 2^14 (2^23 / 2^9) cards; each card represents 512 bytes in a region // -> 14 bits per card; must have enough bits to hold the max card index // -> may encode up to 4 cards into it, using 61 bits (5 bits header + 4 * 14) // // M L // S S // B B // +------+ +---------------+--------------+-----+ // |unused| ... | card_index1 | card_index0 |SSS00| // +------+ +---------------+--------------+-----+ class G1CardSetInlinePtr : public StackObj { friendclass G1CardSetContainersTest;
// Common base class for card set containers where the memory for the entries is // managed on the (C-)heap. Depending on the current use, one of the two overlapping // members are used: // // While such an object is assigned to a card set container, we utilize the // reference count for memory management. // // In this case the object is one of three states: // 1: Live: The object is visible to other threads, thus can // safely be accessed by other threads (_ref_count >= 3). // 2: Dead: The object is visible to only a single thread and may be // safely reclaimed (_ref_count == 1). // 3: Reclaimed: The object's memory has been reclaimed ((_ref_count & 0x1) == 0). // To maintain these constraints, live objects should have ((_ref_count & 0x1) == 1), // which requires that we increment the reference counts by 2 starting at _ref_count = 3. // // All but inline pointers are of this kind. For those, card entries are stored // directly in the ContainerPtr of the ConcurrentHashTable node. class G1CardSetContainer {
uintptr_t _ref_count; protected:
~G1CardSetContainer() = default; public:
G1CardSetContainer() : _ref_count(3) { }
// Decrement refcount potentially while racing increment, so we need // to check the value after attempting to decrement.
uintptr_t decrement_refcount();
// Log of largest card index that can be stored in any G1CardSetContainer static uint LogCardsPerRegionLimit;
class G1CardSetHowl : public G1CardSetContainer { public: typedef uint EntryCountType; using ContainerPtr = G1CardSet::ContainerPtr;
EntryCountType volatile _num_entries; private:
ContainerPtr _buckets[2]; // Do not add class member variables beyond this point
// Iterates over the given ContainerPtr with at index in this Howl card set, // applying a CardOrRangeVisitor on it. template <class CardOrRangeVisitor> void iterate_cardset(ContainerPtr const container, uint index, CardOrRangeVisitor& found, G1CardSetConfiguration* config);
// Iterates over all ContainerPtrs in this Howl card set, applying a CardOrRangeVisitor // on it. template <class CardOrRangeVisitor> void iterate(CardOrRangeVisitor& found, G1CardSetConfiguration* config);
// Iterates over all ContainerPtrs in this Howl card set. Calls // // void operator ()(ContainerPtr* card_set_addr); // // on all of them. template <class ContainerPtrVisitor> void iterate(ContainerPtrVisitor& found, uint num_card_sets);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.