summaryrefslogtreecommitdiff
path: root/deps/v8/test/unittests/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/unittests/wasm')
-rw-r--r--deps/v8/test/unittests/wasm/control-transfer-unittest.cc2
-rw-r--r--deps/v8/test/unittests/wasm/decoder-unittest.cc2
-rw-r--r--deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc154
-rw-r--r--deps/v8/test/unittests/wasm/leb-helper-unittest.cc2
-rw-r--r--deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc8
-rw-r--r--deps/v8/test/unittests/wasm/module-decoder-unittest.cc87
-rw-r--r--deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc2
-rw-r--r--deps/v8/test/unittests/wasm/trap-handler-win-unittest.cc2
-rw-r--r--deps/v8/test/unittests/wasm/trap-handler-x64-unittest.cc10
-rw-r--r--deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc102
-rw-r--r--deps/v8/test/unittests/wasm/wasm-compiler-unittest.cc4
-rw-r--r--deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc4
12 files changed, 292 insertions, 87 deletions
diff --git a/deps/v8/test/unittests/wasm/control-transfer-unittest.cc b/deps/v8/test/unittests/wasm/control-transfer-unittest.cc
index 2b1a034179..938956f07d 100644
--- a/deps/v8/test/unittests/wasm/control-transfer-unittest.cc
+++ b/deps/v8/test/unittests/wasm/control-transfer-unittest.cc
@@ -5,7 +5,7 @@
#include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
-#include "src/v8.h"
+#include "src/init/v8.h"
#include "src/wasm/wasm-interpreter.h"
#include "test/common/wasm/wasm-macro-gen.h"
diff --git a/deps/v8/test/unittests/wasm/decoder-unittest.cc b/deps/v8/test/unittests/wasm/decoder-unittest.cc
index 1d9d0ea15c..c2c0c87aa6 100644
--- a/deps/v8/test/unittests/wasm/decoder-unittest.cc
+++ b/deps/v8/test/unittests/wasm/decoder-unittest.cc
@@ -5,7 +5,7 @@
#include "test/unittests/test-utils.h"
#include "src/base/overflowing-math.h"
-#include "src/objects-inl.h"
+#include "src/objects/objects-inl.h"
#include "src/wasm/decoder.h"
#include "test/common/wasm/wasm-macro-gen.h"
diff --git a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc
index ab38ffdb7c..aaf6215a8a 100644
--- a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc
+++ b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc
@@ -4,10 +4,10 @@
#include "test/unittests/test-utils.h"
-#include "src/objects-inl.h"
-#include "src/objects.h"
-#include "src/ostreams.h"
-#include "src/v8.h"
+#include "src/init/v8.h"
+#include "src/objects/objects-inl.h"
+#include "src/objects/objects.h"
+#include "src/utils/ostreams.h"
#include "src/wasm/function-body-decoder-impl.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/local-decl-encoder.h"
@@ -84,7 +84,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
local_decls.Emit(buffer);
// Emit the code.
if (code.size() > 0) {
- memcpy(buffer + locals_size, code.start(), code.size());
+ memcpy(buffer + locals_size, code.begin(), code.size());
}
if (append_end == kAppendEnd) {
// Append an extra end opcode.
@@ -116,7 +116,7 @@ class FunctionBodyDecoderTest : public TestWithZone {
PrepareBytecode(CodeToVector(std::forward<Code>(raw_code)), append_end);
// Validate the code.
- FunctionBody body(sig, 0, code.start(), code.end());
+ FunctionBody body(sig, 0, code.begin(), code.end());
WasmFeatures unused_detected_features;
DecodeResult result =
VerifyWasmCode(zone()->allocator(), enabled_features_, module,
@@ -304,6 +304,16 @@ TEST_F(FunctionBodyDecoderTest, RefNull) {
ExpectValidates(sigs.r_v(), {kExprRefNull});
}
+TEST_F(FunctionBodyDecoderTest, RefFunc) {
+ WASM_FEATURE_SCOPE(anyref);
+ TestModuleBuilder builder;
+ module = builder.module();
+
+ builder.AddFunction(sigs.v_ii());
+ builder.AddFunction(sigs.ii_v());
+ ExpectValidates(sigs.a_v(), {kExprRefFunc, 1});
+}
+
TEST_F(FunctionBodyDecoderTest, EmptyFunction) {
ExpectValidates(sigs.v_v(), {});
ExpectFailure(sigs.i_i(), {});
@@ -984,6 +994,7 @@ TEST_F(FunctionBodyDecoderTest, ReturnVoid3) {
ExpectFailure(sigs.v_v(), {kExprF32Const, 0, 0, 0, 0});
ExpectFailure(sigs.v_v(), {kExprF64Const, 0, 0, 0, 0, 0, 0, 0, 0});
ExpectFailure(sigs.v_v(), {kExprRefNull});
+ ExpectFailure(sigs.v_v(), {kExprRefFunc, 0});
ExpectFailure(sigs.v_i(), {kExprGetLocal, 0});
}
@@ -2656,6 +2667,14 @@ TEST_F(FunctionBodyDecoderTest, Select) {
{WASM_SELECT(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)});
}
+TEST_F(FunctionBodyDecoderTest, Select_needs_value_type) {
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectFailure(sigs.r_r(),
+ {WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)});
+ ExpectFailure(sigs.a_a(),
+ {WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_ZERO)});
+}
+
TEST_F(FunctionBodyDecoderTest, Select_fail1) {
ExpectFailure(sigs.i_i(), {WASM_SELECT(WASM_F32(0.0), WASM_GET_LOCAL(0),
WASM_GET_LOCAL(0))});
@@ -2669,6 +2688,8 @@ TEST_F(FunctionBodyDecoderTest, Select_fail2) {
for (size_t i = 0; i < arraysize(kValueTypes); i++) {
ValueType type = kValueTypes[i];
if (type == kWasmI32) continue;
+ // Select without specified type is only allowed for number types.
+ if (type == kWasmAnyRef) continue;
ValueType types[] = {type, kWasmI32, type};
FunctionSig sig(1, 2, types);
@@ -2698,6 +2719,34 @@ TEST_F(FunctionBodyDecoderTest, Select_TypeCheck) {
WASM_I64V_1(0))});
}
+TEST_F(FunctionBodyDecoderTest, SelectWithType) {
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectValidates(sigs.i_i(), {WASM_SELECT_I(WASM_GET_LOCAL(0),
+ WASM_GET_LOCAL(0), WASM_ZERO)});
+ ExpectValidates(sigs.f_ff(),
+ {WASM_SELECT_F(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO)});
+ ExpectValidates(sigs.d_dd(),
+ {WASM_SELECT_D(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO)});
+ ExpectValidates(sigs.l_l(),
+ {WASM_SELECT_L(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)});
+ ExpectValidates(sigs.r_r(),
+ {WASM_SELECT_R(WASM_REF_NULL, WASM_REF_NULL, WASM_ZERO)});
+ ExpectValidates(sigs.a_a(),
+ {WASM_SELECT_A(WASM_REF_NULL, WASM_REF_NULL, WASM_ZERO)});
+}
+
+TEST_F(FunctionBodyDecoderTest, SelectWithType_fail) {
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectFailure(sigs.i_i(), {WASM_SELECT_F(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0),
+ WASM_ZERO)});
+ ExpectFailure(sigs.f_ff(),
+ {WASM_SELECT_D(WASM_F32(0.0), WASM_F32(0.0), WASM_ZERO)});
+ ExpectFailure(sigs.d_dd(),
+ {WASM_SELECT_L(WASM_F64(0.0), WASM_F64(0.0), WASM_ZERO)});
+ ExpectFailure(sigs.l_l(),
+ {WASM_SELECT_I(WASM_I64V_1(0), WASM_I64V_1(0), WASM_ZERO)});
+}
+
TEST_F(FunctionBodyDecoderTest, Throw) {
WASM_FEATURE_SCOPE(eh);
TestModuleBuilder builder;
@@ -3169,16 +3218,87 @@ TEST_F(FunctionBodyDecoderTest, TableCopy) {
{WASM_TABLE_COPY(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
}
-TEST_F(FunctionBodyDecoderTest, BulkTableOpsWithoutTable) {
+TEST_F(FunctionBodyDecoderTest, TableGrow) {
TestModuleBuilder builder;
- builder.InitializeTable();
- builder.AddPassiveElementSegment();
+ byte tab_func = builder.AddTable(kWasmAnyFunc, 10, true, 20);
+ byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20);
- WASM_FEATURE_SCOPE(bulk_memory);
- ExpectFailure(sigs.v_v(),
- {WASM_TABLE_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
- ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(0)});
- ExpectFailure(sigs.v_v(), {WASM_TABLE_COPY(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
+ module = builder.module();
+
+ ExpectFailure(sigs.i_a(),
+ {WASM_TABLE_GROW(tab_func, WASM_REF_NULL, WASM_ONE)});
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectValidates(sigs.i_a(),
+ {WASM_TABLE_GROW(tab_func, WASM_REF_NULL, WASM_ONE)});
+ ExpectValidates(sigs.i_r(),
+ {WASM_TABLE_GROW(tab_ref, WASM_REF_NULL, WASM_ONE)});
+ // Anyfunc table cannot be initialized with an anyref value.
+ ExpectFailure(sigs.i_r(),
+ {WASM_TABLE_GROW(tab_func, WASM_GET_LOCAL(0), WASM_ONE)});
+ // Anyref table can be initialized with an anyfunc value.
+ ExpectValidates(sigs.i_a(),
+ {WASM_TABLE_GROW(tab_ref, WASM_GET_LOCAL(0), WASM_ONE)});
+ // Check that the table index gets verified.
+ ExpectFailure(sigs.i_r(),
+ {WASM_TABLE_GROW(tab_ref + 2, WASM_REF_NULL, WASM_ONE)});
+}
+
+TEST_F(FunctionBodyDecoderTest, TableSize) {
+ TestModuleBuilder builder;
+ int tab = builder.AddTable(kWasmAnyFunc, 10, true, 20);
+
+ module = builder.module();
+
+ ExpectFailure(sigs.i_v(), {WASM_TABLE_SIZE(tab)});
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectValidates(sigs.i_v(), {WASM_TABLE_SIZE(tab)});
+ ExpectFailure(sigs.i_v(), {WASM_TABLE_SIZE(tab + 2)});
+}
+
+TEST_F(FunctionBodyDecoderTest, TableFill) {
+ TestModuleBuilder builder;
+ byte tab_func = builder.AddTable(kWasmAnyFunc, 10, true, 20);
+ byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20);
+
+ module = builder.module();
+
+ ExpectFailure(sigs.v_a(),
+ {WASM_TABLE_FILL(tab_func, WASM_ONE, WASM_REF_NULL, WASM_ONE)});
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectValidates(sigs.v_a(), {WASM_TABLE_FILL(tab_func, WASM_ONE,
+ WASM_REF_NULL, WASM_ONE)});
+ ExpectValidates(sigs.v_r(), {WASM_TABLE_FILL(tab_ref, WASM_ONE, WASM_REF_NULL,
+ WASM_ONE)});
+ // Anyfunc table cannot be initialized with an anyref value.
+ ExpectFailure(sigs.v_r(), {WASM_TABLE_FILL(tab_func, WASM_ONE,
+ WASM_GET_LOCAL(0), WASM_ONE)});
+ // Anyref table can be initialized with an anyfunc value.
+ ExpectValidates(sigs.v_a(), {WASM_TABLE_FILL(tab_ref, WASM_ONE,
+ WASM_GET_LOCAL(0), WASM_ONE)});
+ // Check that the table index gets verified.
+ ExpectFailure(sigs.v_r(), {WASM_TABLE_FILL(tab_ref + 2, WASM_ONE,
+ WASM_REF_NULL, WASM_ONE)});
+}
+
+TEST_F(FunctionBodyDecoderTest, TableOpsWithoutTable) {
+ TestModuleBuilder builder;
+ builder.AddTable(kWasmAnyRef, 10, true, 20);
+ {
+ WASM_FEATURE_SCOPE(anyref);
+ ExpectFailure(sigs.i_v(), {WASM_TABLE_GROW(0, WASM_REF_NULL, WASM_ONE)});
+ ExpectFailure(sigs.i_v(), {WASM_TABLE_SIZE(0)});
+ ExpectFailure(sigs.i_r(),
+ {WASM_TABLE_FILL(0, WASM_ONE, WASM_REF_NULL, WASM_ONE)});
+ }
+ {
+ WASM_FEATURE_SCOPE(bulk_memory);
+ builder.AddPassiveElementSegment();
+ ExpectFailure(sigs.v_v(),
+ {WASM_TABLE_INIT(0, WASM_ZERO, WASM_ZERO, WASM_ZERO)});
+ ExpectFailure(sigs.v_v(), {WASM_ELEM_DROP(0)});
+ ExpectFailure(sigs.v_v(),
+ {WASM_TABLE_COPY(WASM_ZERO, WASM_ZERO, WASM_ZERO)});
+ }
}
class BranchTableIteratorTest : public TestWithZone {
@@ -3326,6 +3446,12 @@ TEST_F(WasmOpcodeLengthTest, VariableLength) {
ExpectLength(4, kExprGetGlobal, U32V_3(44));
ExpectLength(5, kExprGetGlobal, U32V_4(66));
ExpectLength(6, kExprGetGlobal, U32V_5(77));
+
+ ExpectLength(2, kExprRefFunc, U32V_1(1));
+ ExpectLength(3, kExprRefFunc, U32V_2(33));
+ ExpectLength(4, kExprRefFunc, U32V_3(44));
+ ExpectLength(5, kExprRefFunc, U32V_4(66));
+ ExpectLength(6, kExprRefFunc, U32V_5(77));
}
TEST_F(WasmOpcodeLengthTest, LoadsAndStores) {
diff --git a/deps/v8/test/unittests/wasm/leb-helper-unittest.cc b/deps/v8/test/unittests/wasm/leb-helper-unittest.cc
index 704703a3ea..601de59c57 100644
--- a/deps/v8/test/unittests/wasm/leb-helper-unittest.cc
+++ b/deps/v8/test/unittests/wasm/leb-helper-unittest.cc
@@ -4,7 +4,7 @@
#include "test/unittests/test-utils.h"
-#include "src/objects-inl.h"
+#include "src/objects/objects-inl.h"
#include "src/wasm/decoder.h"
#include "src/wasm/leb-helper.h"
diff --git a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc
index 20f3d2bf3b..5f56da3a23 100644
--- a/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc
+++ b/deps/v8/test/unittests/wasm/loop-assignment-analysis-unittest.cc
@@ -4,10 +4,10 @@
#include "test/unittests/test-utils.h"
-#include "src/bit-vector.h"
-#include "src/objects-inl.h"
-#include "src/objects.h"
-#include "src/v8.h"
+#include "src/init/v8.h"
+#include "src/objects/objects-inl.h"
+#include "src/objects/objects.h"
+#include "src/utils/bit-vector.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module.h"
diff --git a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc
index 6fd4902f78..d63819ba70 100644
--- a/deps/v8/test/unittests/wasm/module-decoder-unittest.cc
+++ b/deps/v8/test/unittests/wasm/module-decoder-unittest.cc
@@ -4,8 +4,8 @@
#include "test/unittests/test-utils.h"
-#include "src/handles.h"
-#include "src/objects-inl.h"
+#include "src/handles/handles.h"
+#include "src/objects/objects-inl.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-features.h"
#include "src/wasm/wasm-limits.h"
@@ -29,7 +29,8 @@ namespace module_decoder_unittest {
#define WASM_INIT_EXPR_F32(val) WASM_F32(val), kExprEnd
#define WASM_INIT_EXPR_I64(val) WASM_I64(val), kExprEnd
#define WASM_INIT_EXPR_F64(val) WASM_F64(val), kExprEnd
-#define WASM_INIT_EXPR_ANYREF WASM_REF_NULL, kExprEnd
+#define WASM_INIT_EXPR_REF_NULL WASM_REF_NULL, kExprEnd
+#define WASM_INIT_EXPR_REF_FUNC(val) WASM_REF_FUNC(val), kExprEnd
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GET_GLOBAL(index), kExprEnd
#define REF_NULL_ELEMENT kExprRefNull, kExprEnd
@@ -270,26 +271,75 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) {
TEST_F(WasmModuleVerifyTest, AnyRefGlobal) {
WASM_FEATURE_SCOPE(anyref);
static const byte data[] = {
- SECTION(Global, // --
- ENTRY_COUNT(1), // --
- kLocalAnyRef, // local type
- 0, // immutable
- WASM_INIT_EXPR_ANYREF) // init
- };
+ // sig#0 ---------------------------------------------------------------
+ SIGNATURES_SECTION_VOID_VOID,
+ // funcs ---------------------------------------------------------------
+ TWO_EMPTY_FUNCTIONS(SIG_INDEX(0)),
+ SECTION(Global, // --
+ ENTRY_COUNT(2), // --
+ kLocalAnyRef, // local type
+ 0, // immutable
+ WASM_INIT_EXPR_REF_NULL, // init
+ kLocalAnyRef, // local type
+ 0, // immutable
+ WASM_INIT_EXPR_REF_FUNC(1)), // init
+ TWO_EMPTY_BODIES};
{
- // Should decode to exactly one global.
+ // Should decode to two globals.
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
- EXPECT_EQ(1u, result.value()->globals.size());
- EXPECT_EQ(0u, result.value()->functions.size());
+ EXPECT_EQ(2u, result.value()->globals.size());
+ EXPECT_EQ(2u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
- const WasmGlobal* global = &result.value()->globals.back();
+ const WasmGlobal* global = &result.value()->globals[0];
+ EXPECT_EQ(kWasmAnyRef, global->type);
+ EXPECT_FALSE(global->mutability);
+ EXPECT_EQ(WasmInitExpr::kRefNullConst, global->init.kind);
+ global = &result.value()->globals[1];
EXPECT_EQ(kWasmAnyRef, global->type);
EXPECT_FALSE(global->mutability);
+ EXPECT_EQ(WasmInitExpr::kRefFuncConst, global->init.kind);
+ EXPECT_EQ(uint32_t{1}, global->init.val.function_index);
+ }
+}
+
+TEST_F(WasmModuleVerifyTest, AnyFuncGlobal) {
+ WASM_FEATURE_SCOPE(anyref);
+ static const byte data[] = {
+ // sig#0 ---------------------------------------------------------------
+ SIGNATURES_SECTION_VOID_VOID,
+ // funcs ---------------------------------------------------------------
+ TWO_EMPTY_FUNCTIONS(SIG_INDEX(0)),
+ SECTION(Global, // --
+ ENTRY_COUNT(2), // --
+ kLocalAnyFunc, // local type
+ 0, // immutable
+ WASM_INIT_EXPR_REF_NULL, // init
+ kLocalAnyFunc, // local type
+ 0, // immutable
+ WASM_INIT_EXPR_REF_FUNC(1)), // init
+ TWO_EMPTY_BODIES};
+ {
+ // Should decode to two globals.
+ ModuleResult result = DecodeModule(data, data + sizeof(data));
+ EXPECT_OK(result);
+ EXPECT_EQ(2u, result.value()->globals.size());
+ EXPECT_EQ(2u, result.value()->functions.size());
+ EXPECT_EQ(0u, result.value()->data_segments.size());
+
+ const WasmGlobal* global = &result.value()->globals[0];
+ EXPECT_EQ(kWasmAnyFunc, global->type);
+ EXPECT_FALSE(global->mutability);
EXPECT_EQ(WasmInitExpr::kRefNullConst, global->init.kind);
+
+ global = &result.value()->globals[1];
+ EXPECT_EQ(kWasmAnyFunc, global->type);
+ EXPECT_FALSE(global->mutability);
+ EXPECT_EQ(WasmInitExpr::kRefFuncConst, global->init.kind);
+ EXPECT_EQ(uint32_t{1}, global->init.val.function_index);
}
}
@@ -1175,9 +1225,7 @@ TEST_F(WasmModuleVerifyTest, ElementSectionMixedTablesArbitraryOrder) {
EXPECT_VERIFIES(data);
}
-TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefTable) {
- // Test that tables of type 'AnyRef' cannot be initialized by the element
- // section.
+TEST_F(WasmModuleVerifyTest, ElementSectionInitAnyRefTableWithAnyFunc) {
WASM_FEATURE_SCOPE(anyref);
WASM_FEATURE_SCOPE(bulk_memory);
static const byte data[] = {
@@ -1201,9 +1249,11 @@ TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefTable) {
2, // elements count
FUNC_INDEX(0), // entry 0
FUNC_INDEX(0)), // entry 1
+ // code ----------------------------------------------------------------
+ ONE_EMPTY_BODY,
};
- EXPECT_FAILURE(data);
+ EXPECT_VERIFIES(data);
}
TEST_F(WasmModuleVerifyTest, ElementSectionDontInitAnyRefImportedTable) {
@@ -2433,7 +2483,8 @@ TEST_F(WasmModuleVerifyTest, DataCountSegmentCount_omitted) {
#undef WASM_INIT_EXPR_F32
#undef WASM_INIT_EXPR_I64
#undef WASM_INIT_EXPR_F64
-#undef WASM_INIT_EXPR_ANYREF
+#undef WASM_INIT_EXPR_REF_NULL
+#undef WASM_INIT_EXPR_REF_FUNC
#undef WASM_INIT_EXPR_GLOBAL
#undef REF_NULL_ELEMENT
#undef REF_FUNC_ELEMENT
diff --git a/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc b/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc
index 78a9ab3a36..5166b13628 100644
--- a/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc
+++ b/deps/v8/test/unittests/wasm/streaming-decoder-unittest.cc
@@ -4,7 +4,7 @@
#include "test/unittests/test-utils.h"
-#include "src/objects-inl.h"
+#include "src/objects/objects-inl.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/streaming-decoder.h"
diff --git a/deps/v8/test/unittests/wasm/trap-handler-win-unittest.cc b/deps/v8/test/unittests/wasm/trap-handler-win-unittest.cc
index 58302bad74..006f1344ba 100644
--- a/deps/v8/test/unittests/wasm/trap-handler-win-unittest.cc
+++ b/deps/v8/test/unittests/wasm/trap-handler-win-unittest.cc
@@ -5,9 +5,9 @@
#include <windows.h>
#include "include/v8.h"
-#include "src/allocation.h"
#include "src/base/page-allocator.h"
#include "src/trap-handler/trap-handler.h"
+#include "src/utils/allocation.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
diff --git a/deps/v8/test/unittests/wasm/trap-handler-x64-unittest.cc b/deps/v8/test/unittests/wasm/trap-handler-x64-unittest.cc
index 70d4badc62..1659370999 100644
--- a/deps/v8/test/unittests/wasm/trap-handler-x64-unittest.cc
+++ b/deps/v8/test/unittests/wasm/trap-handler-x64-unittest.cc
@@ -21,13 +21,13 @@
#elif V8_OS_WIN
#include "include/v8-wasm-trap-handler-win.h"
#endif
-#include "src/allocation.h"
-#include "src/assembler-inl.h"
#include "src/base/page-allocator.h"
-#include "src/macro-assembler-inl.h"
-#include "src/simulator.h"
+#include "src/codegen/assembler-inl.h"
+#include "src/codegen/macro-assembler-inl.h"
+#include "src/execution/simulator.h"
#include "src/trap-handler/trap-handler.h"
-#include "src/vector.h"
+#include "src/utils/allocation.h"
+#include "src/utils/vector.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-memory.h"
diff --git a/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc b/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc
index 9c7ed8a702..eea1f8208d 100644
--- a/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc
+++ b/deps/v8/test/unittests/wasm/wasm-code-manager-unittest.cc
@@ -158,11 +158,17 @@ class WasmCodeManagerTest : public TestWithContext,
static constexpr uint32_t kNumFunctions = 10;
static constexpr uint32_t kJumpTableSize = RoundUp<kCodeAlignment>(
JumpTableAssembler::SizeForNumberOfSlots(kNumFunctions));
- static size_t page_size;
+ static size_t allocate_page_size;
+ static size_t commit_page_size;
WasmCodeManagerTest() {
- if (page_size == 0) page_size = AllocatePageSize();
- DCHECK_NE(0, page_size);
+ CHECK_EQ(allocate_page_size == 0, commit_page_size == 0);
+ if (allocate_page_size == 0) {
+ allocate_page_size = AllocatePageSize();
+ commit_page_size = CommitPageSize();
+ }
+ CHECK_NE(0, allocate_page_size);
+ CHECK_NE(0, commit_page_size);
}
using NativeModulePtr = std::shared_ptr<NativeModule>;
@@ -193,10 +199,17 @@ class WasmCodeManagerTest : public TestWithContext,
void SetMaxCommittedMemory(size_t limit) {
manager()->SetMaxCommittedMemoryForTesting(limit);
}
+
+ void DisableWin64UnwindInfoForTesting() {
+#if defined(V8_OS_WIN_X64)
+ manager()->DisableWin64UnwindInfoForTesting();
+#endif
+ }
};
// static
-size_t WasmCodeManagerTest::page_size = 0;
+size_t WasmCodeManagerTest::allocate_page_size = 0;
+size_t WasmCodeManagerTest::commit_page_size = 0;
INSTANTIATE_TEST_SUITE_P(Parameterized, WasmCodeManagerTest,
::testing::Values(Fixed, Growable),
@@ -206,93 +219,107 @@ TEST_P(WasmCodeManagerTest, EmptyCase) {
SetMaxCommittedMemory(0);
CHECK_EQ(0, manager()->committed_code_space());
- ASSERT_DEATH_IF_SUPPORTED(AllocModule(page_size, GetParam()),
- "OOM in NativeModule::AllocateForCode commit");
+ ASSERT_DEATH_IF_SUPPORTED(AllocModule(allocate_page_size, GetParam()),
+ "OOM in wasm code commit");
}
TEST_P(WasmCodeManagerTest, AllocateAndGoOverLimit) {
- SetMaxCommittedMemory(page_size);
+ SetMaxCommittedMemory(allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
+
CHECK_EQ(0, manager()->committed_code_space());
- NativeModulePtr native_module = AllocModule(page_size, GetParam());
+ NativeModulePtr native_module = AllocModule(allocate_page_size, GetParam());
CHECK(native_module);
- CHECK_EQ(page_size, manager()->committed_code_space());
+ CHECK_EQ(commit_page_size, manager()->committed_code_space());
WasmCodeRefScope code_ref_scope;
uint32_t index = 0;
WasmCode* code = AddCode(native_module.get(), index++, 1 * kCodeAlignment);
CHECK_NOT_NULL(code);
- CHECK_EQ(page_size, manager()->committed_code_space());
+ CHECK_EQ(commit_page_size, manager()->committed_code_space());
code = AddCode(native_module.get(), index++, 3 * kCodeAlignment);
CHECK_NOT_NULL(code);
- CHECK_EQ(page_size, manager()->committed_code_space());
+ CHECK_EQ(commit_page_size, manager()->committed_code_space());
code = AddCode(native_module.get(), index++,
- page_size - 4 * kCodeAlignment - kJumpTableSize);
+ allocate_page_size - 4 * kCodeAlignment - kJumpTableSize);
CHECK_NOT_NULL(code);
- CHECK_EQ(page_size, manager()->committed_code_space());
+ CHECK_EQ(allocate_page_size, manager()->committed_code_space());
// This fails in "reservation" if we cannot extend the code space, or in
// "commit" it we can (since we hit the allocation limit in the
// WasmCodeManager). Hence don't check for that part of the OOM message.
ASSERT_DEATH_IF_SUPPORTED(
AddCode(native_module.get(), index++, 1 * kCodeAlignment),
- "OOM in NativeModule::AllocateForCode");
+ "OOM in wasm code");
}
TEST_P(WasmCodeManagerTest, TotalLimitIrrespectiveOfModuleCount) {
- SetMaxCommittedMemory(3 * page_size);
- NativeModulePtr nm1 = AllocModule(2 * page_size, GetParam());
- NativeModulePtr nm2 = AllocModule(2 * page_size, GetParam());
+ SetMaxCommittedMemory(3 * allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
+
+ NativeModulePtr nm1 = AllocModule(2 * allocate_page_size, GetParam());
+ NativeModulePtr nm2 = AllocModule(2 * allocate_page_size, GetParam());
CHECK(nm1);
CHECK(nm2);
WasmCodeRefScope code_ref_scope;
- WasmCode* code = AddCode(nm1.get(), 0, 2 * page_size - kJumpTableSize);
+ WasmCode* code =
+ AddCode(nm1.get(), 0, 2 * allocate_page_size - kJumpTableSize);
CHECK_NOT_NULL(code);
ASSERT_DEATH_IF_SUPPORTED(
- AddCode(nm2.get(), 0, 2 * page_size - kJumpTableSize),
- "OOM in NativeModule::AllocateForCode commit");
+ AddCode(nm2.get(), 0, 2 * allocate_page_size - kJumpTableSize),
+ "OOM in wasm code commit");
}
TEST_P(WasmCodeManagerTest, GrowingVsFixedModule) {
- SetMaxCommittedMemory(3 * page_size);
- NativeModulePtr nm = AllocModule(page_size, GetParam());
- size_t module_size = GetParam() == Fixed ? kMaxWasmCodeMemory : page_size;
+ SetMaxCommittedMemory(3 * allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
+
+ NativeModulePtr nm = AllocModule(allocate_page_size, GetParam());
+ size_t module_size =
+ GetParam() == Fixed ? kMaxWasmCodeMemory : allocate_page_size;
size_t remaining_space_in_module = module_size - kJumpTableSize;
if (GetParam() == Fixed) {
// Requesting more than the remaining space fails because the module cannot
// grow.
ASSERT_DEATH_IF_SUPPORTED(
AddCode(nm.get(), 0, remaining_space_in_module + kCodeAlignment),
- "OOM in NativeModule::AllocateForCode");
+ "OOM in wasm code reservation");
} else {
// The module grows by one page. One page remains uncommitted.
WasmCodeRefScope code_ref_scope;
CHECK_NOT_NULL(
AddCode(nm.get(), 0, remaining_space_in_module + kCodeAlignment));
- CHECK_EQ(2 * page_size, manager()->committed_code_space());
+ CHECK_EQ(commit_page_size + allocate_page_size,
+ manager()->committed_code_space());
}
}
TEST_P(WasmCodeManagerTest, CommitIncrements) {
- SetMaxCommittedMemory(10 * page_size);
- NativeModulePtr nm = AllocModule(3 * page_size, GetParam());
+ SetMaxCommittedMemory(10 * allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
+
+ NativeModulePtr nm = AllocModule(3 * allocate_page_size, GetParam());
WasmCodeRefScope code_ref_scope;
WasmCode* code = AddCode(nm.get(), 0, kCodeAlignment);
CHECK_NOT_NULL(code);
- CHECK_EQ(page_size, manager()->committed_code_space());
- code = AddCode(nm.get(), 1, 2 * page_size);
+ CHECK_EQ(commit_page_size, manager()->committed_code_space());
+ code = AddCode(nm.get(), 1, 2 * allocate_page_size);
CHECK_NOT_NULL(code);
- CHECK_EQ(3 * page_size, manager()->committed_code_space());
- code = AddCode(nm.get(), 2, page_size - kCodeAlignment - kJumpTableSize);
+ CHECK_EQ(commit_page_size + 2 * allocate_page_size,
+ manager()->committed_code_space());
+ code = AddCode(nm.get(), 2,
+ allocate_page_size - kCodeAlignment - kJumpTableSize);
CHECK_NOT_NULL(code);
- CHECK_EQ(3 * page_size, manager()->committed_code_space());
+ CHECK_EQ(3 * allocate_page_size, manager()->committed_code_space());
}
TEST_P(WasmCodeManagerTest, Lookup) {
- SetMaxCommittedMemory(2 * page_size);
+ SetMaxCommittedMemory(2 * allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
- NativeModulePtr nm1 = AllocModule(page_size, GetParam());
- NativeModulePtr nm2 = AllocModule(page_size, GetParam());
+ NativeModulePtr nm1 = AllocModule(allocate_page_size, GetParam());
+ NativeModulePtr nm2 = AllocModule(allocate_page_size, GetParam());
Address mid_code1_1;
{
// The {WasmCodeRefScope} needs to die before {nm1} dies.
@@ -334,9 +361,10 @@ TEST_P(WasmCodeManagerTest, Lookup) {
}
TEST_P(WasmCodeManagerTest, LookupWorksAfterRewrite) {
- SetMaxCommittedMemory(2 * page_size);
+ SetMaxCommittedMemory(2 * allocate_page_size);
+ DisableWin64UnwindInfoForTesting();
- NativeModulePtr nm1 = AllocModule(page_size, GetParam());
+ NativeModulePtr nm1 = AllocModule(allocate_page_size, GetParam());
WasmCodeRefScope code_ref_scope;
WasmCode* code0 = AddCode(nm1.get(), 0, kCodeAlignment);
diff --git a/deps/v8/test/unittests/wasm/wasm-compiler-unittest.cc b/deps/v8/test/unittests/wasm/wasm-compiler-unittest.cc
index 3cca4bc55c..4b9f78dfdc 100644
--- a/deps/v8/test/unittests/wasm/wasm-compiler-unittest.cc
+++ b/deps/v8/test/unittests/wasm/wasm-compiler-unittest.cc
@@ -4,10 +4,10 @@
#include "test/unittests/test-utils.h"
+#include "src/codegen/machine-type.h"
+#include "src/codegen/signature.h"
#include "src/compiler/linkage.h"
#include "src/compiler/wasm-compiler.h"
-#include "src/machine-type.h"
-#include "src/signature.h"
#include "src/wasm/value-type.h"
namespace v8 {
diff --git a/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc b/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc
index 807fc40959..2bfe2b6df5 100644
--- a/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc
+++ b/deps/v8/test/unittests/wasm/wasm-module-builder-unittest.cc
@@ -4,9 +4,9 @@
#include "test/unittests/test-utils.h"
-#include "src/v8.h"
+#include "src/init/v8.h"
-#include "src/objects-inl.h"
+#include "src/objects/objects-inl.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/wasm-module-builder.h"