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

Side by Side Diff: src/hydrogen-instructions.h

Issue 11678007: SSI implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 12 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 V(BinaryOperation) \ 57 V(BinaryOperation) \
58 V(BitwiseBinaryOperation) \ 58 V(BitwiseBinaryOperation) \
59 V(ControlInstruction) \ 59 V(ControlInstruction) \
60 V(Instruction) \ 60 V(Instruction) \
61 61
62 62
63 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ 63 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \
64 V(AbnormalExit) \ 64 V(AbnormalExit) \
65 V(AccessArgumentsAt) \ 65 V(AccessArgumentsAt) \
66 V(Add) \ 66 V(Add) \
67 V(SsiDefinition) \
67 V(AllocateObject) \ 68 V(AllocateObject) \
68 V(ApplyArguments) \ 69 V(ApplyArguments) \
69 V(ArgumentsElements) \ 70 V(ArgumentsElements) \
70 V(ArgumentsLength) \ 71 V(ArgumentsLength) \
71 V(ArgumentsObject) \ 72 V(ArgumentsObject) \
72 V(ArrayLiteral) \ 73 V(ArrayLiteral) \
73 V(Bitwise) \ 74 V(Bitwise) \
74 V(BitNot) \ 75 V(BitNot) \
75 V(BlockEntry) \ 76 V(BlockEntry) \
76 V(BoundsCheck) \ 77 V(BoundsCheck) \
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 kIsArguments, 572 kIsArguments,
572 kTruncatingToInt32, 573 kTruncatingToInt32,
573 kIsDead, 574 kIsDead,
574 // Instructions that are allowed to produce full range unsigned integer 575 // Instructions that are allowed to produce full range unsigned integer
575 // values are marked with kUint32 flag. If arithmetic shift or a load from 576 // values are marked with kUint32 flag. If arithmetic shift or a load from
576 // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag 577 // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag
577 // it will deoptimize if result does not fit into signed integer range. 578 // it will deoptimize if result does not fit into signed integer range.
578 // HGraph::ComputeSafeUint32Operations is responsible for setting this 579 // HGraph::ComputeSafeUint32Operations is responsible for setting this
579 // flag. 580 // flag.
580 kUint32, 581 kUint32,
581 kLastFlag = kUint32 582 // SSI construction sets this flag while processing instructions.
583 // This means that a new SSI definition is known to dominate every
584 // instruction in the same basic block that has this flag still unset.
585 kProcessedBySsi,
586 kLastFlag = kProcessedBySsi
582 }; 587 };
583 588
584 STATIC_ASSERT(kLastFlag < kBitsPerInt); 589 STATIC_ASSERT(kLastFlag < kBitsPerInt);
585 590
586 static const int kChangesToDependsFlagsLeftShift = 1; 591 static const int kChangesToDependsFlagsLeftShift = 1;
587 592
588 static GVNFlag ChangesFlagFromInt(int x) { 593 static GVNFlag ChangesFlagFromInt(int x) {
589 return static_cast<GVNFlag>(x * 2); 594 return static_cast<GVNFlag>(x * 2);
590 } 595 }
591 static GVNFlag DependsOnFlagFromInt(int x) { 596 static GVNFlag DependsOnFlagFromInt(int x) {
(...skipping 20 matching lines...) Expand all
612 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) 617 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
613 #undef DECLARE_PREDICATE 618 #undef DECLARE_PREDICATE
614 bool IsPhi() const { return opcode() == kPhi; } 619 bool IsPhi() const { return opcode() == kPhi; }
615 620
616 // Declare virtual predicates for abstract HInstruction or HValue 621 // Declare virtual predicates for abstract HInstruction or HValue
617 #define DECLARE_PREDICATE(type) \ 622 #define DECLARE_PREDICATE(type) \
618 virtual bool Is##type() const { return false; } 623 virtual bool Is##type() const { return false; }
619 HYDROGEN_ABSTRACT_INSTRUCTION_LIST(DECLARE_PREDICATE) 624 HYDROGEN_ABSTRACT_INSTRUCTION_LIST(DECLARE_PREDICATE)
620 #undef DECLARE_PREDICATE 625 #undef DECLARE_PREDICATE
621 626
627 virtual void BuildSsi() { }
628
622 HValue() : block_(NULL), 629 HValue() : block_(NULL),
623 id_(kNoNumber), 630 id_(kNoNumber),
624 type_(HType::Tagged()), 631 type_(HType::Tagged()),
625 use_list_(NULL), 632 use_list_(NULL),
626 range_(NULL), 633 range_(NULL),
627 flags_(0) {} 634 flags_(0) {}
628 virtual ~HValue() {} 635 virtual ~HValue() {}
629 636
630 HBasicBlock* block() const { return block_; } 637 HBasicBlock* block() const { return block_; }
631 void SetBlock(HBasicBlock* block); 638 void SetBlock(HBasicBlock* block);
(...skipping 18 matching lines...) Expand all
650 virtual void AssumeRepresentation(Representation r); 657 virtual void AssumeRepresentation(Representation r);
651 658
652 virtual bool IsConvertibleToInteger() const { return true; } 659 virtual bool IsConvertibleToInteger() const { return true; }
653 660
654 HType type() const { return type_; } 661 HType type() const { return type_; }
655 void set_type(HType new_type) { 662 void set_type(HType new_type) {
656 ASSERT(new_type.IsSubtypeOf(type_)); 663 ASSERT(new_type.IsSubtypeOf(type_));
657 type_ = new_type; 664 type_ = new_type;
658 } 665 }
659 666
667 virtual HValue* ValueBeforeSsi() { return this; }
668
660 // An operation needs to override this function iff: 669 // An operation needs to override this function iff:
661 // 1) it can produce an int32 output. 670 // 1) it can produce an int32 output.
662 // 2) the true value of its output can potentially be minus zero. 671 // 2) the true value of its output can potentially be minus zero.
663 // The implementation must set a flag so that it bails out in the case where 672 // The implementation must set a flag so that it bails out in the case where
664 // it would otherwise output what should be a minus zero as an int32 zero. 673 // it would otherwise output what should be a minus zero as an int32 zero.
665 // If the operation also exists in a form that takes int32 and outputs int32 674 // If the operation also exists in a form that takes int32 and outputs int32
666 // then the operation should return its input value so that we can propagate 675 // then the operation should return its input value so that we can propagate
667 // back. There are three operations that need to propagate back to more than 676 // back. There are three operations that need to propagate back to more than
668 // one input. They are phi and binary div and mul. They always return NULL 677 // one input. They are phi and binary div and mul. They always return NULL
669 // and expect the caller to take care of things. 678 // and expect the caller to take care of things.
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 2837
2829 HValue* receiver() { return OperandAt(0); } 2838 HValue* receiver() { return OperandAt(0); }
2830 HValue* function() { return OperandAt(1); } 2839 HValue* function() { return OperandAt(1); }
2831 2840
2832 virtual HValue* Canonicalize(); 2841 virtual HValue* Canonicalize();
2833 2842
2834 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) 2843 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
2835 }; 2844 };
2836 2845
2837 2846
2847 class HSsiDefinition : public HUnaryOperation {
2848 public:
2849 enum ValueInfoRelation { NONE, NE, GT, GE, EQ, LE, LT, IF_TAGGED_IS_SMI};
2850 static const char* RelationName(ValueInfoRelation r) {
2851 switch (r) {
2852 case NE:
2853 return "NE";
2854 case GT:
2855 return "GT";
2856 case GE:
2857 return "GE";
2858 case EQ:
2859 return "EQ";
2860 case LE:
2861 return "LE";
2862 case LT:
2863 return "LT";
2864 case IF_TAGGED_IS_SMI:
2865 return "IF_TAGGED_IS_SMI";
2866 case NONE:
2867 return "NONE";
2868 default:
2869 UNREACHABLE();
2870 return "UNREACHABLE";
2871 }
2872 }
2873
2874 static HSsiDefinition* New(HValue* previous_definition,
2875 HInstruction* insertion_point,
2876 ValueInfoRelation relation,
2877 HValue* constraint,
2878 int delta = 0);
2879
2880 HValue* previous_definition() { return OperandAt(0); }
2881
2882 virtual HValue* ValueBeforeSsi() { return value_before_ssi_; }
2883
2884 virtual Representation RequiredInputRepresentation(int index) {
2885 return ValueBeforeSsi()->RequiredInputRepresentation(index);
2886 }
2887
2888 virtual void PrintDataTo(StringStream* stream);
2889
2890 HValue* constraint() { return constraint_; }
2891 ValueInfoRelation relation() { return relation_; }
2892 int delta() { return delta_; }
2893
2894 DECLARE_CONCRETE_INSTRUCTION(SsiDefinition)
2895
2896 protected:
2897 virtual bool DataEquals(HValue* other) {
2898 return DataEquals(ValueBeforeSsi());
2899 }
2900
2901 private:
2902 explicit HSsiDefinition(HValue* previous_definition,
2903 HInstruction* insertion_point,
2904 ValueInfoRelation relation,
2905 HValue* constraint,
2906 int delta);
2907
2908 HValue* value_before_ssi_;
2909 ValueInfoRelation relation_;
2910 HValue* constraint_;
2911 int delta_;
2912 };
2913
2914
2838 class HApplyArguments: public HTemplateInstruction<4> { 2915 class HApplyArguments: public HTemplateInstruction<4> {
2839 public: 2916 public:
2840 HApplyArguments(HValue* function, 2917 HApplyArguments(HValue* function,
2841 HValue* receiver, 2918 HValue* receiver,
2842 HValue* length, 2919 HValue* length,
2843 HValue* elements) { 2920 HValue* elements) {
2844 set_representation(Representation::Tagged()); 2921 set_representation(Representation::Tagged());
2845 SetOperandAt(0, function); 2922 SetOperandAt(0, function);
2846 SetOperandAt(1, receiver); 2923 SetOperandAt(1, receiver);
2847 SetOperandAt(2, length); 2924 SetOperandAt(2, length);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 return Representation::Tagged(); 3056 return Representation::Tagged();
2980 } 3057 }
2981 return Representation::Integer32(); 3058 return Representation::Integer32();
2982 } 3059 }
2983 virtual Representation observed_input_representation(int index) { 3060 virtual Representation observed_input_representation(int index) {
2984 return Representation::Integer32(); 3061 return Representation::Integer32();
2985 } 3062 }
2986 3063
2987 virtual void PrintDataTo(StringStream* stream); 3064 virtual void PrintDataTo(StringStream* stream);
2988 3065
3066 virtual void BuildSsi();
3067
2989 HValue* index() { return OperandAt(0); } 3068 HValue* index() { return OperandAt(0); }
2990 HValue* length() { return OperandAt(1); } 3069 HValue* length() { return OperandAt(1); }
2991 3070
2992 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3071 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
2993 3072
2994 protected: 3073 protected:
2995 virtual bool DataEquals(HValue* other) { return true; } 3074 virtual bool DataEquals(HValue* other) { return true; }
2996 BoundsCheckKeyMode key_mode_; 3075 BoundsCheckKeyMode key_mode_;
2997 }; 3076 };
2998 3077
(...skipping 2443 matching lines...) Expand 10 before | Expand all | Expand 10 after
5442 virtual bool IsDeletable() const { return true; } 5521 virtual bool IsDeletable() const { return true; }
5443 }; 5522 };
5444 5523
5445 5524
5446 #undef DECLARE_INSTRUCTION 5525 #undef DECLARE_INSTRUCTION
5447 #undef DECLARE_CONCRETE_INSTRUCTION 5526 #undef DECLARE_CONCRETE_INSTRUCTION
5448 5527
5449 } } // namespace v8::internal 5528 } } // namespace v8::internal
5450 5529
5451 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 5530 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698