Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 1874383002: [wasm] Throw real Error on wasm trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@trapreasons-to-messages
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 5dc9f0be6376db858c13d95c1eac01ec57927e5d..9e94b5f4162e918029fa5e3f834c1cbc5e2c38bc 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -197,12 +197,13 @@ class WasmTrapHelper : public ZoneObject {
}
void BuildTrapCode(wasm::TrapReason reason) {
- Node* exception =
- builder_->String(wasm::WasmOpcodes::TrapReasonMessage(reason));
+ Node* message_id = builder_->NumberConstant(
+ wasm::WasmOpcodes::TrapReasonToMessageId(reason));
Node* end;
Node** control_ptr = builder_->control_;
Node** effect_ptr = builder_->effect_;
wasm::ModuleEnv* module = builder_->module_;
+ DCHECK(traps_[reason] == NULL);
*control_ptr = traps_[reason] =
graph()->NewNode(common()->Merge(1), *control_ptr);
*effect_ptr = effects_[reason] =
@@ -210,14 +211,14 @@ class WasmTrapHelper : public ZoneObject {
if (module && !module->instance->context.is_null()) {
// Use the module context to call the runtime to throw an exception.
- Runtime::FunctionId f = Runtime::kThrow;
+ Runtime::FunctionId f = Runtime::kThrowWasmError;
const Runtime::Function* fun = Runtime::FunctionForId(f);
CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
jsgraph()->zone(), f, fun->nargs, Operator::kNoProperties,
CallDescriptor::kNoFlags);
Node* inputs[] = {
jsgraph()->CEntryStubConstant(fun->result_size), // C entry
- exception, // exception
+ message_id, // message id
jsgraph()->ExternalConstant(
ExternalReference(f, jsgraph()->isolate())), // ref
jsgraph()->Int32Constant(fun->nargs), // arity
@@ -348,6 +349,9 @@ Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects,
buf);
}
+Node* WasmGraphBuilder::NumberConstant(int32_t value) {
+ return jsgraph()->Constant(value);
+}
Node* WasmGraphBuilder::Int32Constant(int32_t value) {
return jsgraph()->Int32Constant(value);

Powered by Google App Engine
This is Rietveld 408576698