#ifdef ART_PAGE_SIZE_AGNOSTIC // Accessor for the page size constant local to the libart. // // The value is only available after the Runtime initialization started - to ensure there is no // static initialization order issues where initialization of other values is dependent on the page // size. In those cases, GetPageSizeSlow() should be used. struct PageSize {
PageSize()
: is_initialized_(true), is_access_allowed_(false) {}
void SetAccessAllowed(bool is_allowed) { // is_initialized_ is set to true when the page size value is initialized during the static // initialization. This CHECK is added as an auxiliary way to help catching incorrect use of // the method.
CHECK(is_initialized_);
is_access_allowed_ = is_allowed;
}
// The page size value. // // It is declared as a static constant value to ensure compiler recognizes that it doesn't change // once it is initialized. // // It is declared as "hidden" i.e. local to the libart, to ensure: // - no other library can access it, so no static initialization dependency from other libraries // is possible; // - the variable can be addressed via offset from the program counter, instead of the global // offset table which would've added another level of indirection. staticconst size_t value_ ALWAYS_HIDDEN;
// There are two flags in the accessor which help to ensure the value is accessed only after the // static initialization is complete. // // is_initialized_ is used to assert the page size value is indeed initialized when the value // access is allowed and when it is accessed. // // is_access_allowed_ is used to ensure the value is only accessed after Runtime initialization // started. constbool is_initialized_; bool is_access_allowed_;
};
// gPageSize should only be used within libart. For most of the other cases MemMap::GetPageSize() // or GetPageSizeSlow() should be used. See also the comment for GetPageSizeSlow(). extern PageSize gPageSize ALWAYS_HIDDEN; #else static constexpr size_t gPageSize = kMinPageSize; #endif
// In the page-size-agnostic configuration the compiler may not recognise gPageSize as a // power-of-two value, and may therefore miss opportunities to optimize: divisions via a // right-shift, modulo via a bitwise-AND. // Here, define two functions which use the optimized implementations explicitly, which should be // used when dividing by or applying modulo of the page size. For simplificty, the same functions // are used under both configurations, as they optimize the page-size-agnostic configuration while // only replicating what the compiler already does on the non-page-size-agnostic configuration. static constexpr ALWAYS_INLINE size_t DivideByPageSize(size_t num) { return (num >> WhichPowerOf2(static_cast<size_t>(gPageSize)));
} static constexpr ALWAYS_INLINE size_t ModuloPageSize(size_t num) { return (num & (gPageSize-1));
}
// Returns whether the given memory offset can be used for generating // an implicit null check. staticinlinebool CanDoImplicitNullCheckOn(uintptr_t offset) { #ifdef ART_USE_SIMULATOR // When the simulator is in use, libart-simulator does not have access to gPageSize. return offset < GetPageSizeSlow(); #else return offset < gPageSize; #endif
}
// Garbage collector constants. static constexpr bool kMovingCollector = true; static constexpr bool kMarkCompactSupport = false && kMovingCollector; // True if we allow moving classes. static constexpr bool kMovingClasses = !kMarkCompactSupport; // When using the Concurrent Collectors (CC or CMC), if // `ART_USE_GENERATIONAL_GC` is true, enable generational collection by default, // i.e. use sticky-bit CC/CMC for minor collections and (full) CC/CMC for major // collections. // This default value can be overridden with the runtime option // `-Xgc:[no]generational_gc`. // // TODO(b/67628039): Consider either: // - renaming this to a better descriptive name (e.g. // `ART_USE_GENERATIONAL_GC_BY_DEFAULT`); or // - removing `ART_USE_GENERATIONAL_GC` and having a fixed default value. // Any of these changes will require adjusting users of this preprocessor // directive and the corresponding build system environment variable (e.g. in // ART's continuous testing). #ifdef ART_USE_GENERATIONAL_GC static constexpr bool kEnableGenerationalGCByDefault = true; #else static constexpr bool kEnableGenerationalGCByDefault = false; #endif
// If true, enable the tlab allocator by default. #ifdef ART_USE_TLAB static constexpr bool kUseTlab = true; #else static constexpr bool kUseTlab = false; #endif
// Kinds of tracing clocks. enumclass TraceClockSource {
kThreadCpu,
kWall,
kDual, // Both wall and thread CPU clocks.
};
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.