Commit 43744b96 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm][anyref] Support decoding of signatures with AnyFunc

With this CL we now also support the decoding of the AnyFunc
type. I will add the type more deeply in subsequent CLs.

R=titzer@chromium.org

Bug: v8:7581
Change-Id: I9f30706a442462f915adfd8f720eb65168b80bb8
Reviewed-on: https://chromium-review.googlesource.com/1014111
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54318}
parent f695855c
......@@ -248,6 +248,9 @@ struct BlockTypeImmediate {
case kLocalS128:
*result = kWasmS128;
return true;
case kLocalAnyFunc:
*result = kWasmAnyFunc;
return true;
case kLocalAnyRef:
*result = kWasmAnyRef;
return true;
......
......@@ -1280,6 +1280,9 @@ class ModuleDecoderImpl : public Decoder {
case kLocalS128:
if (FLAG_experimental_wasm_simd) return kWasmS128;
break;
case kLocalAnyFunc:
if (FLAG_experimental_wasm_anyref) return kWasmAnyFunc;
break;
case kLocalAnyRef:
if (FLAG_experimental_wasm_anyref) return kWasmAnyRef;
break;
......
......@@ -20,6 +20,7 @@ enum ValueType : uint8_t {
kWasmF64,
kWasmS128,
kWasmAnyRef,
kWasmAnyFunc,
kWasmVar,
};
......@@ -234,6 +235,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return MachineType::Float32();
case kWasmF64:
return MachineType::Float64();
case kWasmAnyFunc:
case kWasmAnyRef:
return MachineType::TaggedPointer();
case kWasmS128:
......
......@@ -21,6 +21,7 @@ enum ValueTypeCode : uint8_t {
kLocalF32 = 0x7d,
kLocalF64 = 0x7c,
kLocalS128 = 0x7b,
kLocalAnyFunc = 0x70,
kLocalAnyRef = 0x6f
};
// Binary encoding of other types.
......
......@@ -135,11 +135,14 @@ static size_t SizeOfVarInt(size_t value) {
struct ValueTypePair {
uint8_t code;
ValueType type;
} kValueTypes[] = {{kLocalI32, kWasmI32},
{kLocalI64, kWasmI64},
{kLocalF32, kWasmF32},
{kLocalF64, kWasmF64},
{kLocalAnyRef, kWasmAnyRef}};
} kValueTypes[] = {
{kLocalI32, kWasmI32}, // --
{kLocalI64, kWasmI64}, // --
{kLocalF32, kWasmF32}, // --
{kLocalF64, kWasmF64}, // --
{kLocalAnyFunc, kWasmAnyFunc}, // --
{kLocalAnyRef, kWasmAnyRef} // --
};
class WasmModuleVerifyTest : public TestWithIsolateAndZone {
public:
......@@ -1086,13 +1089,15 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) {
TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) {
// Disable AnyRef support and check that decoding fails.
FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, false);
byte kInvalidType = kLocalAnyRef;
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
data[i] = kInvalidType;
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
byte ref_types[] = {kLocalAnyFunc, kLocalAnyRef};
for (byte invalid_type : ref_types) {
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
data[i] = invalid_type;
FunctionSig* sig =
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
EXPECT_EQ(nullptr, sig);
}
}
}
......
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