Commit af70a503 authored by Frederik Gossen's avatar Frederik Gossen Committed by Commit Bot

[wasm-hint] Unit Test for Wasm Compilation Hints Decoder

This is just one small unit test for now. As we expect to adapt the
encoding this is more of an exercise than exhaustive testing.

Bug: v8:9003

Change-Id: I8f59043c3f7acbb6169254ec6d6ae13251d1054f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1526010
Commit-Queue: Frederik Gossen <frgossen@google.com>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60358}
parent 1adaca3b
......@@ -682,4 +682,19 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_I64_SIGN_EXT_I16(x) x, kExprI64SExtendI16
#define WASM_I64_SIGN_EXT_I32(x) x, kExprI64SExtendI32
//------------------------------------------------------------------------------
// Compilation Hints.
//------------------------------------------------------------------------------
#define COMPILE_STRATEGY_DEFAULT (0x00)
#define COMPILE_STRATEGY_LAZY (0x01)
#define COMPILE_STRATEGY_EAGER (0x02)
#define FIRST_TIER_DEFAULT (0x00 << 2)
#define FIRST_TIER_INTERPRETER (0x01 << 2)
#define FIRST_TIER_BASELINE (0x02 << 2)
#define FIRST_TIER_OPTIMIZED (0x03 << 2)
#define SECOND_TIER_DEFAULT (0x00 << 4)
#define SECOND_TIER_INTERPRETER (0x01 << 4)
#define SECOND_TIER_BASELINE (0x02 << 4)
#define SECOND_TIER_OPTIMIZED (0x03 << 4)
#endif // V8_WASM_MACRO_GEN_H_
......@@ -74,6 +74,11 @@ struct CheckLEB1 : std::integral_constant<size_t, num> {
ADD_COUNT('s', 'o', 'u', 'r', 'c', 'e', 'M', 'a', 'p', 'p', 'i', \
'n', 'g', 'U', 'R', 'L'), \
ADD_COUNT(__VA_ARGS__))
#define SECTION_COMPILATION_HINTS(...) \
SECTION(Unknown, \
ADD_COUNT('c', 'o', 'm', 'p', 'i', 'l', 'a', 't', 'i', 'o', 'n', \
'H', 'i', 'n', 't', 's'), \
ADD_COUNT(__VA_ARGS__))
#define FAIL_IF_NO_EXPERIMENTAL_EH(data) \
do { \
......@@ -1307,6 +1312,42 @@ TEST_F(WasmModuleVerifyTest, MultipleTablesWithFlag) {
EXPECT_EQ(kWasmAnyRef, result.value()->tables[1].type);
}
TEST_F(WasmModuleVerifyTest, TieringCompilationHints) {
WASM_FEATURE_SCOPE(compilation_hints);
static const byte data[] = {
SIGNATURES_SECTION(1, SIG_ENTRY_v_v),
FUNCTION_SIGNATURES_SECTION(3, 0, 0, 0),
SECTION_COMPILATION_HINTS(
FIRST_TIER_INTERPRETER | SECOND_TIER_BASELINE,
FIRST_TIER_BASELINE | SECOND_TIER_OPTIMIZED,
FIRST_TIER_INTERPRETER | SECOND_TIER_INTERPRETER),
SECTION(Code, ENTRY_COUNT(3), NOP_BODY, NOP_BODY, NOP_BODY),
};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(3u, result.value()->compilation_hints.size());
EXPECT_EQ(WasmCompilationHintStrategy::kDefault,
result.value()->compilation_hints[0].strategy);
EXPECT_EQ(WasmCompilationHintTier::kInterpreter,
result.value()->compilation_hints[0].first_tier);
EXPECT_EQ(WasmCompilationHintTier::kBaseline,
result.value()->compilation_hints[0].second_tier);
EXPECT_EQ(WasmCompilationHintStrategy::kDefault,
result.value()->compilation_hints[1].strategy);
EXPECT_EQ(WasmCompilationHintTier::kBaseline,
result.value()->compilation_hints[1].first_tier);
EXPECT_EQ(WasmCompilationHintTier::kOptimized,
result.value()->compilation_hints[1].second_tier);
EXPECT_EQ(WasmCompilationHintStrategy::kDefault,
result.value()->compilation_hints[2].strategy);
EXPECT_EQ(WasmCompilationHintTier::kInterpreter,
result.value()->compilation_hints[2].first_tier);
EXPECT_EQ(WasmCompilationHintTier::kInterpreter,
result.value()->compilation_hints[2].second_tier);
}
class WasmSignatureDecodeTest : public TestWithZone {
public:
WasmFeatures enabled_features_;
......@@ -2414,6 +2455,7 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_omitted) {
#undef SECTION_NAMES
#undef EMPTY_NAMES_SECTION
#undef SECTION_SRC_MAP
#undef SECTION_COMPILATION_HINTS
#undef FAIL_IF_NO_EXPERIMENTAL_EH
#undef X1
#undef X2
......
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