Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: test/unittests/compiler/node-test-utils.cc

Issue 1458603012: [Interpreter] Add CreateClosure to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Better matching. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/unittests/compiler/node-test-utils.cc
diff --git a/test/unittests/compiler/node-test-utils.cc b/test/unittests/compiler/node-test-utils.cc
index 713a4bc440889231b58a93f42e8490898c1442b7..8428dcc2592317146ff33ec668d4a62ad4fe8c25 100644
--- a/test/unittests/compiler/node-test-utils.cc
+++ b/test/unittests/compiler/node-test-utils.cc
@@ -1858,6 +1858,84 @@ class IsJSCallMatcher final : public NodeMatcher {
const Matcher<Node*> control_matcher_;
};
+
+class CreateClosureParametersMatcher final
+ : public MatcherInterface<CreateClosureParameters*> {
+ public:
+ explicit CreateClosureParametersMatcher(CreateClosureParameters* parameters)
+ : parameters_(parameters) {}
+
+ void DescribeTo(::std::ostream* os) const final {
+ *os << "is a CreateClosureParameters instance";
+ }
+
+ bool MatchAndExplain(CreateClosureParameters* parameters,
+ MatchResultListener* listener) const override {
+ if (parameters == NULL) {
+ *listener << "which is NULL";
+ return false;
+ }
+ if (*parameters->shared_info() != *parameters_->shared_info()) {
+ *listener << "whose shared function info is "
+ << *parameters->shared_info() << " but should have been "
+ << *parameters_->shared_info();
+ return false;
+ }
+ if (parameters->pretenure() != parameters_->pretenure()) {
+ *listener << "whose tenured flag is " << parameters->pretenure()
+ << " but should have been " << parameters_->pretenure();
+ return false;
+ }
+ return true;
+ }
+
+ private:
+ CreateClosureParameters* parameters_;
+};
+
+
+class IsCreateClosureMatcher final : public NodeMatcher {
+ public:
+ IsCreateClosureMatcher(
+ const Matcher<CreateClosureParameters*>& parameters_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::Value::kJSCreateClosure),
+ parameters_matcher_(parameters_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ void DescribeTo(std::ostream* os) const final {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value (";
+ parameters_matcher_.DescribeTo(os);
+ *os << "), effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
+ if (!NodeMatcher::MatchAndExplain(node, listener)) {
+ return false;
+ }
+ CreateClosureParameters parameters =
+ OpParameter<CreateClosureParameters>(node);
+ return (PrintMatchAndExplain(&parameters, "value", parameters_matcher_,
Michael Starzinger 2015/11/23 11:18:38 Instead of going through extra lengths of making t
oth 2015/11/24 12:29:36 Done.
+ listener) &&
+ PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<CreateClosureParameters*> parameters_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
} // namespace
@@ -2535,6 +2613,21 @@ Matcher<Node*> IsJSCallRuntime(std::vector<Matcher<Node*>> value_matchers,
}
+Matcher<CreateClosureParameters*> IsCreateClosureParameters(
+ CreateClosureParameters* parameters) {
+ return MakeMatcher(new CreateClosureParametersMatcher(parameters));
+}
+
+
+Matcher<Node*> IsCreateClosure(
+ const Matcher<CreateClosureParameters*>& parameters_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsCreateClosureMatcher(
+ parameters_matcher, effect_matcher, control_matcher));
+}
+
+
#define IS_BINOP_MATCHER(Name) \
Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
const Matcher<Node*>& rhs_matcher) { \

Powered by Google App Engine
This is Rietveld 408576698