diff options
author | Andreas Gampe <agampe@google.com> | 2014-07-14 16:21:44 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-07-21 23:36:31 -0700 |
commit | 7ea6f79bbddd69d5db86a8656a31aaaf64ae2582 (patch) | |
tree | c64f89b15ca71e87317f6dd405ef4a5560b73e01 /compiler/dex | |
parent | e72ff8022968b23efedc56c0afdc1d24e8a928c2 (diff) | |
download | art-7ea6f79bbddd69d5db86a8656a31aaaf64ae2582.tar.gz art-7ea6f79bbddd69d5db86a8656a31aaaf64ae2582.tar.bz2 art-7ea6f79bbddd69d5db86a8656a31aaaf64ae2582.zip |
ART: Throw StackOverflowError in native code
Initialize stack-overflow errors in native code to be able to reduce
the preserved area size of the stack.
Includes a refactoring away from constexpr in instruction_set.h to allow
for easy changing of the values.
Change-Id: I117cc8485f43da5f0a470f0f5e5b3dc3b5a06246
Diffstat (limited to 'compiler/dex')
-rw-r--r-- | compiler/dex/quick/arm/call_arm.cc | 4 | ||||
-rw-r--r-- | compiler/dex/quick/arm64/call_arm64.cc | 4 | ||||
-rw-r--r-- | compiler/dex/quick/mir_to_lir.h | 30 |
3 files changed, 13 insertions, 25 deletions
diff --git a/compiler/dex/quick/arm/call_arm.cc b/compiler/dex/quick/arm/call_arm.cc index 6b96e929a..5059c5fc9 100644 --- a/compiler/dex/quick/arm/call_arm.cc +++ b/compiler/dex/quick/arm/call_arm.cc @@ -358,7 +358,7 @@ void ArmMir2Lir::GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) { */ bool skip_overflow_check = mir_graph_->MethodIsLeaf() && !IsLargeFrame(frame_size_, kArm); NewLIR0(kPseudoMethodEntry); - constexpr size_t kStackOverflowReservedUsableBytes = kArmStackOverflowReservedBytes - + const size_t kStackOverflowReservedUsableBytes = GetStackOverflowReservedBytes(kArm) - Thread::kStackOverflowSignalReservedBytes; bool large_frame = (static_cast<size_t>(frame_size_) > kStackOverflowReservedUsableBytes); if (!skip_overflow_check) { @@ -381,7 +381,7 @@ void ArmMir2Lir::GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) { // This is done before the callee save instructions to avoid any possibility // of these overflowing. This uses r12 and that's never saved in a callee // save. - OpRegRegImm(kOpSub, rs_r12, rs_rARM_SP, kArmStackOverflowReservedBytes); + OpRegRegImm(kOpSub, rs_r12, rs_rARM_SP, GetStackOverflowReservedBytes(kArm)); Load32Disp(rs_r12, 0, rs_r12); MarkPossibleStackOverflowException(); } diff --git a/compiler/dex/quick/arm64/call_arm64.cc b/compiler/dex/quick/arm64/call_arm64.cc index d946ee39e..5e95500b2 100644 --- a/compiler/dex/quick/arm64/call_arm64.cc +++ b/compiler/dex/quick/arm64/call_arm64.cc @@ -330,8 +330,8 @@ void Arm64Mir2Lir::GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) NewLIR0(kPseudoMethodEntry); - constexpr size_t kStackOverflowReservedUsableBytes = kArm64StackOverflowReservedBytes - - Thread::kStackOverflowSignalReservedBytes; + const size_t kStackOverflowReservedUsableBytes = GetStackOverflowReservedBytes(kArm64) - + Thread::kStackOverflowSignalReservedBytes; const bool large_frame = static_cast<size_t>(frame_size_) > kStackOverflowReservedUsableBytes; const int spill_count = num_core_spills_ + num_fp_spills_; const int spill_size = (spill_count * kArm64PointerSize + 15) & ~0xf; // SP 16 byte alignment. diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index 512849f25..c7fafcb9b 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -214,32 +214,20 @@ static constexpr size_t kLargeFrameSize = 2 * KB; // The constant is from experience with frameworks code. static constexpr size_t kSmallFrameSize = 1 * KB; -// Determine whether a frame is small or large, used in the decision on whether to elide a -// stack overflow check on method entry. -// -// A frame is considered large when it's either above kLargeFrameSize, or a quarter of the -// overflow-usable stack space. -static constexpr bool IsLargeFrame(size_t size, InstructionSet isa) { - return size >= kLargeFrameSize || size >= GetStackOverflowReservedBytes(isa) / 4; -} - -// We want to ensure that on all systems kSmallFrameSize will lead to false in IsLargeFrame. -COMPILE_ASSERT(!IsLargeFrame(kSmallFrameSize, kArm), - kSmallFrameSize_is_not_a_small_frame_arm); -COMPILE_ASSERT(!IsLargeFrame(kSmallFrameSize, kArm64), - kSmallFrameSize_is_not_a_small_frame_arm64); -COMPILE_ASSERT(!IsLargeFrame(kSmallFrameSize, kMips), - kSmallFrameSize_is_not_a_small_frame_mips); -COMPILE_ASSERT(!IsLargeFrame(kSmallFrameSize, kX86), - kSmallFrameSize_is_not_a_small_frame_x86); -COMPILE_ASSERT(!IsLargeFrame(kSmallFrameSize, kX86_64), - kSmallFrameSize_is_not_a_small_frame_x64_64); - class Mir2Lir : public Backend { public: static constexpr bool kFailOnSizeError = true && kIsDebugBuild; static constexpr bool kReportSizeError = true && kIsDebugBuild; + // Determine whether a frame is small or large, used in the decision on whether to elide a + // stack overflow check on method entry. + // + // A frame is considered large when it's either above kLargeFrameSize, or a quarter of the + // overflow-usable stack space. + static bool IsLargeFrame(size_t size, InstructionSet isa) { + return size >= kLargeFrameSize || size >= GetStackOverflowReservedBytes(isa) / 4; + } + /* * Auxiliary information describing the location of data embedded in the Dalvik * byte code stream. |