[test] Migrate cctest/test-sloppy-equality to unittests/
Bug: v8:12781 Change-Id: I1b0be6803d6a9f4ab7071bc3ae5abeb8f29ce9c9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829753 Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org> Reviewed-by: Emanuel Ziegler <ecmziegler@chromium.org> Cr-Commit-Position: refs/heads/main@{#82680}
This commit is contained in:
parent
d4d27367ec
commit
0cbfcede6d
@ -85,6 +85,7 @@ v8_source_set("cctest_sources") {
|
||||
"../common/c-signature.h",
|
||||
"../common/call-tester.h",
|
||||
"../common/flag-utils.h",
|
||||
"../common/node-observer-tester.h",
|
||||
"../common/scope-test-helper.h",
|
||||
"../common/unicode-helpers.cc",
|
||||
"../common/unicode-helpers.h",
|
||||
@ -97,7 +98,6 @@ v8_source_set("cctest_sources") {
|
||||
"compiler/codegen-tester.h",
|
||||
"compiler/function-tester.cc",
|
||||
"compiler/function-tester.h",
|
||||
"compiler/node-observer-tester.h",
|
||||
"compiler/test-atomic-load-store-codegen.cc",
|
||||
"compiler/test-basic-block-profiler.cc",
|
||||
"compiler/test-branch-combine.cc",
|
||||
@ -132,7 +132,6 @@ v8_source_set("cctest_sources") {
|
||||
"compiler/test-run-tail-calls.cc",
|
||||
"compiler/test-run-unwinding-info.cc",
|
||||
"compiler/test-run-variables.cc",
|
||||
"compiler/test-sloppy-equality.cc",
|
||||
"compiler/test-verify-type.cc",
|
||||
"expression-type-collector-macros.h",
|
||||
"feedback-vector-helper.h",
|
||||
|
@ -211,7 +211,6 @@
|
||||
|
||||
# %ObserveNode tests rely on TurboFan.
|
||||
'test-calls-with-arraylike-or-spread/*': [SKIP],
|
||||
'test-sloppy-equality/*' : [SKIP],
|
||||
'test-js-to-wasm/*': [SKIP],
|
||||
'test-verify-type/*': [SKIP],
|
||||
}], # variant == nooptimization
|
||||
@ -608,7 +607,6 @@
|
||||
'test-run-unwinding-info/*': [SKIP],
|
||||
'test-run-variables/*': [SKIP],
|
||||
'test-serialize/*': [SKIP],
|
||||
'test-sloppy-equality/*' : [SKIP],
|
||||
'test-swiss-name-dictionary-csa/*': [SKIP],
|
||||
'test-torque/*': [SKIP],
|
||||
'test-unwinder-code-pages/PCIsInV8_LargeCodeObject_CodePagesAPI': [SKIP],
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include "include/v8-function.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "test/cctest/compiler/node-observer-tester.h"
|
||||
#include "test/cctest/test-api.h"
|
||||
#include "test/common/node-observer-tester.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -3,8 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/compiler/js-operator.h"
|
||||
#include "test/cctest/compiler/node-observer-tester.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/common/flag-utils.h"
|
||||
#include "test/common/node-observer-tester.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "include/v8-value.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/node-observer-tester.h"
|
||||
#include "test/cctest/test-api.h"
|
||||
#include "test/common/node-observer-tester.h"
|
||||
#include "test/common/wasm/test-signatures.h"
|
||||
#include "test/common/wasm/wasm-macro-gen.h"
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
// Copyright 2021 the V8 project authors. All rights reserved.
|
||||
// Copyright 2022 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_
|
||||
#define V8_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_
|
||||
#ifndef V8_COMMON_NODEOBSERVER_TESTER_H_
|
||||
#define V8_COMMON_NODEOBSERVER_TESTER_H_
|
||||
|
||||
#include "src/compiler/node-observer.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "src/objects/type-hints.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -88,4 +87,4 @@ class ModificationObserver : public NodeObserver {
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_CCTEST_COMPILER_NODEOBSERVER_TESTER_H_
|
||||
#endif // V8_COMMON_NODEOBSERVER_TESTER_H_
|
@ -224,9 +224,9 @@ v8_source_set("unittests_sources") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"../../test/common/assembler-tester.h",
|
||||
"../../testing/gmock-support.h",
|
||||
"../../testing/gtest-support.h",
|
||||
"../common/assembler-tester.h",
|
||||
"../common/c-signature.h",
|
||||
"../common/call-tester.h",
|
||||
"../common/scope-test-helper.h",
|
||||
@ -234,6 +234,7 @@ v8_source_set("unittests_sources") {
|
||||
"../common/unicode-helpers.h",
|
||||
"../common/value-helper.cc",
|
||||
"../common/value-helper.h",
|
||||
"../common/node-observer-tester.h",
|
||||
"api/access-check-unittest.cc",
|
||||
"api/accessor-unittest.cc",
|
||||
"api/api-icu-unittest.cc",
|
||||
@ -354,6 +355,7 @@ v8_source_set("unittests_sources") {
|
||||
"compiler/simplified-lowering-unittest.cc",
|
||||
"compiler/simplified-operator-reducer-unittest.cc",
|
||||
"compiler/simplified-operator-unittest.cc",
|
||||
"compiler/sloppy-equality-unittest.cc",
|
||||
"compiler/state-values-utils-unittest.cc",
|
||||
"compiler/typed-optimization-unittest.cc",
|
||||
"compiler/typer-unittest.cc",
|
||||
|
@ -1,14 +1,18 @@
|
||||
// Copyright 2021 the V8 project authors. All rights reserved.
|
||||
// Copyright 2022 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "test/cctest/compiler/node-observer-tester.h"
|
||||
#include "test/common/flag-utils.h"
|
||||
#include "test/common/node-observer-tester.h"
|
||||
#include "test/unittests/test-utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
using SloppyEqualityTest = TestWithContextAndZone;
|
||||
|
||||
struct TestCase {
|
||||
TestCase(const char* l, const char* r, NodeObserver* observer)
|
||||
: warmup{std::make_pair(l, r)}, observer(observer) {
|
||||
@ -24,14 +28,14 @@ class TestSloppyEqualityFactory {
|
||||
|
||||
NodeObserver* SpeculativeNumberEqual(NumberOperationHint hint) {
|
||||
return zone_->New<CreationObserver>([hint](const Node* node) {
|
||||
CHECK_EQ(IrOpcode::kSpeculativeNumberEqual, node->opcode());
|
||||
CHECK_EQ(hint, NumberOperationHintOf(node->op()));
|
||||
EXPECT_EQ(IrOpcode::kSpeculativeNumberEqual, node->opcode());
|
||||
EXPECT_EQ(hint, NumberOperationHintOf(node->op()));
|
||||
});
|
||||
}
|
||||
|
||||
NodeObserver* JSEqual(CompareOperationHint /*hint*/) {
|
||||
return zone_->New<CreationObserver>([](const Node* node) {
|
||||
CHECK_EQ(IrOpcode::kJSEqual, node->opcode());
|
||||
EXPECT_EQ(IrOpcode::kJSEqual, node->opcode());
|
||||
// TODO(paolosev): compare hint
|
||||
});
|
||||
}
|
||||
@ -40,12 +44,12 @@ class TestSloppyEqualityFactory {
|
||||
IrOpcode::Value modified_op) {
|
||||
return zone_->New<ModificationObserver>(
|
||||
[created_op](const Node* node) {
|
||||
CHECK_EQ(created_op, node->opcode());
|
||||
EXPECT_EQ(created_op, node->opcode());
|
||||
},
|
||||
[modified_op](const Node* node, const ObservableNodeState& old_state)
|
||||
-> NodeObserver::Observation {
|
||||
if (old_state.opcode() != node->opcode()) {
|
||||
CHECK_EQ(modified_op, node->opcode());
|
||||
EXPECT_EQ(modified_op, node->opcode());
|
||||
return NodeObserver::Observation::kStop;
|
||||
}
|
||||
return NodeObserver::Observation::kContinue;
|
||||
@ -56,13 +60,10 @@ class TestSloppyEqualityFactory {
|
||||
Zone* zone_;
|
||||
};
|
||||
|
||||
TEST(TestSloppyEquality) {
|
||||
TEST_F(SloppyEqualityTest, SloppyEqualityTest) {
|
||||
FlagScope<bool> allow_natives_syntax(&i::FLAG_allow_natives_syntax, true);
|
||||
FlagScope<bool> always_turbofan(&i::FLAG_always_turbofan, false);
|
||||
HandleAndZoneScope handle_and_zone_scope;
|
||||
Isolate* isolate = handle_and_zone_scope.main_isolate();
|
||||
Zone zone(isolate->allocator(), ZONE_NAME);
|
||||
TestSloppyEqualityFactory f(&zone);
|
||||
TestSloppyEqualityFactory f(zone());
|
||||
// TODO(nicohartmann@, v8:5660): Collect more precise feedback for some useful
|
||||
// cases.
|
||||
TestCase cases[] = {
|
||||
@ -131,8 +132,8 @@ TEST(TestSloppyEquality) {
|
||||
}
|
||||
|
||||
{
|
||||
compiler::ObserveNodeScope scope(isolate, c.observer);
|
||||
CompileRun(src.str().c_str());
|
||||
compiler::ObserveNodeScope scope(i_isolate(), c.observer);
|
||||
TryRunJS(src.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
@ -400,6 +400,14 @@ using TestWithIsolateAndZone = //
|
||||
WithDefaultPlatformMixin< //
|
||||
::testing::Test>>>>>;
|
||||
|
||||
using TestWithContextAndZone = //
|
||||
WithZoneMixin< //
|
||||
WithContextMixin< //
|
||||
WithIsolateScopeMixin< //
|
||||
WithIsolateMixin< //
|
||||
WithDefaultPlatformMixin< //
|
||||
::testing::Test>>>>>;
|
||||
|
||||
using TestWithNativeContext = //
|
||||
WithInternalIsolateMixin< //
|
||||
WithContextMixin< //
|
||||
|
@ -257,6 +257,7 @@
|
||||
'RegExpTest.MacroAssemblerNativeSuccess': [SKIP],
|
||||
'RegExpTest.MacroAssemblerStackOverflow': [SKIP],
|
||||
'RegExpTest.Graph': [SKIP],
|
||||
'SloppyEqualityTest/*' : [SKIP],
|
||||
'DisasmX64Test.*': [SKIP],
|
||||
|
||||
# Tests generated irregexp code.
|
||||
@ -290,4 +291,10 @@
|
||||
'RegExpTestWithContext.UnicodePropertyEscapeCodeSize': [SKIP],
|
||||
}], # no_i18n == True
|
||||
|
||||
##############################################################################
|
||||
['variant == nooptimization', {
|
||||
# %ObserveNode tests rely on TurboFan.
|
||||
'SloppyEqualityTest/*' : [SKIP],
|
||||
}], # variant == nooptimization
|
||||
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user