diff options
author | 2023-09-28 16:24:15 +0100 | |
---|---|---|
committer | 2023-11-30 00:02:56 +0000 | |
commit | 14165e156cc23a5bbe7d70d606b3b260721e48dd (patch) | |
tree | fdbd20ab22084b81fbd6d197e5de22b3401554a9 /runtime/thread.cc | |
parent | 54417d2c7e5254f8941119f8f16476c1a45e028a (diff) |
Initialize gPageSize at runtime via sysconf
This changes gPageSize to a global constant const in page size agnostic
configuration, dynamically initialized with the runtime-determined page
size value. This finishes adding basic support of page size agnostic
ART configuration, however without yet enabling it.
With page size agnosticism disabled, gPageSize etc. derived values in
the global scope are still constexpr.
As part of that, introduce helpers for gPageSize and the derived
constants in the global scope, in a way that guarantees correct static
initialization order:
- GlobalConst is a helper class that acts as a global constant;
- ART_PAGE_SIZE_AGNOSTIC_DECLARE etc. - helper macros for declaring the
constants either as the global constants or constexpr depends on the
configuration.
The helpers are used for the gPageSize and derived values stored in the
global scope.
Test: Same as for I5430741a8494b340ed7fd2d8692c41a59ad9c530.
The whole patches chain was tested as a whole.
Change-Id: Id1c18004346ba5c6c94e02cdf8b0b0bb3b99af70
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r-- | runtime/thread.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc index d4019f1acc..73008eb183 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -153,7 +153,8 @@ static constexpr size_t kSuspendTimeDuringFlip = 5'000; // of the stack (lowest memory). The higher portion of the memory // is protected against reads and the lower is available for use while // throwing the StackOverflow exception. -static const size_t gStackOverflowProtectedSize = kMemoryToolStackGuardSizeScale * gPageSize; +ART_PAGE_SIZE_AGNOSTIC_DECLARE_AND_DEFINE(size_t, gStackOverflowProtectedSize, + kMemoryToolStackGuardSizeScale * gPageSize); static const char* kThreadNameDuringStartup = "<native thread without managed peer>"; @@ -1363,7 +1364,8 @@ bool Thread::InitStackHwm() { // // On systems with 4K page size, typically the minimum stack size will be 4+8+4 = 16K. // The thread won't be able to do much with this stack: even the GC takes between 8K and 12K. - DCHECK_ALIGNED_PARAM(gStackOverflowProtectedSize, gPageSize); + DCHECK_ALIGNED_PARAM(static_cast<size_t>(gStackOverflowProtectedSize), + static_cast<int32_t>(gPageSize)); size_t min_stack = gStackOverflowProtectedSize + RoundUp(GetStackOverflowReservedBytes(kRuntimeISA) + 4 * KB, gPageSize); if (read_stack_size <= min_stack) { |