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 | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc index 68a2bb6ff14..fe93210ca7a 100644 --- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc @@ -827,15 +827,15 @@ TEST_F(WasmModuleVerifyTest, MultipleSignatures) { ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(3u, result.value()->signatures.size()); - if (result.value()->signatures.size() == 3) { - EXPECT_EQ(0u, result.value()->signatures[0]->return_count()); - EXPECT_EQ(1u, result.value()->signatures[1]->return_count()); - EXPECT_EQ(1u, result.value()->signatures[2]->return_count()); - - EXPECT_EQ(0u, result.value()->signatures[0]->parameter_count()); - EXPECT_EQ(1u, result.value()->signatures[1]->parameter_count()); - EXPECT_EQ(2u, result.value()->signatures[2]->parameter_count()); + EXPECT_EQ(3u, result.value()->types.size()); + if (result.value()->types.size() == 3) { + EXPECT_EQ(0u, result.value()->signature(0)->return_count()); + EXPECT_EQ(1u, result.value()->signature(1)->return_count()); + EXPECT_EQ(1u, result.value()->signature(2)->return_count()); + + EXPECT_EQ(0u, result.value()->signature(0)->parameter_count()); + EXPECT_EQ(1u, result.value()->signature(1)->parameter_count()); + EXPECT_EQ(2u, result.value()->signature(2)->parameter_count()); } EXPECT_OFF_END_FAILURE(data, 1); @@ -1037,7 +1037,7 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction) { ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); if (result.ok()) { - EXPECT_EQ(1u, result.value()->signatures.size()); + EXPECT_EQ(1u, result.value()->types.size()); EXPECT_EQ(1u, result.value()->functions.size()); EXPECT_EQ(1u, result.value()->tables.size()); EXPECT_EQ(1u, result.value()->tables[0].initial_size); @@ -1123,7 +1123,7 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) { ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(1u, result.value()->signatures.size()); + EXPECT_EQ(1u, result.value()->types.size()); EXPECT_EQ(1u, result.value()->functions.size()); EXPECT_EQ(1u, result.value()->tables.size()); EXPECT_EQ(1u, result.value()->tables[0].initial_size); @@ -1151,7 +1151,7 @@ TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) { ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(2u, result.value()->signatures.size()); + EXPECT_EQ(2u, result.value()->types.size()); EXPECT_EQ(4u, result.value()->functions.size()); EXPECT_EQ(1u, result.value()->tables.size()); EXPECT_EQ(8u, result.value()->tables[0].initial_size); @@ -1487,10 +1487,9 @@ TEST_F(WasmModuleVerifyTest, TieringCompilationHints) { static const byte data[] = { SIGNATURES_SECTION(1, SIG_ENTRY_v_v), FUNCTION_SIGNATURES_SECTION(3, 0, 0, 0), - SECTION_COMPILATION_HINTS( - BASELINE_TIER_INTERPRETER | TOP_TIER_BASELINE, - BASELINE_TIER_BASELINE | TOP_TIER_OPTIMIZED, - BASELINE_TIER_INTERPRETER | TOP_TIER_INTERPRETER), + SECTION_COMPILATION_HINTS(BASELINE_TIER_BASELINE | TOP_TIER_BASELINE, + BASELINE_TIER_BASELINE | TOP_TIER_OPTIMIZED, + BASELINE_TIER_OPTIMIZED | TOP_TIER_OPTIMIZED), SECTION(Code, ENTRY_COUNT(3), NOP_BODY, NOP_BODY, NOP_BODY), }; @@ -1500,7 +1499,7 @@ TEST_F(WasmModuleVerifyTest, TieringCompilationHints) { EXPECT_EQ(3u, result.value()->compilation_hints.size()); EXPECT_EQ(WasmCompilationHintStrategy::kDefault, result.value()->compilation_hints[0].strategy); - EXPECT_EQ(WasmCompilationHintTier::kInterpreter, + EXPECT_EQ(WasmCompilationHintTier::kBaseline, result.value()->compilation_hints[0].baseline_tier); EXPECT_EQ(WasmCompilationHintTier::kBaseline, result.value()->compilation_hints[0].top_tier); @@ -1512,9 +1511,9 @@ TEST_F(WasmModuleVerifyTest, TieringCompilationHints) { result.value()->compilation_hints[1].top_tier); EXPECT_EQ(WasmCompilationHintStrategy::kDefault, result.value()->compilation_hints[2].strategy); - EXPECT_EQ(WasmCompilationHintTier::kInterpreter, + EXPECT_EQ(WasmCompilationHintTier::kOptimized, result.value()->compilation_hints[2].baseline_tier); - EXPECT_EQ(WasmCompilationHintTier::kInterpreter, + EXPECT_EQ(WasmCompilationHintTier::kOptimized, result.value()->compilation_hints[2].top_tier); } @@ -2429,26 +2428,40 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) { TEST_F(WasmModuleVerifyTest, SourceMappingURLSection) { static const byte data[] = { + WASM_MODULE_HEADER, SECTION_SRC_MAP('s', 'r', 'c', '/', 'x', 'y', 'z', '.', 'c')}; - ModuleResult result = DecodeModule(data, data + sizeof(data)); + ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data)); EXPECT_TRUE(result.ok()); - EXPECT_EQ("src/xyz.c", result.value()->source_map_url); + EXPECT_EQ(WasmDebugSymbols::Type::SourceMap, + result.value()->debug_symbols.type); + ModuleWireBytes wire_bytes(data, data + sizeof(data)); + WasmName external_url = + wire_bytes.GetNameOrNull(result.value()->debug_symbols.external_url); + EXPECT_EQ("src/xyz.c", std::string(external_url.data(), external_url.size())); } TEST_F(WasmModuleVerifyTest, BadSourceMappingURLSection) { static const byte data[] = { + WASM_MODULE_HEADER, SECTION_SRC_MAP('s', 'r', 'c', '/', 'x', 0xff, 'z', '.', 'c')}; - ModuleResult result = DecodeModule(data, data + sizeof(data)); + ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data)); EXPECT_TRUE(result.ok()); - EXPECT_EQ(0u, result.value()->source_map_url.size()); + EXPECT_EQ(WasmDebugSymbols::Type::None, result.value()->debug_symbols.type); + EXPECT_EQ(0u, result.value()->debug_symbols.external_url.length()); } TEST_F(WasmModuleVerifyTest, MultipleSourceMappingURLSections) { - static const byte data[] = {SECTION_SRC_MAP('a', 'b', 'c'), + static const byte data[] = {WASM_MODULE_HEADER, + SECTION_SRC_MAP('a', 'b', 'c'), SECTION_SRC_MAP('p', 'q', 'r')}; - ModuleResult result = DecodeModule(data, data + sizeof(data)); + ModuleResult result = DecodeModuleNoHeader(data, data + sizeof(data)); EXPECT_TRUE(result.ok()); - EXPECT_EQ("abc", result.value()->source_map_url); + EXPECT_EQ(WasmDebugSymbols::Type::SourceMap, + result.value()->debug_symbols.type); + ModuleWireBytes wire_bytes(data, data + sizeof(data)); + WasmName external_url = + wire_bytes.GetNameOrNull(result.value()->debug_symbols.external_url); + EXPECT_EQ("abc", std::string(external_url.data(), external_url.size())); } TEST_F(WasmModuleVerifyTest, MultipleNameSections) { |