From d6ead37d265d7215cf9c5f768f279e21bd170212 Mon Sep 17 00:00:00 2001 From: Mostyn Bramley-Moore Date: Thu, 28 Sep 2017 19:55:52 +0200 Subject: [PATCH] [jumbo] add unittests jumbo support TBR=jkummerow@chromium.org Bug: chromium:746958 Change-Id: I7500b6206c4ceb087672de5b61b7e7ad234bb425 Reviewed-on: https://chromium-review.googlesource.com/690397 Commit-Queue: Jakob Kummerow Reviewed-by: Jakob Kummerow Cr-Commit-Position: refs/heads/master@{#48213} --- test/unittests/BUILD.gn | 38 ++- test/unittests/api/remote-object-unittest.cc | 2 + test/unittests/base/logging-unittest.cc | 2 + .../unittests/base/template-utils-unittest.cc | 2 + .../common-operator-reducer-unittest.cc | 2 + .../compiler/common-operator-unittest.cc | 3 +- .../dead-code-elimination-unittest.cc | 2 + .../compiler/graph-reducer-unittest.cc | 2 + .../compiler/instruction-unittest.cc | 2 + .../compiler/js-operator-unittest.cc | 2 + .../unittests/compiler/node-cache-unittest.cc | 2 + .../compiler/node-properties-unittest.cc | 2 + test/unittests/compiler/node-test-utils.cc | 311 ++++++++---------- .../simplified-operator-reducer-unittest.cc | 2 + .../compiler/typed-optimization-unittest.cc | 2 + .../libplatform/default-platform-unittest.cc | 2 + .../libplatform/task-queue-unittest.cc | 2 + .../libplatform/worker-thread-unittest.cc | 36 +- .../wasm/function-body-decoder-unittest.cc | 2 + .../unittests/wasm/module-decoder-unittest.cc | 2 + test/unittests/wasm/wasm-heap-unittest.cc | 4 +- 21 files changed, 234 insertions(+), 190 deletions(-) diff --git a/test/unittests/BUILD.gn b/test/unittests/BUILD.gn index 3209157f75..0f8d8c6cfc 100644 --- a/test/unittests/BUILD.gn +++ b/test/unittests/BUILD.gn @@ -7,6 +7,30 @@ import("../../gni/v8.gni") v8_executable("unittests") { testonly = true + # TODO(machenbach): Translate from gyp. + #['OS=="aix"', { + # 'ldflags': [ '-Wl,-bbigtoc' ], + #}], + + deps = [ + ":unittests_sources", + "../..:v8_for_testing", + "../..:v8_libbase", + "../..:v8_libplatform", + "//build/config:exe_and_shlib_deps", + "//build/win:default_exe_manifest", + "//testing/gmock", + "//testing/gtest", + ] + + configs = [ + "../..:external_config", + "../..:internal_config_base", + ] +} +v8_source_set("unittests_sources") { + testonly = true + sources = [ "../../test/common/wasm/wasm-macro-gen.h", "../../testing/gmock-support.h", @@ -168,6 +192,15 @@ v8_executable("unittests") { "zone/zone-unittest.cc", ] + if (use_jumbo_build) { + jumbo_excluded_sources = [ + # TODO(mostynb@opera.com): figure out how to make this build in both + # modes. Template issues on windows if we add a functional_unittest + # namespace as with the other files. + "base/functional-unittest.cc", + ] + } + if (v8_current_cpu == "arm") { sources += [ "compiler/arm/instruction-selector-arm-unittest.cc" ] } else if (v8_current_cpu == "arm64") { @@ -191,11 +224,6 @@ v8_executable("unittests") { "../..:internal_config_base", ] - # TODO(machenbach): Translate from gyp. - #['OS=="aix"', { - # 'ldflags': [ '-Wl,-bbigtoc' ], - #}], - deps = [ "../..:v8_for_testing", "../..:v8_libbase", diff --git a/test/unittests/api/remote-object-unittest.cc b/test/unittests/api/remote-object-unittest.cc index 27612fae6f..40754d50f4 100644 --- a/test/unittests/api/remote-object-unittest.cc +++ b/test/unittests/api/remote-object-unittest.cc @@ -11,6 +11,7 @@ #include "test/unittests/test-utils.h" namespace v8 { +namespace remote_object_unittest { typedef TestWithIsolate RemoteObjectTest; @@ -115,4 +116,5 @@ TEST_F(RemoteObjectTest, ClassOf) { EXPECT_STREQ("test_class", *result); } +} // namespace remote_object_unittest } // namespace v8 diff --git a/test/unittests/base/logging-unittest.cc b/test/unittests/base/logging-unittest.cc index 0b9c116c55..fd334ec49d 100644 --- a/test/unittests/base/logging-unittest.cc +++ b/test/unittests/base/logging-unittest.cc @@ -10,6 +10,7 @@ namespace v8 { namespace base { +namespace logging_unittest { namespace { @@ -243,5 +244,6 @@ TEST(LoggingDeathTest, V8_DcheckCanBeOverridden) { "Dread pirate"); } +} // namespace logging_unittest } // namespace base } // namespace v8 diff --git a/test/unittests/base/template-utils-unittest.cc b/test/unittests/base/template-utils-unittest.cc index ceb99a4524..ea8796a123 100644 --- a/test/unittests/base/template-utils-unittest.cc +++ b/test/unittests/base/template-utils-unittest.cc @@ -8,6 +8,7 @@ namespace v8 { namespace base { +namespace template_utils_unittest { //////////////////////////// // Test make_array. @@ -100,5 +101,6 @@ static_assert(has_output_operator::value, static_assert(!has_output_operator::value, "const TestClass2 can not be output"); +} // namespace template_utils_unittest } // namespace base } // namespace v8 diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc index ecc3070785..6618dfb452 100644 --- a/test/unittests/compiler/common-operator-reducer-unittest.cc +++ b/test/unittests/compiler/common-operator-reducer-unittest.cc @@ -17,6 +17,7 @@ using testing::StrictMock; namespace v8 { namespace internal { namespace compiler { +namespace common_operator_reducer_unittest { class CommonOperatorReducerTest : public GraphTest { public: @@ -491,6 +492,7 @@ TEST_F(CommonOperatorReducerTest, SelectToFloat64Abs) { EXPECT_THAT(r.replacement(), IsFloat64Abs(p0)); } +} // namespace common_operator_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/common-operator-unittest.cc b/test/unittests/compiler/common-operator-unittest.cc index 761ce70a01..b51d5f3cf6 100644 --- a/test/unittests/compiler/common-operator-unittest.cc +++ b/test/unittests/compiler/common-operator-unittest.cc @@ -13,7 +13,7 @@ namespace v8 { namespace internal { namespace compiler { - +namespace common_operator_unittest { // ----------------------------------------------------------------------------- // Shared operators. @@ -387,6 +387,7 @@ TEST_F(CommonOperatorTest, Projection) { } } +} // namespace common_operator_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/dead-code-elimination-unittest.cc b/test/unittests/compiler/dead-code-elimination-unittest.cc index d0351bf5f5..d1f914c68e 100644 --- a/test/unittests/compiler/dead-code-elimination-unittest.cc +++ b/test/unittests/compiler/dead-code-elimination-unittest.cc @@ -14,6 +14,7 @@ using testing::StrictMock; namespace v8 { namespace internal { namespace compiler { +namespace dead_code_elimination_unittest { class DeadCodeEliminationTest : public GraphTest { public: @@ -368,6 +369,7 @@ TEST_F(DeadCodeEliminationTest, TerminateWithDeadControlInput) { EXPECT_THAT(r.replacement(), IsDead()); } +} // namespace dead_code_elimination_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/graph-reducer-unittest.cc b/test/unittests/compiler/graph-reducer-unittest.cc index f6f5994932..dc2f2189d1 100644 --- a/test/unittests/compiler/graph-reducer-unittest.cc +++ b/test/unittests/compiler/graph-reducer-unittest.cc @@ -21,6 +21,7 @@ using testing::UnorderedElementsAre; namespace v8 { namespace internal { namespace compiler { +namespace graph_reducer_unittest { namespace { @@ -872,6 +873,7 @@ TEST_F(GraphReducerTest, Order) { } } +} // namespace graph_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/instruction-unittest.cc b/test/unittests/compiler/instruction-unittest.cc index 443c42b62a..96add7fdd8 100644 --- a/test/unittests/compiler/instruction-unittest.cc +++ b/test/unittests/compiler/instruction-unittest.cc @@ -10,6 +10,7 @@ namespace v8 { namespace internal { namespace compiler { +namespace instruction_unittest { namespace { @@ -170,6 +171,7 @@ TEST_F(InstructionTest, PrepareInsertAfter) { } } +} // namespace instruction_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/js-operator-unittest.cc b/test/unittests/compiler/js-operator-unittest.cc index 886fbe02ce..8a458a736f 100644 --- a/test/unittests/compiler/js-operator-unittest.cc +++ b/test/unittests/compiler/js-operator-unittest.cc @@ -11,6 +11,7 @@ namespace v8 { namespace internal { namespace compiler { +namespace js_operator_unittest { // ----------------------------------------------------------------------------- // Shared operators. @@ -112,6 +113,7 @@ TEST_P(JSSharedOperatorTest, Properties) { INSTANTIATE_TEST_CASE_P(JSOperatorTest, JSSharedOperatorTest, ::testing::ValuesIn(kSharedOperators)); +} // namespace js_operator_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/node-cache-unittest.cc b/test/unittests/compiler/node-cache-unittest.cc index 3c92876abd..f77377deda 100644 --- a/test/unittests/compiler/node-cache-unittest.cc +++ b/test/unittests/compiler/node-cache-unittest.cc @@ -12,6 +12,7 @@ using testing::Contains; namespace v8 { namespace internal { namespace compiler { +namespace node_cache_unittest { typedef GraphTest NodeCacheTest; @@ -154,6 +155,7 @@ TEST_F(NodeCacheTest, GetCachedNodes_int64) { } } +} // namespace node_cache_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/node-properties-unittest.cc b/test/unittests/compiler/node-properties-unittest.cc index a18f2032f5..b3b76cef79 100644 --- a/test/unittests/compiler/node-properties-unittest.cc +++ b/test/unittests/compiler/node-properties-unittest.cc @@ -14,6 +14,7 @@ using testing::IsNull; namespace v8 { namespace internal { namespace compiler { +namespace node_properties_unittest { class NodePropertiesTest : public TestWithZone { public: @@ -118,6 +119,7 @@ TEST_F(NodePropertiesTest, CollectControlProjections_Switch) { EXPECT_EQ(if_default, result[2]); } +} // namespace node_properties_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/node-test-utils.cc b/test/unittests/compiler/node-test-utils.cc index b867c8271b..52fd02b0a6 100644 --- a/test/unittests/compiler/node-test-utils.cc +++ b/test/unittests/compiler/node-test-utils.cc @@ -47,10 +47,9 @@ bool PrintMatchAndExplain(const T& value, const std::string& value_name, return true; } - -class NodeMatcher : public MatcherInterface { +class TestNodeMatcher : public MatcherInterface { public: - explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} + explicit TestNodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} void DescribeTo(std::ostream* os) const override { *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; @@ -74,17 +73,16 @@ class NodeMatcher : public MatcherInterface { const IrOpcode::Value opcode_; }; - -class IsBranchMatcher final : public NodeMatcher { +class IsBranchMatcher final : public TestNodeMatcher { public: IsBranchMatcher(const Matcher& value_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kBranch), + : TestNodeMatcher(IrOpcode::kBranch), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -93,7 +91,7 @@ class IsBranchMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -105,17 +103,16 @@ class IsBranchMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsSwitchMatcher final : public NodeMatcher { +class IsSwitchMatcher final : public TestNodeMatcher { public: IsSwitchMatcher(const Matcher& value_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kSwitch), + : TestNodeMatcher(IrOpcode::kSwitch), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -124,7 +121,7 @@ class IsSwitchMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -136,17 +133,16 @@ class IsSwitchMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsIfValueMatcher final : public NodeMatcher { +class IsIfValueMatcher final : public TestNodeMatcher { public: IsIfValueMatcher(const Matcher& value_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kIfValue), + : TestNodeMatcher(IrOpcode::kIfValue), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -155,7 +151,7 @@ class IsIfValueMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node->op()), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -167,22 +163,21 @@ class IsIfValueMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsControl1Matcher final : public NodeMatcher { +class IsControl1Matcher final : public TestNodeMatcher { public: IsControl1Matcher(IrOpcode::Value opcode, const Matcher& control_matcher) - : NodeMatcher(opcode), control_matcher_(control_matcher) {} + : TestNodeMatcher(opcode), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control ("; control_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), "control", control_matcher_, listener)); } @@ -191,18 +186,17 @@ class IsControl1Matcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsControl2Matcher final : public NodeMatcher { +class IsControl2Matcher final : public TestNodeMatcher { public: IsControl2Matcher(IrOpcode::Value opcode, const Matcher& control0_matcher, const Matcher& control1_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), control0_matcher_(control0_matcher), control1_matcher_(control1_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control0 ("; control0_matcher_.DescribeTo(os); *os << ") and control1 ("; @@ -211,7 +205,7 @@ class IsControl2Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), "control0", control0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), @@ -223,20 +217,19 @@ class IsControl2Matcher final : public NodeMatcher { const Matcher control1_matcher_; }; - -class IsControl3Matcher final : public NodeMatcher { +class IsControl3Matcher final : public TestNodeMatcher { public: IsControl3Matcher(IrOpcode::Value opcode, const Matcher& control0_matcher, const Matcher& control1_matcher, const Matcher& control2_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), control0_matcher_(control0_matcher), control1_matcher_(control1_matcher), control2_matcher_(control2_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose control0 ("; control0_matcher_.DescribeTo(os); *os << ") and control1 ("; @@ -247,7 +240,7 @@ class IsControl3Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), "control0", control0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), @@ -262,21 +255,21 @@ class IsControl3Matcher final : public NodeMatcher { const Matcher control2_matcher_; }; - -class IsBeginRegionMatcher final : public NodeMatcher { +class IsBeginRegionMatcher final : public TestNodeMatcher { public: explicit IsBeginRegionMatcher(const Matcher& effect_matcher) - : NodeMatcher(IrOpcode::kBeginRegion), effect_matcher_(effect_matcher) {} + : TestNodeMatcher(IrOpcode::kBeginRegion), + effect_matcher_(effect_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose effect ("; effect_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", effect_matcher_, listener)); } @@ -285,17 +278,16 @@ class IsBeginRegionMatcher final : public NodeMatcher { const Matcher effect_matcher_; }; - -class IsFinishRegionMatcher final : public NodeMatcher { +class IsFinishRegionMatcher final : public TestNodeMatcher { public: IsFinishRegionMatcher(const Matcher& value_matcher, const Matcher& effect_matcher) - : NodeMatcher(IrOpcode::kFinishRegion), + : TestNodeMatcher(IrOpcode::kFinishRegion), value_matcher_(value_matcher), effect_matcher_(effect_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and effect ("; @@ -304,7 +296,7 @@ class IsFinishRegionMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", @@ -316,13 +308,12 @@ class IsFinishRegionMatcher final : public NodeMatcher { const Matcher effect_matcher_; }; - -class IsReturnMatcher final : public NodeMatcher { +class IsReturnMatcher final : public TestNodeMatcher { public: IsReturnMatcher(const Matcher& value_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kReturn), + : TestNodeMatcher(IrOpcode::kReturn), value_matcher_(value_matcher), value2_matcher_(_), effect_matcher_(effect_matcher), @@ -333,7 +324,7 @@ class IsReturnMatcher final : public NodeMatcher { const Matcher& value2_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kReturn), + : TestNodeMatcher(IrOpcode::kReturn), value_matcher_(value_matcher), value2_matcher_(value2_matcher), effect_matcher_(effect_matcher), @@ -341,7 +332,7 @@ class IsReturnMatcher final : public NodeMatcher { has_second_return_value_(true) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); if (has_second_return_value_) { @@ -356,7 +347,7 @@ class IsReturnMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value", value_matcher_, listener) && (!has_second_return_value_ || @@ -376,17 +367,16 @@ class IsReturnMatcher final : public NodeMatcher { bool has_second_return_value_; }; - -class IsTerminateMatcher final : public NodeMatcher { +class IsTerminateMatcher final : public TestNodeMatcher { public: IsTerminateMatcher(const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kTerminate), + : TestNodeMatcher(IrOpcode::kTerminate), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose effect ("; effect_matcher_.DescribeTo(os); *os << ") and control ("; @@ -395,7 +385,7 @@ class IsTerminateMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", effect_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -407,16 +397,16 @@ class IsTerminateMatcher final : public NodeMatcher { const Matcher control_matcher_; }; -class IsTypeGuardMatcher final : public NodeMatcher { +class IsTypeGuardMatcher final : public TestNodeMatcher { public: IsTypeGuardMatcher(const Matcher& value_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kTypeGuard), + : TestNodeMatcher(IrOpcode::kTypeGuard), value_matcher_(value_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ") and control ("; @@ -425,7 +415,7 @@ class IsTypeGuardMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value", value_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetControlInput(node), @@ -438,20 +428,20 @@ class IsTypeGuardMatcher final : public NodeMatcher { }; template -class IsConstantMatcher final : public NodeMatcher { +class IsConstantMatcher final : public TestNodeMatcher { public: IsConstantMatcher(IrOpcode::Value opcode, const Matcher& value_matcher) - : NodeMatcher(opcode), value_matcher_(value_matcher) {} + : TestNodeMatcher(opcode), value_matcher_(value_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose value ("; value_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "value", value_matcher_, listener)); } @@ -460,21 +450,20 @@ class IsConstantMatcher final : public NodeMatcher { const Matcher value_matcher_; }; - -class IsSelectMatcher final : public NodeMatcher { +class IsSelectMatcher final : public TestNodeMatcher { public: IsSelectMatcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher) - : NodeMatcher(IrOpcode::kSelect), + : TestNodeMatcher(IrOpcode::kSelect), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), value2_matcher_(value2_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -488,7 +477,7 @@ class IsSelectMatcher final : public NodeMatcher { bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { return ( - NodeMatcher::MatchAndExplain(node, listener) && + TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(SelectParametersOf(node->op()).representation(), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0", @@ -506,21 +495,20 @@ class IsSelectMatcher final : public NodeMatcher { const Matcher value2_matcher_; }; - -class IsPhiMatcher final : public NodeMatcher { +class IsPhiMatcher final : public TestNodeMatcher { public: IsPhiMatcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kPhi), + : TestNodeMatcher(IrOpcode::kPhi), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -533,7 +521,7 @@ class IsPhiMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(PhiRepresentationOf(node->op()), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), @@ -551,15 +539,14 @@ class IsPhiMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsPhi2Matcher final : public NodeMatcher { +class IsPhi2Matcher final : public TestNodeMatcher { public: IsPhi2Matcher(const Matcher& type_matcher, const Matcher& value0_matcher, const Matcher& value1_matcher, const Matcher& value2_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kPhi), + : TestNodeMatcher(IrOpcode::kPhi), type_matcher_(type_matcher), value0_matcher_(value0_matcher), value1_matcher_(value1_matcher), @@ -567,7 +554,7 @@ class IsPhi2Matcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose representation ("; type_matcher_.DescribeTo(os); *os << "), value0 ("; @@ -582,7 +569,7 @@ class IsPhi2Matcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(PhiRepresentationOf(node->op()), "representation", type_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), @@ -603,19 +590,18 @@ class IsPhi2Matcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsEffectPhiMatcher final : public NodeMatcher { +class IsEffectPhiMatcher final : public TestNodeMatcher { public: IsEffectPhiMatcher(const Matcher& effect0_matcher, const Matcher& effect1_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kEffectPhi), + : TestNodeMatcher(IrOpcode::kEffectPhi), effect0_matcher_(effect0_matcher), effect1_matcher_(effect1_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << "), effect0 ("; effect0_matcher_.DescribeTo(os); *os << "), effect1 ("; @@ -626,7 +612,7 @@ class IsEffectPhiMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0), "effect0", effect0_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1), @@ -641,17 +627,16 @@ class IsEffectPhiMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsProjectionMatcher final : public NodeMatcher { +class IsProjectionMatcher final : public TestNodeMatcher { public: IsProjectionMatcher(const Matcher& index_matcher, const Matcher& base_matcher) - : NodeMatcher(IrOpcode::kProjection), + : TestNodeMatcher(IrOpcode::kProjection), index_matcher_(index_matcher), base_matcher_(base_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose index ("; index_matcher_.DescribeTo(os); *os << ") and base ("; @@ -660,7 +645,7 @@ class IsProjectionMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "index", index_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -672,21 +657,20 @@ class IsProjectionMatcher final : public NodeMatcher { const Matcher base_matcher_; }; - -class IsCallMatcher final : public NodeMatcher { +class IsCallMatcher final : public TestNodeMatcher { public: IsCallMatcher(const Matcher& descriptor_matcher, const std::vector>& value_matchers, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kCall), + : TestNodeMatcher(IrOpcode::kCall), descriptor_matcher_(descriptor_matcher), value_matchers_(value_matchers), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); for (size_t i = 0; i < value_matchers_.size(); ++i) { if (i == 0) { *os << " whose value0 ("; @@ -703,7 +687,7 @@ class IsCallMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - if (!NodeMatcher::MatchAndExplain(node, listener) || + if (!TestNodeMatcher::MatchAndExplain(node, listener) || !PrintMatchAndExplain(OpParameter(node), "descriptor", descriptor_matcher_, listener)) { return false; @@ -738,21 +722,20 @@ class IsCallMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsTailCallMatcher final : public NodeMatcher { +class IsTailCallMatcher final : public TestNodeMatcher { public: IsTailCallMatcher(const Matcher& descriptor_matcher, const std::vector>& value_matchers, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kTailCall), + : TestNodeMatcher(IrOpcode::kTailCall), descriptor_matcher_(descriptor_matcher), value_matchers_(value_matchers), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); for (size_t i = 0; i < value_matchers_.size(); ++i) { if (i == 0) { *os << " whose value0 ("; @@ -769,7 +752,7 @@ class IsTailCallMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - if (!NodeMatcher::MatchAndExplain(node, listener) || + if (!TestNodeMatcher::MatchAndExplain(node, listener) || !PrintMatchAndExplain(OpParameter(node), "descriptor", descriptor_matcher_, listener)) { return false; @@ -804,7 +787,7 @@ class IsTailCallMatcher final : public NodeMatcher { const Matcher control_matcher_; }; -class IsSpeculativeBinopMatcher final : public NodeMatcher { +class IsSpeculativeBinopMatcher final : public TestNodeMatcher { public: IsSpeculativeBinopMatcher(IrOpcode::Value opcode, const Matcher& hint_matcher, @@ -812,7 +795,7 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { const Matcher& rhs_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), hint_matcher_(hint_matcher), lhs_matcher_(lhs_matcher), rhs_matcher_(rhs_matcher), @@ -820,7 +803,7 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && // TODO(bmeurer): The type parameter is currently ignored. PrintMatchAndExplain(OpParameter(node->op()), "hints", hint_matcher_, listener) && @@ -843,18 +826,18 @@ class IsSpeculativeBinopMatcher final : public NodeMatcher { const Matcher control_matcher_; }; -class IsAllocateMatcher final : public NodeMatcher { +class IsAllocateMatcher final : public TestNodeMatcher { public: IsAllocateMatcher(const Matcher& size_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kAllocate), + : TestNodeMatcher(IrOpcode::kAllocate), size_matcher_(size_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "size", size_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", @@ -869,21 +852,20 @@ class IsAllocateMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsLoadFieldMatcher final : public NodeMatcher { +class IsLoadFieldMatcher final : public TestNodeMatcher { public: IsLoadFieldMatcher(const Matcher& access_matcher, const Matcher& base_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kLoadField), + : TestNodeMatcher(IrOpcode::kLoadField), access_matcher_(access_matcher), base_matcher_(base_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -896,7 +878,7 @@ class IsLoadFieldMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -914,15 +896,14 @@ class IsLoadFieldMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsStoreFieldMatcher final : public NodeMatcher { +class IsStoreFieldMatcher final : public TestNodeMatcher { public: IsStoreFieldMatcher(const Matcher& access_matcher, const Matcher& base_matcher, const Matcher& value_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kStoreField), + : TestNodeMatcher(IrOpcode::kStoreField), access_matcher_(access_matcher), base_matcher_(base_matcher), value_matcher_(value_matcher), @@ -930,7 +911,7 @@ class IsStoreFieldMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -945,7 +926,7 @@ class IsStoreFieldMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -966,14 +947,14 @@ class IsStoreFieldMatcher final : public NodeMatcher { const Matcher control_matcher_; }; -class IsLoadElementMatcher final : public NodeMatcher { +class IsLoadElementMatcher final : public TestNodeMatcher { public: IsLoadElementMatcher(const Matcher& access_matcher, const Matcher& base_matcher, const Matcher& index_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kLoadElement), + : TestNodeMatcher(IrOpcode::kLoadElement), access_matcher_(access_matcher), base_matcher_(base_matcher), index_matcher_(index_matcher), @@ -981,7 +962,7 @@ class IsLoadElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -996,7 +977,7 @@ class IsLoadElementMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -1017,8 +998,7 @@ class IsLoadElementMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsStoreElementMatcher final : public NodeMatcher { +class IsStoreElementMatcher final : public TestNodeMatcher { public: IsStoreElementMatcher(const Matcher& access_matcher, const Matcher& base_matcher, @@ -1026,7 +1006,7 @@ class IsStoreElementMatcher final : public NodeMatcher { const Matcher& value_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kStoreElement), + : TestNodeMatcher(IrOpcode::kStoreElement), access_matcher_(access_matcher), base_matcher_(base_matcher), index_matcher_(index_matcher), @@ -1035,7 +1015,7 @@ class IsStoreElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << "), base ("; @@ -1052,7 +1032,7 @@ class IsStoreElementMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", @@ -1077,14 +1057,14 @@ class IsStoreElementMatcher final : public NodeMatcher { }; #define LOAD_MATCHER(kLoad) \ - class Is##kLoad##Matcher final : public NodeMatcher { \ + class Is##kLoad##Matcher final : public TestNodeMatcher { \ public: \ Is##kLoad##Matcher(const Matcher& rep_matcher, \ const Matcher& base_matcher, \ const Matcher& index_matcher, \ const Matcher& effect_matcher, \ const Matcher& control_matcher) \ - : NodeMatcher(IrOpcode::k##kLoad), \ + : TestNodeMatcher(IrOpcode::k##kLoad), \ rep_matcher_(rep_matcher), \ base_matcher_(base_matcher), \ index_matcher_(index_matcher), \ @@ -1092,7 +1072,7 @@ class IsStoreElementMatcher final : public NodeMatcher { control_matcher_(control_matcher) {} \ \ void DescribeTo(std::ostream* os) const final { \ - NodeMatcher::DescribeTo(os); \ + TestNodeMatcher::DescribeTo(os); \ *os << " whose rep ("; \ rep_matcher_.DescribeTo(os); \ *os << "), base ("; \ @@ -1116,7 +1096,7 @@ class IsStoreElementMatcher final : public NodeMatcher { if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \ control_node = NodeProperties::GetControlInput(node); \ } \ - return (NodeMatcher::MatchAndExplain(node, listener) && \ + return (TestNodeMatcher::MatchAndExplain(node, listener) && \ PrintMatchAndExplain(OpParameter(node), \ "rep", rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ @@ -1141,7 +1121,7 @@ LOAD_MATCHER(Load) LOAD_MATCHER(UnalignedLoad) #define STORE_MATCHER(kStore) \ - class Is##kStore##Matcher final : public NodeMatcher { \ + class Is##kStore##Matcher final : public TestNodeMatcher { \ public: \ Is##kStore##Matcher(const Matcher& rep_matcher, \ const Matcher& base_matcher, \ @@ -1149,7 +1129,7 @@ LOAD_MATCHER(UnalignedLoad) const Matcher& value_matcher, \ const Matcher& effect_matcher, \ const Matcher& control_matcher) \ - : NodeMatcher(IrOpcode::k##kStore), \ + : TestNodeMatcher(IrOpcode::k##kStore), \ rep_matcher_(rep_matcher), \ base_matcher_(base_matcher), \ index_matcher_(index_matcher), \ @@ -1158,7 +1138,7 @@ LOAD_MATCHER(UnalignedLoad) control_matcher_(control_matcher) {} \ \ void DescribeTo(std::ostream* os) const final { \ - NodeMatcher::DescribeTo(os); \ + TestNodeMatcher::DescribeTo(os); \ *os << " whose rep ("; \ rep_matcher_.DescribeTo(os); \ *os << "), base ("; \ @@ -1184,7 +1164,7 @@ LOAD_MATCHER(UnalignedLoad) if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \ control_node = NodeProperties::GetControlInput(node); \ } \ - return (NodeMatcher::MatchAndExplain(node, listener) && \ + return (TestNodeMatcher::MatchAndExplain(node, listener) && \ PrintMatchAndExplain(OpParameter(node), \ "rep", rep_matcher_, listener) && \ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \ @@ -1211,21 +1191,21 @@ LOAD_MATCHER(UnalignedLoad) STORE_MATCHER(Store) STORE_MATCHER(UnalignedStore) -class IsStackSlotMatcher final : public NodeMatcher { +class IsStackSlotMatcher final : public TestNodeMatcher { public: explicit IsStackSlotMatcher( const Matcher& rep_matcher) - : NodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} + : TestNodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose rep ("; rep_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "rep", rep_matcher_, listener)); } @@ -1234,20 +1214,20 @@ class IsStackSlotMatcher final : public NodeMatcher { const Matcher rep_matcher_; }; -class IsToNumberMatcher final : public NodeMatcher { +class IsToNumberMatcher final : public TestNodeMatcher { public: IsToNumberMatcher(const Matcher& base_matcher, const Matcher& context_matcher, const Matcher& effect_matcher, const Matcher& control_matcher) - : NodeMatcher(IrOpcode::kJSToNumber), + : TestNodeMatcher(IrOpcode::kJSToNumber), base_matcher_(base_matcher), context_matcher_(context_matcher), effect_matcher_(effect_matcher), control_matcher_(control_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose base ("; base_matcher_.DescribeTo(os); *os << "), context ("; @@ -1260,7 +1240,7 @@ class IsToNumberMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", base_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetContextInput(node), @@ -1278,17 +1258,16 @@ class IsToNumberMatcher final : public NodeMatcher { const Matcher control_matcher_; }; - -class IsLoadContextMatcher final : public NodeMatcher { +class IsLoadContextMatcher final : public TestNodeMatcher { public: IsLoadContextMatcher(const Matcher& access_matcher, const Matcher& context_matcher) - : NodeMatcher(IrOpcode::kJSLoadContext), + : TestNodeMatcher(IrOpcode::kJSLoadContext), access_matcher_(access_matcher), context_matcher_(context_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose access ("; access_matcher_.DescribeTo(os); *os << ") and context ("; @@ -1297,7 +1276,7 @@ class IsLoadContextMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(OpParameter(node), "access", access_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetContextInput(node), @@ -1309,20 +1288,20 @@ class IsLoadContextMatcher final : public NodeMatcher { const Matcher context_matcher_; }; -class IsQuadopMatcher final : public NodeMatcher { +class IsQuadopMatcher final : public TestNodeMatcher { public: IsQuadopMatcher(IrOpcode::Value opcode, const Matcher& a_matcher, const Matcher& b_matcher, const Matcher& c_matcher, const Matcher& d_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), a_matcher_(a_matcher), b_matcher_(b_matcher), c_matcher_(c_matcher), d_matcher_(d_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose a ("; a_matcher_.DescribeTo(os); *os << ") and b ("; @@ -1335,7 +1314,7 @@ class IsQuadopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a", a_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b", @@ -1353,18 +1332,18 @@ class IsQuadopMatcher final : public NodeMatcher { const Matcher d_matcher_; }; -class IsTernopMatcher final : public NodeMatcher { +class IsTernopMatcher final : public TestNodeMatcher { public: IsTernopMatcher(IrOpcode::Value opcode, const Matcher& lhs_matcher, const Matcher& mid_matcher, const Matcher& rhs_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), lhs_matcher_(lhs_matcher), mid_matcher_(mid_matcher), rhs_matcher_(rhs_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose lhs ("; lhs_matcher_.DescribeTo(os); *os << ") and mid ("; @@ -1375,7 +1354,7 @@ class IsTernopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", lhs_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid", @@ -1390,16 +1369,16 @@ class IsTernopMatcher final : public NodeMatcher { const Matcher rhs_matcher_; }; -class IsBinopMatcher final : public NodeMatcher { +class IsBinopMatcher final : public TestNodeMatcher { public: IsBinopMatcher(IrOpcode::Value opcode, const Matcher& lhs_matcher, const Matcher& rhs_matcher) - : NodeMatcher(opcode), + : TestNodeMatcher(opcode), lhs_matcher_(lhs_matcher), rhs_matcher_(rhs_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose lhs ("; lhs_matcher_.DescribeTo(os); *os << ") and rhs ("; @@ -1408,7 +1387,7 @@ class IsBinopMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", lhs_matcher_, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", @@ -1420,21 +1399,20 @@ class IsBinopMatcher final : public NodeMatcher { const Matcher rhs_matcher_; }; - -class IsUnopMatcher final : public NodeMatcher { +class IsUnopMatcher final : public TestNodeMatcher { public: IsUnopMatcher(IrOpcode::Value opcode, const Matcher& input_matcher) - : NodeMatcher(opcode), input_matcher_(input_matcher) {} + : TestNodeMatcher(opcode), input_matcher_(input_matcher) {} void DescribeTo(std::ostream* os) const final { - NodeMatcher::DescribeTo(os); + TestNodeMatcher::DescribeTo(os); *os << " whose input ("; input_matcher_.DescribeTo(os); *os << ")"; } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "input", input_matcher_, listener)); } @@ -1443,11 +1421,10 @@ class IsUnopMatcher final : public NodeMatcher { const Matcher input_matcher_; }; - -class IsParameterMatcher final : public NodeMatcher { +class IsParameterMatcher final : public TestNodeMatcher { public: explicit IsParameterMatcher(const Matcher& index_matcher) - : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} + : TestNodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} void DescribeTo(std::ostream* os) const override { *os << "is a Parameter node with index("; @@ -1456,7 +1433,7 @@ class IsParameterMatcher final : public NodeMatcher { } bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { - return (NodeMatcher::MatchAndExplain(node, listener) && + return (TestNodeMatcher::MatchAndExplain(node, listener) && PrintMatchAndExplain(ParameterIndexOf(node->op()), "index", index_matcher_, listener)); } @@ -1468,7 +1445,7 @@ class IsParameterMatcher final : public NodeMatcher { } // namespace Matcher IsDead() { - return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kDead)); } Matcher IsEnd(const Matcher& control0_matcher) { @@ -2050,11 +2027,11 @@ Matcher IsParameter(const Matcher index_matcher) { Matcher IsLoadFramePointer() { - return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadFramePointer)); } Matcher IsLoadParentFramePointer() { - return MakeMatcher(new NodeMatcher(IrOpcode::kLoadParentFramePointer)); + return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadParentFramePointer)); } #define IS_QUADOP_MATCHER(Name) \ diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc index cde85133f3..2e67c0d4df 100644 --- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc +++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc @@ -19,6 +19,7 @@ using testing::BitEq; namespace v8 { namespace internal { namespace compiler { +namespace simplified_operator_reducer_unittest { class SimplifiedOperatorReducerTest : public GraphTest { public: @@ -498,6 +499,7 @@ TEST_F(SimplifiedOperatorReducerTest, ObjectIsSmiWithNumberConstant) { } } +} // namespace simplified_operator_reducer_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/typed-optimization-unittest.cc b/test/unittests/compiler/typed-optimization-unittest.cc index 820ef56e60..b527a36c55 100644 --- a/test/unittests/compiler/typed-optimization-unittest.cc +++ b/test/unittests/compiler/typed-optimization-unittest.cc @@ -22,6 +22,7 @@ using testing::IsNaN; namespace v8 { namespace internal { namespace compiler { +namespace typed_optimization_unittest { namespace { @@ -219,6 +220,7 @@ TEST_F(TypedOptimizationTest, JSToBooleanWithNonZeroPlainNumber) { EXPECT_THAT(r.replacement(), IsTrueConstant()); } +} // namespace typed_optimization_unittest } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/libplatform/default-platform-unittest.cc b/test/unittests/libplatform/default-platform-unittest.cc index c98f5dee62..f9b3e0b98f 100644 --- a/test/unittests/libplatform/default-platform-unittest.cc +++ b/test/unittests/libplatform/default-platform-unittest.cc @@ -11,6 +11,7 @@ using testing::StrictMock; namespace v8 { namespace platform { +namespace default_platform_unittest { namespace { @@ -166,5 +167,6 @@ TEST(DefaultPlatformTest, PendingIdleTasksAreDestroyedOnShutdown) { } } +} // namespace default_platform_unittest } // namespace platform } // namespace v8 diff --git a/test/unittests/libplatform/task-queue-unittest.cc b/test/unittests/libplatform/task-queue-unittest.cc index 2de104b9c0..9bb160dd31 100644 --- a/test/unittests/libplatform/task-queue-unittest.cc +++ b/test/unittests/libplatform/task-queue-unittest.cc @@ -13,6 +13,7 @@ using testing::StrictMock; namespace v8 { namespace platform { +namespace task_queue_unittest { namespace { @@ -56,5 +57,6 @@ TEST(TaskQueueTest, TerminateMultipleReaders) { thread2.Join(); } +} // namespace task_queue_unittest } // namespace platform } // namespace v8 diff --git a/test/unittests/libplatform/worker-thread-unittest.cc b/test/unittests/libplatform/worker-thread-unittest.cc index f0b41e78dd..7079d22eb6 100644 --- a/test/unittests/libplatform/worker-thread-unittest.cc +++ b/test/unittests/libplatform/worker-thread-unittest.cc @@ -24,6 +24,25 @@ struct MockTask : public Task { } // namespace +// Needs to be in v8::platform due to BlockUntilQueueEmptyForTesting +// being private. +TEST(WorkerThreadTest, PostSingleTask) { + TaskQueue queue; + WorkerThread thread1(&queue); + WorkerThread thread2(&queue); + + InSequence s; + StrictMock* task = new StrictMock; + EXPECT_CALL(*task, Run()); + EXPECT_CALL(*task, Die()); + queue.Append(task); + + // The next call should not time out. + queue.BlockUntilQueueEmptyForTesting(); + queue.Terminate(); +} + +namespace worker_thread_unittest { TEST(WorkerThreadTest, Basic) { static const size_t kNumTasks = 10; @@ -44,21 +63,6 @@ TEST(WorkerThreadTest, Basic) { queue.Terminate(); } -TEST(WorkerThreadTest, PostSingleTask) { - TaskQueue queue; - WorkerThread thread1(&queue); - WorkerThread thread2(&queue); - - InSequence s; - StrictMock* task = new StrictMock; - EXPECT_CALL(*task, Run()); - EXPECT_CALL(*task, Die()); - queue.Append(task); - - // The next call should not time out. - queue.BlockUntilQueueEmptyForTesting(); - queue.Terminate(); -} - +} // namespace worker_thread_unittest } // namespace platform } // namespace v8 diff --git a/test/unittests/wasm/function-body-decoder-unittest.cc b/test/unittests/wasm/function-body-decoder-unittest.cc index 15925b1c07..bda1073281 100644 --- a/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/test/unittests/wasm/function-body-decoder-unittest.cc @@ -22,6 +22,7 @@ namespace v8 { namespace internal { namespace wasm { +namespace function_body_decoder_unittest { #define B1(a) WASM_BLOCK(a) #define B2(a, b) WASM_BLOCK(a, b) @@ -2950,6 +2951,7 @@ TEST_F(BytecodeIteratorTest, WithLocalDecls) { #undef EXPECT_VERIFIES #undef EXPECT_FAILURE +} // namespace function_body_decoder_unittest } // namespace wasm } // namespace internal } // namespace v8 diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc index 3086f8e025..2e76d374d3 100644 --- a/test/unittests/wasm/module-decoder-unittest.cc +++ b/test/unittests/wasm/module-decoder-unittest.cc @@ -15,6 +15,7 @@ namespace v8 { namespace internal { namespace wasm { +namespace module_decoder_unittest { #define WASM_INIT_EXPR_I32V_1(val) WASM_I32V_1(val), kExprEnd #define WASM_INIT_EXPR_I32V_2(val) WASM_I32V_2(val), kExprEnd @@ -1812,6 +1813,7 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) { #undef EXPECT_OFF_END_FAILURE #undef EXPECT_OK +} // namespace module_decoder_unittest } // namespace wasm } // namespace internal } // namespace v8 diff --git a/test/unittests/wasm/wasm-heap-unittest.cc b/test/unittests/wasm/wasm-heap-unittest.cc index 532c1cf86d..6e75e84b43 100644 --- a/test/unittests/wasm/wasm-heap-unittest.cc +++ b/test/unittests/wasm/wasm-heap-unittest.cc @@ -10,8 +10,9 @@ namespace v8 { namespace internal { namespace wasm { +namespace wasm_heap_unittest { -class DisjointAllocationPoolTest : public testing::Test { +class DisjointAllocationPoolTest : public ::testing::Test { public: Address A(size_t n) { return reinterpret_cast
(n); } void CheckLooksLike(const DisjointAllocationPool& mem, @@ -150,6 +151,7 @@ TEST_F(DisjointAllocationPoolTest, MergingSkipLargerSrcWithGap) { CheckLooksLike(a, {{10, 15}, {20, 35}, {36, 40}}); } +} // namespace wasm_heap_unittest } // namespace wasm } // namespace internal } // namespace v8