summaryrefslogtreecommitdiffstats
path: root/runtime/instruction_set.cc
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-07-14 16:21:44 -0700
committerAndreas Gampe <agampe@google.com>2014-07-21 23:36:31 -0700
commit7ea6f79bbddd69d5db86a8656a31aaaf64ae2582 (patch)
treec64f89b15ca71e87317f6dd405ef4a5560b73e01 /runtime/instruction_set.cc
parente72ff8022968b23efedc56c0afdc1d24e8a928c2 (diff)
downloadart-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 'runtime/instruction_set.cc')
-rw-r--r--runtime/instruction_set.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/runtime/instruction_set.cc b/runtime/instruction_set.cc
index 5b6039647..d7e358ce9 100644
--- a/runtime/instruction_set.cc
+++ b/runtime/instruction_set.cc
@@ -83,6 +83,44 @@ size_t GetInstructionSetAlignment(InstructionSet isa) {
}
}
+
+static constexpr size_t kDefaultStackOverflowReservedBytes = 16 * KB;
+static constexpr size_t kMipsStackOverflowReservedBytes = kDefaultStackOverflowReservedBytes;
+
+// TODO: Lower once implicit stack-overflow checks can work with less than 16K.
+static constexpr size_t kArmStackOverflowReservedBytes = (kIsDebugBuild ? 16 : 16) * KB;
+static constexpr size_t kArm64StackOverflowReservedBytes = (kIsDebugBuild ? 16 : 16) * KB;
+static constexpr size_t kX86StackOverflowReservedBytes = (kIsDebugBuild ? 16 : 16) * KB;
+static constexpr size_t kX86_64StackOverflowReservedBytes = (kIsDebugBuild ? 16 : 16) * KB;
+
+size_t GetStackOverflowReservedBytes(InstructionSet isa) {
+ switch (isa) {
+ case kArm: // Intentional fall-through.
+ case kThumb2:
+ return kArmStackOverflowReservedBytes;
+
+ case kArm64:
+ return kArm64StackOverflowReservedBytes;
+
+ case kMips:
+ return kMipsStackOverflowReservedBytes;
+
+ case kX86:
+ return kX86StackOverflowReservedBytes;
+
+ case kX86_64:
+ return kX86_64StackOverflowReservedBytes;
+
+ case kNone:
+ LOG(FATAL) << "kNone has no stack overflow size";
+ return 0;
+
+ default:
+ LOG(FATAL) << "Unknown instruction set" << isa;
+ return 0;
+ }
+}
+
std::string InstructionSetFeatures::GetFeatureString() const {
std::string result;
if ((mask_ & kHwDiv) != 0) {