/* * Copyright (c) 2014, 2020, 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. *
*/
// Per-region attributes often used during garbage collection to avoid costly // lookups for that information all over the place. struct G1HeapRegionAttr { public: typedef int8_t region_type_t; // remset_is_tracked_t is essentially bool, but we need precise control // on the size, and sizeof(bool) is implementation specific. typedef uint8_t remset_is_tracked_t;
public: // Selection of the values for the _type field were driven to micro-optimize the // encoding and frequency of the checks. // The most common check for a given reference is whether the region is in the // collection set or not, and which generation this region is in. // The selected encoding allows us to use a single check (> NotInCSet) for the // former. // // The other values are used for objects in regions requiring various special handling, // eager reclamation of humongous objects or optional regions. staticconst region_type_t Optional = -4; // The region is optional not in the current collection set. staticconst region_type_t HumongousCandidate = -3; // The region is a humongous candidate not in the current collection set. staticconst region_type_t NewSurvivor = -2; // The region is a new (ly allocated) survivor region. staticconst region_type_t NotInCSet = -1; // The region is not in the collection set. staticconst region_type_t Young = 0; // The region is in the collection set and a young region. staticconst region_type_t Old = 1; // The region is in the collection set and an old region. staticconst region_type_t Num = 2;
constchar* get_type_str() const { switch (type()) { case Optional: return"Optional"; case HumongousCandidate: return"HumongousCandidate"; case NewSurvivor: return"NewSurvivor"; case NotInCSet: return"NotInCSet"; case Young: return"Young"; case Old: return"Old"; default: ShouldNotReachHere(); return"";
}
}
// Table for all regions in the heap for above. // // We use this to speed up reference processing during young collection and // quickly reclaim humongous objects. For the latter, at the start of GC, by adding // it as a humongous region we enable special handling for that region. During the // reference iteration closures, when we see a humongous region, we then simply mark // it as referenced, i.e. live, and remove it from this table to prevent further // processing on it. // // This means that this does NOT completely correspond to the information stored // in a HeapRegion, but only to what is interesting for the current young collection. class G1HeapRegionAttrBiasedMappedArray : public G1BiasedMappedArray<G1HeapRegionAttr> { protected:
G1HeapRegionAttr default_value() const { return G1HeapRegionAttr(G1HeapRegionAttr::NotInCSet); } public: void set_optional(uintptr_t index, bool remset_is_tracked) {
assert(get_by_index(index).is_default(), "Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Optional, remset_is_tracked));
}
void set_new_survivor_region(uintptr_t index) {
assert(get_by_index(index).is_default(), "Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
get_ref_by_index(index)->set_new_survivor();
}
void set_humongous_candidate(uintptr_t index, bool remset_is_tracked) {
assert(get_by_index(index).is_default(), "Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::HumongousCandidate, remset_is_tracked));
}
void set_in_young(uintptr_t index) {
assert(get_by_index(index).is_default(), "Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Young, true));
}
void set_in_old(uintptr_t index, bool remset_is_tracked) {
assert(get_by_index(index).is_default(), "Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Old, remset_is_tracked));
}
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.