From a00b54b74bee06c006b8bebfbef85e2801de293c Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 3 Dec 2019 14:36:42 +0000 Subject: Helpers and refactorings to prepare for interpreter optimizations (x64) - Add data structure offsets that will be used in assembly code. - Be explicit about a stack overflow in a fault handler. - Move assembly helper code in asm_support so interpreter can use it. - Support putting literals in InterpreterCache. - Fix artHandleFillArrayDataFromCode for x64. Bug: 119800099 Test: test.py Change-Id: I2729f87fe5d09c04ae2e7081636f0cd89ac14c21 --- runtime/fault_handler.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'runtime/fault_handler.cc') diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc index 5c2830d96b..cae7debc03 100644 --- a/runtime/fault_handler.cc +++ b/runtime/fault_handler.cc @@ -291,10 +291,11 @@ bool FaultManager::IsInGeneratedCode(siginfo_t* siginfo, void* context, bool che ArtMethod* method_obj = nullptr; uintptr_t return_pc = 0; uintptr_t sp = 0; + bool is_stack_overflow = false; // Get the architecture specific method address and return address. These // are in architecture specific files in arch//fault_handler_. - GetMethodAndReturnPcAndSp(siginfo, context, &method_obj, &return_pc, &sp); + GetMethodAndReturnPcAndSp(siginfo, context, &method_obj, &return_pc, &sp, &is_stack_overflow); // If we don't have a potential method, we're outta here. VLOG(signals) << "potential method: " << method_obj; @@ -336,7 +337,15 @@ bool FaultManager::IsInGeneratedCode(siginfo_t* siginfo, void* context, bool che reinterpret_cast(method_header->GetEntryPoint()); VLOG(signals) << "pc offset: " << std::hex << sought_offset; } - uint32_t dexpc = method_header->ToDexPc(method_obj, return_pc, false); + uint32_t dexpc = dex::kDexNoIndex; + if (is_stack_overflow) { + // If it's an implicit stack overflow check, the frame is not setup, so we + // just infer the dex PC as zero. + dexpc = 0; + } else { + CHECK_EQ(*reinterpret_cast(sp), method_obj); + dexpc = method_header->ToDexPc(reinterpret_cast(sp), return_pc, false); + } VLOG(signals) << "dexpc: " << dexpc; return !check_dex_pc || dexpc != dex::kDexNoIndex; } @@ -380,9 +389,11 @@ bool JavaStackTraceHandler::Action(int sig ATTRIBUTE_UNUSED, siginfo_t* siginfo, ArtMethod* method = nullptr; uintptr_t return_pc = 0; uintptr_t sp = 0; + bool is_stack_overflow = false; Thread* self = Thread::Current(); - manager_->GetMethodAndReturnPcAndSp(siginfo, context, &method, &return_pc, &sp); + manager_->GetMethodAndReturnPcAndSp( + siginfo, context, &method, &return_pc, &sp, &is_stack_overflow); // Inside of generated code, sp[0] is the method, so sp is the frame. self->SetTopOfStack(reinterpret_cast(sp)); self->DumpJavaStack(LOG_STREAM(ERROR)); -- cgit v1.2.3-59-g8ed1b