[wasm][test] Various test cleanups
Changes: - Remove an obsolete TODO from wasm-module-builder. - Replace CHECK with gTest's EXPECT in unittests. - Remove setting of --experimental-wasm-liftoff-extern-ref in wasm-gc. - Test test-gc/JSAccess with Liftoff. - Remove useless #undef's from module-decoder-unittest. Change-Id: I11b4a3dde9683cc9c7d1eb89b1a63e1859505aad Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2659063 Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#72455}
This commit is contained in:
parent
0b8bfd8590
commit
0461065ca9
@ -504,8 +504,6 @@ void WriteGlobalInitializer(ZoneBuffer* buffer, const WasmInitExpr& init,
|
||||
case WasmInitExpr::kRttSub:
|
||||
// The operand to rtt.sub must be emitted first.
|
||||
WriteGlobalInitializer(buffer, *init.operand(), kWasmBottom);
|
||||
// TODO(7748): If immediates for rtts remain in the standard, adapt this
|
||||
// to emit them.
|
||||
STATIC_ASSERT((kExprRttSub >> 8) == kGCPrefix);
|
||||
buffer->write_u8(kGCPrefix);
|
||||
buffer->write_u8(static_cast<uint8_t>(kExprRttSub));
|
||||
|
@ -204,7 +204,6 @@ ValueType optref(uint32_t type_index) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmBasicStruct) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
|
||||
const byte type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
@ -277,7 +276,6 @@ WASM_COMPILED_EXEC_TEST(WasmBasicStruct) {
|
||||
// struct refs types in globals and if-results.
|
||||
WASM_COMPILED_EXEC_TEST(WasmRefAsNonNull) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
@ -308,7 +306,6 @@ WASM_COMPILED_EXEC_TEST(WasmRefAsNonNull) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmBrOnNull) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte type_index =
|
||||
tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
@ -346,7 +343,6 @@ WASM_COMPILED_EXEC_TEST(WasmBrOnNull) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(BrOnCast) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
ValueType kDataRefNull = ValueType::Ref(HeapType::kData, kNullable);
|
||||
const byte type_index = tester.DefineStruct({F(kWasmI32, true)});
|
||||
const byte other_type_index = tester.DefineStruct({F(kWasmF32, true)});
|
||||
@ -418,7 +414,6 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmRefEq) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
byte type_index = tester.DefineStruct({F(kWasmI32, true), F(kWasmI32, true)});
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
ValueType kOptRefType = optref(type_index);
|
||||
@ -458,7 +453,6 @@ WASM_COMPILED_EXEC_TEST(WasmRefEq) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmPackedStructU) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
|
||||
const byte type_index = tester.DefineStruct(
|
||||
{F(kWasmI8, true), F(kWasmI16, true), F(kWasmI32, true)});
|
||||
@ -496,7 +490,6 @@ WASM_COMPILED_EXEC_TEST(WasmPackedStructU) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmPackedStructS) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
|
||||
const byte type_index = tester.DefineStruct(
|
||||
{F(kWasmI8, true), F(kWasmI16, true), F(kWasmI32, true)});
|
||||
@ -614,7 +607,6 @@ TEST(WasmLetInstruction) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmBasicArray) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
|
||||
const byte type_index = tester.DefineArray(wasm::kWasmI32, true);
|
||||
ValueType kRefTypes[] = {ref(type_index)};
|
||||
@ -690,7 +682,6 @@ WASM_COMPILED_EXEC_TEST(WasmBasicArray) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmPackedArrayU) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte array_index = tester.DefineArray(kWasmI8, true);
|
||||
ValueType array_type = optref(array_index);
|
||||
|
||||
@ -726,7 +717,6 @@ WASM_COMPILED_EXEC_TEST(WasmPackedArrayU) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(WasmPackedArrayS) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte array_index = tester.DefineArray(kWasmI16, true);
|
||||
ValueType array_type = optref(array_index);
|
||||
|
||||
@ -762,7 +752,6 @@ WASM_COMPILED_EXEC_TEST(WasmPackedArrayS) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(NewDefault) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte struct_type = tester.DefineStruct(
|
||||
{F(wasm::kWasmI32, true), F(wasm::kWasmF64, true), F(optref(0), true)});
|
||||
const byte array_type = tester.DefineArray(wasm::kWasmI32, true);
|
||||
@ -958,7 +947,6 @@ TEST(NoDepthRtt) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(ArrayNewMap) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
|
||||
const byte type_index = tester.DefineArray(kWasmI32, true);
|
||||
|
||||
@ -987,7 +975,6 @@ WASM_COMPILED_EXEC_TEST(ArrayNewMap) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(FunctionRefs) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte func_index =
|
||||
tester.DefineFunction(tester.sigs.i_v(), {}, {WASM_I32V(42), kExprEnd});
|
||||
const byte sig_index = 0;
|
||||
@ -1046,7 +1033,6 @@ WASM_COMPILED_EXEC_TEST(FunctionRefs) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(CallRef) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
byte callee = tester.DefineFunction(
|
||||
tester.sigs.i_ii(), {},
|
||||
{WASM_I32_ADD(WASM_LOCAL_GET(0), WASM_LOCAL_GET(1)), kExprEnd});
|
||||
@ -1066,7 +1052,6 @@ WASM_COMPILED_EXEC_TEST(CallRef) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(RefTestCastNull) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
byte type_index = tester.DefineStruct({F(wasm::kWasmI32, true)});
|
||||
|
||||
const byte kRefTestNull = tester.DefineFunction(
|
||||
@ -1215,7 +1200,6 @@ WASM_COMPILED_EXEC_TEST(AbstractTypeChecks) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(BasicI31) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte kSigned = tester.DefineFunction(
|
||||
tester.sigs.i_i(), {},
|
||||
{WASM_I31_GET_S(WASM_I31_NEW(WASM_LOCAL_GET(0))), kExprEnd});
|
||||
@ -1237,7 +1221,6 @@ WASM_COMPILED_EXEC_TEST(BasicI31) {
|
||||
// be modified (made to run longer) to measure performance of casts.
|
||||
WASM_COMPILED_EXEC_TEST(CastsBenchmark) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte SuperType = tester.DefineStruct({F(wasm::kWasmI32, true)});
|
||||
const byte SubType =
|
||||
tester.DefineStruct({F(wasm::kWasmI32, true), F(wasm::kWasmI32, true)});
|
||||
@ -1337,7 +1320,6 @@ WASM_COMPILED_EXEC_TEST(CastsBenchmark) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(GlobalInitReferencingGlobal) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
const byte from = tester.AddGlobal(kWasmI32, false, WasmInitExpr(42));
|
||||
const byte to =
|
||||
tester.AddGlobal(kWasmI32, false, WasmInitExpr::GlobalGet(from));
|
||||
@ -1352,7 +1334,6 @@ WASM_COMPILED_EXEC_TEST(GlobalInitReferencingGlobal) {
|
||||
|
||||
WASM_COMPILED_EXEC_TEST(IndirectNullSetManually) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
FLAG_experimental_liftoff_extern_ref = true;
|
||||
byte sig_index = tester.DefineSignature(tester.sigs.i_i());
|
||||
tester.DefineTable(ValueType::Ref(sig_index, kNullable), 1, 1);
|
||||
byte func_index = tester.DefineFunction(
|
||||
@ -1366,8 +1347,8 @@ WASM_COMPILED_EXEC_TEST(IndirectNullSetManually) {
|
||||
tester.CheckHasThrown(func_index, 42);
|
||||
}
|
||||
|
||||
TEST(JsAccess) {
|
||||
WasmGCTester tester;
|
||||
WASM_COMPILED_EXEC_TEST(JsAccess) {
|
||||
WasmGCTester tester(execution_tier);
|
||||
const byte type_index = tester.DefineStruct({F(wasm::kWasmI32, true)});
|
||||
ValueType kRefType = ref(type_index);
|
||||
ValueType kSupertypeToI[] = {kWasmI32, kWasmDataRef};
|
||||
|
@ -3311,8 +3311,6 @@ TEST_F(WasmModuleVerifyTest, Memory64DataSegment) {
|
||||
#undef NOP_BODY
|
||||
#undef SIG_ENTRY_i_i
|
||||
#undef UNKNOWN_SECTION
|
||||
#undef COUNT_ARGS
|
||||
#undef CHECK_LEB1
|
||||
#undef ADD_COUNT
|
||||
#undef SECTION
|
||||
#undef TYPE_SECTION
|
||||
|
@ -66,100 +66,104 @@ TEST_F(WasmSubtypingTest, Subtyping) {
|
||||
// Value types are unrelated, except if they are equal.
|
||||
for (ValueType subtype : numeric_types) {
|
||||
for (ValueType supertype : numeric_types) {
|
||||
CHECK_EQ(IsSubtypeOf(subtype, supertype, module1, module),
|
||||
subtype == supertype);
|
||||
EXPECT_EQ(IsSubtypeOf(subtype, supertype, module1, module),
|
||||
subtype == supertype);
|
||||
}
|
||||
}
|
||||
|
||||
// Value types are unrelated with reference types.
|
||||
for (ValueType value_type : numeric_types) {
|
||||
for (ValueType ref_type : ref_types) {
|
||||
CHECK(!IsSubtypeOf(value_type, ref_type, module1, module));
|
||||
CHECK(!IsSubtypeOf(ref_type, value_type, module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(value_type, ref_type, module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ref_type, value_type, module1, module));
|
||||
}
|
||||
}
|
||||
|
||||
for (ValueType ref_type : ref_types) {
|
||||
// Concrete reference types, i31ref and dataref are subtypes of eqref,
|
||||
// externref/funcref/anyref are not.
|
||||
CHECK_EQ(IsSubtypeOf(ref_type, kWasmEqRef, module1, module),
|
||||
ref_type != kWasmFuncRef && ref_type != kWasmExternRef &&
|
||||
ref_type != kWasmAnyRef);
|
||||
EXPECT_EQ(IsSubtypeOf(ref_type, kWasmEqRef, module1, module),
|
||||
ref_type != kWasmFuncRef && ref_type != kWasmExternRef &&
|
||||
ref_type != kWasmAnyRef);
|
||||
// Non-nullable struct/array types are subtypes of dataref.
|
||||
CHECK_EQ(
|
||||
EXPECT_EQ(
|
||||
IsSubtypeOf(ref_type, kWasmDataRef, module1, module),
|
||||
ref_type == kWasmDataRef ||
|
||||
(ref_type.kind() == ValueType::kRef && ref_type.has_index()));
|
||||
// Each reference type is a subtype of itself.
|
||||
CHECK(IsSubtypeOf(ref_type, ref_type, module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref_type, ref_type, module1, module));
|
||||
// Each reference type is a subtype of anyref.
|
||||
CHECK(IsSubtypeOf(ref_type, kWasmAnyRef, module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref_type, kWasmAnyRef, module1, module));
|
||||
// Only anyref is a subtype of anyref.
|
||||
CHECK_EQ(IsSubtypeOf(kWasmAnyRef, ref_type, module1, module),
|
||||
ref_type == kWasmAnyRef);
|
||||
EXPECT_EQ(IsSubtypeOf(kWasmAnyRef, ref_type, module1, module),
|
||||
ref_type == kWasmAnyRef);
|
||||
}
|
||||
|
||||
// The rest of ref. types are unrelated.
|
||||
for (ValueType type_1 : {kWasmExternRef, kWasmFuncRef, kWasmI31Ref}) {
|
||||
for (ValueType type_2 : {kWasmExternRef, kWasmFuncRef, kWasmI31Ref}) {
|
||||
CHECK_EQ(IsSubtypeOf(type_1, type_2, module1, module),
|
||||
type_1 == type_2);
|
||||
EXPECT_EQ(IsSubtypeOf(type_1, type_2, module1, module),
|
||||
type_1 == type_2);
|
||||
}
|
||||
}
|
||||
|
||||
// Unrelated refs are unrelated.
|
||||
CHECK(!IsSubtypeOf(ref(0), ref(2), module1, module));
|
||||
CHECK(!IsSubtypeOf(optRef(3), optRef(1), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ref(0), ref(2), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(optRef(3), optRef(1), module1, module));
|
||||
// ref is a subtype of optref for the same struct/array.
|
||||
CHECK(IsSubtypeOf(ref(0), optRef(0), module1, module));
|
||||
CHECK(IsSubtypeOf(ref(2), optRef(2), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref(0), optRef(0), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref(2), optRef(2), module1, module));
|
||||
// optref is not a subtype of ref for the same struct/array.
|
||||
CHECK(!IsSubtypeOf(optRef(0), ref(0), module1, module));
|
||||
CHECK(!IsSubtypeOf(optRef(2), ref(2), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(optRef(0), ref(0), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(optRef(2), ref(2), module1, module));
|
||||
// ref is a subtype of optref if the same is true for the underlying
|
||||
// structs/arrays.
|
||||
CHECK(IsSubtypeOf(ref(3), optRef(2), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref(3), optRef(2), module1, module));
|
||||
// Prefix subtyping for structs.
|
||||
CHECK(IsSubtypeOf(optRef(4), optRef(0), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(optRef(4), optRef(0), module1, module));
|
||||
// Mutable fields are invariant.
|
||||
CHECK(!IsSubtypeOf(ref(0), ref(5), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ref(0), ref(5), module1, module));
|
||||
// Immutable fields are covariant.
|
||||
CHECK(IsSubtypeOf(ref(1), ref(0), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref(1), ref(0), module1, module));
|
||||
// Prefix subtyping + immutable field covariance for structs.
|
||||
CHECK(IsSubtypeOf(optRef(4), optRef(1), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(optRef(4), optRef(1), module1, module));
|
||||
// No subtyping between mutable/immutable fields.
|
||||
CHECK(!IsSubtypeOf(ref(7), ref(6), module1, module));
|
||||
CHECK(!IsSubtypeOf(ref(6), ref(7), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ref(7), ref(6), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ref(6), ref(7), module1, module));
|
||||
// Recursive types.
|
||||
CHECK(IsSubtypeOf(ref(9), ref(8), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ref(9), ref(8), module1, module));
|
||||
|
||||
// Identical rtts are subtypes of each other.
|
||||
CHECK(IsSubtypeOf(ValueType::Rtt(5, 3), ValueType::Rtt(5, 3), module1,
|
||||
module2));
|
||||
CHECK(IsSubtypeOf(ValueType::Rtt(5), ValueType::Rtt(5), module1, module2));
|
||||
EXPECT_TRUE(IsSubtypeOf(ValueType::Rtt(5, 3), ValueType::Rtt(5, 3), module1,
|
||||
module2));
|
||||
EXPECT_TRUE(
|
||||
IsSubtypeOf(ValueType::Rtt(5), ValueType::Rtt(5), module1, module2));
|
||||
// Rtts of unrelated types are unrelated.
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(1, 1), ValueType::Rtt(2, 1), module1,
|
||||
module2));
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(1), ValueType::Rtt(2), module1, module2));
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(1, 0), ValueType::Rtt(2), module1,
|
||||
module2));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ValueType::Rtt(1, 1), ValueType::Rtt(2, 1),
|
||||
module1, module2));
|
||||
EXPECT_TRUE(
|
||||
!IsSubtypeOf(ValueType::Rtt(1), ValueType::Rtt(2), module1, module2));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ValueType::Rtt(1, 0), ValueType::Rtt(2), module1,
|
||||
module2));
|
||||
// Rtts of different depth are unrelated.
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(5, 1), ValueType::Rtt(5, 3), module1,
|
||||
module2));
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(5, 8), ValueType::Rtt(5, 3), module1,
|
||||
module2));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ValueType::Rtt(5, 1), ValueType::Rtt(5, 3),
|
||||
module1, module2));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ValueType::Rtt(5, 8), ValueType::Rtt(5, 3),
|
||||
module1, module2));
|
||||
// Rtts of identical types are subtype-related.
|
||||
CHECK(IsSubtypeOf(ValueType::Rtt(8, 1), ValueType::Rtt(9, 1), module1,
|
||||
module));
|
||||
CHECK(IsSubtypeOf(ValueType::Rtt(8), ValueType::Rtt(9), module1, module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ValueType::Rtt(8, 1), ValueType::Rtt(9, 1), module1,
|
||||
module));
|
||||
EXPECT_TRUE(
|
||||
IsSubtypeOf(ValueType::Rtt(8), ValueType::Rtt(9), module1, module));
|
||||
// Rtts of subtypes are not related.
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(1, 1), ValueType::Rtt(0, 1), module1,
|
||||
module));
|
||||
CHECK(!IsSubtypeOf(ValueType::Rtt(1), ValueType::Rtt(0), module1, module));
|
||||
EXPECT_TRUE(!IsSubtypeOf(ValueType::Rtt(1, 1), ValueType::Rtt(0, 1),
|
||||
module1, module));
|
||||
EXPECT_TRUE(
|
||||
!IsSubtypeOf(ValueType::Rtt(1), ValueType::Rtt(0), module1, module));
|
||||
// rtt(t, d) <: rtt(t)
|
||||
for (uint8_t depth : {0, 1, 5}) {
|
||||
CHECK(IsSubtypeOf(ValueType::Rtt(1, depth), ValueType::Rtt(1), module1,
|
||||
module));
|
||||
EXPECT_TRUE(IsSubtypeOf(ValueType::Rtt(1, depth), ValueType::Rtt(1),
|
||||
module1, module));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ TEST_F(SignalHandlerFallbackTest, DoTest) {
|
||||
const int save_sigs = 1;
|
||||
if (!sigsetjmp(continuation_, save_sigs)) {
|
||||
constexpr bool use_default_signal_handler = true;
|
||||
CHECK(v8::V8::EnableWebAssemblyTrapHandler(use_default_signal_handler));
|
||||
EXPECT_TRUE(
|
||||
v8::V8::EnableWebAssemblyTrapHandler(use_default_signal_handler));
|
||||
CrashOnPurpose();
|
||||
FAIL();
|
||||
} else {
|
||||
|
@ -52,7 +52,7 @@ class ExceptionHandlerFallbackTest : public ::testing::Test {
|
||||
void TearDown() override {
|
||||
// be a good citizen and remove the exception handler.
|
||||
ULONG result = RemoveVectoredExceptionHandler(registered_handler_);
|
||||
CHECK(result);
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -61,9 +61,9 @@ class ExceptionHandlerFallbackTest : public ::testing::Test {
|
||||
v8::PageAllocator* page_allocator = i::GetPlatformPageAllocator();
|
||||
// Make the allocated memory accessible so that from now on memory accesses
|
||||
// do not cause an exception anymore.
|
||||
CHECK(i::SetPermissions(page_allocator, g_start_address,
|
||||
page_allocator->AllocatePageSize(),
|
||||
v8::PageAllocator::kReadWrite));
|
||||
EXPECT_TRUE(i::SetPermissions(page_allocator, g_start_address,
|
||||
page_allocator->AllocatePageSize(),
|
||||
v8::PageAllocator::kReadWrite));
|
||||
// The memory access should work now, we can continue execution.
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
@ -74,7 +74,7 @@ class ExceptionHandlerFallbackTest : public ::testing::Test {
|
||||
|
||||
TEST_F(ExceptionHandlerFallbackTest, DoTest) {
|
||||
constexpr bool use_default_handler = true;
|
||||
CHECK(v8::V8::EnableWebAssemblyTrapHandler(use_default_handler));
|
||||
EXPECT_TRUE(v8::V8::EnableWebAssemblyTrapHandler(use_default_handler));
|
||||
// In the original test setup the test memory is protected against any kind of
|
||||
// access. Therefore the access here causes an access violation exception,
|
||||
// which should be caught by the exception handler we install above. In the
|
||||
@ -83,8 +83,8 @@ TEST_F(ExceptionHandlerFallbackTest, DoTest) {
|
||||
// memory access again. This time we expect the memory access to work.
|
||||
constexpr int test_value = 42;
|
||||
WriteToTestMemory(test_value);
|
||||
CHECK_EQ(test_value, ReadFromTestMemory());
|
||||
CHECK(g_handler_got_executed);
|
||||
EXPECT_EQ(test_value, ReadFromTestMemory());
|
||||
EXPECT_TRUE(g_handler_got_executed);
|
||||
v8::internal::trap_handler::RemoveTrapHandler();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class TrapHandlerTest : public TestWithIsolate,
|
||||
backing_store_ = BackingStore::AllocateWasmMemory(i_isolate(), 1, 1,
|
||||
SharedFlag::kNotShared);
|
||||
CHECK(backing_store_);
|
||||
CHECK(backing_store_->has_guard_regions());
|
||||
EXPECT_TRUE(backing_store_->has_guard_regions());
|
||||
// The allocated backing store ends with a guard page.
|
||||
crash_address_ = reinterpret_cast<Address>(backing_store_->buffer_start()) +
|
||||
backing_store_->byte_length() + 32;
|
||||
@ -104,11 +104,11 @@ class TrapHandlerTest : public TestWithIsolate,
|
||||
sigemptyset(&action.sa_mask);
|
||||
action.sa_flags = SA_SIGINFO;
|
||||
// SIGSEGV happens for wasm oob memory accesses on Linux.
|
||||
CHECK_EQ(0, sigaction(SIGSEGV, &action, &g_old_segv_action));
|
||||
EXPECT_EQ(0, sigaction(SIGSEGV, &action, &g_old_segv_action));
|
||||
// SIGBUS happens for wasm oob memory accesses on macOS.
|
||||
CHECK_EQ(0, sigaction(SIGBUS, &action, &g_old_bus_action));
|
||||
EXPECT_EQ(0, sigaction(SIGBUS, &action, &g_old_bus_action));
|
||||
// SIGFPE to simulate crashes which are not handled by the trap handler.
|
||||
CHECK_EQ(0, sigaction(SIGFPE, &action, &g_old_fpe_action));
|
||||
EXPECT_EQ(0, sigaction(SIGFPE, &action, &g_old_fpe_action));
|
||||
#elif V8_OS_WIN
|
||||
g_registered_handler =
|
||||
AddVectoredExceptionHandler(/*first=*/0, TestHandler);
|
||||
@ -117,7 +117,7 @@ class TrapHandlerTest : public TestWithIsolate,
|
||||
|
||||
void TearDown() override {
|
||||
// We should always have left wasm code.
|
||||
CHECK(!GetThreadInWasmFlag());
|
||||
EXPECT_TRUE(!GetThreadInWasmFlag());
|
||||
buffer_.reset();
|
||||
recovery_buffer_.reset();
|
||||
backing_store_.reset();
|
||||
@ -128,9 +128,9 @@ class TrapHandlerTest : public TestWithIsolate,
|
||||
#if V8_OS_LINUX || V8_OS_MACOSX || V8_OS_FREEBSD
|
||||
// The test handler cleans up the signal handler setup in the test. If the
|
||||
// test handler was not called, we have to do the cleanup ourselves.
|
||||
CHECK_EQ(0, sigaction(SIGSEGV, &g_old_segv_action, nullptr));
|
||||
CHECK_EQ(0, sigaction(SIGFPE, &g_old_fpe_action, nullptr));
|
||||
CHECK_EQ(0, sigaction(SIGBUS, &g_old_bus_action, nullptr));
|
||||
EXPECT_EQ(0, sigaction(SIGSEGV, &g_old_segv_action, nullptr));
|
||||
EXPECT_EQ(0, sigaction(SIGFPE, &g_old_fpe_action, nullptr));
|
||||
EXPECT_EQ(0, sigaction(SIGBUS, &g_old_bus_action, nullptr));
|
||||
#elif V8_OS_WIN
|
||||
RemoveVectoredExceptionHandler(g_registered_handler);
|
||||
g_registered_handler = nullptr;
|
||||
@ -232,21 +232,21 @@ class TrapHandlerTest : public TestWithIsolate,
|
||||
GeneratedCode<void>::FromAddress(
|
||||
i_isolate(), reinterpret_cast<Address>(buffer_->start()))
|
||||
.Call();
|
||||
CHECK(!g_test_handler_executed);
|
||||
EXPECT_FALSE(g_test_handler_executed);
|
||||
}
|
||||
|
||||
// Execute the code in buffer. We expect a crash which we recover from in the
|
||||
// test handler.
|
||||
void ExecuteExpectCrash(TestingAssemblerBuffer* buffer,
|
||||
bool check_wasm_flag = true) {
|
||||
CHECK(!g_test_handler_executed);
|
||||
EXPECT_FALSE(g_test_handler_executed);
|
||||
buffer->MakeExecutable();
|
||||
GeneratedCode<void>::FromAddress(i_isolate(),
|
||||
reinterpret_cast<Address>(buffer->start()))
|
||||
.Call();
|
||||
CHECK(g_test_handler_executed);
|
||||
EXPECT_TRUE(g_test_handler_executed);
|
||||
g_test_handler_executed = false;
|
||||
if (check_wasm_flag) CHECK(!GetThreadInWasmFlag());
|
||||
if (check_wasm_flag) EXPECT_FALSE(GetThreadInWasmFlag());
|
||||
}
|
||||
|
||||
bool test_handler_executed() { return g_test_handler_executed; }
|
||||
@ -457,12 +457,12 @@ TEST_P(TrapHandlerTest, TestCrashInOtherThread) {
|
||||
desc.instr_size, 1, &protected_instruction);
|
||||
|
||||
CodeRunner runner(this, buffer_.get());
|
||||
CHECK(!GetThreadInWasmFlag());
|
||||
EXPECT_FALSE(GetThreadInWasmFlag());
|
||||
// Set the thread-in-wasm flag manually in this thread.
|
||||
*trap_handler::GetThreadInWasmThreadLocalAddress() = 1;
|
||||
CHECK(runner.Start());
|
||||
EXPECT_TRUE(runner.Start());
|
||||
runner.Join();
|
||||
CHECK(GetThreadInWasmFlag());
|
||||
EXPECT_TRUE(GetThreadInWasmFlag());
|
||||
// Reset the thread-in-wasm flag.
|
||||
*trap_handler::GetThreadInWasmThreadLocalAddress() = 0;
|
||||
}
|
||||
|
@ -28,16 +28,16 @@ void DisjointAllocationPoolTest::CheckPool(
|
||||
const DisjointAllocationPool& mem,
|
||||
std::initializer_list<base::AddressRegion> expected_regions) {
|
||||
const auto& regions = mem.regions();
|
||||
CHECK_EQ(regions.size(), expected_regions.size());
|
||||
EXPECT_EQ(regions.size(), expected_regions.size());
|
||||
auto iter = expected_regions.begin();
|
||||
for (auto it = regions.begin(), e = regions.end(); it != e; ++it, ++iter) {
|
||||
CHECK_EQ(*it, *iter);
|
||||
EXPECT_EQ(*it, *iter);
|
||||
}
|
||||
}
|
||||
|
||||
void DisjointAllocationPoolTest::CheckRange(base::AddressRegion region1,
|
||||
base::AddressRegion region2) {
|
||||
CHECK_EQ(region1, region2);
|
||||
EXPECT_EQ(region1, region2);
|
||||
}
|
||||
|
||||
DisjointAllocationPool DisjointAllocationPoolTest::Make(
|
||||
@ -51,7 +51,7 @@ DisjointAllocationPool DisjointAllocationPoolTest::Make(
|
||||
|
||||
TEST_F(DisjointAllocationPoolTest, ConstructEmpty) {
|
||||
DisjointAllocationPool a;
|
||||
CHECK(a.IsEmpty());
|
||||
EXPECT_TRUE(a.IsEmpty());
|
||||
CheckPool(a, {});
|
||||
a.Merge({1, 4});
|
||||
CheckPool(a, {{1, 4}});
|
||||
@ -59,7 +59,7 @@ TEST_F(DisjointAllocationPoolTest, ConstructEmpty) {
|
||||
|
||||
TEST_F(DisjointAllocationPoolTest, ConstructWithRange) {
|
||||
DisjointAllocationPool a({1, 4});
|
||||
CHECK(!a.IsEmpty());
|
||||
EXPECT_FALSE(a.IsEmpty());
|
||||
CheckPool(a, {{1, 4}});
|
||||
}
|
||||
|
||||
@ -70,16 +70,16 @@ TEST_F(DisjointAllocationPoolTest, SimpleExtract) {
|
||||
CheckRange(b, {1, 2});
|
||||
a.Merge(b);
|
||||
CheckPool(a, {{1, 4}});
|
||||
CHECK_EQ(a.regions().size(), 1);
|
||||
CHECK_EQ(a.regions().begin()->begin(), 1);
|
||||
CHECK_EQ(a.regions().begin()->end(), 5);
|
||||
EXPECT_EQ(a.regions().size(), uint32_t{1});
|
||||
EXPECT_EQ(a.regions().begin()->begin(), uint32_t{1});
|
||||
EXPECT_EQ(a.regions().begin()->end(), uint32_t{5});
|
||||
}
|
||||
|
||||
TEST_F(DisjointAllocationPoolTest, ExtractAll) {
|
||||
DisjointAllocationPool a({1, 4});
|
||||
base::AddressRegion b = a.Allocate(4);
|
||||
CheckRange(b, {1, 4});
|
||||
CHECK(a.IsEmpty());
|
||||
EXPECT_TRUE(a.IsEmpty());
|
||||
a.Merge(b);
|
||||
CheckPool(a, {{1, 4}});
|
||||
}
|
||||
@ -88,14 +88,14 @@ TEST_F(DisjointAllocationPoolTest, FailToExtract) {
|
||||
DisjointAllocationPool a = Make({{1, 4}});
|
||||
base::AddressRegion b = a.Allocate(5);
|
||||
CheckPool(a, {{1, 4}});
|
||||
CHECK(b.is_empty());
|
||||
EXPECT_TRUE(b.is_empty());
|
||||
}
|
||||
|
||||
TEST_F(DisjointAllocationPoolTest, FailToExtractExact) {
|
||||
DisjointAllocationPool a = Make({{1, 4}, {10, 4}});
|
||||
base::AddressRegion b = a.Allocate(5);
|
||||
CheckPool(a, {{1, 4}, {10, 4}});
|
||||
CHECK(b.is_empty());
|
||||
EXPECT_TRUE(b.is_empty());
|
||||
}
|
||||
|
||||
TEST_F(DisjointAllocationPoolTest, ExtractExact) {
|
||||
|
@ -22,7 +22,7 @@ TEST_F(WasmCallDescriptorTest, TestExternRefIsGrouped) {
|
||||
|
||||
for (size_t i = 0; i < kMaxCount; i += 2) {
|
||||
params[i] = kWasmExternRef;
|
||||
CHECK_LT(i + 1, kMaxCount);
|
||||
EXPECT_TRUE(i + 1 < kMaxCount);
|
||||
params[i + 1] = kWasmI32;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ TEST_F(WasmCallDescriptorTest, TestExternRefIsGrouped) {
|
||||
compiler::GetWasmCallDescriptor(zone(), &sig);
|
||||
|
||||
// The WasmInstance is the implicit first parameter.
|
||||
CHECK_EQ(count + 1, desc->ParameterCount());
|
||||
EXPECT_EQ(count + 1, desc->ParameterCount());
|
||||
|
||||
bool has_untagged_stack_param = false;
|
||||
bool has_tagged_register_param = false;
|
||||
@ -45,7 +45,7 @@ TEST_F(WasmCallDescriptorTest, TestExternRefIsGrouped) {
|
||||
if (location.IsRegister()) {
|
||||
has_tagged_register_param = true;
|
||||
} else {
|
||||
CHECK(location.IsCallerFrameSlot());
|
||||
EXPECT_TRUE(location.IsCallerFrameSlot());
|
||||
max_tagged_stack_location =
|
||||
std::max(max_tagged_stack_location, location.AsCallerFrameSlot());
|
||||
}
|
||||
@ -55,14 +55,14 @@ TEST_F(WasmCallDescriptorTest, TestExternRefIsGrouped) {
|
||||
min_untagged_stack_location = std::min(min_untagged_stack_location,
|
||||
location.AsCallerFrameSlot());
|
||||
} else {
|
||||
CHECK(location.IsRegister());
|
||||
EXPECT_TRUE(location.IsRegister());
|
||||
}
|
||||
}
|
||||
}
|
||||
// There should never be a tagged parameter in a register and an untagged
|
||||
// parameter on the stack at the same time.
|
||||
CHECK_EQ(false, has_tagged_register_param && has_untagged_stack_param);
|
||||
CHECK_LT(max_tagged_stack_location, min_untagged_stack_location);
|
||||
EXPECT_EQ(false, has_tagged_register_param && has_untagged_stack_param);
|
||||
EXPECT_TRUE(max_tagged_stack_location < min_untagged_stack_location);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user