Commit 0cbfcede authored by Feng Yu's avatar Feng Yu Committed by V8 LUCI CQ

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