[wasm][anyref] Add support for AnyRef in signature decoding
R=titzer@chromium.org Bug: v8:7581 Change-Id: I51c585aafa71cbc20565974929cba8327d7f8427 Reviewed-on: https://chromium-review.googlesource.com/973305 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Cr-Commit-Position: refs/heads/master@{#52133}
This commit is contained in:
parent
8985083369
commit
80df03e31f
@ -588,6 +588,8 @@ DEFINE_BOOL(experimental_wasm_sat_f2i_conversions, false,
|
||||
"enable non-trapping float-to-int conversions for wasm")
|
||||
DEFINE_BOOL(experimental_wasm_se, false,
|
||||
"enable prototype sign extension opcodes for wasm")
|
||||
DEFINE_BOOL(experimental_wasm_anyref, false,
|
||||
"enable prototype anyref support for wasm")
|
||||
|
||||
DEFINE_BOOL(wasm_opt, false, "enable wasm optimization")
|
||||
DEFINE_BOOL(wasm_no_bounds_checks, false,
|
||||
|
@ -241,6 +241,9 @@ struct BlockTypeOperand {
|
||||
case kLocalS128:
|
||||
*result = kWasmS128;
|
||||
return true;
|
||||
case kLocalAnyRef:
|
||||
*result = kWasmAnyRef;
|
||||
return true;
|
||||
default:
|
||||
*result = kWasmVar;
|
||||
return false;
|
||||
|
@ -1244,10 +1244,14 @@ class ModuleDecoderImpl : public Decoder {
|
||||
case kLocalF64:
|
||||
return kWasmF64;
|
||||
default:
|
||||
if (IsWasm() && FLAG_experimental_wasm_simd) {
|
||||
if (IsWasm()) {
|
||||
switch (t) {
|
||||
case kLocalS128:
|
||||
return kWasmS128;
|
||||
if (FLAG_experimental_wasm_simd) return kWasmS128;
|
||||
break;
|
||||
case kLocalAnyRef:
|
||||
if (FLAG_experimental_wasm_anyref) return kWasmAnyRef;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ enum ValueTypeCode : uint8_t {
|
||||
kLocalI64 = 0x7e,
|
||||
kLocalF32 = 0x7d,
|
||||
kLocalF64 = 0x7c,
|
||||
kLocalS128 = 0x7b
|
||||
kLocalS128 = 0x7b,
|
||||
kLocalAnyRef = 0x6f
|
||||
};
|
||||
// Binary encoding of other types.
|
||||
constexpr uint8_t kWasmFunctionTypeCode = 0x60;
|
||||
|
@ -23,6 +23,7 @@ constexpr ValueType kWasmI32 = MachineRepresentation::kWord32;
|
||||
constexpr ValueType kWasmI64 = MachineRepresentation::kWord64;
|
||||
constexpr ValueType kWasmF32 = MachineRepresentation::kFloat32;
|
||||
constexpr ValueType kWasmF64 = MachineRepresentation::kFloat64;
|
||||
constexpr ValueType kWasmAnyRef = MachineRepresentation::kTaggedPointer;
|
||||
constexpr ValueType kWasmS128 = MachineRepresentation::kSimd128;
|
||||
constexpr ValueType kWasmVar = MachineRepresentation::kTagged;
|
||||
|
||||
@ -749,6 +750,8 @@ class V8_EXPORT_PRIVATE WasmOpcodes {
|
||||
return kLocalF64;
|
||||
case kWasmS128:
|
||||
return kLocalS128;
|
||||
case kWasmAnyRef:
|
||||
return kLocalAnyRef;
|
||||
case kWasmStmt:
|
||||
return kLocalVoid;
|
||||
default:
|
||||
|
@ -137,7 +137,8 @@ struct ValueTypePair {
|
||||
} kValueTypes[] = {{kLocalI32, kWasmI32},
|
||||
{kLocalI64, kWasmI64},
|
||||
{kLocalF32, kWasmF32},
|
||||
{kLocalF64, kWasmF64}};
|
||||
{kLocalF64, kWasmF64},
|
||||
{kLocalAnyRef, kWasmAnyRef}};
|
||||
|
||||
class WasmModuleVerifyTest : public TestWithIsolateAndZone {
|
||||
public:
|
||||
@ -894,7 +895,17 @@ TEST_F(WasmModuleVerifyTest, IndirectFunctionInvalidIndex) {
|
||||
EXPECT_FAILURE(data);
|
||||
}
|
||||
|
||||
class WasmSignatureDecodeTest : public TestWithZone {};
|
||||
class WasmSignatureDecodeTest : public TestWithZone {
|
||||
public:
|
||||
WasmSignatureDecodeTest()
|
||||
// In the following tests we turn on support for AnyRef by default. There
|
||||
// is a test (Fail_anyref_without_flag) which explicitly turns off support
|
||||
// for AnyRef.
|
||||
: flag_scope(&FLAG_experimental_wasm_anyref, true) {}
|
||||
|
||||
private:
|
||||
FlagScope<bool> flag_scope;
|
||||
};
|
||||
|
||||
TEST_F(WasmSignatureDecodeTest, Ok_v_v) {
|
||||
static const byte data[] = {SIG_ENTRY_v_v};
|
||||
@ -1010,6 +1021,19 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) {
|
||||
byte kInvalidType = 76;
|
||||
for (size_t i = 0; i < SIZEOF_SIG_ENTRY_x_xx; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user