diff options
Diffstat (limited to 'deps/v8/test/unittests/wasm/module-decoder-unittest.cc')
-rw-r--r-- | deps/v8/test/unittests/wasm/module-decoder-unittest.cc | 228 |
1 files changed, 141 insertions, 87 deletions
diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc index 26b4f74a7ab..3507f897f91 100644 --- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc @@ -7,6 +7,7 @@ #include "src/handles.h" #include "src/objects-inl.h" #include "src/wasm/module-decoder.h" +#include "src/wasm/wasm-features.h" #include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-opcodes.h" #include "test/common/wasm/flag-utils.h" @@ -146,6 +147,8 @@ struct ValueTypePair { class WasmModuleVerifyTest : public TestWithIsolateAndZone { public: + WasmFeatures enabled_features_; + ModuleResult DecodeModule(const byte* module_start, const byte* module_end) { // Add the wasm magic and version number automatically. size_t size = static_cast<size_t>(module_end - module_start); @@ -154,18 +157,39 @@ class WasmModuleVerifyTest : public TestWithIsolateAndZone { auto temp = new byte[total]; memcpy(temp, header, sizeof(header)); memcpy(temp + sizeof(header), module_start, size); - ModuleResult result = - SyncDecodeWasmModule(isolate(), temp, temp + total, false, kWasmOrigin); + ModuleResult result = DecodeWasmModule( + enabled_features_, temp, temp + total, false, kWasmOrigin, + isolate()->counters(), isolate()->allocator()); delete[] temp; return result; } ModuleResult DecodeModuleNoHeader(const byte* module_start, const byte* module_end) { - return SyncDecodeWasmModule(isolate(), module_start, module_end, false, - kWasmOrigin); + return DecodeWasmModule(enabled_features_, module_start, module_end, false, + kWasmOrigin, isolate()->counters(), + isolate()->allocator()); + } +}; + +namespace { +class EnableBoolScope { + public: + bool prev_; + bool* ptr_; + explicit EnableBoolScope(bool* ptr, bool val = true) + : prev_(*ptr), ptr_(ptr) { + *ptr = val; } + ~EnableBoolScope() { *ptr_ = prev_; } }; +#define WASM_FEATURE_SCOPE(feat) \ + EnableBoolScope feat##_scope(&this->enabled_features_.feat) + +#define WASM_FEATURE_SCOPE_VAL(feat, val) \ + EnableBoolScope feat##_scope(&this->enabled_features_.feat, val) +} // namespace + TEST_F(WasmModuleVerifyTest, WrongMagic) { for (uint32_t x = 1; x; x <<= 1) { const byte data[] = {U32_LE(kWasmMagic ^ x), U32_LE(kWasmVersion)}; @@ -217,7 +241,7 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) { } TEST_F(WasmModuleVerifyTest, AnyRefGlobal) { - EXPERIMENTAL_FLAG_SCOPE(anyref); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { SECTION(Global, 5), // -- 1, @@ -243,7 +267,7 @@ TEST_F(WasmModuleVerifyTest, AnyRefGlobal) { } TEST_F(WasmModuleVerifyTest, AnyRefGlobalWithGlobalInit) { - EXPERIMENTAL_FLAG_SCOPE(anyref); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { SECTION(Import, 8), // section header 1, // number of imports @@ -313,6 +337,7 @@ TEST_F(WasmModuleVerifyTest, ZeroGlobals) { } TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) { + WASM_FEATURE_SCOPE(mut_global); { static const byte data[] = { SECTION(Global, 6), // -- @@ -444,7 +469,7 @@ TEST_F(WasmModuleVerifyTest, ZeroExceptions) { }; FAIL_IF_NO_EXPERIMENTAL_EH(data); - EXPERIMENTAL_FLAG_SCOPE(eh); + WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); EXPECT_EQ(0u, result.val->exceptions.size()); @@ -458,7 +483,7 @@ TEST_F(WasmModuleVerifyTest, OneI32Exception) { }; FAIL_IF_NO_EXPERIMENTAL_EH(data); - EXPERIMENTAL_FLAG_SCOPE(eh); + WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); EXPECT_EQ(1u, result.val->exceptions.size()); @@ -476,7 +501,7 @@ TEST_F(WasmModuleVerifyTest, TwoExceptions) { 1, kLocalI32}; FAIL_IF_NO_EXPERIMENTAL_EH(data); - EXPERIMENTAL_FLAG_SCOPE(eh); + WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); EXPECT_EQ(2u, result.val->exceptions.size()); @@ -495,7 +520,7 @@ TEST_F(WasmModuleVerifyTest, Exception_invalid_type) { FAIL_IF_NO_EXPERIMENTAL_EH(data); // Should fail decoding exception section. - EXPERIMENTAL_FLAG_SCOPE(eh); + WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_FALSE(result.ok()); } @@ -939,7 +964,7 @@ TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) { TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTables) { // Test that if we have multiple tables, in the element section we can target // and initialize all tables. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -969,7 +994,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTables) { TEST_F(WasmModuleVerifyTest, ElementSectionMixedTables) { // Test that if we have multiple tables, both imported and module-defined, in // the element section we can target and initialize all tables. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -1026,7 +1051,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTables) { TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTablesArbitraryOrder) { // Test that the order in which tables are targeted in the element secion // can be arbitrary. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -1060,7 +1085,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTablesArbitraryOrder) { TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) { // Test that the order in which tables are targeted in the element secion can // be arbitrary. In this test, tables can be both imported and module-defined. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -1117,7 +1142,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) { TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefTable) { // Test that tables of type 'AnyRef' cannot be initialized by the element // section. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -1147,7 +1172,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefTable) { TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefImportedTable) { // Test that imported tables of type AnyRef cannot be initialized in the // elements section. - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { // sig#0 --------------------------------------------------------------- SIGNATURES_SECTION_VOID_VOID, @@ -1231,7 +1256,7 @@ TEST_F(WasmModuleVerifyTest, MultipleTablesWithoutFlag) { } TEST_F(WasmModuleVerifyTest, MultipleTablesWithFlag) { - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_anyref, true); + WASM_FEATURE_SCOPE(anyref); static const byte data[] = { SECTION(Table, 7), // table section ENTRY_COUNT(2), // 2 tables @@ -1257,22 +1282,18 @@ TEST_F(WasmModuleVerifyTest, MultipleTablesWithFlag) { 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; + WasmFeatures enabled_features_; + + FunctionSig* DecodeSig(const byte* start, const byte* end) { + return DecodeWasmSignatureForTesting(enabled_features_, zone(), start, end); + } }; TEST_F(WasmSignatureDecodeTest, Ok_v_v) { static const byte data[] = {SIG_ENTRY_v_v}; v8::internal::AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); - FunctionSig* sig = - DecodeWasmSignatureForTesting(&zone, data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_TRUE(sig != nullptr); EXPECT_EQ(0u, sig->parameter_count()); @@ -1280,11 +1301,11 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_v) { } TEST_F(WasmSignatureDecodeTest, Ok_t_v) { + WASM_FEATURE_SCOPE(anyref); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueTypePair ret_type = kValueTypes[i]; const byte data[] = {SIG_ENTRY_x(ret_type.code)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_TRUE(sig != nullptr); EXPECT_EQ(0u, sig->parameter_count()); @@ -1294,11 +1315,11 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_v) { } TEST_F(WasmSignatureDecodeTest, Ok_v_t) { + WASM_FEATURE_SCOPE(anyref); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueTypePair param_type = kValueTypes[i]; const byte data[] = {SIG_ENTRY_v_x(param_type.code)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_TRUE(sig != nullptr); EXPECT_EQ(1u, sig->parameter_count()); @@ -1308,13 +1329,13 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_t) { } TEST_F(WasmSignatureDecodeTest, Ok_t_t) { + WASM_FEATURE_SCOPE(anyref); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueTypePair ret_type = kValueTypes[i]; for (size_t j = 0; j < arraysize(kValueTypes); j++) { ValueTypePair param_type = kValueTypes[j]; const byte data[] = {SIG_ENTRY_x_x(ret_type.code, param_type.code)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_TRUE(sig != nullptr); EXPECT_EQ(1u, sig->parameter_count()); @@ -1326,14 +1347,15 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_t) { } TEST_F(WasmSignatureDecodeTest, Ok_i_tt) { + WASM_FEATURE_SCOPE(anyref); + WASM_FEATURE_SCOPE(mv); for (size_t i = 0; i < arraysize(kValueTypes); i++) { ValueTypePair p0_type = kValueTypes[i]; for (size_t j = 0; j < arraysize(kValueTypes); j++) { ValueTypePair p1_type = kValueTypes[j]; const byte data[] = { SIG_ENTRY_x_xx(kLocalI32, p0_type.code, p1_type.code)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_TRUE(sig != nullptr); EXPECT_EQ(2u, sig->parameter_count()); @@ -1344,25 +1366,45 @@ TEST_F(WasmSignatureDecodeTest, Ok_i_tt) { } } +TEST_F(WasmSignatureDecodeTest, Ok_tt_tt) { + WASM_FEATURE_SCOPE(anyref); + WASM_FEATURE_SCOPE(mv); + for (size_t i = 0; i < arraysize(kValueTypes); i++) { + ValueTypePair p0_type = kValueTypes[i]; + for (size_t j = 0; j < arraysize(kValueTypes); j++) { + ValueTypePair p1_type = kValueTypes[j]; + const byte data[] = {SIG_ENTRY_xx_xx(p0_type.code, p1_type.code, + p0_type.code, p1_type.code)}; + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); + + EXPECT_TRUE(sig != nullptr); + EXPECT_EQ(2u, sig->parameter_count()); + EXPECT_EQ(2u, sig->return_count()); + EXPECT_EQ(p0_type.type, sig->GetParam(0)); + EXPECT_EQ(p1_type.type, sig->GetParam(1)); + EXPECT_EQ(p0_type.type, sig->GetReturn(0)); + EXPECT_EQ(p1_type.type, sig->GetReturn(1)); + } + } +} + TEST_F(WasmSignatureDecodeTest, TooManyParams) { static const byte data[] = {kWasmFunctionTypeCode, WASM_I32V_3(kV8MaxWasmFunctionParams + 1), kLocalI32, 0}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_FALSE(sig != nullptr); } TEST_F(WasmSignatureDecodeTest, TooManyReturns) { for (int i = 0; i < 2; i++) { - FlagScope<bool> flag_scope(&FLAG_experimental_wasm_mv, i != 0); + bool enable_mv = i != 0; + WASM_FEATURE_SCOPE_VAL(mv, enable_mv); const int max_return_count = static_cast<int>( - FLAG_experimental_wasm_mv ? kV8MaxWasmFunctionMultiReturns - : kV8MaxWasmFunctionReturns); + enable_mv ? kV8MaxWasmFunctionMultiReturns : kV8MaxWasmFunctionReturns); byte data[] = {kWasmFunctionTypeCode, 0, WASM_I32V_3(max_return_count + 1), kLocalI32}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } } @@ -1375,7 +1417,7 @@ TEST_F(WasmSignatureDecodeTest, Fail_off_end) { for (int i = 0; i < p + 1; i++) { // Should fall off the end for all signatures. - FunctionSig* sig = DecodeWasmSignatureForTesting(zone(), data, data + i); + FunctionSig* sig = DecodeSig(data, data + i); EXPECT_EQ(nullptr, sig); } } @@ -1383,14 +1425,13 @@ 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); + WASM_FEATURE_SCOPE_VAL(anyref, false); 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)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } } @@ -1401,41 +1442,43 @@ TEST_F(WasmSignatureDecodeTest, Fail_invalid_type) { 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)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } } TEST_F(WasmSignatureDecodeTest, Fail_invalid_ret_type1) { static const byte data[] = {SIG_ENTRY_x_x(kLocalVoid, kLocalI32)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type1) { static const byte data[] = {SIG_ENTRY_x_x(kLocalI32, kLocalVoid)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } TEST_F(WasmSignatureDecodeTest, Fail_invalid_param_type2) { static const byte data[] = {SIG_ENTRY_x_xx(kLocalI32, kLocalI32, kLocalVoid)}; - FunctionSig* sig = - DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data)); + FunctionSig* sig = DecodeSig(data, data + sizeof(data)); EXPECT_EQ(nullptr, sig); } class WasmFunctionVerifyTest : public TestWithIsolateAndZone { public: - WasmFunctionVerifyTest() {} - virtual ~WasmFunctionVerifyTest() {} - + WasmFeatures enabled_features_; WasmModule module; Vector<const byte> bytes; - DISALLOW_COPY_AND_ASSIGN(WasmFunctionVerifyTest); + + FunctionResult DecodeWasmFunction(const ModuleWireBytes& wire_bytes, + const WasmModule* module, + const byte* function_start, + const byte* function_end) { + return DecodeWasmFunctionForTesting(enabled_features_, zone(), wire_bytes, + module, function_start, function_end, + isolate()->counters()); + } }; TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { @@ -1453,8 +1496,8 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) { kExprEnd // body }; - FunctionResult result = SyncDecodeWasmFunction( - isolate(), zone(), bytes, &module, data, data + sizeof(data)); + FunctionResult result = + DecodeWasmFunction(bytes, &module, data, data + sizeof(data)); EXPECT_OK(result); if (result.val && result.ok()) { @@ -1583,6 +1626,7 @@ TEST_F(WasmModuleVerifyTest, ImportTable_nosigs1) { } TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) { + WASM_FEATURE_SCOPE(mut_global); { static const byte data[] = { SECTION(Import, 8), // section header @@ -1614,6 +1658,7 @@ TEST_F(WasmModuleVerifyTest, ImportTable_mutable_global) { } TEST_F(WasmModuleVerifyTest, ImportTable_mutability_malformed) { + WASM_FEATURE_SCOPE(mut_global); static const byte data[] = { SECTION(Import, 8), 1, // -- @@ -2021,61 +2066,68 @@ TEST_F(WasmModuleVerifyTest, Regression684855) { EXPECT_VERIFIES(data); } -#define EXPECT_INIT_EXPR(Type, type, value, ...) \ - { \ - static const byte data[] = {__VA_ARGS__, kExprEnd}; \ - WasmInitExpr expr = \ - DecodeWasmInitExprForTesting(data, data + sizeof(data)); \ - EXPECT_EQ(WasmInitExpr::k##Type##Const, expr.kind); \ - EXPECT_EQ(value, expr.val.type##_const); \ +class WasmInitExprDecodeTest : public TestWithZone { + public: + WasmInitExprDecodeTest() {} + + WasmFeatures enabled_features_; + + WasmInitExpr DecodeInitExpr(const byte* start, const byte* end) { + return DecodeWasmInitExprForTesting(enabled_features_, start, end); + } +}; + +#define EXPECT_INIT_EXPR(Type, type, value, ...) \ + { \ + static const byte data[] = {__VA_ARGS__, kExprEnd}; \ + WasmInitExpr expr = DecodeInitExpr(data, data + sizeof(data)); \ + EXPECT_EQ(WasmInitExpr::k##Type##Const, expr.kind); \ + EXPECT_EQ(value, expr.val.type##_const); \ } -TEST_F(WasmModuleVerifyTest, InitExpr_i32) { +#define EXPECT_INIT_EXPR_FAIL(...) \ + { \ + static const byte data[] = {__VA_ARGS__, kExprEnd}; \ + WasmInitExpr expr = DecodeInitExpr(data, data + sizeof(data)); \ + EXPECT_EQ(WasmInitExpr::kNone, expr.kind); \ + } + +TEST_F(WasmInitExprDecodeTest, InitExpr_i32) { EXPECT_INIT_EXPR(I32, i32, 33, WASM_I32V_1(33)); EXPECT_INIT_EXPR(I32, i32, -21, WASM_I32V_1(-21)); EXPECT_INIT_EXPR(I32, i32, 437, WASM_I32V_2(437)); EXPECT_INIT_EXPR(I32, i32, 77777, WASM_I32V_3(77777)); } -TEST_F(WasmModuleVerifyTest, InitExpr_f32) { +TEST_F(WasmInitExprDecodeTest, InitExpr_f32) { EXPECT_INIT_EXPR(F32, f32, static_cast<float>(13.1), WASM_F32(13.1)); EXPECT_INIT_EXPR(F32, f32, static_cast<float>(-21.1), WASM_F32(-21.1)); EXPECT_INIT_EXPR(F32, f32, static_cast<float>(437.2), WASM_F32(437.2)); EXPECT_INIT_EXPR(F32, f32, static_cast<float>(77777.3), WASM_F32(77777.3)); } -TEST_F(WasmModuleVerifyTest, InitExpr_i64) { +TEST_F(WasmInitExprDecodeTest, InitExpr_i64) { EXPECT_INIT_EXPR(I64, i64, 33, WASM_I64V_1(33)); EXPECT_INIT_EXPR(I64, i64, -21, WASM_I64V_2(-21)); EXPECT_INIT_EXPR(I64, i64, 437, WASM_I64V_5(437)); EXPECT_INIT_EXPR(I64, i64, 77777, WASM_I64V_7(77777)); } -TEST_F(WasmModuleVerifyTest, InitExpr_f64) { +TEST_F(WasmInitExprDecodeTest, InitExpr_f64) { EXPECT_INIT_EXPR(F64, f64, 83.22, WASM_F64(83.22)); EXPECT_INIT_EXPR(F64, f64, -771.3, WASM_F64(-771.3)); EXPECT_INIT_EXPR(F64, f64, 43703.0, WASM_F64(43703.0)); EXPECT_INIT_EXPR(F64, f64, 77999.1, WASM_F64(77999.1)); } -TEST_F(WasmModuleVerifyTest, InitExpr_AnyRef) { - EXPERIMENTAL_FLAG_SCOPE(anyref); +TEST_F(WasmInitExprDecodeTest, InitExpr_AnyRef) { + WASM_FEATURE_SCOPE(anyref); static const byte data[] = {kExprRefNull, kExprEnd}; - WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); + WasmInitExpr expr = DecodeInitExpr(data, data + sizeof(data)); EXPECT_EQ(WasmInitExpr::kAnyRefConst, expr.kind); } -#undef EXPECT_INIT_EXPR - -#define EXPECT_INIT_EXPR_FAIL(...) \ - { \ - static const byte data[] = {__VA_ARGS__, kExprEnd}; \ - WasmInitExpr expr = \ - DecodeWasmInitExprForTesting(data, data + sizeof(data)); \ - EXPECT_EQ(WasmInitExpr::kNone, expr.kind); \ - } - -TEST_F(WasmModuleVerifyTest, InitExpr_illegal) { +TEST_F(WasmInitExprDecodeTest, InitExpr_illegal) { EXPECT_INIT_EXPR_FAIL(WASM_I32V_1(0), WASM_I32V_1(0)); EXPECT_INIT_EXPR_FAIL(WASM_GET_LOCAL(0)); EXPECT_INIT_EXPR_FAIL(WASM_SET_LOCAL(0, WASM_I32V_1(0))); @@ -2083,8 +2135,6 @@ TEST_F(WasmModuleVerifyTest, InitExpr_illegal) { EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)); } -#undef EXPECT_INIT_EXPR_FAIL - TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) { static const byte data[] = { SECTION(Unknown, 4), 1, 'X', 17, 18, // -- @@ -2173,6 +2223,10 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) { CheckSections(data, data + sizeof(data), expected, arraysize(expected)); } +#undef WASM_FEATURE_SCOPE +#undef WASM_FEATURE_SCOPE_VAL +#undef EXPECT_INIT_EXPR +#undef EXPECT_INIT_EXPR_FAIL #undef WASM_INIT_EXPR_I32V_1 #undef WASM_INIT_EXPR_I32V_2 #undef WASM_INIT_EXPR_I32V_3 |