Commit 510246f6 authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Use the native_context for the TypeError in ToJS()

With this CL we use isolate->native_context() to provide a context for
the CEntryStub of the runtime call. The native_context() is sufficient
here because Runtime::kWasmThrowTypeError does not use the context.

R=titzer@chromium.org
TEST=mjsunit/wasm/ffi-error.js
BUG=chromium:639492

Review-Url: https://codereview.chromium.org/2291043002
Cr-Commit-Position: refs/heads/master@{#39014}
parent 4099b1a3
...@@ -2197,11 +2197,11 @@ Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) { ...@@ -2197,11 +2197,11 @@ Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) {
case wasm::kAstI32: case wasm::kAstI32:
return BuildChangeInt32ToTagged(node); return BuildChangeInt32ToTagged(node);
case wasm::kAstI64: case wasm::kAstI64:
DCHECK(module_ && !module_->instance->context.is_null()); // Throw a TypeError. The native context is good enough here because we
// Throw a TypeError. // only throw a TypeError.
return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(), return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
module_->instance->context, nullptr, 0, effect_, jsgraph()->isolate()->native_context(), nullptr,
*control_); 0, effect_, *control_);
case wasm::kAstF32: case wasm::kAstF32:
node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(), node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(),
node); node);
......
...@@ -78,3 +78,23 @@ assertThrows(function() { ...@@ -78,3 +78,23 @@ assertThrows(function() {
module.exports.function_with_invalid_signature(33, 88); module.exports.function_with_invalid_signature(33, 88);
}, TypeError); }, TypeError);
})(); })();
(function I64JSImportThrows() {
var builder = new WasmModuleBuilder();
var sig_index = builder.addType(kSig_i_i);
var sig_i64_index = builder.addType(kSig_i_l);
var index = builder.addImport("func", sig_i64_index);
builder.addFunction("main", sig_index)
.addBody([
kExprGetLocal, 0,
kExprI64SConvertI32,
kExprCallImport, kArity1, index // --
]) // --
.exportFunc();
var func = function() {return {};};
var main = builder.instantiate({func: func}).exports.main;
assertThrows(function() {
main(13);
}, TypeError);
})();
...@@ -93,6 +93,7 @@ var kAstF64 = 4; ...@@ -93,6 +93,7 @@ var kAstF64 = 4;
var kSig_i = makeSig([], [kAstI32]); var kSig_i = makeSig([], [kAstI32]);
var kSig_d = makeSig([], [kAstF64]); var kSig_d = makeSig([], [kAstF64]);
var kSig_i_i = makeSig([kAstI32], [kAstI32]); var kSig_i_i = makeSig([kAstI32], [kAstI32]);
var kSig_i_l = makeSig([kAstI64], [kAstI32]);
var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]); var kSig_i_ii = makeSig([kAstI32, kAstI32], [kAstI32]);
var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]); var kSig_i_iii = makeSig([kAstI32, kAstI32, kAstI32], [kAstI32]);
var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]); var kSig_d_dd = makeSig([kAstF64, kAstF64], [kAstF64]);
......
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