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

Side by Side Diff: test/unittests/compiler/graph-unittest.cc

Issue 621863002: [turbofan] Fix lowering of typed loads/stores. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix comment Created 6 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/unittests/compiler/graph-unittest.h" 5 #include "test/unittests/compiler/graph-unittest.h"
6 6
7 #include <ostream> // NOLINT(readability/streams) 7 #include <ostream> // NOLINT(readability/streams)
8 8
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/simplified-operator.h"
10 11
11 using testing::_; 12 using testing::_;
12 using testing::MakeMatcher; 13 using testing::MakeMatcher;
13 using testing::MatcherInterface; 14 using testing::MatcherInterface;
14 using testing::MatchResultListener; 15 using testing::MatchResultListener;
15 using testing::StringMatchResultListener; 16 using testing::StringMatchResultListener;
16 17
17 namespace v8 { 18 namespace v8 {
18 namespace internal { 19 namespace internal {
19 20
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 Node* GraphTest::Int64Constant(int64_t value) { 62 Node* GraphTest::Int64Constant(int64_t value) {
62 return graph()->NewNode(common()->Int64Constant(value)); 63 return graph()->NewNode(common()->Int64Constant(value));
63 } 64 }
64 65
65 66
66 Node* GraphTest::NumberConstant(volatile double value) { 67 Node* GraphTest::NumberConstant(volatile double value) {
67 return graph()->NewNode(common()->NumberConstant(value)); 68 return graph()->NewNode(common()->NumberConstant(value));
68 } 69 }
69 70
70 71
72 Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
73 return HeapConstant(Unique<HeapObject>::CreateUninitialized(value));
74 }
75
76
71 Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) { 77 Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
72 return graph()->NewNode(common()->HeapConstant(value)); 78 Node* node = graph()->NewNode(common()->HeapConstant(value));
79 Type* type = Type::Constant(value.handle(), zone());
80 NodeProperties::SetBounds(node, Bounds(type));
81 return node;
73 } 82 }
74 83
75 84
76 Node* GraphTest::FalseConstant() { 85 Node* GraphTest::FalseConstant() {
77 return HeapConstant( 86 return HeapConstant(
78 Unique<HeapObject>::CreateImmovable(factory()->false_value())); 87 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
79 } 88 }
80 89
81 90
82 Node* GraphTest::TrueConstant() { 91 Node* GraphTest::TrueConstant() {
83 return HeapConstant( 92 return HeapConstant(
84 Unique<HeapObject>::CreateImmovable(factory()->true_value())); 93 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
85 } 94 }
86 95
87 96
97 Node* GraphTest::UndefinedConstant() {
98 return HeapConstant(
99 Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
100 }
101
102
88 Matcher<Node*> GraphTest::IsFalseConstant() { 103 Matcher<Node*> GraphTest::IsFalseConstant() {
89 return IsHeapConstant( 104 return IsHeapConstant(
90 Unique<HeapObject>::CreateImmovable(factory()->false_value())); 105 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
91 } 106 }
92 107
93 108
94 Matcher<Node*> GraphTest::IsTrueConstant() { 109 Matcher<Node*> GraphTest::IsTrueConstant() {
95 return IsHeapConstant( 110 return IsHeapConstant(
96 Unique<HeapObject>::CreateImmovable(factory()->true_value())); 111 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
97 } 112 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 const Matcher<CallDescriptor*> descriptor_matcher_; 438 const Matcher<CallDescriptor*> descriptor_matcher_;
424 const Matcher<Node*> value0_matcher_; 439 const Matcher<Node*> value0_matcher_;
425 const Matcher<Node*> value1_matcher_; 440 const Matcher<Node*> value1_matcher_;
426 const Matcher<Node*> value2_matcher_; 441 const Matcher<Node*> value2_matcher_;
427 const Matcher<Node*> value3_matcher_; 442 const Matcher<Node*> value3_matcher_;
428 const Matcher<Node*> effect_matcher_; 443 const Matcher<Node*> effect_matcher_;
429 const Matcher<Node*> control_matcher_; 444 const Matcher<Node*> control_matcher_;
430 }; 445 };
431 446
432 447
448 class IsLoadFieldMatcher FINAL : public NodeMatcher {
449 public:
450 IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
451 const Matcher<Node*>& base_matcher,
452 const Matcher<Node*>& effect_matcher)
453 : NodeMatcher(IrOpcode::kLoadField),
454 access_matcher_(access_matcher),
455 base_matcher_(base_matcher),
456 effect_matcher_(effect_matcher) {}
457
458 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
459 NodeMatcher::DescribeTo(os);
460 *os << " whose access (";
461 access_matcher_.DescribeTo(os);
462 *os << "), base (";
463 base_matcher_.DescribeTo(os);
464 *os << ") and effect (";
465 effect_matcher_.DescribeTo(os);
466 *os << ")";
467 }
468
469 virtual bool MatchAndExplain(Node* node,
470 MatchResultListener* listener) const OVERRIDE {
471 return (NodeMatcher::MatchAndExplain(node, listener) &&
472 PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
473 access_matcher_, listener) &&
474 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
475 base_matcher_, listener) &&
476 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
477 effect_matcher_, listener));
478 }
479
480 private:
481 const Matcher<FieldAccess> access_matcher_;
482 const Matcher<Node*> base_matcher_;
483 const Matcher<Node*> effect_matcher_;
484 };
485
486
487 class IsLoadElementMatcher FINAL : public NodeMatcher {
488 public:
489 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
490 const Matcher<Node*>& base_matcher,
491 const Matcher<Node*>& index_matcher,
492 const Matcher<Node*>& length_matcher,
493 const Matcher<Node*>& effect_matcher,
494 const Matcher<Node*>& control_matcher)
495 : NodeMatcher(IrOpcode::kLoadElement),
496 access_matcher_(access_matcher),
497 base_matcher_(base_matcher),
498 index_matcher_(index_matcher),
499 length_matcher_(length_matcher),
500 effect_matcher_(effect_matcher),
501 control_matcher_(control_matcher) {}
502
503 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
504 NodeMatcher::DescribeTo(os);
505 *os << " whose access (";
506 access_matcher_.DescribeTo(os);
507 *os << "), base (";
508 base_matcher_.DescribeTo(os);
509 *os << "), index (";
510 index_matcher_.DescribeTo(os);
511 *os << "), length (";
512 length_matcher_.DescribeTo(os);
513 *os << "), effect (";
514 effect_matcher_.DescribeTo(os);
515 *os << ") and control (";
516 control_matcher_.DescribeTo(os);
517 *os << ")";
518 }
519
520 virtual bool MatchAndExplain(Node* node,
521 MatchResultListener* listener) const OVERRIDE {
522 return (NodeMatcher::MatchAndExplain(node, listener) &&
523 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
524 access_matcher_, listener) &&
525 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
526 base_matcher_, listener) &&
527 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
528 "index", index_matcher_, listener) &&
529 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
530 "length", length_matcher_, listener) &&
531 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
532 effect_matcher_, listener) &&
533 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
534 "control", control_matcher_, listener));
535 }
536
537 private:
538 const Matcher<ElementAccess> access_matcher_;
539 const Matcher<Node*> base_matcher_;
540 const Matcher<Node*> index_matcher_;
541 const Matcher<Node*> length_matcher_;
542 const Matcher<Node*> effect_matcher_;
543 const Matcher<Node*> control_matcher_;
544 };
545
546
547 class IsStoreElementMatcher FINAL : public NodeMatcher {
548 public:
549 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
550 const Matcher<Node*>& base_matcher,
551 const Matcher<Node*>& index_matcher,
552 const Matcher<Node*>& length_matcher,
553 const Matcher<Node*>& value_matcher,
554 const Matcher<Node*>& effect_matcher,
555 const Matcher<Node*>& control_matcher)
556 : NodeMatcher(IrOpcode::kStoreElement),
557 access_matcher_(access_matcher),
558 base_matcher_(base_matcher),
559 index_matcher_(index_matcher),
560 length_matcher_(length_matcher),
561 value_matcher_(value_matcher),
562 effect_matcher_(effect_matcher),
563 control_matcher_(control_matcher) {}
564
565 virtual void DescribeTo(std::ostream* os) const OVERRIDE {
566 NodeMatcher::DescribeTo(os);
567 *os << " whose access (";
568 access_matcher_.DescribeTo(os);
569 *os << "), base (";
570 base_matcher_.DescribeTo(os);
571 *os << "), index (";
572 index_matcher_.DescribeTo(os);
573 *os << "), length (";
574 length_matcher_.DescribeTo(os);
575 *os << "), value (";
576 value_matcher_.DescribeTo(os);
577 *os << "), effect (";
578 effect_matcher_.DescribeTo(os);
579 *os << ") and control (";
580 control_matcher_.DescribeTo(os);
581 *os << ")";
582 }
583
584 virtual bool MatchAndExplain(Node* node,
585 MatchResultListener* listener) const OVERRIDE {
586 return (NodeMatcher::MatchAndExplain(node, listener) &&
587 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
588 access_matcher_, listener) &&
589 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
590 base_matcher_, listener) &&
591 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
592 "index", index_matcher_, listener) &&
593 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
594 "length", length_matcher_, listener) &&
595 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
596 "value", value_matcher_, listener) &&
597 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
598 effect_matcher_, listener) &&
599 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
600 "control", control_matcher_, listener));
601 }
602
603 private:
604 const Matcher<ElementAccess> access_matcher_;
605 const Matcher<Node*> base_matcher_;
606 const Matcher<Node*> index_matcher_;
607 const Matcher<Node*> length_matcher_;
608 const Matcher<Node*> value_matcher_;
609 const Matcher<Node*> effect_matcher_;
610 const Matcher<Node*> control_matcher_;
611 };
612
613
433 class IsLoadMatcher FINAL : public NodeMatcher { 614 class IsLoadMatcher FINAL : public NodeMatcher {
434 public: 615 public:
435 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher, 616 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
436 const Matcher<Node*>& base_matcher, 617 const Matcher<Node*>& base_matcher,
437 const Matcher<Node*>& index_matcher, 618 const Matcher<Node*>& index_matcher,
438 const Matcher<Node*>& effect_matcher, 619 const Matcher<Node*>& effect_matcher,
439 const Matcher<Node*>& control_matcher) 620 const Matcher<Node*>& control_matcher)
440 : NodeMatcher(IrOpcode::kLoad), 621 : NodeMatcher(IrOpcode::kLoad),
441 rep_matcher_(rep_matcher), 622 rep_matcher_(rep_matcher),
442 base_matcher_(base_matcher), 623 base_matcher_(base_matcher),
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 const Matcher<Node*>& value2_matcher, 889 const Matcher<Node*>& value2_matcher,
709 const Matcher<Node*>& value3_matcher, 890 const Matcher<Node*>& value3_matcher,
710 const Matcher<Node*>& effect_matcher, 891 const Matcher<Node*>& effect_matcher,
711 const Matcher<Node*>& control_matcher) { 892 const Matcher<Node*>& control_matcher) {
712 return MakeMatcher(new IsCallMatcher( 893 return MakeMatcher(new IsCallMatcher(
713 descriptor_matcher, value0_matcher, value1_matcher, value2_matcher, 894 descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
714 value3_matcher, effect_matcher, control_matcher)); 895 value3_matcher, effect_matcher, control_matcher));
715 } 896 }
716 897
717 898
899 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
900 const Matcher<Node*>& base_matcher,
901 const Matcher<Node*>& effect_matcher) {
902 return MakeMatcher(
903 new IsLoadFieldMatcher(access_matcher, base_matcher, effect_matcher));
904 }
905
906
907 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
908 const Matcher<Node*>& base_matcher,
909 const Matcher<Node*>& index_matcher,
910 const Matcher<Node*>& length_matcher,
911 const Matcher<Node*>& effect_matcher,
912 const Matcher<Node*>& control_matcher) {
913 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
914 index_matcher, length_matcher,
915 effect_matcher, control_matcher));
916 }
917
918
919 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
920 const Matcher<Node*>& base_matcher,
921 const Matcher<Node*>& index_matcher,
922 const Matcher<Node*>& length_matcher,
923 const Matcher<Node*>& value_matcher,
924 const Matcher<Node*>& effect_matcher,
925 const Matcher<Node*>& control_matcher) {
926 return MakeMatcher(new IsStoreElementMatcher(
927 access_matcher, base_matcher, index_matcher, length_matcher,
928 value_matcher, effect_matcher, control_matcher));
929 }
930
931
718 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, 932 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
719 const Matcher<Node*>& base_matcher, 933 const Matcher<Node*>& base_matcher,
720 const Matcher<Node*>& index_matcher, 934 const Matcher<Node*>& index_matcher,
721 const Matcher<Node*>& effect_matcher, 935 const Matcher<Node*>& effect_matcher,
722 const Matcher<Node*>& control_matcher) { 936 const Matcher<Node*>& control_matcher) {
723 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, 937 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
724 effect_matcher, control_matcher)); 938 effect_matcher, control_matcher));
725 } 939 }
726 940
727 941
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 IS_UNOP_MATCHER(ChangeUint32ToUint64) 987 IS_UNOP_MATCHER(ChangeUint32ToUint64)
774 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) 988 IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
775 IS_UNOP_MATCHER(TruncateFloat64ToInt32) 989 IS_UNOP_MATCHER(TruncateFloat64ToInt32)
776 IS_UNOP_MATCHER(TruncateInt64ToInt32) 990 IS_UNOP_MATCHER(TruncateInt64ToInt32)
777 IS_UNOP_MATCHER(Float64Sqrt) 991 IS_UNOP_MATCHER(Float64Sqrt)
778 #undef IS_UNOP_MATCHER 992 #undef IS_UNOP_MATCHER
779 993
780 } // namespace compiler 994 } // namespace compiler
781 } // namespace internal 995 } // namespace internal
782 } // namespace v8 996 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/graph-unittest.h ('k') | test/unittests/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698