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

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

Issue 1419373007: [Interpreter] Adds implementation of bytecode graph builder for LoadICSloppy/Strict (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added unittests and addressed review comments 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 bfb9c06960c0424db611e33a32217dbd96882af4..8de2c0e8a1b79f1568d91b3d8fe85c0f6b0df423 100644
--- a/test/unittests/compiler/node-test-utils.cc
+++ b/test/unittests/compiler/node-test-utils.cc
@@ -1404,6 +1404,7 @@ class IsUnopMatcher final : public NodeMatcher {
const Matcher<Node*> input_matcher_;
};
+
class IsParameterMatcher final : public NodeMatcher {
public:
explicit IsParameterMatcher(const Matcher<int>& index_matcher)
@@ -1425,6 +1426,113 @@ class IsParameterMatcher final : public NodeMatcher {
const Matcher<int> index_matcher_;
};
+
+// TODO(mythria): Check if we can use the same matcher for Load and Store
+class IsNamedLoadMatcher final : public NodeMatcher {
+ public:
+ IsNamedLoadMatcher(IrOpcode::Value opcode,
rmcilroy 2015/11/09 15:23:01 don't pass the opcode to this constructor, just us
mythria 2015/11/10 09:55:35 Done.
+ const Matcher<NamedAccess>& named_access_matcher,
+ const Matcher<Node*>& object_value_matcher,
+ const Matcher<Node*>& feedback_vector_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(opcode),
+ named_access_matcher_(named_access_matcher),
+ object_value_matcher_(object_value_matcher),
+ feedback_vector_matcher_(feedback_vector_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ void DescribeTo(std::ostream* os) const final {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose object (";
+ object_value_matcher_.DescribeTo(os);
+ *os << ") feedback vector (";
rmcilroy 2015/11/09 15:23:01 /s/)/),/
mythria 2015/11/10 09:55:35 Done.
+ feedback_vector_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) ||
+ !PrintMatchAndExplain(OpParameter<const NamedAccess>(node),
+ "descriptor", named_access_matcher_, listener)) {
+ return false;
+ }
+ std::ostringstream ost;
+ ost << "Object ";
+ if (!PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), ost.str(),
+ object_value_matcher_, listener)) {
+ return false;
+ }
+ ost.clear();
+ ost << "FeedbackVector ";
+ if (!PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), ost.str(),
+ feedback_vector_matcher_, listener)) {
+ return false;
+ }
rmcilroy 2015/11/09 15:23:01 Please use the same pattern as the other matchers
mythria 2015/11/10 09:55:36 Done.
+ return (PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<NamedAccess> named_access_matcher_;
+ const Matcher<Node*> object_value_matcher_;
+ const Matcher<Node*> feedback_vector_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsNamedAccessMatcher final : public MatcherInterface<NamedAccess> {
rmcilroy 2015/11/09 15:23:01 As discussed, remove this.
mythria 2015/11/10 09:55:35 Done.
+ public:
+ IsNamedAccessMatcher(LanguageMode language_mode, const Handle<Name>& name,
+ const int slot_id)
+ : language_mode_(language_mode), name_(name), slot_id_(slot_id) {}
+
+ void DescribeTo(std::ostream* os) const final {
+ *os << " NamedAccess with language_mode (";
+ *os << language_mode_;
+ *os << ") name (";
+ *os << name_;
+ *os << ") slot (";
+ *os << slot_id_;
+ *os << ")";
+ }
+
+ bool MatchAndExplain(NamedAccess node,
+ MatchResultListener* listener) const final {
+ if (node.language_mode() != language_mode_) {
+ *listener << "whose languagemode is " << node.language_mode()
+ << " but should have been " << language_mode_;
+ return false;
+ }
+ if (!name_->StrictEquals(*node.name())) {
+ *listener << "whose name is " << node.name() << " but should have been "
+ << name_;
+ return false;
+ }
+ if (node.feedback().slot().ToInt() != slot_id_) {
+ *listener << "whose slot is " << node.feedback().slot().ToInt()
+ << " but should have been " << slot_id_;
+ return false;
+ }
+ // TODO(mythria): Check if Handle<TypeFeedbackVector>
+ // (node.feedback().vector()) is equal to expected value
+ return true;
+ }
+
+ private:
+ const LanguageMode language_mode_;
+ const Handle<Name> name_;
+ const int slot_id_;
+};
+
} // namespace
@@ -1998,6 +2106,24 @@ Matcher<Node*> IsLoadFramePointer() {
}
+Matcher<Node*> IsNamedLoad(const Matcher<NamedAccess>& node_access_matcher,
rmcilroy 2015/11/09 15:23:01 IsJSLoadNamed (Follow the name of the IrOpcode)
mythria 2015/11/10 09:55:35 Done.
+ const Matcher<Node*>& object_value_matcher,
+ const Matcher<Node*>& feedback_vector_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsNamedLoadMatcher(
+ IrOpcode::kJSLoadNamed, node_access_matcher, object_value_matcher,
+ feedback_vector_matcher, effect_matcher, control_matcher));
+}
+
+
+Matcher<NamedAccess> IsNamedAccess(LanguageMode language_mode,
rmcilroy 2015/11/09 15:23:00 As discussed offline, let's not add a new NamedAcc
mythria 2015/11/10 09:55:36 As discussed, I pass Handle<Name> instead of match
+ const Handle<Name>& name,
+ const int slot_id) {
+ return MakeMatcher(new IsNamedAccessMatcher(language_mode, name, slot_id));
+}
+
+
#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