[wasm-simd] Set default args for v128 values

Instantiating a module that contains a function (exported) with a v128
in its signature is fine, but then later calling it will trap.

So v128 values are technically not callable from JS, but we can give it
a default argument of 0, and will later trap anyway. This is useful when
fuzzers generate functions with v128 in the signature of the main
function that we then later try to call.

Bug: chromium:1129068
Change-Id: I93f239a0355b8059e25b8bd5f1274d151d71ee11
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2419657
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70038}
This commit is contained in:
Ng Zhi An 2020-09-21 13:31:37 -07:00 committed by Commit Bot
parent 4a2b2b2e56
commit 83fa52a543
2 changed files with 8 additions and 2 deletions

View File

@ -60,6 +60,9 @@ OwnedVector<WasmValue> MakeDefaultInterpreterArguments(Isolate* isolate,
case ValueType::kF64:
arguments[i] = WasmValue(0.0);
break;
case ValueType::kS128:
arguments[i] = WasmValue(Simd128{});
break;
case ValueType::kOptRef:
arguments[i] =
WasmValue(Handle<Object>::cast(isolate->factory()->null_value()));
@ -70,7 +73,6 @@ OwnedVector<WasmValue> MakeDefaultInterpreterArguments(Isolate* isolate,
case ValueType::kI16:
case ValueType::kStmt:
case ValueType::kBottom:
case ValueType::kS128:
UNREACHABLE();
}
}
@ -88,6 +90,9 @@ OwnedVector<Handle<Object>> MakeDefaultArguments(Isolate* isolate,
case ValueType::kI32:
case ValueType::kF32:
case ValueType::kF64:
case ValueType::kS128:
// Argument here for kS128 does not matter as we should error out before
// hitting this case.
arguments[i] = handle(Smi::zero(), isolate);
break;
case ValueType::kI64:
@ -102,7 +107,6 @@ OwnedVector<Handle<Object>> MakeDefaultArguments(Isolate* isolate,
case ValueType::kI16:
case ValueType::kStmt:
case ValueType::kBottom:
case ValueType::kS128:
UNREACHABLE();
}
}

View File

@ -123,6 +123,8 @@ const char* ValueTypeToConstantName(ValueType type) {
return "kWasmF32";
case ValueType::kF64:
return "kWasmF64";
case ValueType::kS128:
return "kWasmS128";
case ValueType::kOptRef:
switch (type.heap_representation()) {
case HeapType::kExtern: