[wasm] FromJS throws a TypeError for I64 values.
This behavior is required by the WebAssembly spec. TEST=mjsunit/wasm/ffi-error.js:I64ParamsInSignatureThrows R=titzer@chromium.org Review-Url: https://codereview.chromium.org/2360653002 Cr-Commit-Position: refs/heads/master@{#39600}
This commit is contained in:
parent
b11a8b4d41
commit
4c1d574b22
@ -2393,15 +2393,11 @@ Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wasm::kAstI64:
|
case wasm::kAstI64:
|
||||||
// TODO(titzer): JS->i64 has no good solution right now. Using 32 bits.
|
// Throw a TypeError. The native context is good enough here because we
|
||||||
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToWord32(),
|
// only throw a TypeError.
|
||||||
num);
|
return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
|
||||||
if (jsgraph()->machine()->Is64()) {
|
jsgraph()->isolate()->native_context(), nullptr,
|
||||||
// We cannot change an int32 to an int64 on a 32 bit platform. Instead
|
0, effect_, *control_);
|
||||||
// we will split the parameter node later.
|
|
||||||
num = graph()->NewNode(jsgraph()->machine()->ChangeInt32ToInt64(), num);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case wasm::kAstF32:
|
case wasm::kAstF32:
|
||||||
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(),
|
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(),
|
||||||
num);
|
num);
|
||||||
|
@ -79,6 +79,23 @@ assertThrows(function() {
|
|||||||
}, TypeError);
|
}, TypeError);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(function I64ParamsInSignatureThrows() {
|
||||||
|
var builder = new WasmModuleBuilder();
|
||||||
|
|
||||||
|
builder.addMemory(1, 1, true);
|
||||||
|
builder.addFunction("function_with_invalid_signature", kSig_i_l)
|
||||||
|
.addBody([
|
||||||
|
kExprGetLocal, 0,
|
||||||
|
kExprI32ConvertI64
|
||||||
|
])
|
||||||
|
.exportFunc()
|
||||||
|
|
||||||
|
var module = builder.instantiate();
|
||||||
|
|
||||||
|
assertThrows(function() {
|
||||||
|
module.exports.function_with_invalid_signature(33);
|
||||||
|
}, TypeError);
|
||||||
|
})();
|
||||||
|
|
||||||
(function I64JSImportThrows() {
|
(function I64JSImportThrows() {
|
||||||
var builder = new WasmModuleBuilder();
|
var builder = new WasmModuleBuilder();
|
||||||
|
Loading…
Reference in New Issue
Block a user