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 { ...@@ -248,6 +248,9 @@ struct BlockTypeImmediate {
case kLocalS128: case kLocalS128:
*result = kWasmS128; *result = kWasmS128;
return true; return true;
case kLocalAnyFunc:
*result = kWasmAnyFunc;
return true;
case kLocalAnyRef: case kLocalAnyRef:
*result = kWasmAnyRef; *result = kWasmAnyRef;
return true; return true;
......
...@@ -1280,6 +1280,9 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1280,6 +1280,9 @@ class ModuleDecoderImpl : public Decoder {
case kLocalS128: case kLocalS128:
if (FLAG_experimental_wasm_simd) return kWasmS128; if (FLAG_experimental_wasm_simd) return kWasmS128;
break; break;
case kLocalAnyFunc:
if (FLAG_experimental_wasm_anyref) return kWasmAnyFunc;
break;
case kLocalAnyRef: case kLocalAnyRef:
if (FLAG_experimental_wasm_anyref) return kWasmAnyRef; if (FLAG_experimental_wasm_anyref) return kWasmAnyRef;
break; break;
......
...@@ -20,6 +20,7 @@ enum ValueType : uint8_t { ...@@ -20,6 +20,7 @@ enum ValueType : uint8_t {
kWasmF64, kWasmF64,
kWasmS128, kWasmS128,
kWasmAnyRef, kWasmAnyRef,
kWasmAnyFunc,
kWasmVar, kWasmVar,
}; };
...@@ -234,6 +235,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -234,6 +235,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return MachineType::Float32(); return MachineType::Float32();
case kWasmF64: case kWasmF64:
return MachineType::Float64(); return MachineType::Float64();
case kWasmAnyFunc:
case kWasmAnyRef: case kWasmAnyRef:
return MachineType::TaggedPointer(); return MachineType::TaggedPointer();
case kWasmS128: case kWasmS128:
......
...@@ -21,6 +21,7 @@ enum ValueTypeCode : uint8_t { ...@@ -21,6 +21,7 @@ enum ValueTypeCode : uint8_t {
kLocalF32 = 0x7d, kLocalF32 = 0x7d,
kLocalF64 = 0x7c, kLocalF64 = 0x7c,
kLocalS128 = 0x7b, kLocalS128 = 0x7b,
kLocalAnyFunc = 0x70,
kLocalAnyRef = 0x6f kLocalAnyRef = 0x6f
}; };
// Binary encoding of other types. // Binary encoding of other types.
......
...@@ -135,11 +135,14 @@ static size_t SizeOfVarInt(size_t value) { ...@@ -135,11 +135,14 @@ static size_t SizeOfVarInt(size_t value) {
struct ValueTypePair { struct ValueTypePair {
uint8_t code; uint8_t code;
ValueType type; ValueType type;
} kValueTypes[] = {{kLocalI32, kWasmI32}, } kValueTypes[] = {
{kLocalI64, kWasmI64}, {kLocalI32, kWasmI32}, // --
{kLocalF32, kWasmF32}, {kLocalI64, kWasmI64}, // --
{kLocalF64, kWasmF64}, {kLocalF32, kWasmF32}, // --
{kLocalAnyRef, kWasmAnyRef}}; {kLocalF64, kWasmF64}, // --
{kLocalAnyFunc, kWasmAnyFunc}, // --
{kLocalAnyRef, kWasmAnyRef} // --
};
class WasmModuleVerifyTest : public TestWithIsolateAndZone { class WasmModuleVerifyTest : public TestWithIsolateAndZone {
public: public:
...@@ -1086,13 +1089,15 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) { ...@@ -1086,13 +1089,15 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) {
TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) { TEST_F(WasmSignatureDecodeTest, Fail_anyref_without_flag) {
// Disable AnyRef support and check that decoding fails. // Disable AnyRef support and check that decoding fails.
FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, false); FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, false);
byte kInvalidType = kLocalAnyRef; byte ref_types[] = {kLocalAnyFunc, kLocalAnyRef};
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) { for (byte invalid_type : ref_types) {
byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)}; for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
data[i] = kInvalidType; byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalI32)};
FunctionSig* sig = data[i] = invalid_type;
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); FunctionSig* sig =
EXPECT_EQ(nullptr, 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