summaryrefslogtreecommitdiff
path: root/runtime/thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r--runtime/thread.cc39
1 files changed, 17 insertions, 22 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index a8133a1fda..19d9485f5e 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -504,6 +504,13 @@ static size_t FixStackSize(size_t stack_size) {
// so include that here to support apps that expect large native stacks.
stack_size += 1 * MB;
+ // Under sanitization, frames of the interpreter may become bigger, both for C code as
+ // well as the ShadowFrame. Ensure a larger minimum size. Otherwise initialization
+ // of all core classes cannot be done in all test circumstances.
+ if (kMemoryToolIsAvailable) {
+ stack_size = std::max(2 * MB, stack_size);
+ }
+
// It's not possible to request a stack smaller than the system-defined PTHREAD_STACK_MIN.
if (stack_size < PTHREAD_STACK_MIN) {
stack_size = PTHREAD_STACK_MIN;
@@ -598,7 +605,7 @@ void Thread::InstallImplicitProtection() {
1u;
#endif
volatile char space[kPageSize - (kAsanMultiplier * 256)];
- char sink ATTRIBUTE_UNUSED = space[zero];
+ char sink ATTRIBUTE_UNUSED = space[zero]; // NOLINT
if (reinterpret_cast<uintptr_t>(space) >= target + kPageSize) {
Touch(target);
}
@@ -1116,21 +1123,10 @@ bool Thread::InitStackHwm() {
Runtime* runtime = Runtime::Current();
bool implicit_stack_check = !runtime->ExplicitStackOverflowChecks() && !runtime->IsAotCompiler();
- // Valgrind on arm doesn't give the right values here. Do not install the guard page, and
- // effectively disable stack overflow checks (we'll get segfaults, potentially) by setting
- // stack_begin to 0.
- const bool valgrind_on_arm =
- (kRuntimeISA == InstructionSet::kArm || kRuntimeISA == InstructionSet::kArm64) &&
- kMemoryToolIsValgrind &&
- RUNNING_ON_MEMORY_TOOL != 0;
- if (valgrind_on_arm) {
- tlsPtr_.stack_begin = nullptr;
- }
-
ResetDefaultStackEnd();
// Install the protected region if we are doing implicit overflow checks.
- if (implicit_stack_check && !valgrind_on_arm) {
+ if (implicit_stack_check) {
// The thread might have protected region at the bottom. We need
// to install our own region so we need to move the limits
// of the stack to make room for it.
@@ -1583,7 +1579,7 @@ void Thread::FullSuspendCheck() {
VLOG(threads) << this << " self-suspending";
// Make thread appear suspended to other threads, release mutator_lock_.
// Transition to suspended and back to runnable, re-acquire share on mutator_lock_.
- ScopedThreadSuspension(this, kSuspended);
+ ScopedThreadSuspension(this, kSuspended); // NOLINT
VLOG(threads) << this << " self-reviving";
}
@@ -2049,15 +2045,15 @@ void Thread::FinishStartup() {
// Finish attaching the main thread.
ScopedObjectAccess soa(Thread::Current());
- Thread::Current()->CreatePeer("main", false, runtime->GetMainThreadGroup());
- Thread::Current()->AssertNoPendingException();
+ soa.Self()->CreatePeer("main", false, runtime->GetMainThreadGroup());
+ soa.Self()->AssertNoPendingException();
- Runtime::Current()->GetClassLinker()->RunRootClinits();
+ runtime->RunRootClinits(soa.Self());
// The thread counts as started from now on. We need to add it to the ThreadGroup. For regular
// threads, this is done in Thread.start() on the Java side.
- Thread::Current()->NotifyThreadGroup(soa, runtime->GetMainThreadGroup());
- Thread::Current()->AssertNoPendingException();
+ soa.Self()->NotifyThreadGroup(soa, runtime->GetMainThreadGroup());
+ soa.Self()->AssertNoPendingException();
}
void Thread::Shutdown() {
@@ -3656,8 +3652,7 @@ class ReferenceMapVisitor : public StackVisitor {
RootVisitor& _visitor)
: number_of_dex_registers(method->DexInstructionData().RegistersSize()),
code_info(_code_info),
- dex_register_map(code_info.GetDexRegisterMapOf(map,
- number_of_dex_registers)),
+ dex_register_map(code_info.GetDexRegisterMapOf(map)),
visitor(_visitor) {
}
@@ -3670,7 +3665,7 @@ class ReferenceMapVisitor : public StackVisitor {
REQUIRES_SHARED(Locks::mutator_lock_) {
bool found = false;
for (size_t dex_reg = 0; dex_reg != number_of_dex_registers; ++dex_reg) {
- DexRegisterLocation location = dex_register_map.GetDexRegisterLocation(dex_reg);
+ DexRegisterLocation location = dex_register_map[dex_reg];
if (location.GetKind() == kind && static_cast<size_t>(location.GetValue()) == index) {
visitor(ref, dex_reg, stack_visitor);
found = true;