diff options
Diffstat (limited to 'runtime/arch/instruction_set.cc')
-rw-r--r-- | runtime/arch/instruction_set.cc | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/runtime/arch/instruction_set.cc b/runtime/arch/instruction_set.cc index 81ca010423..b35e0889e4 100644 --- a/runtime/arch/instruction_set.cc +++ b/runtime/arch/instruction_set.cc @@ -18,6 +18,7 @@ // Explicitly include our own elf.h to avoid Linux and other dependencies. #include "../elf.h" +#include "base/bit_utils.h" #include "globals.h" namespace art { @@ -113,14 +114,44 @@ size_t GetInstructionSetAlignment(InstructionSet isa) { } } -static constexpr size_t kDefaultStackOverflowReservedBytes = 16 * KB; -static constexpr size_t kMipsStackOverflowReservedBytes = kDefaultStackOverflowReservedBytes; -static constexpr size_t kMips64StackOverflowReservedBytes = kDefaultStackOverflowReservedBytes; - -static constexpr size_t kArmStackOverflowReservedBytes = 8 * KB; -static constexpr size_t kArm64StackOverflowReservedBytes = 8 * KB; -static constexpr size_t kX86StackOverflowReservedBytes = 8 * KB; -static constexpr size_t kX86_64StackOverflowReservedBytes = 8 * KB; +#if !defined(ART_STACK_OVERFLOW_GAP_arm) || !defined(ART_STACK_OVERFLOW_GAP_arm64) || \ + !defined(ART_STACK_OVERFLOW_GAP_mips) || !defined(ART_STACK_OVERFLOW_GAP_mips64) || \ + !defined(ART_STACK_OVERFLOW_GAP_x86) || !defined(ART_STACK_OVERFLOW_GAP_x86_64) +#error "Missing defines for stack overflow gap" +#endif + +static constexpr size_t kArmStackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_arm; +static constexpr size_t kArm64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_arm64; +static constexpr size_t kMipsStackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_mips; +static constexpr size_t kMips64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_mips64; +static constexpr size_t kX86StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_x86; +static constexpr size_t kX86_64StackOverflowReservedBytes = ART_STACK_OVERFLOW_GAP_x86_64; + +static_assert(IsAligned<kPageSize>(kArmStackOverflowReservedBytes), "ARM gap not page aligned"); +static_assert(IsAligned<kPageSize>(kArm64StackOverflowReservedBytes), "ARM64 gap not page aligned"); +static_assert(IsAligned<kPageSize>(kMipsStackOverflowReservedBytes), "Mips gap not page aligned"); +static_assert(IsAligned<kPageSize>(kMips64StackOverflowReservedBytes), + "Mips64 gap not page aligned"); +static_assert(IsAligned<kPageSize>(kX86StackOverflowReservedBytes), "X86 gap not page aligned"); +static_assert(IsAligned<kPageSize>(kX86_64StackOverflowReservedBytes), + "X86_64 gap not page aligned"); + +#if !defined(ART_FRAME_SIZE_LIMIT) +#error "ART frame size limit missing" +#endif + +// TODO: Should we require an extra page (RoundUp(SIZE) + kPageSize)? +static_assert(ART_FRAME_SIZE_LIMIT < kArmStackOverflowReservedBytes, "Frame size limit too large"); +static_assert(ART_FRAME_SIZE_LIMIT < kArm64StackOverflowReservedBytes, + "Frame size limit too large"); +static_assert(ART_FRAME_SIZE_LIMIT < kMipsStackOverflowReservedBytes, + "Frame size limit too large"); +static_assert(ART_FRAME_SIZE_LIMIT < kMips64StackOverflowReservedBytes, + "Frame size limit too large"); +static_assert(ART_FRAME_SIZE_LIMIT < kX86StackOverflowReservedBytes, + "Frame size limit too large"); +static_assert(ART_FRAME_SIZE_LIMIT < kX86_64StackOverflowReservedBytes, + "Frame size limit too large"); size_t GetStackOverflowReservedBytes(InstructionSet isa) { switch (isa) { |