Commit 89272565 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Fix source positions for rethrown exceptions.

This fixes the source position printed in the stack trace for exceptions
rethrown from within Wasm code. This only affects the message propagated
to the console, not the trace stored as part of the exception object.

Note that there still is a more fundamental issues with preserving the
original message of a caught exception and funneling it through to each
rethrow site, which is still missing. This change just makes sure that
the interpreter and TurboFan are consistent.

R=clemensh@chromium.org
TEST=message/fail/wasm-exception-rethrow
BUG=v8:8091

Change-Id: Iac04149ded3c54f5b23faeb83b1228081bbd3dfa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1598754Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61374}
parent e0d7f816
...@@ -2254,13 +2254,16 @@ Node* WasmGraphBuilder::BuildDecodeException64BitValue(Node* values_array, ...@@ -2254,13 +2254,16 @@ Node* WasmGraphBuilder::BuildDecodeException64BitValue(Node* values_array,
Node* WasmGraphBuilder::Rethrow(Node* except_obj) { Node* WasmGraphBuilder::Rethrow(Node* except_obj) {
needs_stack_check_ = true; needs_stack_check_ = true;
// TODO(v8:8091): Currently the message of the original exception is not being
// preserved when rethrown to the console. The pending message will need to be
// saved when caught and restored here while being rethrown.
WasmThrowDescriptor interface_descriptor; WasmThrowDescriptor interface_descriptor;
auto call_descriptor = Linkage::GetStubCallDescriptor( auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), interface_descriptor, mcgraph()->zone(), interface_descriptor,
interface_descriptor.GetStackParameterCount(), CallDescriptor::kNoFlags, interface_descriptor.GetStackParameterCount(), CallDescriptor::kNoFlags,
Operator::kNoProperties, StubCallMode::kCallWasmRuntimeStub); Operator::kNoProperties, StubCallMode::kCallWasmRuntimeStub);
Node* call_target = mcgraph()->RelocatableIntPtrConstant( Node* call_target = mcgraph()->RelocatableIntPtrConstant(
wasm::WasmCode::kWasmThrow, RelocInfo::WASM_STUB_CALL); wasm::WasmCode::kWasmRethrow, RelocInfo::WASM_STUB_CALL);
return SetEffect(SetControl( return SetEffect(SetControl(
graph()->NewNode(mcgraph()->common()->Call(call_descriptor), call_target, graph()->NewNode(mcgraph()->common()->Call(call_descriptor), call_target,
except_obj, Effect(), Control()))); except_obj, Effect(), Control())));
......
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm --experimental-wasm-eh
load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
let except = builder.addException(kSig_v_i);
builder.addFunction("rethrow0", kSig_v_v)
.addBody([
kExprTry, kWasmStmt,
kExprI32Const, 23,
kExprThrow, except,
kExprCatch,
kExprRethrow,
kExprEnd,
]).exportFunc();
let instance = builder.instantiate();
instance.exports.rethrow0();
wasm-function[0]:5: RuntimeError: wasm exception
RuntimeError: wasm exception
at rethrow0 (wasm-function[0]:5)
at *%(basename)s:21:18
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