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

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

Issue 18596005: Allocation folding integrated into the GVN phase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
« no previous file with comments | « src/hydrogen-gvn.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 785
786 enum Flag { 786 enum Flag {
787 kFlexibleRepresentation, 787 kFlexibleRepresentation,
788 kCannotBeTagged, 788 kCannotBeTagged,
789 // Participate in Global Value Numbering, i.e. elimination of 789 // Participate in Global Value Numbering, i.e. elimination of
790 // unnecessary recomputations. If an instruction sets this flag, it must 790 // unnecessary recomputations. If an instruction sets this flag, it must
791 // implement DataEquals(), which will be used to determine if other 791 // implement DataEquals(), which will be used to determine if other
792 // occurrences of the instruction are indeed the same. 792 // occurrences of the instruction are indeed the same.
793 kUseGVN, 793 kUseGVN,
794 // Track instructions that are dominating side effects. If an instruction 794 // Track instructions that are dominating side effects. If an instruction
795 // sets this flag, it must implement SetSideEffectDominator() and should 795 // sets this flag, it must implement HandleSideEffectDominator() and should
796 // indicate which side effects to track by setting GVN flags. 796 // indicate which side effects to track by setting GVN flags.
797 kTrackSideEffectDominators, 797 kTrackSideEffectDominators,
798 kCanOverflow, 798 kCanOverflow,
799 kBailoutOnMinusZero, 799 kBailoutOnMinusZero,
800 kCanBeDivByZero, 800 kCanBeDivByZero,
801 kAllowUndefinedAsNaN, 801 kAllowUndefinedAsNaN,
802 kIsArguments, 802 kIsArguments,
803 kTruncatingToInt32, 803 kTruncatingToInt32,
804 kAllUsesTruncatingToInt32, 804 kAllUsesTruncatingToInt32,
805 // Set after an instruction is killed. 805 // Set after an instruction is killed.
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 1104
1105 // Updated the inferred type of this instruction and returns true if 1105 // Updated the inferred type of this instruction and returns true if
1106 // it has changed. 1106 // it has changed.
1107 bool UpdateInferredType(); 1107 bool UpdateInferredType();
1108 1108
1109 virtual HType CalculateInferredType(); 1109 virtual HType CalculateInferredType();
1110 1110
1111 // This function must be overridden for instructions which have the 1111 // This function must be overridden for instructions which have the
1112 // kTrackSideEffectDominators flag set, to track instructions that are 1112 // kTrackSideEffectDominators flag set, to track instructions that are
1113 // dominating side effects. 1113 // dominating side effects.
1114 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { 1114 virtual void HandleSideEffectDominator(GVNFlag side_effect,
1115 HValue* dominator) {
1115 UNREACHABLE(); 1116 UNREACHABLE();
1116 } 1117 }
1117 1118
1118 // Check if this instruction has some reason that prevents elimination. 1119 // Check if this instruction has some reason that prevents elimination.
1119 bool CannotBeEliminated() const { 1120 bool CannotBeEliminated() const {
1120 return HasObservableSideEffects() || !IsDeletable(); 1121 return HasObservableSideEffects() || !IsDeletable();
1121 } 1122 }
1122 1123
1123 #ifdef DEBUG 1124 #ifdef DEBUG
1124 virtual void Verify() = 0; 1125 virtual void Verify() = 0;
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2769 } 2770 }
2770 }; 2771 };
2771 check_map->map_set_.Sort(); 2772 check_map->map_set_.Sort();
2772 return check_map; 2773 return check_map;
2773 } 2774 }
2774 2775
2775 virtual bool HasEscapingOperandAt(int index) { return false; } 2776 virtual bool HasEscapingOperandAt(int index) { return false; }
2776 virtual Representation RequiredInputRepresentation(int index) { 2777 virtual Representation RequiredInputRepresentation(int index) {
2777 return Representation::Tagged(); 2778 return Representation::Tagged();
2778 } 2779 }
2779 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator); 2780 virtual void HandleSideEffectDominator(GVNFlag side_effect,
2781 HValue* dominator);
2780 virtual void PrintDataTo(StringStream* stream); 2782 virtual void PrintDataTo(StringStream* stream);
2781 virtual HType CalculateInferredType(); 2783 virtual HType CalculateInferredType();
2782 2784
2783 HValue* value() { return OperandAt(0); } 2785 HValue* value() { return OperandAt(0); }
2784 SmallMapList* map_set() { return &map_set_; } 2786 SmallMapList* map_set() { return &map_set_; }
2785 2787
2786 virtual void FinalizeUniqueValueId(); 2788 virtual void FinalizeUniqueValueId();
2787 2789
2788 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) 2790 DECLARE_CONCRETE_INSTRUCTION(CheckMaps)
2789 2791
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 // Maximum instance size for which allocations will be inlined. 4972 // Maximum instance size for which allocations will be inlined.
4971 static const int kMaxSize = 64 * kPointerSize; 4973 static const int kMaxSize = 64 * kPointerSize;
4972 4974
4973 HValue* context() { return OperandAt(0); } 4975 HValue* context() { return OperandAt(0); }
4974 Handle<JSFunction> constructor() { return constructor_; } 4976 Handle<JSFunction> constructor() { return constructor_; }
4975 Handle<Map> constructor_initial_map() { return constructor_initial_map_; } 4977 Handle<Map> constructor_initial_map() { return constructor_initial_map_; }
4976 4978
4977 virtual Representation RequiredInputRepresentation(int index) { 4979 virtual Representation RequiredInputRepresentation(int index) {
4978 return Representation::Tagged(); 4980 return Representation::Tagged();
4979 } 4981 }
4982
4980 virtual Handle<Map> GetMonomorphicJSObjectMap() { 4983 virtual Handle<Map> GetMonomorphicJSObjectMap() {
4981 ASSERT(!constructor_initial_map_.is_null()); 4984 ASSERT(!constructor_initial_map_.is_null());
4982 return constructor_initial_map_; 4985 return constructor_initial_map_;
4983 } 4986 }
4987
4984 virtual HType CalculateInferredType(); 4988 virtual HType CalculateInferredType();
4985 4989
4986 DECLARE_CONCRETE_INSTRUCTION(AllocateObject) 4990 DECLARE_CONCRETE_INSTRUCTION(AllocateObject)
4987 4991
4988 private: 4992 private:
4989 // TODO(svenpanne) Might be safe, but leave it out until we know for sure. 4993 // TODO(svenpanne) Might be safe, but leave it out until we know for sure.
4990 // virtual bool IsDeletable() const { return true; } 4994 // virtual bool IsDeletable() const { return true; }
4991 4995
4992 Handle<JSFunction> constructor_; 4996 Handle<JSFunction> constructor_;
4993 Handle<Map> constructor_initial_map_; 4997 Handle<Map> constructor_initial_map_;
4994 }; 4998 };
4995 4999
4996 5000
4997 class HAllocate: public HTemplateInstruction<2> { 5001 class HAllocate: public HTemplateInstruction<2> {
4998 public: 5002 public:
4999 enum Flags { 5003 enum Flags {
5000 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0, 5004 CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0,
5001 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5005 CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5002 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5006 CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5003 ALLOCATE_DOUBLE_ALIGNED = 1 << 3 5007 ALLOCATE_DOUBLE_ALIGNED = 1 << 3
5004 }; 5008 };
5005 5009
5006 HAllocate(HValue* context, HValue* size, HType type, Flags flags) 5010 HAllocate(HValue* context, HValue* size, HType type, Flags flags)
5007 : type_(type), 5011 : type_(type),
5008 flags_(flags) { 5012 flags_(flags) {
5009 SetOperandAt(0, context); 5013 SetOperandAt(0, context);
5010 SetOperandAt(1, size); 5014 SetOperandAt(1, size);
5011 set_representation(Representation::Tagged()); 5015 set_representation(Representation::Tagged());
5016 SetFlag(kTrackSideEffectDominators);
5012 SetGVNFlag(kChangesNewSpacePromotion); 5017 SetGVNFlag(kChangesNewSpacePromotion);
5018 SetGVNFlag(kDependsOnNewSpacePromotion);
5013 } 5019 }
5014 5020
5015 static Flags DefaultFlags() { 5021 static Flags DefaultFlags() {
5016 return CAN_ALLOCATE_IN_NEW_SPACE; 5022 return CAN_ALLOCATE_IN_NEW_SPACE;
5017 } 5023 }
5018 5024
5019 static Flags DefaultFlags(ElementsKind kind) { 5025 static Flags DefaultFlags(ElementsKind kind) {
5020 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE; 5026 Flags flags = CAN_ALLOCATE_IN_NEW_SPACE;
5021 if (IsFastDoubleElementsKind(kind)) { 5027 if (IsFastDoubleElementsKind(kind)) {
5022 flags = static_cast<HAllocate::Flags>( 5028 flags = static_cast<HAllocate::Flags>(
5023 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); 5029 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
5024 } 5030 }
5025 return flags; 5031 return flags;
5026 } 5032 }
5027 5033
5028 HValue* context() { return OperandAt(0); } 5034 HValue* context() { return OperandAt(0); }
5029 HValue* size() { return OperandAt(1); } 5035 HValue* size() { return OperandAt(1); }
5036 HType type() { return type_; }
5030 5037
5031 virtual Representation RequiredInputRepresentation(int index) { 5038 virtual Representation RequiredInputRepresentation(int index) {
5032 if (index == 0) { 5039 if (index == 0) {
5033 return Representation::Tagged(); 5040 return Representation::Tagged();
5034 } else { 5041 } else {
5035 return Representation::Integer32(); 5042 return Representation::Integer32();
5036 } 5043 }
5037 } 5044 }
5038 5045
5039 virtual HType CalculateInferredType(); 5046 virtual HType CalculateInferredType();
(...skipping 16 matching lines...) Expand all
5056 } 5063 }
5057 5064
5058 bool GuaranteedInNewSpace() const { 5065 bool GuaranteedInNewSpace() const {
5059 return CanAllocateInNewSpace() && !CanAllocateInOldSpace(); 5066 return CanAllocateInNewSpace() && !CanAllocateInOldSpace();
5060 } 5067 }
5061 5068
5062 bool MustAllocateDoubleAligned() const { 5069 bool MustAllocateDoubleAligned() const {
5063 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0; 5070 return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0;
5064 } 5071 }
5065 5072
5073 void UpdateSize(HValue* size) {
5074 SetOperandAt(1, size);
5075 }
5076
5077 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5078 HValue* dominator);
5079
5066 virtual void PrintDataTo(StringStream* stream); 5080 virtual void PrintDataTo(StringStream* stream);
5067 5081
5068 DECLARE_CONCRETE_INSTRUCTION(Allocate) 5082 DECLARE_CONCRETE_INSTRUCTION(Allocate)
5069 5083
5070 private: 5084 private:
5071 HType type_; 5085 HType type_;
5072 Flags flags_; 5086 Flags flags_;
5073 }; 5087 };
5074 5088
5075 5089
5076 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5090 class HInnerAllocatedObject: public HTemplateInstruction<1> {
5077 public: 5091 public:
5078 HInnerAllocatedObject(HValue* value, int offset) 5092 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
5079 : offset_(offset) { 5093 : offset_(offset),
5094 type_(type) {
5080 ASSERT(value->IsAllocate()); 5095 ASSERT(value->IsAllocate());
5081 SetOperandAt(0, value); 5096 SetOperandAt(0, value);
5082 set_representation(Representation::Tagged()); 5097 set_representation(Representation::Tagged());
5083 } 5098 }
5084 5099
5085 HValue* base_object() { return OperandAt(0); } 5100 HValue* base_object() { return OperandAt(0); }
5086 int offset() { return offset_; } 5101 int offset() { return offset_; }
5087 5102
5088 virtual Representation RequiredInputRepresentation(int index) { 5103 virtual Representation RequiredInputRepresentation(int index) {
5089 return Representation::Tagged(); 5104 return Representation::Tagged();
5090 } 5105 }
5091 5106
5107 virtual HType CalculateInferredType() { return type_; }
5108
5092 virtual void PrintDataTo(StringStream* stream); 5109 virtual void PrintDataTo(StringStream* stream);
5093 5110
5094 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) 5111 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
5095 5112
5096 private: 5113 private:
5097 int offset_; 5114 int offset_;
5115 HType type_;
5098 }; 5116 };
5099 5117
5100 5118
5101 inline bool StoringValueNeedsWriteBarrier(HValue* value) { 5119 inline bool StoringValueNeedsWriteBarrier(HValue* value) {
5102 return !value->type().IsBoolean() 5120 return !value->type().IsBoolean()
5103 && !value->type().IsSmi() 5121 && !value->type().IsSmi()
5104 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); 5122 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable());
5105 } 5123 }
5106 5124
5107 5125
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
5797 virtual Representation RequiredInputRepresentation(int index) { 5815 virtual Representation RequiredInputRepresentation(int index) {
5798 if (FLAG_track_double_fields && 5816 if (FLAG_track_double_fields &&
5799 index == 1 && field_representation_.IsDouble()) { 5817 index == 1 && field_representation_.IsDouble()) {
5800 return field_representation_; 5818 return field_representation_;
5801 } else if (FLAG_track_fields && 5819 } else if (FLAG_track_fields &&
5802 index == 1 && field_representation_.IsSmi()) { 5820 index == 1 && field_representation_.IsSmi()) {
5803 return field_representation_; 5821 return field_representation_;
5804 } 5822 }
5805 return Representation::Tagged(); 5823 return Representation::Tagged();
5806 } 5824 }
5807 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { 5825 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5826 HValue* dominator) {
5808 ASSERT(side_effect == kChangesNewSpacePromotion); 5827 ASSERT(side_effect == kChangesNewSpacePromotion);
5809 new_space_dominator_ = dominator; 5828 new_space_dominator_ = dominator;
5810 } 5829 }
5811 virtual void PrintDataTo(StringStream* stream); 5830 virtual void PrintDataTo(StringStream* stream);
5812 5831
5813 HValue* object() { return OperandAt(0); } 5832 HValue* object() { return OperandAt(0); }
5814 HValue* value() { return OperandAt(1); } 5833 HValue* value() { return OperandAt(1); }
5815 5834
5816 HObjectAccess access() const { return access_; } 5835 HObjectAccess access() const { return access_; }
5817 Handle<Map> transition() const { return transition_; } 5836 Handle<Map> transition() const { return transition_; }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
5991 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } 6010 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
5992 bool IsUninitialized() { return is_uninitialized_; } 6011 bool IsUninitialized() { return is_uninitialized_; }
5993 void SetUninitialized(bool is_uninitialized) { 6012 void SetUninitialized(bool is_uninitialized) {
5994 is_uninitialized_ = is_uninitialized; 6013 is_uninitialized_ = is_uninitialized;
5995 } 6014 }
5996 6015
5997 bool IsConstantHoleStore() { 6016 bool IsConstantHoleStore() {
5998 return value()->IsConstant() && HConstant::cast(value())->IsTheHole(); 6017 return value()->IsConstant() && HConstant::cast(value())->IsTheHole();
5999 } 6018 }
6000 6019
6001 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { 6020 virtual void HandleSideEffectDominator(GVNFlag side_effect,
6021 HValue* dominator) {
6002 ASSERT(side_effect == kChangesNewSpacePromotion); 6022 ASSERT(side_effect == kChangesNewSpacePromotion);
6003 new_space_dominator_ = dominator; 6023 new_space_dominator_ = dominator;
6004 } 6024 }
6005 6025
6006 HValue* new_space_dominator() const { return new_space_dominator_; } 6026 HValue* new_space_dominator() const { return new_space_dominator_; }
6007 6027
6008 bool NeedsWriteBarrier() { 6028 bool NeedsWriteBarrier() {
6009 if (value_is_smi()) { 6029 if (value_is_smi()) {
6010 return false; 6030 return false;
6011 } else { 6031 } else {
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
6682 virtual bool IsDeletable() const { return true; } 6702 virtual bool IsDeletable() const { return true; }
6683 }; 6703 };
6684 6704
6685 6705
6686 #undef DECLARE_INSTRUCTION 6706 #undef DECLARE_INSTRUCTION
6687 #undef DECLARE_CONCRETE_INSTRUCTION 6707 #undef DECLARE_CONCRETE_INSTRUCTION
6688 6708
6689 } } // namespace v8::internal 6709 } } // namespace v8::internal
6690 6710
6691 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6711 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-gvn.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698