Commit 5bc1809e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Simplify unwinding of interpreter activations.

R=clemensh@chromium.org

Change-Id: I3c5f38c33d5fdb08f927e5417d4d85652d0125ac
Reviewed-on: https://chromium-review.googlesource.com/c/1454603Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59366}
parent b43d8a67
......@@ -1747,10 +1747,6 @@ Object Isolate::UnwindAndFindHandler() {
if (trap_handler::IsThreadInWasm()) {
trap_handler::ClearThreadInWasm();
}
WasmInterpreterEntryFrame* interpreter_frame =
WasmInterpreterEntryFrame::cast(frame);
// TODO(wasm): Implement try-catch in the interpreter.
interpreter_frame->debug_info()->Unwind(frame->fp());
} break;
case StackFrame::JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH: {
......
......@@ -216,15 +216,21 @@ class InterpreterHandle {
Handle<Object> exception =
isolate_->factory()->NewWasmRuntimeError(message_id);
isolate_->Throw(*exception);
// Handle this exception. Return without trying to read back the
// return value.
// Handle this exception locally within the activation.
auto result = thread->HandleException(isolate_);
return result == WasmInterpreter::Thread::HANDLED;
} break;
if (result == WasmInterpreter::Thread::HANDLED) break;
// If no local handler was found, we fall-thru to {STOPPED}.
DCHECK_EQ(WasmInterpreter::State::STOPPED, thread->state());
V8_FALLTHROUGH;
}
case WasmInterpreter::State::STOPPED:
// An exception happened, and the current activation was unwound.
// An exception happened, and the current activation was unwound
// without hitting a local exception handler. All that remains to be
// done is finish the activation and let the exception propagate.
DCHECK_EQ(thread->ActivationFrameBase(activation_id),
thread->GetFrameCount());
DCHECK(isolate_->has_pending_exception());
FinishActivation(frame_pointer, activation_id);
return false;
// RUNNING should never occur here.
case WasmInterpreter::State::RUNNING:
......@@ -379,20 +385,6 @@ class InterpreterHandle {
return thread->GetFrame(frame_range.first + idx);
}
void Unwind(Address frame_pointer) {
// Find the current activation.
DCHECK_EQ(1, activations_.count(frame_pointer));
// Activations must be properly stacked:
DCHECK_EQ(activations_.size() - 1, activations_[frame_pointer]);
uint32_t activation_id = static_cast<uint32_t>(activations_.size() - 1);
// The top activation must have no active frames. The interpreter already
// had a chance to handle exceptions and hence dropped all frames.
DCHECK_EQ(interpreter()->GetThread(0)->GetFrameCount(),
interpreter()->GetThread(0)->ActivationFrameBase(activation_id));
// All that remains to be done is finish the activation.
FinishActivation(frame_pointer, activation_id);
}
uint64_t NumInterpretedCalls() {
DCHECK_EQ(1, interpreter()->GetThreadCount());
return interpreter()->GetThread(0)->NumInterpretedCalls();
......@@ -626,10 +618,6 @@ wasm::WasmInterpreter::FramePtr WasmDebugInfo::GetInterpretedFrame(
return GetInterpreterHandle(*this)->GetInterpretedFrame(frame_pointer, idx);
}
void WasmDebugInfo::Unwind(Address frame_pointer) {
return GetInterpreterHandle(*this)->Unwind(frame_pointer);
}
uint64_t WasmDebugInfo::NumInterpretedCalls() {
auto* handle = GetInterpreterHandleOrNull(*this);
return handle ? handle->NumInterpretedCalls() : 0;
......
......@@ -710,10 +710,6 @@ class WasmDebugInfo : public Struct {
std::unique_ptr<wasm::InterpretedFrame, wasm::InterpretedFrameDeleter>
GetInterpretedFrame(Address frame_pointer, int frame_index);
// Unwind the interpreted stack belonging to the passed interpreter entry
// frame.
void Unwind(Address frame_pointer);
// Returns the number of calls / function frames executed in the interpreter.
uint64_t NumInterpretedCalls();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment