[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;
|
||||
}
|
||||
case wasm::kAstI64:
|
||||
// TODO(titzer): JS->i64 has no good solution right now. Using 32 bits.
|
||||
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToWord32(),
|
||||
num);
|
||||
if (jsgraph()->machine()->Is64()) {
|
||||
// We cannot change an int32 to an int64 on a 32 bit platform. Instead
|
||||
// we will split the parameter node later.
|
||||
num = graph()->NewNode(jsgraph()->machine()->ChangeInt32ToInt64(), num);
|
||||
}
|
||||
break;
|
||||
// Throw a TypeError. The native context is good enough here because we
|
||||
// only throw a TypeError.
|
||||
return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
|
||||
jsgraph()->isolate()->native_context(), nullptr,
|
||||
0, effect_, *control_);
|
||||
case wasm::kAstF32:
|
||||
num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(),
|
||||
num);
|
||||
|
@ -79,6 +79,23 @@ assertThrows(function() {
|
||||
}, 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() {
|
||||
var builder = new WasmModuleBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user