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

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

Issue 148573005: A64: Synchronize with r16249. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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.h ('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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 V(Change) \ 90 V(Change) \
91 V(CheckFunction) \ 91 V(CheckFunction) \
92 V(CheckHeapObject) \ 92 V(CheckHeapObject) \
93 V(CheckInstanceType) \ 93 V(CheckInstanceType) \
94 V(CheckMaps) \ 94 V(CheckMaps) \
95 V(CheckMapValue) \ 95 V(CheckMapValue) \
96 V(CheckSmi) \ 96 V(CheckSmi) \
97 V(ClampToUint8) \ 97 V(ClampToUint8) \
98 V(ClassOfTestAndBranch) \ 98 V(ClassOfTestAndBranch) \
99 V(CompareNumericAndBranch) \ 99 V(CompareNumericAndBranch) \
100 V(CompareHoleAndBranch) \
100 V(CompareGeneric) \ 101 V(CompareGeneric) \
101 V(CompareObjectEqAndBranch) \ 102 V(CompareObjectEqAndBranch) \
102 V(CompareMap) \ 103 V(CompareMap) \
103 V(Constant) \ 104 V(Constant) \
104 V(Context) \ 105 V(Context) \
105 V(DateField) \ 106 V(DateField) \
106 V(DebugBreak) \ 107 V(DebugBreak) \
107 V(DeclareGlobals) \ 108 V(DeclareGlobals) \
108 V(Deoptimize) \ 109 V(Deoptimize) \
109 V(Div) \ 110 V(Div) \
(...skipping 25 matching lines...) Expand all
135 V(LeaveInlined) \ 136 V(LeaveInlined) \
136 V(LoadContextSlot) \ 137 V(LoadContextSlot) \
137 V(LoadExternalArrayPointer) \ 138 V(LoadExternalArrayPointer) \
138 V(LoadFieldByIndex) \ 139 V(LoadFieldByIndex) \
139 V(LoadFunctionPrototype) \ 140 V(LoadFunctionPrototype) \
140 V(LoadGlobalCell) \ 141 V(LoadGlobalCell) \
141 V(LoadGlobalGeneric) \ 142 V(LoadGlobalGeneric) \
142 V(LoadKeyed) \ 143 V(LoadKeyed) \
143 V(LoadKeyedGeneric) \ 144 V(LoadKeyedGeneric) \
144 V(LoadNamedField) \ 145 V(LoadNamedField) \
145 V(LoadNamedFieldPolymorphic) \
146 V(LoadNamedGeneric) \ 146 V(LoadNamedGeneric) \
147 V(MapEnumLength) \ 147 V(MapEnumLength) \
148 V(MathFloorOfDiv) \ 148 V(MathFloorOfDiv) \
149 V(MathMinMax) \ 149 V(MathMinMax) \
150 V(Mod) \ 150 V(Mod) \
151 V(Mul) \ 151 V(Mul) \
152 V(OsrEntry) \ 152 V(OsrEntry) \
153 V(OuterContext) \ 153 V(OuterContext) \
154 V(Parameter) \ 154 V(Parameter) \
155 V(Power) \ 155 V(Power) \
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 V(DoubleArrayElements) \ 203 V(DoubleArrayElements) \
204 V(DoubleFields) \ 204 V(DoubleFields) \
205 V(ElementsKind) \ 205 V(ElementsKind) \
206 V(ElementsPointer) \ 206 V(ElementsPointer) \
207 V(GlobalVars) \ 207 V(GlobalVars) \
208 V(InobjectFields) \ 208 V(InobjectFields) \
209 V(OsrEntries) \ 209 V(OsrEntries) \
210 V(ExternalMemory) 210 V(ExternalMemory)
211 211
212 212
213 #define DECLARE_ABSTRACT_INSTRUCTION(type) \ 213 #define DECLARE_ABSTRACT_INSTRUCTION(type) \
214 virtual bool Is##type() const { return true; } \ 214 virtual bool Is##type() const V8_FINAL V8_OVERRIDE { return true; } \
215 static H##type* cast(HValue* value) { \ 215 static H##type* cast(HValue* value) { \
216 ASSERT(value->Is##type()); \ 216 ASSERT(value->Is##type()); \
217 return reinterpret_cast<H##type*>(value); \ 217 return reinterpret_cast<H##type*>(value); \
218 } 218 }
219 219
220 220
221 #define DECLARE_CONCRETE_INSTRUCTION(type) \ 221 #define DECLARE_CONCRETE_INSTRUCTION(type) \
222 virtual LInstruction* CompileToLithium(LChunkBuilder* builder); \ 222 virtual LInstruction* CompileToLithium( \
223 static H##type* cast(HValue* value) { \ 223 LChunkBuilder* builder) V8_FINAL V8_OVERRIDE; \
224 ASSERT(value->Is##type()); \ 224 static H##type* cast(HValue* value) { \
225 return reinterpret_cast<H##type*>(value); \ 225 ASSERT(value->Is##type()); \
226 } \ 226 return reinterpret_cast<H##type*>(value); \
227 virtual Opcode opcode() const { return HValue::k##type; } 227 } \
228 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
229 return HValue::k##type; \
230 }
228 231
229 232
230 class Range: public ZoneObject { 233 class Range V8_FINAL : public ZoneObject {
231 public: 234 public:
232 Range() 235 Range()
233 : lower_(kMinInt), 236 : lower_(kMinInt),
234 upper_(kMaxInt), 237 upper_(kMaxInt),
235 next_(NULL), 238 next_(NULL),
236 can_be_minus_zero_(false) { } 239 can_be_minus_zero_(false) { }
237 240
238 Range(int32_t lower, int32_t upper) 241 Range(int32_t lower, int32_t upper)
239 : lower_(lower), 242 : lower_(lower),
240 upper_(upper), 243 upper_(upper),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 bool MulAndCheckOverflow(const Representation& r, Range* other); 298 bool MulAndCheckOverflow(const Representation& r, Range* other);
296 299
297 private: 300 private:
298 int32_t lower_; 301 int32_t lower_;
299 int32_t upper_; 302 int32_t upper_;
300 Range* next_; 303 Range* next_;
301 bool can_be_minus_zero_; 304 bool can_be_minus_zero_;
302 }; 305 };
303 306
304 307
305 class UniqueValueId { 308 class UniqueValueId V8_FINAL {
306 public: 309 public:
307 UniqueValueId() : raw_address_(NULL) { } 310 UniqueValueId() : raw_address_(NULL) { }
308 311
309 explicit UniqueValueId(Object* object) { 312 explicit UniqueValueId(Object* object) {
310 raw_address_ = reinterpret_cast<Address>(object); 313 raw_address_ = reinterpret_cast<Address>(object);
311 ASSERT(IsInitialized()); 314 ASSERT(IsInitialized());
312 } 315 }
313 316
314 explicit UniqueValueId(Handle<Object> handle) { 317 explicit UniqueValueId(Handle<Object> handle) {
315 static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1); 318 static const Address kEmptyHandleSentinel = reinterpret_cast<Address>(1);
(...skipping 21 matching lines...) Expand all
337 intptr_t Hashcode() const { 340 intptr_t Hashcode() const {
338 ASSERT(IsInitialized()); 341 ASSERT(IsInitialized());
339 return reinterpret_cast<intptr_t>(raw_address_); 342 return reinterpret_cast<intptr_t>(raw_address_);
340 } 343 }
341 344
342 private: 345 private:
343 Address raw_address_; 346 Address raw_address_;
344 }; 347 };
345 348
346 349
347 class HType { 350 class HType V8_FINAL {
348 public: 351 public:
349 static HType None() { return HType(kNone); } 352 static HType None() { return HType(kNone); }
350 static HType Tagged() { return HType(kTagged); } 353 static HType Tagged() { return HType(kTagged); }
351 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } 354 static HType TaggedPrimitive() { return HType(kTaggedPrimitive); }
352 static HType TaggedNumber() { return HType(kTaggedNumber); } 355 static HType TaggedNumber() { return HType(kTaggedNumber); }
353 static HType Smi() { return HType(kSmi); } 356 static HType Smi() { return HType(kSmi); }
354 static HType HeapNumber() { return HType(kHeapNumber); } 357 static HType HeapNumber() { return HType(kHeapNumber); }
355 static HType String() { return HType(kString); } 358 static HType String() { return HType(kString); }
356 static HType Boolean() { return HType(kBoolean); } 359 static HType Boolean() { return HType(kBoolean); }
357 static HType NonPrimitive() { return HType(kNonPrimitive); } 360 static HType NonPrimitive() { return HType(kNonPrimitive); }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 491
489 private: 492 private:
490 HUseListNode* tail_; 493 HUseListNode* tail_;
491 HValue* value_; 494 HValue* value_;
492 int index_; 495 int index_;
493 }; 496 };
494 497
495 498
496 // We reuse use list nodes behind the scenes as uses are added and deleted. 499 // We reuse use list nodes behind the scenes as uses are added and deleted.
497 // This class is the safe way to iterate uses while deleting them. 500 // This class is the safe way to iterate uses while deleting them.
498 class HUseIterator BASE_EMBEDDED { 501 class HUseIterator V8_FINAL BASE_EMBEDDED {
499 public: 502 public:
500 bool Done() { return current_ == NULL; } 503 bool Done() { return current_ == NULL; }
501 void Advance(); 504 void Advance();
502 505
503 HValue* value() { 506 HValue* value() {
504 ASSERT(!Done()); 507 ASSERT(!Done());
505 return value_; 508 return value_;
506 } 509 }
507 510
508 int index() { 511 int index() {
(...skipping 23 matching lines...) Expand all
532 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) 535 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG)
533 #undef DECLARE_FLAG 536 #undef DECLARE_FLAG
534 kAfterLastFlag, 537 kAfterLastFlag,
535 kLastFlag = kAfterLastFlag - 1, 538 kLastFlag = kAfterLastFlag - 1,
536 #define COUNT_FLAG(type) + 1 539 #define COUNT_FLAG(type) + 1
537 kNumberOfTrackedSideEffects = 0 GVN_TRACKED_FLAG_LIST(COUNT_FLAG) 540 kNumberOfTrackedSideEffects = 0 GVN_TRACKED_FLAG_LIST(COUNT_FLAG)
538 #undef COUNT_FLAG 541 #undef COUNT_FLAG
539 }; 542 };
540 543
541 544
542 class DecompositionResult BASE_EMBEDDED { 545 class DecompositionResult V8_FINAL BASE_EMBEDDED {
543 public: 546 public:
544 DecompositionResult() : base_(NULL), offset_(0), scale_(0) {} 547 DecompositionResult() : base_(NULL), offset_(0), scale_(0) {}
545 548
546 HValue* base() { return base_; } 549 HValue* base() { return base_; }
547 int offset() { return offset_; } 550 int offset() { return offset_; }
548 int scale() { return scale_; } 551 int scale() { return scale_; }
549 552
550 bool Apply(HValue* other_base, int other_offset, int other_scale = 0) { 553 bool Apply(HValue* other_base, int other_offset, int other_scale = 0) {
551 if (base_ == NULL) { 554 if (base_ == NULL) {
552 base_ = other_base; 555 base_ = other_base;
(...skipping 27 matching lines...) Expand all
580 583
581 HValue* base_; 584 HValue* base_;
582 int offset_; 585 int offset_;
583 int scale_; 586 int scale_;
584 }; 587 };
585 588
586 589
587 typedef EnumSet<GVNFlag> GVNFlagSet; 590 typedef EnumSet<GVNFlag> GVNFlagSet;
588 591
589 592
590 class HValue: public ZoneObject { 593 class HValue : public ZoneObject {
591 public: 594 public:
592 static const int kNoNumber = -1; 595 static const int kNoNumber = -1;
593 596
594 enum Flag { 597 enum Flag {
595 kFlexibleRepresentation, 598 kFlexibleRepresentation,
596 kCannotBeTagged, 599 kCannotBeTagged,
597 // Participate in Global Value Numbering, i.e. elimination of 600 // Participate in Global Value Numbering, i.e. elimination of
598 // unnecessary recomputations. If an instruction sets this flag, it must 601 // unnecessary recomputations. If an instruction sets this flag, it must
599 // implement DataEquals(), which will be used to determine if other 602 // implement DataEquals(), which will be used to determine if other
600 // occurrences of the instruction are indeed the same. 603 // occurrences of the instruction are indeed the same.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 798
796 // Mark this HValue as dead and to be removed from other HValues' use lists. 799 // Mark this HValue as dead and to be removed from other HValues' use lists.
797 void Kill(); 800 void Kill();
798 801
799 int flags() const { return flags_; } 802 int flags() const { return flags_; }
800 void SetFlag(Flag f) { flags_ |= (1 << f); } 803 void SetFlag(Flag f) { flags_ |= (1 << f); }
801 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } 804 void ClearFlag(Flag f) { flags_ &= ~(1 << f); }
802 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } 805 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; }
803 806
804 // Returns true if the flag specified is set for all uses, false otherwise. 807 // Returns true if the flag specified is set for all uses, false otherwise.
805 bool CheckUsesForFlag(Flag f); 808 bool CheckUsesForFlag(Flag f) const;
806 // Returns true if the flag specified is set for all uses, and this set 809 // Returns true if the flag specified is set for all uses, and this set
807 // of uses is non-empty. 810 // of uses is non-empty.
808 bool HasAtLeastOneUseWithFlagAndNoneWithout(Flag f); 811 bool HasAtLeastOneUseWithFlagAndNoneWithout(Flag f) const;
809 812
810 GVNFlagSet gvn_flags() const { return gvn_flags_; } 813 GVNFlagSet gvn_flags() const { return gvn_flags_; }
811 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } 814 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); }
812 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } 815 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); }
813 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } 816 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); }
814 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } 817 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); }
815 void ClearAllSideEffects() { 818 void ClearAllSideEffects() {
816 gvn_flags_.Remove(AllSideEffectsFlagSet()); 819 gvn_flags_.Remove(AllSideEffectsFlagSet());
817 } 820 }
818 bool HasSideEffects() const { 821 bool HasSideEffects() const {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 HValue* context, \ 1078 HValue* context, \
1076 P1 p1, \ 1079 P1 p1, \
1077 P2 p2, \ 1080 P2 p2, \
1078 P3 p3, \ 1081 P3 p3, \
1079 P4 p4, \ 1082 P4 p4, \
1080 P5 p5) { \ 1083 P5 p5) { \
1081 return new(zone) I(p1, p2, p3, p4, p5); \ 1084 return new(zone) I(p1, p2, p3, p4, p5); \
1082 } 1085 }
1083 1086
1084 1087
1085 class HInstruction: public HValue { 1088 class HInstruction : public HValue {
1086 public: 1089 public:
1087 HInstruction* next() const { return next_; } 1090 HInstruction* next() const { return next_; }
1088 HInstruction* previous() const { return previous_; } 1091 HInstruction* previous() const { return previous_; }
1089 1092
1090 virtual void PrintTo(StringStream* stream); 1093 virtual void PrintTo(StringStream* stream) V8_OVERRIDE;
1091 virtual void PrintDataTo(StringStream* stream); 1094 virtual void PrintDataTo(StringStream* stream);
1092 1095
1093 bool IsLinked() const { return block() != NULL; } 1096 bool IsLinked() const { return block() != NULL; }
1094 void Unlink(); 1097 void Unlink();
1095 void InsertBefore(HInstruction* next); 1098 void InsertBefore(HInstruction* next);
1096 void InsertAfter(HInstruction* previous); 1099 void InsertAfter(HInstruction* previous);
1097 1100
1098 // The position is a write-once variable. 1101 // The position is a write-once variable.
1099 int position() const { return position_; } 1102 int position() const { return position_; }
1100 bool has_position() const { return position_ != RelocInfo::kNoPosition; } 1103 bool has_position() const { return position_ != RelocInfo::kNoPosition; }
1101 void set_position(int position) { 1104 void set_position(int position) {
1102 ASSERT(!has_position()); 1105 ASSERT(!has_position());
1103 ASSERT(position != RelocInfo::kNoPosition); 1106 ASSERT(position != RelocInfo::kNoPosition);
1104 position_ = position; 1107 position_ = position;
1105 } 1108 }
1106 1109
1107 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); } 1110 bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
1108 1111
1109 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; 1112 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0;
1110 1113
1111 #ifdef DEBUG 1114 #ifdef DEBUG
1112 virtual void Verify(); 1115 virtual void Verify() V8_OVERRIDE;
1113 #endif 1116 #endif
1114 1117
1115 virtual bool IsCall() { return false; } 1118 virtual bool IsCall() { return false; }
1116 1119
1117 DECLARE_ABSTRACT_INSTRUCTION(Instruction) 1120 DECLARE_ABSTRACT_INSTRUCTION(Instruction)
1118 1121
1119 protected: 1122 protected:
1120 HInstruction(HType type = HType::Tagged()) 1123 HInstruction(HType type = HType::Tagged())
1121 : HValue(type), 1124 : HValue(type),
1122 next_(NULL), 1125 next_(NULL),
1123 previous_(NULL), 1126 previous_(NULL),
1124 position_(RelocInfo::kNoPosition) { 1127 position_(RelocInfo::kNoPosition) {
1125 SetGVNFlag(kDependsOnOsrEntries); 1128 SetGVNFlag(kDependsOnOsrEntries);
1126 } 1129 }
1127 1130
1128 virtual void DeleteFromGraph() { Unlink(); } 1131 virtual void DeleteFromGraph() V8_OVERRIDE { Unlink(); }
1129 1132
1130 private: 1133 private:
1131 void InitializeAsFirst(HBasicBlock* block) { 1134 void InitializeAsFirst(HBasicBlock* block) {
1132 ASSERT(!IsLinked()); 1135 ASSERT(!IsLinked());
1133 SetBlock(block); 1136 SetBlock(block);
1134 } 1137 }
1135 1138
1136 void PrintMnemonicTo(StringStream* stream); 1139 void PrintMnemonicTo(StringStream* stream);
1137 1140
1138 HInstruction* next_; 1141 HInstruction* next_;
1139 HInstruction* previous_; 1142 HInstruction* previous_;
1140 int position_; 1143 int position_;
1141 1144
1142 friend class HBasicBlock; 1145 friend class HBasicBlock;
1143 }; 1146 };
1144 1147
1145 1148
1146 template<int V> 1149 template<int V>
1147 class HTemplateInstruction : public HInstruction { 1150 class HTemplateInstruction : public HInstruction {
1148 public: 1151 public:
1149 int OperandCount() { return V; } 1152 virtual int OperandCount() V8_FINAL V8_OVERRIDE { return V; }
1150 HValue* OperandAt(int i) const { return inputs_[i]; } 1153 virtual HValue* OperandAt(int i) const V8_FINAL V8_OVERRIDE {
1154 return inputs_[i];
1155 }
1151 1156
1152 protected: 1157 protected:
1153 HTemplateInstruction(HType type = HType::Tagged()) : HInstruction(type) {} 1158 HTemplateInstruction(HType type = HType::Tagged()) : HInstruction(type) {}
1154 1159
1155 void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } 1160 virtual void InternalSetOperandAt(int i, HValue* value) V8_FINAL V8_OVERRIDE {
1161 inputs_[i] = value;
1162 }
1156 1163
1157 private: 1164 private:
1158 EmbeddedContainer<HValue*, V> inputs_; 1165 EmbeddedContainer<HValue*, V> inputs_;
1159 }; 1166 };
1160 1167
1161 1168
1162 class HControlInstruction: public HInstruction { 1169 class HControlInstruction : public HInstruction {
1163 public: 1170 public:
1164 virtual HBasicBlock* SuccessorAt(int i) = 0; 1171 virtual HBasicBlock* SuccessorAt(int i) = 0;
1165 virtual int SuccessorCount() = 0; 1172 virtual int SuccessorCount() = 0;
1166 virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0; 1173 virtual void SetSuccessorAt(int i, HBasicBlock* block) = 0;
1167 1174
1168 virtual void PrintDataTo(StringStream* stream); 1175 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1169 1176
1170 HBasicBlock* FirstSuccessor() { 1177 HBasicBlock* FirstSuccessor() {
1171 return SuccessorCount() > 0 ? SuccessorAt(0) : NULL; 1178 return SuccessorCount() > 0 ? SuccessorAt(0) : NULL;
1172 } 1179 }
1173 HBasicBlock* SecondSuccessor() { 1180 HBasicBlock* SecondSuccessor() {
1174 return SuccessorCount() > 1 ? SuccessorAt(1) : NULL; 1181 return SuccessorCount() > 1 ? SuccessorAt(1) : NULL;
1175 } 1182 }
1176 1183
1177 DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction) 1184 DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction)
1178 }; 1185 };
1179 1186
1180 1187
1181 class HSuccessorIterator BASE_EMBEDDED { 1188 class HSuccessorIterator V8_FINAL BASE_EMBEDDED {
1182 public: 1189 public:
1183 explicit HSuccessorIterator(HControlInstruction* instr) 1190 explicit HSuccessorIterator(HControlInstruction* instr)
1184 : instr_(instr), current_(0) { } 1191 : instr_(instr), current_(0) { }
1185 1192
1186 bool Done() { return current_ >= instr_->SuccessorCount(); } 1193 bool Done() { return current_ >= instr_->SuccessorCount(); }
1187 HBasicBlock* Current() { return instr_->SuccessorAt(current_); } 1194 HBasicBlock* Current() { return instr_->SuccessorAt(current_); }
1188 void Advance() { current_++; } 1195 void Advance() { current_++; }
1189 1196
1190 private: 1197 private:
1191 HControlInstruction* instr_; 1198 HControlInstruction* instr_;
1192 int current_; 1199 int current_;
1193 }; 1200 };
1194 1201
1195 1202
1196 template<int S, int V> 1203 template<int S, int V>
1197 class HTemplateControlInstruction: public HControlInstruction { 1204 class HTemplateControlInstruction : public HControlInstruction {
1198 public: 1205 public:
1199 int SuccessorCount() { return S; } 1206 int SuccessorCount() V8_OVERRIDE { return S; }
1200 HBasicBlock* SuccessorAt(int i) { return successors_[i]; } 1207 HBasicBlock* SuccessorAt(int i) V8_OVERRIDE { return successors_[i]; }
1201 void SetSuccessorAt(int i, HBasicBlock* block) { successors_[i] = block; } 1208 void SetSuccessorAt(int i, HBasicBlock* block) V8_OVERRIDE {
1209 successors_[i] = block;
1210 }
1202 1211
1203 int OperandCount() { return V; } 1212 int OperandCount() V8_OVERRIDE { return V; }
1204 HValue* OperandAt(int i) const { return inputs_[i]; } 1213 HValue* OperandAt(int i) const V8_OVERRIDE { return inputs_[i]; }
1205 1214
1206 1215
1207 protected: 1216 protected:
1208 void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } 1217 void InternalSetOperandAt(int i, HValue* value) V8_OVERRIDE {
1218 inputs_[i] = value;
1219 }
1209 1220
1210 private: 1221 private:
1211 EmbeddedContainer<HBasicBlock*, S> successors_; 1222 EmbeddedContainer<HBasicBlock*, S> successors_;
1212 EmbeddedContainer<HValue*, V> inputs_; 1223 EmbeddedContainer<HValue*, V> inputs_;
1213 }; 1224 };
1214 1225
1215 1226
1216 class HBlockEntry: public HTemplateInstruction<0> { 1227 class HBlockEntry V8_FINAL : public HTemplateInstruction<0> {
1217 public: 1228 public:
1218 virtual Representation RequiredInputRepresentation(int index) { 1229 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1219 return Representation::None(); 1230 return Representation::None();
1220 } 1231 }
1221 1232
1222 DECLARE_CONCRETE_INSTRUCTION(BlockEntry) 1233 DECLARE_CONCRETE_INSTRUCTION(BlockEntry)
1223 }; 1234 };
1224 1235
1225 1236
1226 class HDummyUse: public HTemplateInstruction<1> { 1237 class HDummyUse V8_FINAL : public HTemplateInstruction<1> {
1227 public: 1238 public:
1228 explicit HDummyUse(HValue* value) 1239 explicit HDummyUse(HValue* value)
1229 : HTemplateInstruction<1>(HType::Smi()) { 1240 : HTemplateInstruction<1>(HType::Smi()) {
1230 SetOperandAt(0, value); 1241 SetOperandAt(0, value);
1231 // Pretend to be a Smi so that the HChange instructions inserted 1242 // Pretend to be a Smi so that the HChange instructions inserted
1232 // before any use generate as little code as possible. 1243 // before any use generate as little code as possible.
1233 set_representation(Representation::Tagged()); 1244 set_representation(Representation::Tagged());
1234 } 1245 }
1235 1246
1236 HValue* value() { return OperandAt(0); } 1247 HValue* value() { return OperandAt(0); }
1237 1248
1238 virtual bool HasEscapingOperandAt(int index) { return false; } 1249 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
1239 virtual Representation RequiredInputRepresentation(int index) { 1250 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1240 return Representation::None(); 1251 return Representation::None();
1241 } 1252 }
1242 1253
1243 virtual void PrintDataTo(StringStream* stream); 1254 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1244 1255
1245 DECLARE_CONCRETE_INSTRUCTION(DummyUse); 1256 DECLARE_CONCRETE_INSTRUCTION(DummyUse);
1246 }; 1257 };
1247 1258
1248 1259
1249 class HDeoptimize: public HTemplateInstruction<0> { 1260 class HDeoptimize V8_FINAL : public HTemplateInstruction<0> {
1250 public: 1261 public:
1251 DECLARE_INSTRUCTION_FACTORY_P1(HDeoptimize, Deoptimizer::BailoutType); 1262 DECLARE_INSTRUCTION_FACTORY_P2(HDeoptimize, const char*,
1263 Deoptimizer::BailoutType);
1252 1264
1253 virtual Representation RequiredInputRepresentation(int index) { 1265 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1254 return Representation::None(); 1266 return Representation::None();
1255 } 1267 }
1256 1268
1269 const char* reason() const { return reason_; }
1257 Deoptimizer::BailoutType type() { return type_; } 1270 Deoptimizer::BailoutType type() { return type_; }
1258 1271
1259 DECLARE_CONCRETE_INSTRUCTION(Deoptimize) 1272 DECLARE_CONCRETE_INSTRUCTION(Deoptimize)
1260 1273
1261 private: 1274 private:
1262 explicit HDeoptimize(Deoptimizer::BailoutType type) : type_(type) {} 1275 explicit HDeoptimize(const char* reason, Deoptimizer::BailoutType type)
1276 : reason_(reason), type_(type) {}
1263 1277
1278 const char* reason_;
1264 Deoptimizer::BailoutType type_; 1279 Deoptimizer::BailoutType type_;
1265 }; 1280 };
1266 1281
1267 1282
1268 // Inserts an int3/stop break instruction for debugging purposes. 1283 // Inserts an int3/stop break instruction for debugging purposes.
1269 class HDebugBreak: public HTemplateInstruction<0> { 1284 class HDebugBreak V8_FINAL : public HTemplateInstruction<0> {
1270 public: 1285 public:
1271 virtual Representation RequiredInputRepresentation(int index) { 1286 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1272 return Representation::None(); 1287 return Representation::None();
1273 } 1288 }
1274 1289
1275 DECLARE_CONCRETE_INSTRUCTION(DebugBreak) 1290 DECLARE_CONCRETE_INSTRUCTION(DebugBreak)
1276 }; 1291 };
1277 1292
1278 1293
1279 class HGoto: public HTemplateControlInstruction<1, 0> { 1294 class HGoto V8_FINAL : public HTemplateControlInstruction<1, 0> {
1280 public: 1295 public:
1281 explicit HGoto(HBasicBlock* target) { 1296 explicit HGoto(HBasicBlock* target) {
1282 SetSuccessorAt(0, target); 1297 SetSuccessorAt(0, target);
1283 } 1298 }
1284 1299
1285 virtual Representation RequiredInputRepresentation(int index) { 1300 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1286 return Representation::None(); 1301 return Representation::None();
1287 } 1302 }
1288 1303
1289 virtual void PrintDataTo(StringStream* stream); 1304 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1290 1305
1291 DECLARE_CONCRETE_INSTRUCTION(Goto) 1306 DECLARE_CONCRETE_INSTRUCTION(Goto)
1292 }; 1307 };
1293 1308
1294 1309
1295 class HUnaryControlInstruction: public HTemplateControlInstruction<2, 1> { 1310 class HUnaryControlInstruction : public HTemplateControlInstruction<2, 1> {
1296 public: 1311 public:
1297 HUnaryControlInstruction(HValue* value, 1312 HUnaryControlInstruction(HValue* value,
1298 HBasicBlock* true_target, 1313 HBasicBlock* true_target,
1299 HBasicBlock* false_target) { 1314 HBasicBlock* false_target) {
1300 SetOperandAt(0, value); 1315 SetOperandAt(0, value);
1301 SetSuccessorAt(0, true_target); 1316 SetSuccessorAt(0, true_target);
1302 SetSuccessorAt(1, false_target); 1317 SetSuccessorAt(1, false_target);
1303 } 1318 }
1304 1319
1305 virtual void PrintDataTo(StringStream* stream); 1320 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1306 1321
1307 HValue* value() { return OperandAt(0); } 1322 HValue* value() { return OperandAt(0); }
1308 }; 1323 };
1309 1324
1310 1325
1311 class HBranch: public HUnaryControlInstruction { 1326 class HBranch V8_FINAL : public HUnaryControlInstruction {
1312 public: 1327 public:
1313 HBranch(HValue* value, 1328 HBranch(HValue* value,
1314 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(), 1329 ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
1315 HBasicBlock* true_target = NULL, 1330 HBasicBlock* true_target = NULL,
1316 HBasicBlock* false_target = NULL) 1331 HBasicBlock* false_target = NULL)
1317 : HUnaryControlInstruction(value, true_target, false_target), 1332 : HUnaryControlInstruction(value, true_target, false_target),
1318 expected_input_types_(expected_input_types) { 1333 expected_input_types_(expected_input_types) {
1319 SetFlag(kAllowUndefinedAsNaN); 1334 SetFlag(kAllowUndefinedAsNaN);
1320 } 1335 }
1321 1336
1322 virtual Representation RequiredInputRepresentation(int index) { 1337 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1323 return Representation::None(); 1338 return Representation::None();
1324 } 1339 }
1325 virtual Representation observed_input_representation(int index); 1340 virtual Representation observed_input_representation(int index) V8_OVERRIDE;
1326 1341
1327 ToBooleanStub::Types expected_input_types() const { 1342 ToBooleanStub::Types expected_input_types() const {
1328 return expected_input_types_; 1343 return expected_input_types_;
1329 } 1344 }
1330 1345
1331 DECLARE_CONCRETE_INSTRUCTION(Branch) 1346 DECLARE_CONCRETE_INSTRUCTION(Branch)
1332 1347
1333 private: 1348 private:
1334 ToBooleanStub::Types expected_input_types_; 1349 ToBooleanStub::Types expected_input_types_;
1335 }; 1350 };
1336 1351
1337 1352
1338 class HCompareMap: public HUnaryControlInstruction { 1353 class HCompareMap V8_FINAL : public HUnaryControlInstruction {
1339 public: 1354 public:
1340 HCompareMap(HValue* value, 1355 HCompareMap(HValue* value,
1341 Handle<Map> map, 1356 Handle<Map> map,
1342 HBasicBlock* true_target = NULL, 1357 HBasicBlock* true_target = NULL,
1343 HBasicBlock* false_target = NULL) 1358 HBasicBlock* false_target = NULL)
1344 : HUnaryControlInstruction(value, true_target, false_target), 1359 : HUnaryControlInstruction(value, true_target, false_target),
1345 map_(map) { 1360 map_(map) {
1346 ASSERT(!map.is_null()); 1361 ASSERT(!map.is_null());
1347 } 1362 }
1348 1363
1349 virtual void PrintDataTo(StringStream* stream); 1364 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1350 1365
1351 Handle<Map> map() const { return map_; } 1366 Handle<Map> map() const { return map_; }
1352 1367
1353 virtual Representation RequiredInputRepresentation(int index) { 1368 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1354 return Representation::Tagged(); 1369 return Representation::Tagged();
1355 } 1370 }
1356 1371
1357 DECLARE_CONCRETE_INSTRUCTION(CompareMap) 1372 DECLARE_CONCRETE_INSTRUCTION(CompareMap)
1358 1373
1359 private: 1374 private:
1360 Handle<Map> map_; 1375 Handle<Map> map_;
1361 }; 1376 };
1362 1377
1363 1378
1364 class HContext: public HTemplateInstruction<0> { 1379 class HContext V8_FINAL : public HTemplateInstruction<0> {
1365 public: 1380 public:
1366 static HContext* New(Zone* zone) { 1381 static HContext* New(Zone* zone) {
1367 return new(zone) HContext(); 1382 return new(zone) HContext();
1368 } 1383 }
1369 1384
1370 virtual Representation RequiredInputRepresentation(int index) { 1385 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1371 return Representation::None(); 1386 return Representation::None();
1372 } 1387 }
1373 1388
1374 DECLARE_CONCRETE_INSTRUCTION(Context) 1389 DECLARE_CONCRETE_INSTRUCTION(Context)
1375 1390
1376 protected: 1391 protected:
1377 virtual bool DataEquals(HValue* other) { return true; } 1392 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1378 1393
1379 private: 1394 private:
1380 HContext() { 1395 HContext() {
1381 set_representation(Representation::Tagged()); 1396 set_representation(Representation::Tagged());
1382 SetFlag(kUseGVN); 1397 SetFlag(kUseGVN);
1383 } 1398 }
1384 1399
1385 virtual bool IsDeletable() const { return true; } 1400 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
1386 }; 1401 };
1387 1402
1388 1403
1389 class HReturn: public HTemplateControlInstruction<0, 3> { 1404 class HReturn V8_FINAL : public HTemplateControlInstruction<0, 3> {
1390 public: 1405 public:
1391 static HInstruction* New(Zone* zone, 1406 static HInstruction* New(Zone* zone,
1392 HValue* context, 1407 HValue* context,
1393 HValue* value, 1408 HValue* value,
1394 HValue* parameter_count) { 1409 HValue* parameter_count) {
1395 return new(zone) HReturn(value, context, parameter_count); 1410 return new(zone) HReturn(value, context, parameter_count);
1396 } 1411 }
1397 1412
1398 static HInstruction* New(Zone* zone, 1413 static HInstruction* New(Zone* zone,
1399 HValue* context, 1414 HValue* context,
1400 HValue* value) { 1415 HValue* value) {
1401 return new(zone) HReturn(value, context, 0); 1416 return new(zone) HReturn(value, context, 0);
1402 } 1417 }
1403 1418
1404 virtual Representation RequiredInputRepresentation(int index) { 1419 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1405 return Representation::Tagged(); 1420 return Representation::Tagged();
1406 } 1421 }
1407 1422
1408 virtual void PrintDataTo(StringStream* stream); 1423 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1409 1424
1410 HValue* value() { return OperandAt(0); } 1425 HValue* value() { return OperandAt(0); }
1411 HValue* context() { return OperandAt(1); } 1426 HValue* context() { return OperandAt(1); }
1412 HValue* parameter_count() { return OperandAt(2); } 1427 HValue* parameter_count() { return OperandAt(2); }
1413 1428
1414 DECLARE_CONCRETE_INSTRUCTION(Return) 1429 DECLARE_CONCRETE_INSTRUCTION(Return)
1415 1430
1416 private: 1431 private:
1417 HReturn(HValue* value, HValue* context, HValue* parameter_count) { 1432 HReturn(HValue* value, HValue* context, HValue* parameter_count) {
1418 SetOperandAt(0, value); 1433 SetOperandAt(0, value);
1419 SetOperandAt(1, context); 1434 SetOperandAt(1, context);
1420 SetOperandAt(2, parameter_count); 1435 SetOperandAt(2, parameter_count);
1421 } 1436 }
1422 }; 1437 };
1423 1438
1424 1439
1425 class HAbnormalExit: public HTemplateControlInstruction<0, 0> { 1440 class HAbnormalExit V8_FINAL : public HTemplateControlInstruction<0, 0> {
1426 public: 1441 public:
1427 virtual Representation RequiredInputRepresentation(int index) { 1442 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1428 return Representation::None(); 1443 return Representation::None();
1429 } 1444 }
1430 1445
1431 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) 1446 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit)
1432 }; 1447 };
1433 1448
1434 1449
1435 class HUnaryOperation: public HTemplateInstruction<1> { 1450 class HUnaryOperation : public HTemplateInstruction<1> {
1436 public: 1451 public:
1437 HUnaryOperation(HValue* value, HType type = HType::Tagged()) 1452 HUnaryOperation(HValue* value, HType type = HType::Tagged())
1438 : HTemplateInstruction<1>(type) { 1453 : HTemplateInstruction<1>(type) {
1439 SetOperandAt(0, value); 1454 SetOperandAt(0, value);
1440 } 1455 }
1441 1456
1442 static HUnaryOperation* cast(HValue* value) { 1457 static HUnaryOperation* cast(HValue* value) {
1443 return reinterpret_cast<HUnaryOperation*>(value); 1458 return reinterpret_cast<HUnaryOperation*>(value);
1444 } 1459 }
1445 1460
1446 HValue* value() const { return OperandAt(0); } 1461 HValue* value() const { return OperandAt(0); }
1447 virtual void PrintDataTo(StringStream* stream); 1462 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1448 }; 1463 };
1449 1464
1450 1465
1451 class HThrow: public HTemplateInstruction<2> { 1466 class HThrow V8_FINAL : public HTemplateInstruction<2> {
1452 public: 1467 public:
1453 static HThrow* New(Zone* zone, 1468 static HThrow* New(Zone* zone,
1454 HValue* context, 1469 HValue* context,
1455 HValue* value) { 1470 HValue* value) {
1456 return new(zone) HThrow(context, value); 1471 return new(zone) HThrow(context, value);
1457 } 1472 }
1458 1473
1459 virtual Representation RequiredInputRepresentation(int index) { 1474 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1460 return Representation::Tagged(); 1475 return Representation::Tagged();
1461 } 1476 }
1462 1477
1463 HValue* context() { return OperandAt(0); } 1478 HValue* context() { return OperandAt(0); }
1464 HValue* value() { return OperandAt(1); } 1479 HValue* value() { return OperandAt(1); }
1465 1480
1466 DECLARE_CONCRETE_INSTRUCTION(Throw) 1481 DECLARE_CONCRETE_INSTRUCTION(Throw)
1467 1482
1468 private: 1483 private:
1469 HThrow(HValue* context, HValue* value) { 1484 HThrow(HValue* context, HValue* value) {
1470 SetOperandAt(0, context); 1485 SetOperandAt(0, context);
1471 SetOperandAt(1, value); 1486 SetOperandAt(1, value);
1472 SetAllSideEffects(); 1487 SetAllSideEffects();
1473 } 1488 }
1474 }; 1489 };
1475 1490
1476 1491
1477 class HUseConst: public HUnaryOperation { 1492 class HUseConst V8_FINAL : public HUnaryOperation {
1478 public: 1493 public:
1479 DECLARE_INSTRUCTION_FACTORY_P1(HUseConst, HValue*); 1494 DECLARE_INSTRUCTION_FACTORY_P1(HUseConst, HValue*);
1480 1495
1481 virtual Representation RequiredInputRepresentation(int index) { 1496 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1482 return Representation::None(); 1497 return Representation::None();
1483 } 1498 }
1484 1499
1485 DECLARE_CONCRETE_INSTRUCTION(UseConst) 1500 DECLARE_CONCRETE_INSTRUCTION(UseConst)
1486 1501
1487 private: 1502 private:
1488 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } 1503 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { }
1489 }; 1504 };
1490 1505
1491 1506
1492 class HForceRepresentation: public HTemplateInstruction<1> { 1507 class HForceRepresentation V8_FINAL : public HTemplateInstruction<1> {
1493 public: 1508 public:
1494 DECLARE_INSTRUCTION_FACTORY_P2(HForceRepresentation, HValue*, Representation); 1509 DECLARE_INSTRUCTION_FACTORY_P2(HForceRepresentation, HValue*, Representation);
1495 1510
1496 HValue* value() { return OperandAt(0); } 1511 HValue* value() { return OperandAt(0); }
1497 1512
1498 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1513 virtual HValue* EnsureAndPropagateNotMinusZero(
1514 BitVector* visited) V8_OVERRIDE;
1499 1515
1500 virtual Representation RequiredInputRepresentation(int index) { 1516 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1501 return representation(); // Same as the output representation. 1517 return representation(); // Same as the output representation.
1502 } 1518 }
1503 1519
1504 virtual void PrintDataTo(StringStream* stream); 1520 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1505 1521
1506 DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation) 1522 DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
1507 1523
1508 private: 1524 private:
1509 HForceRepresentation(HValue* value, Representation required_representation) { 1525 HForceRepresentation(HValue* value, Representation required_representation) {
1510 SetOperandAt(0, value); 1526 SetOperandAt(0, value);
1511 set_representation(required_representation); 1527 set_representation(required_representation);
1512 } 1528 }
1513 }; 1529 };
1514 1530
1515 1531
1516 class HChange: public HUnaryOperation { 1532 class HChange V8_FINAL : public HUnaryOperation {
1517 public: 1533 public:
1518 HChange(HValue* value, 1534 HChange(HValue* value,
1519 Representation to, 1535 Representation to,
1520 bool is_truncating_to_smi, 1536 bool is_truncating_to_smi,
1521 bool is_truncating_to_int32, 1537 bool is_truncating_to_int32)
1522 bool allow_undefined_as_nan)
1523 : HUnaryOperation(value) { 1538 : HUnaryOperation(value) {
1524 ASSERT(!value->representation().IsNone()); 1539 ASSERT(!value->representation().IsNone());
1525 ASSERT(!to.IsNone()); 1540 ASSERT(!to.IsNone());
1526 ASSERT(!value->representation().Equals(to)); 1541 ASSERT(!value->representation().Equals(to));
1527 set_representation(to); 1542 set_representation(to);
1528 SetFlag(kUseGVN); 1543 SetFlag(kUseGVN);
1529 if (allow_undefined_as_nan) SetFlag(kAllowUndefinedAsNaN);
1530 if (is_truncating_to_smi) SetFlag(kTruncatingToSmi); 1544 if (is_truncating_to_smi) SetFlag(kTruncatingToSmi);
1531 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32); 1545 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32);
1532 if (value->representation().IsSmi() || value->type().IsSmi()) { 1546 if (value->representation().IsSmi() || value->type().IsSmi()) {
1533 set_type(HType::Smi()); 1547 set_type(HType::Smi());
1534 } else { 1548 } else {
1535 set_type(HType::TaggedNumber()); 1549 set_type(HType::TaggedNumber());
1536 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); 1550 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion);
1537 } 1551 }
1538 } 1552 }
1539 1553
1540 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1554 bool can_convert_undefined_to_nan() {
1541 virtual HType CalculateInferredType(); 1555 return CheckUsesForFlag(kAllowUndefinedAsNaN);
1542 virtual HValue* Canonicalize(); 1556 }
1557
1558 virtual HValue* EnsureAndPropagateNotMinusZero(
1559 BitVector* visited) V8_OVERRIDE;
1560 virtual HType CalculateInferredType() V8_OVERRIDE;
1561 virtual HValue* Canonicalize() V8_OVERRIDE;
1543 1562
1544 Representation from() const { return value()->representation(); } 1563 Representation from() const { return value()->representation(); }
1545 Representation to() const { return representation(); } 1564 Representation to() const { return representation(); }
1546 bool allow_undefined_as_nan() const {
1547 return CheckFlag(kAllowUndefinedAsNaN);
1548 }
1549 bool deoptimize_on_minus_zero() const { 1565 bool deoptimize_on_minus_zero() const {
1550 return CheckFlag(kBailoutOnMinusZero); 1566 return CheckFlag(kBailoutOnMinusZero);
1551 } 1567 }
1552 virtual Representation RequiredInputRepresentation(int index) { 1568 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1553 return from(); 1569 return from();
1554 } 1570 }
1555 1571
1556 virtual Range* InferRange(Zone* zone); 1572 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
1557 1573
1558 virtual void PrintDataTo(StringStream* stream); 1574 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1559 1575
1560 DECLARE_CONCRETE_INSTRUCTION(Change) 1576 DECLARE_CONCRETE_INSTRUCTION(Change)
1561 1577
1562 protected: 1578 protected:
1563 virtual bool DataEquals(HValue* other) { return true; } 1579 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1564 1580
1565 private: 1581 private:
1566 virtual bool IsDeletable() const { 1582 virtual bool IsDeletable() const V8_OVERRIDE {
1567 return !from().IsTagged() || value()->type().IsSmi(); 1583 return !from().IsTagged() || value()->type().IsSmi();
1568 } 1584 }
1569 }; 1585 };
1570 1586
1571 1587
1572 class HClampToUint8: public HUnaryOperation { 1588 class HClampToUint8 V8_FINAL : public HUnaryOperation {
1573 public: 1589 public:
1574 DECLARE_INSTRUCTION_FACTORY_P1(HClampToUint8, HValue*); 1590 DECLARE_INSTRUCTION_FACTORY_P1(HClampToUint8, HValue*);
1575 1591
1576 virtual Representation RequiredInputRepresentation(int index) { 1592 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1577 return Representation::None(); 1593 return Representation::None();
1578 } 1594 }
1579 1595
1580 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) 1596 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8)
1581 1597
1582 protected: 1598 protected:
1583 virtual bool DataEquals(HValue* other) { return true; } 1599 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1584 1600
1585 private: 1601 private:
1586 explicit HClampToUint8(HValue* value) 1602 explicit HClampToUint8(HValue* value)
1587 : HUnaryOperation(value) { 1603 : HUnaryOperation(value) {
1588 set_representation(Representation::Integer32()); 1604 set_representation(Representation::Integer32());
1589 SetFlag(kAllowUndefinedAsNaN); 1605 SetFlag(kAllowUndefinedAsNaN);
1590 SetFlag(kUseGVN); 1606 SetFlag(kUseGVN);
1591 } 1607 }
1592 1608
1593 virtual bool IsDeletable() const { return true; } 1609 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
1594 }; 1610 };
1595 1611
1596 1612
1597 enum RemovableSimulate { 1613 enum RemovableSimulate {
1598 REMOVABLE_SIMULATE, 1614 REMOVABLE_SIMULATE,
1599 FIXED_SIMULATE 1615 FIXED_SIMULATE
1600 }; 1616 };
1601 1617
1602 1618
1603 class HSimulate: public HInstruction { 1619 class HSimulate V8_FINAL : public HInstruction {
1604 public: 1620 public:
1605 HSimulate(BailoutId ast_id, 1621 HSimulate(BailoutId ast_id,
1606 int pop_count, 1622 int pop_count,
1607 Zone* zone, 1623 Zone* zone,
1608 RemovableSimulate removable) 1624 RemovableSimulate removable)
1609 : ast_id_(ast_id), 1625 : ast_id_(ast_id),
1610 pop_count_(pop_count), 1626 pop_count_(pop_count),
1611 values_(2, zone), 1627 values_(2, zone),
1612 assigned_indexes_(2, zone), 1628 assigned_indexes_(2, zone),
1613 zone_(zone), 1629 zone_(zone),
1614 removable_(removable) {} 1630 removable_(removable) {}
1615 virtual ~HSimulate() {} 1631 ~HSimulate() {}
1616 1632
1617 virtual void PrintDataTo(StringStream* stream); 1633 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1618 1634
1619 bool HasAstId() const { return !ast_id_.IsNone(); } 1635 bool HasAstId() const { return !ast_id_.IsNone(); }
1620 BailoutId ast_id() const { return ast_id_; } 1636 BailoutId ast_id() const { return ast_id_; }
1621 void set_ast_id(BailoutId id) { 1637 void set_ast_id(BailoutId id) {
1622 ASSERT(!HasAstId()); 1638 ASSERT(!HasAstId());
1623 ast_id_ = id; 1639 ast_id_ = id;
1624 } 1640 }
1625 1641
1626 int pop_count() const { return pop_count_; } 1642 int pop_count() const { return pop_count_; }
1627 const ZoneList<HValue*>* values() const { return &values_; } 1643 const ZoneList<HValue*>* values() const { return &values_; }
1628 int GetAssignedIndexAt(int index) const { 1644 int GetAssignedIndexAt(int index) const {
1629 ASSERT(HasAssignedIndexAt(index)); 1645 ASSERT(HasAssignedIndexAt(index));
1630 return assigned_indexes_[index]; 1646 return assigned_indexes_[index];
1631 } 1647 }
1632 bool HasAssignedIndexAt(int index) const { 1648 bool HasAssignedIndexAt(int index) const {
1633 return assigned_indexes_[index] != kNoIndex; 1649 return assigned_indexes_[index] != kNoIndex;
1634 } 1650 }
1635 void AddAssignedValue(int index, HValue* value) { 1651 void AddAssignedValue(int index, HValue* value) {
1636 AddValue(index, value); 1652 AddValue(index, value);
1637 } 1653 }
1638 void AddPushedValue(HValue* value) { 1654 void AddPushedValue(HValue* value) {
1639 AddValue(kNoIndex, value); 1655 AddValue(kNoIndex, value);
1640 } 1656 }
1641 int ToOperandIndex(int environment_index) { 1657 int ToOperandIndex(int environment_index) {
1642 for (int i = 0; i < assigned_indexes_.length(); ++i) { 1658 for (int i = 0; i < assigned_indexes_.length(); ++i) {
1643 if (assigned_indexes_[i] == environment_index) return i; 1659 if (assigned_indexes_[i] == environment_index) return i;
1644 } 1660 }
1645 return -1; 1661 return -1;
1646 } 1662 }
1647 virtual int OperandCount() { return values_.length(); } 1663 virtual int OperandCount() V8_OVERRIDE { return values_.length(); }
1648 virtual HValue* OperandAt(int index) const { return values_[index]; } 1664 virtual HValue* OperandAt(int index) const V8_OVERRIDE {
1665 return values_[index];
1666 }
1649 1667
1650 virtual bool HasEscapingOperandAt(int index) { return false; } 1668 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
1651 virtual Representation RequiredInputRepresentation(int index) { 1669 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1652 return Representation::None(); 1670 return Representation::None();
1653 } 1671 }
1654 1672
1655 void MergeWith(ZoneList<HSimulate*>* list); 1673 void MergeWith(ZoneList<HSimulate*>* list);
1656 bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; } 1674 bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; }
1657 1675
1658 DECLARE_CONCRETE_INSTRUCTION(Simulate) 1676 DECLARE_CONCRETE_INSTRUCTION(Simulate)
1659 1677
1660 #ifdef DEBUG 1678 #ifdef DEBUG
1661 virtual void Verify(); 1679 virtual void Verify() V8_OVERRIDE;
1662 void set_closure(Handle<JSFunction> closure) { closure_ = closure; } 1680 void set_closure(Handle<JSFunction> closure) { closure_ = closure; }
1663 Handle<JSFunction> closure() const { return closure_; } 1681 Handle<JSFunction> closure() const { return closure_; }
1664 #endif 1682 #endif
1665 1683
1666 protected: 1684 protected:
1667 virtual void InternalSetOperandAt(int index, HValue* value) { 1685 virtual void InternalSetOperandAt(int index, HValue* value) V8_OVERRIDE {
1668 values_[index] = value; 1686 values_[index] = value;
1669 } 1687 }
1670 1688
1671 private: 1689 private:
1672 static const int kNoIndex = -1; 1690 static const int kNoIndex = -1;
1673 void AddValue(int index, HValue* value) { 1691 void AddValue(int index, HValue* value) {
1674 assigned_indexes_.Add(index, zone_); 1692 assigned_indexes_.Add(index, zone_);
1675 // Resize the list of pushed values. 1693 // Resize the list of pushed values.
1676 values_.Add(NULL, zone_); 1694 values_.Add(NULL, zone_);
1677 // Set the operand through the base method in HValue to make sure that the 1695 // Set the operand through the base method in HValue to make sure that the
(...skipping 12 matching lines...) Expand all
1690 ZoneList<int> assigned_indexes_; 1708 ZoneList<int> assigned_indexes_;
1691 Zone* zone_; 1709 Zone* zone_;
1692 RemovableSimulate removable_; 1710 RemovableSimulate removable_;
1693 1711
1694 #ifdef DEBUG 1712 #ifdef DEBUG
1695 Handle<JSFunction> closure_; 1713 Handle<JSFunction> closure_;
1696 #endif 1714 #endif
1697 }; 1715 };
1698 1716
1699 1717
1700 class HEnvironmentMarker: public HTemplateInstruction<1> { 1718 class HEnvironmentMarker V8_FINAL : public HTemplateInstruction<1> {
1701 public: 1719 public:
1702 enum Kind { BIND, LOOKUP }; 1720 enum Kind { BIND, LOOKUP };
1703 1721
1704 HEnvironmentMarker(Kind kind, int index) 1722 HEnvironmentMarker(Kind kind, int index)
1705 : kind_(kind), index_(index), next_simulate_(NULL) { } 1723 : kind_(kind), index_(index), next_simulate_(NULL) { }
1706 1724
1707 Kind kind() { return kind_; } 1725 Kind kind() { return kind_; }
1708 int index() { return index_; } 1726 int index() { return index_; }
1709 HSimulate* next_simulate() { return next_simulate_; } 1727 HSimulate* next_simulate() { return next_simulate_; }
1710 void set_next_simulate(HSimulate* simulate) { 1728 void set_next_simulate(HSimulate* simulate) {
1711 next_simulate_ = simulate; 1729 next_simulate_ = simulate;
1712 } 1730 }
1713 1731
1714 virtual Representation RequiredInputRepresentation(int index) { 1732 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1715 return Representation::None(); 1733 return Representation::None();
1716 } 1734 }
1717 1735
1718 virtual void PrintDataTo(StringStream* stream); 1736 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1719 1737
1720 #ifdef DEBUG 1738 #ifdef DEBUG
1721 void set_closure(Handle<JSFunction> closure) { 1739 void set_closure(Handle<JSFunction> closure) {
1722 ASSERT(closure_.is_null()); 1740 ASSERT(closure_.is_null());
1723 ASSERT(!closure.is_null()); 1741 ASSERT(!closure.is_null());
1724 closure_ = closure; 1742 closure_ = closure;
1725 } 1743 }
1726 Handle<JSFunction> closure() const { return closure_; } 1744 Handle<JSFunction> closure() const { return closure_; }
1727 #endif 1745 #endif
1728 1746
1729 DECLARE_CONCRETE_INSTRUCTION(EnvironmentMarker); 1747 DECLARE_CONCRETE_INSTRUCTION(EnvironmentMarker);
1730 1748
1731 private: 1749 private:
1732 Kind kind_; 1750 Kind kind_;
1733 int index_; 1751 int index_;
1734 HSimulate* next_simulate_; 1752 HSimulate* next_simulate_;
1735 1753
1736 #ifdef DEBUG 1754 #ifdef DEBUG
1737 Handle<JSFunction> closure_; 1755 Handle<JSFunction> closure_;
1738 #endif 1756 #endif
1739 }; 1757 };
1740 1758
1741 1759
1742 class HStackCheck: public HTemplateInstruction<1> { 1760 class HStackCheck V8_FINAL : public HTemplateInstruction<1> {
1743 public: 1761 public:
1744 enum Type { 1762 enum Type {
1745 kFunctionEntry, 1763 kFunctionEntry,
1746 kBackwardsBranch 1764 kBackwardsBranch
1747 }; 1765 };
1748 1766
1749 DECLARE_INSTRUCTION_FACTORY_P2(HStackCheck, HValue*, Type); 1767 DECLARE_INSTRUCTION_FACTORY_P2(HStackCheck, HValue*, Type);
1750 1768
1751 HValue* context() { return OperandAt(0); } 1769 HValue* context() { return OperandAt(0); }
1752 1770
1753 virtual Representation RequiredInputRepresentation(int index) { 1771 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1754 return Representation::Tagged(); 1772 return Representation::Tagged();
1755 } 1773 }
1756 1774
1757 void Eliminate() { 1775 void Eliminate() {
1758 // The stack check eliminator might try to eliminate the same stack 1776 // The stack check eliminator might try to eliminate the same stack
1759 // check instruction multiple times. 1777 // check instruction multiple times.
1760 if (IsLinked()) { 1778 if (IsLinked()) {
1761 DeleteAndReplaceWith(NULL); 1779 DeleteAndReplaceWith(NULL);
1762 } 1780 }
1763 } 1781 }
(...skipping 18 matching lines...) Expand all
1782 DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return. 1800 DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return.
1783 CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value. 1801 CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value.
1784 GETTER_CALL_RETURN, // Returning from a getter, need to restore context. 1802 GETTER_CALL_RETURN, // Returning from a getter, need to restore context.
1785 SETTER_CALL_RETURN // Use the RHS of the assignment as the return value. 1803 SETTER_CALL_RETURN // Use the RHS of the assignment as the return value.
1786 }; 1804 };
1787 1805
1788 1806
1789 class HArgumentsObject; 1807 class HArgumentsObject;
1790 1808
1791 1809
1792 class HEnterInlined: public HTemplateInstruction<0> { 1810 class HEnterInlined V8_FINAL : public HTemplateInstruction<0> {
1793 public: 1811 public:
1794 static HEnterInlined* New(Zone* zone, 1812 static HEnterInlined* New(Zone* zone,
1795 HValue* context, 1813 HValue* context,
1796 Handle<JSFunction> closure, 1814 Handle<JSFunction> closure,
1797 int arguments_count, 1815 int arguments_count,
1798 FunctionLiteral* function, 1816 FunctionLiteral* function,
1799 InliningKind inlining_kind, 1817 InliningKind inlining_kind,
1800 Variable* arguments_var, 1818 Variable* arguments_var,
1801 HArgumentsObject* arguments_object, 1819 HArgumentsObject* arguments_object,
1802 bool undefined_receiver) { 1820 bool undefined_receiver) {
1803 return new(zone) HEnterInlined(closure, arguments_count, function, 1821 return new(zone) HEnterInlined(closure, arguments_count, function,
1804 inlining_kind, arguments_var, 1822 inlining_kind, arguments_var,
1805 arguments_object, undefined_receiver, zone); 1823 arguments_object, undefined_receiver, zone);
1806 } 1824 }
1807 1825
1808 void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone); 1826 void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone);
1809 ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; } 1827 ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; }
1810 1828
1811 virtual void PrintDataTo(StringStream* stream); 1829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1812 1830
1813 Handle<JSFunction> closure() const { return closure_; } 1831 Handle<JSFunction> closure() const { return closure_; }
1814 int arguments_count() const { return arguments_count_; } 1832 int arguments_count() const { return arguments_count_; }
1815 bool arguments_pushed() const { return arguments_pushed_; } 1833 bool arguments_pushed() const { return arguments_pushed_; }
1816 void set_arguments_pushed() { arguments_pushed_ = true; } 1834 void set_arguments_pushed() { arguments_pushed_ = true; }
1817 FunctionLiteral* function() const { return function_; } 1835 FunctionLiteral* function() const { return function_; }
1818 InliningKind inlining_kind() const { return inlining_kind_; } 1836 InliningKind inlining_kind() const { return inlining_kind_; }
1819 bool undefined_receiver() const { return undefined_receiver_; } 1837 bool undefined_receiver() const { return undefined_receiver_; }
1820 1838
1821 virtual Representation RequiredInputRepresentation(int index) { 1839 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1822 return Representation::None(); 1840 return Representation::None();
1823 } 1841 }
1824 1842
1825 Variable* arguments_var() { return arguments_var_; } 1843 Variable* arguments_var() { return arguments_var_; }
1826 HArgumentsObject* arguments_object() { return arguments_object_; } 1844 HArgumentsObject* arguments_object() { return arguments_object_; }
1827 1845
1828 DECLARE_CONCRETE_INSTRUCTION(EnterInlined) 1846 DECLARE_CONCRETE_INSTRUCTION(EnterInlined)
1829 1847
1830 private: 1848 private:
1831 HEnterInlined(Handle<JSFunction> closure, 1849 HEnterInlined(Handle<JSFunction> closure,
(...skipping 20 matching lines...) Expand all
1852 bool arguments_pushed_; 1870 bool arguments_pushed_;
1853 FunctionLiteral* function_; 1871 FunctionLiteral* function_;
1854 InliningKind inlining_kind_; 1872 InliningKind inlining_kind_;
1855 Variable* arguments_var_; 1873 Variable* arguments_var_;
1856 HArgumentsObject* arguments_object_; 1874 HArgumentsObject* arguments_object_;
1857 bool undefined_receiver_; 1875 bool undefined_receiver_;
1858 ZoneList<HBasicBlock*> return_targets_; 1876 ZoneList<HBasicBlock*> return_targets_;
1859 }; 1877 };
1860 1878
1861 1879
1862 class HLeaveInlined: public HTemplateInstruction<0> { 1880 class HLeaveInlined V8_FINAL : public HTemplateInstruction<0> {
1863 public: 1881 public:
1864 HLeaveInlined() { } 1882 HLeaveInlined() { }
1865 1883
1866 virtual Representation RequiredInputRepresentation(int index) { 1884 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1867 return Representation::None(); 1885 return Representation::None();
1868 } 1886 }
1869 1887
1870 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) 1888 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined)
1871 }; 1889 };
1872 1890
1873 1891
1874 class HPushArgument: public HUnaryOperation { 1892 class HPushArgument V8_FINAL : public HUnaryOperation {
1875 public: 1893 public:
1876 DECLARE_INSTRUCTION_FACTORY_P1(HPushArgument, HValue*); 1894 DECLARE_INSTRUCTION_FACTORY_P1(HPushArgument, HValue*);
1877 1895
1878 virtual Representation RequiredInputRepresentation(int index) { 1896 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1879 return Representation::Tagged(); 1897 return Representation::Tagged();
1880 } 1898 }
1881 1899
1882 HValue* argument() { return OperandAt(0); } 1900 HValue* argument() { return OperandAt(0); }
1883 1901
1884 DECLARE_CONCRETE_INSTRUCTION(PushArgument) 1902 DECLARE_CONCRETE_INSTRUCTION(PushArgument)
1885 1903
1886 private: 1904 private:
1887 explicit HPushArgument(HValue* value) : HUnaryOperation(value) { 1905 explicit HPushArgument(HValue* value) : HUnaryOperation(value) {
1888 set_representation(Representation::Tagged()); 1906 set_representation(Representation::Tagged());
1889 } 1907 }
1890 }; 1908 };
1891 1909
1892 1910
1893 class HThisFunction: public HTemplateInstruction<0> { 1911 class HThisFunction V8_FINAL : public HTemplateInstruction<0> {
1894 public: 1912 public:
1895 HThisFunction() { 1913 HThisFunction() {
1896 set_representation(Representation::Tagged()); 1914 set_representation(Representation::Tagged());
1897 SetFlag(kUseGVN); 1915 SetFlag(kUseGVN);
1898 } 1916 }
1899 1917
1900 virtual Representation RequiredInputRepresentation(int index) { 1918 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1901 return Representation::None(); 1919 return Representation::None();
1902 } 1920 }
1903 1921
1904 DECLARE_CONCRETE_INSTRUCTION(ThisFunction) 1922 DECLARE_CONCRETE_INSTRUCTION(ThisFunction)
1905 1923
1906 protected: 1924 protected:
1907 virtual bool DataEquals(HValue* other) { return true; } 1925 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1908 1926
1909 private: 1927 private:
1910 virtual bool IsDeletable() const { return true; } 1928 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
1911 }; 1929 };
1912 1930
1913 1931
1914 class HOuterContext: public HUnaryOperation { 1932 class HOuterContext V8_FINAL : public HUnaryOperation {
1915 public: 1933 public:
1916 DECLARE_INSTRUCTION_FACTORY_P1(HOuterContext, HValue*); 1934 DECLARE_INSTRUCTION_FACTORY_P1(HOuterContext, HValue*);
1917 1935
1918 DECLARE_CONCRETE_INSTRUCTION(OuterContext); 1936 DECLARE_CONCRETE_INSTRUCTION(OuterContext);
1919 1937
1920 virtual Representation RequiredInputRepresentation(int index) { 1938 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1921 return Representation::Tagged(); 1939 return Representation::Tagged();
1922 } 1940 }
1923 1941
1924 protected: 1942 protected:
1925 virtual bool DataEquals(HValue* other) { return true; } 1943 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1926 1944
1927 private: 1945 private:
1928 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { 1946 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) {
1929 set_representation(Representation::Tagged()); 1947 set_representation(Representation::Tagged());
1930 SetFlag(kUseGVN); 1948 SetFlag(kUseGVN);
1931 } 1949 }
1932 1950
1933 virtual bool IsDeletable() const { return true; } 1951 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
1934 }; 1952 };
1935 1953
1936 1954
1937 class HDeclareGlobals: public HUnaryOperation { 1955 class HDeclareGlobals V8_FINAL : public HUnaryOperation {
1938 public: 1956 public:
1939 HDeclareGlobals(HValue* context, 1957 HDeclareGlobals(HValue* context,
1940 Handle<FixedArray> pairs, 1958 Handle<FixedArray> pairs,
1941 int flags) 1959 int flags)
1942 : HUnaryOperation(context), 1960 : HUnaryOperation(context),
1943 pairs_(pairs), 1961 pairs_(pairs),
1944 flags_(flags) { 1962 flags_(flags) {
1945 set_representation(Representation::Tagged()); 1963 set_representation(Representation::Tagged());
1946 SetAllSideEffects(); 1964 SetAllSideEffects();
1947 } 1965 }
1948 1966
1949 static HDeclareGlobals* New(Zone* zone, 1967 static HDeclareGlobals* New(Zone* zone,
1950 HValue* context, 1968 HValue* context,
1951 Handle<FixedArray> pairs, 1969 Handle<FixedArray> pairs,
1952 int flags) { 1970 int flags) {
1953 return new(zone) HDeclareGlobals(context, pairs, flags); 1971 return new(zone) HDeclareGlobals(context, pairs, flags);
1954 } 1972 }
1955 1973
1956 HValue* context() { return OperandAt(0); } 1974 HValue* context() { return OperandAt(0); }
1957 Handle<FixedArray> pairs() const { return pairs_; } 1975 Handle<FixedArray> pairs() const { return pairs_; }
1958 int flags() const { return flags_; } 1976 int flags() const { return flags_; }
1959 1977
1960 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals) 1978 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals)
1961 1979
1962 virtual Representation RequiredInputRepresentation(int index) { 1980 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1963 return Representation::Tagged(); 1981 return Representation::Tagged();
1964 } 1982 }
1965 1983
1966 private: 1984 private:
1967 Handle<FixedArray> pairs_; 1985 Handle<FixedArray> pairs_;
1968 int flags_; 1986 int flags_;
1969 }; 1987 };
1970 1988
1971 1989
1972 class HGlobalObject: public HUnaryOperation { 1990 class HGlobalObject V8_FINAL : public HUnaryOperation {
1973 public: 1991 public:
1974 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { 1992 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
1975 set_representation(Representation::Tagged()); 1993 set_representation(Representation::Tagged());
1976 SetFlag(kUseGVN); 1994 SetFlag(kUseGVN);
1977 } 1995 }
1978 1996
1979 static HGlobalObject* New(Zone* zone, HValue* context) { 1997 static HGlobalObject* New(Zone* zone, HValue* context) {
1980 return new(zone) HGlobalObject(context); 1998 return new(zone) HGlobalObject(context);
1981 } 1999 }
1982 2000
1983 DECLARE_CONCRETE_INSTRUCTION(GlobalObject) 2001 DECLARE_CONCRETE_INSTRUCTION(GlobalObject)
1984 2002
1985 virtual Representation RequiredInputRepresentation(int index) { 2003 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
1986 return Representation::Tagged(); 2004 return Representation::Tagged();
1987 } 2005 }
1988 2006
1989 protected: 2007 protected:
1990 virtual bool DataEquals(HValue* other) { return true; } 2008 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
1991 2009
1992 private: 2010 private:
1993 virtual bool IsDeletable() const { return true; } 2011 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
1994 }; 2012 };
1995 2013
1996 2014
1997 class HGlobalReceiver: public HUnaryOperation { 2015 class HGlobalReceiver V8_FINAL : public HUnaryOperation {
1998 public: 2016 public:
1999 DECLARE_INSTRUCTION_FACTORY_P1(HGlobalReceiver, HValue*); 2017 DECLARE_INSTRUCTION_FACTORY_P1(HGlobalReceiver, HValue*);
2000 2018
2001 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) 2019 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver)
2002 2020
2003 virtual Representation RequiredInputRepresentation(int index) { 2021 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2004 return Representation::Tagged(); 2022 return Representation::Tagged();
2005 } 2023 }
2006 2024
2007 protected: 2025 protected:
2008 virtual bool DataEquals(HValue* other) { return true; } 2026 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2009 2027
2010 private: 2028 private:
2011 explicit HGlobalReceiver(HValue* global_object) 2029 explicit HGlobalReceiver(HValue* global_object)
2012 : HUnaryOperation(global_object) { 2030 : HUnaryOperation(global_object) {
2013 set_representation(Representation::Tagged()); 2031 set_representation(Representation::Tagged());
2014 SetFlag(kUseGVN); 2032 SetFlag(kUseGVN);
2015 } 2033 }
2016 2034
2017 virtual bool IsDeletable() const { return true; } 2035 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2018 }; 2036 };
2019 2037
2020 2038
2021 template <int V> 2039 template <int V>
2022 class HCall: public HTemplateInstruction<V> { 2040 class HCall : public HTemplateInstruction<V> {
2023 public: 2041 public:
2024 // The argument count includes the receiver. 2042 // The argument count includes the receiver.
2025 explicit HCall<V>(int argument_count) : argument_count_(argument_count) { 2043 explicit HCall<V>(int argument_count) : argument_count_(argument_count) {
2026 this->set_representation(Representation::Tagged()); 2044 this->set_representation(Representation::Tagged());
2027 this->SetAllSideEffects(); 2045 this->SetAllSideEffects();
2028 } 2046 }
2029 2047
2030 virtual HType CalculateInferredType() { return HType::Tagged(); } 2048 virtual HType CalculateInferredType() V8_FINAL V8_OVERRIDE {
2049 return HType::Tagged();
2050 }
2031 2051
2032 virtual int argument_count() const { return argument_count_; } 2052 virtual int argument_count() const { return argument_count_; }
2033 2053
2034 virtual bool IsCall() { return true; } 2054 virtual bool IsCall() V8_FINAL V8_OVERRIDE { return true; }
2035 2055
2036 private: 2056 private:
2037 int argument_count_; 2057 int argument_count_;
2038 }; 2058 };
2039 2059
2040 2060
2041 class HUnaryCall: public HCall<1> { 2061 class HUnaryCall : public HCall<1> {
2042 public: 2062 public:
2043 HUnaryCall(HValue* value, int argument_count) 2063 HUnaryCall(HValue* value, int argument_count)
2044 : HCall<1>(argument_count) { 2064 : HCall<1>(argument_count) {
2045 SetOperandAt(0, value); 2065 SetOperandAt(0, value);
2046 } 2066 }
2047 2067
2048 virtual Representation RequiredInputRepresentation(int index) { 2068 virtual Representation RequiredInputRepresentation(
2069 int index) V8_FINAL V8_OVERRIDE {
2049 return Representation::Tagged(); 2070 return Representation::Tagged();
2050 } 2071 }
2051 2072
2052 virtual void PrintDataTo(StringStream* stream); 2073 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2053 2074
2054 HValue* value() { return OperandAt(0); } 2075 HValue* value() { return OperandAt(0); }
2055 }; 2076 };
2056 2077
2057 2078
2058 class HBinaryCall: public HCall<2> { 2079 class HBinaryCall : public HCall<2> {
2059 public: 2080 public:
2060 HBinaryCall(HValue* first, HValue* second, int argument_count) 2081 HBinaryCall(HValue* first, HValue* second, int argument_count)
2061 : HCall<2>(argument_count) { 2082 : HCall<2>(argument_count) {
2062 SetOperandAt(0, first); 2083 SetOperandAt(0, first);
2063 SetOperandAt(1, second); 2084 SetOperandAt(1, second);
2064 } 2085 }
2065 2086
2066 virtual void PrintDataTo(StringStream* stream); 2087 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2067 2088
2068 virtual Representation RequiredInputRepresentation(int index) { 2089 virtual Representation RequiredInputRepresentation(
2090 int index) V8_FINAL V8_OVERRIDE {
2069 return Representation::Tagged(); 2091 return Representation::Tagged();
2070 } 2092 }
2071 2093
2072 HValue* first() { return OperandAt(0); } 2094 HValue* first() { return OperandAt(0); }
2073 HValue* second() { return OperandAt(1); } 2095 HValue* second() { return OperandAt(1); }
2074 }; 2096 };
2075 2097
2076 2098
2077 class HInvokeFunction: public HBinaryCall { 2099 class HInvokeFunction V8_FINAL : public HBinaryCall {
2078 public: 2100 public:
2079 HInvokeFunction(HValue* context, HValue* function, int argument_count) 2101 HInvokeFunction(HValue* context, HValue* function, int argument_count)
2080 : HBinaryCall(context, function, argument_count) { 2102 : HBinaryCall(context, function, argument_count) {
2081 } 2103 }
2082 2104
2083 static HInvokeFunction* New(Zone* zone, 2105 static HInvokeFunction* New(Zone* zone,
2084 HValue* context, 2106 HValue* context,
2085 HValue* function, 2107 HValue* function,
2086 int argument_count) { 2108 int argument_count) {
2087 return new(zone) HInvokeFunction(context, function, argument_count); 2109 return new(zone) HInvokeFunction(context, function, argument_count);
(...skipping 11 matching lines...) Expand all
2099 2121
2100 static HInvokeFunction* New(Zone* zone, 2122 static HInvokeFunction* New(Zone* zone,
2101 HValue* context, 2123 HValue* context,
2102 HValue* function, 2124 HValue* function,
2103 Handle<JSFunction> known_function, 2125 Handle<JSFunction> known_function,
2104 int argument_count) { 2126 int argument_count) {
2105 return new(zone) HInvokeFunction(context, function, 2127 return new(zone) HInvokeFunction(context, function,
2106 known_function, argument_count); 2128 known_function, argument_count);
2107 } 2129 }
2108 2130
2109 virtual Representation RequiredInputRepresentation(int index) {
2110 return Representation::Tagged();
2111 }
2112
2113 HValue* context() { return first(); } 2131 HValue* context() { return first(); }
2114 HValue* function() { return second(); } 2132 HValue* function() { return second(); }
2115 Handle<JSFunction> known_function() { return known_function_; } 2133 Handle<JSFunction> known_function() { return known_function_; }
2116 int formal_parameter_count() const { return formal_parameter_count_; } 2134 int formal_parameter_count() const { return formal_parameter_count_; }
2117 2135
2118 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) 2136 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction)
2119 2137
2120 private: 2138 private:
2121 Handle<JSFunction> known_function_; 2139 Handle<JSFunction> known_function_;
2122 int formal_parameter_count_; 2140 int formal_parameter_count_;
2123 }; 2141 };
2124 2142
2125 2143
2126 class HCallConstantFunction: public HCall<0> { 2144 class HCallConstantFunction V8_FINAL : public HCall<0> {
2127 public: 2145 public:
2128 HCallConstantFunction(Handle<JSFunction> function, int argument_count) 2146 HCallConstantFunction(Handle<JSFunction> function, int argument_count)
2129 : HCall<0>(argument_count), 2147 : HCall<0>(argument_count),
2130 function_(function), 2148 function_(function),
2131 formal_parameter_count_(function->shared()->formal_parameter_count()) {} 2149 formal_parameter_count_(function->shared()->formal_parameter_count()) {}
2132 2150
2133 Handle<JSFunction> function() const { return function_; } 2151 Handle<JSFunction> function() const { return function_; }
2134 int formal_parameter_count() const { return formal_parameter_count_; } 2152 int formal_parameter_count() const { return formal_parameter_count_; }
2135 2153
2136 bool IsApplyFunction() const { 2154 bool IsApplyFunction() const {
2137 return function_->code() == 2155 return function_->code() ==
2138 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply); 2156 Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply);
2139 } 2157 }
2140 2158
2141 virtual void PrintDataTo(StringStream* stream); 2159 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2142 2160
2143 virtual Representation RequiredInputRepresentation(int index) { 2161 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2144 return Representation::None(); 2162 return Representation::None();
2145 } 2163 }
2146 2164
2147 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction) 2165 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction)
2148 2166
2149 private: 2167 private:
2150 Handle<JSFunction> function_; 2168 Handle<JSFunction> function_;
2151 int formal_parameter_count_; 2169 int formal_parameter_count_;
2152 }; 2170 };
2153 2171
2154 2172
2155 class HCallKeyed: public HBinaryCall { 2173 class HCallKeyed V8_FINAL : public HBinaryCall {
2156 public: 2174 public:
2157 HCallKeyed(HValue* context, HValue* key, int argument_count) 2175 HCallKeyed(HValue* context, HValue* key, int argument_count)
2158 : HBinaryCall(context, key, argument_count) { 2176 : HBinaryCall(context, key, argument_count) {
2159 } 2177 }
2160 2178
2161 virtual Representation RequiredInputRepresentation(int index) {
2162 return Representation::Tagged();
2163 }
2164
2165 HValue* context() { return first(); } 2179 HValue* context() { return first(); }
2166 HValue* key() { return second(); } 2180 HValue* key() { return second(); }
2167 2181
2168 DECLARE_CONCRETE_INSTRUCTION(CallKeyed) 2182 DECLARE_CONCRETE_INSTRUCTION(CallKeyed)
2169 }; 2183 };
2170 2184
2171 2185
2172 class HCallNamed: public HUnaryCall { 2186 class HCallNamed V8_FINAL : public HUnaryCall {
2173 public: 2187 public:
2174 HCallNamed(HValue* context, Handle<String> name, int argument_count) 2188 HCallNamed(HValue* context, Handle<String> name, int argument_count)
2175 : HUnaryCall(context, argument_count), name_(name) { 2189 : HUnaryCall(context, argument_count), name_(name) {
2176 } 2190 }
2177 2191
2178 virtual void PrintDataTo(StringStream* stream); 2192 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2179 2193
2180 HValue* context() { return value(); } 2194 HValue* context() { return value(); }
2181 Handle<String> name() const { return name_; } 2195 Handle<String> name() const { return name_; }
2182 2196
2183 DECLARE_CONCRETE_INSTRUCTION(CallNamed) 2197 DECLARE_CONCRETE_INSTRUCTION(CallNamed)
2184 2198
2185 virtual Representation RequiredInputRepresentation(int index) {
2186 return Representation::Tagged();
2187 }
2188
2189 private: 2199 private:
2190 Handle<String> name_; 2200 Handle<String> name_;
2191 }; 2201 };
2192 2202
2193 2203
2194 class HCallFunction: public HBinaryCall { 2204 class HCallFunction V8_FINAL : public HBinaryCall {
2195 public: 2205 public:
2196 HCallFunction(HValue* context, HValue* function, int argument_count) 2206 HCallFunction(HValue* context, HValue* function, int argument_count)
2197 : HBinaryCall(context, function, argument_count) { 2207 : HBinaryCall(context, function, argument_count) {
2198 } 2208 }
2199 2209
2200 static HCallFunction* New(Zone* zone, 2210 static HCallFunction* New(Zone* zone,
2201 HValue* context, 2211 HValue* context,
2202 HValue* function, 2212 HValue* function,
2203 int argument_count) { 2213 int argument_count) {
2204 return new(zone) HCallFunction(context, function, argument_count); 2214 return new(zone) HCallFunction(context, function, argument_count);
2205 } 2215 }
2206 2216
2207 HValue* context() { return first(); } 2217 HValue* context() { return first(); }
2208 HValue* function() { return second(); } 2218 HValue* function() { return second(); }
2209 2219
2210 virtual Representation RequiredInputRepresentation(int index) {
2211 return Representation::Tagged();
2212 }
2213
2214 DECLARE_CONCRETE_INSTRUCTION(CallFunction) 2220 DECLARE_CONCRETE_INSTRUCTION(CallFunction)
2215 }; 2221 };
2216 2222
2217 2223
2218 class HCallGlobal: public HUnaryCall { 2224 class HCallGlobal V8_FINAL : public HUnaryCall {
2219 public: 2225 public:
2220 HCallGlobal(HValue* context, Handle<String> name, int argument_count) 2226 HCallGlobal(HValue* context, Handle<String> name, int argument_count)
2221 : HUnaryCall(context, argument_count), name_(name) { 2227 : HUnaryCall(context, argument_count), name_(name) {
2222 } 2228 }
2223 2229
2224 static HCallGlobal* New(Zone* zone, 2230 static HCallGlobal* New(Zone* zone,
2225 HValue* context, 2231 HValue* context,
2226 Handle<String> name, 2232 Handle<String> name,
2227 int argument_count) { 2233 int argument_count) {
2228 return new(zone) HCallGlobal(context, name, argument_count); 2234 return new(zone) HCallGlobal(context, name, argument_count);
2229 } 2235 }
2230 2236
2231 virtual void PrintDataTo(StringStream* stream); 2237 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2232 2238
2233 HValue* context() { return value(); } 2239 HValue* context() { return value(); }
2234 Handle<String> name() const { return name_; } 2240 Handle<String> name() const { return name_; }
2235 2241
2236 virtual Representation RequiredInputRepresentation(int index) {
2237 return Representation::Tagged();
2238 }
2239
2240 DECLARE_CONCRETE_INSTRUCTION(CallGlobal) 2242 DECLARE_CONCRETE_INSTRUCTION(CallGlobal)
2241 2243
2242 private: 2244 private:
2243 Handle<String> name_; 2245 Handle<String> name_;
2244 }; 2246 };
2245 2247
2246 2248
2247 class HCallKnownGlobal: public HCall<0> { 2249 class HCallKnownGlobal V8_FINAL : public HCall<0> {
2248 public: 2250 public:
2249 HCallKnownGlobal(Handle<JSFunction> target, int argument_count) 2251 HCallKnownGlobal(Handle<JSFunction> target, int argument_count)
2250 : HCall<0>(argument_count), 2252 : HCall<0>(argument_count),
2251 target_(target), 2253 target_(target),
2252 formal_parameter_count_(target->shared()->formal_parameter_count()) { } 2254 formal_parameter_count_(target->shared()->formal_parameter_count()) { }
2253 2255
2254 virtual void PrintDataTo(StringStream* stream); 2256 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2255 2257
2256 Handle<JSFunction> target() const { return target_; } 2258 Handle<JSFunction> target() const { return target_; }
2257 int formal_parameter_count() const { return formal_parameter_count_; } 2259 int formal_parameter_count() const { return formal_parameter_count_; }
2258 2260
2259 virtual Representation RequiredInputRepresentation(int index) { 2261 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2260 return Representation::None(); 2262 return Representation::None();
2261 } 2263 }
2262 2264
2263 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal) 2265 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal)
2264 2266
2265 private: 2267 private:
2266 Handle<JSFunction> target_; 2268 Handle<JSFunction> target_;
2267 int formal_parameter_count_; 2269 int formal_parameter_count_;
2268 }; 2270 };
2269 2271
2270 2272
2271 class HCallNew: public HBinaryCall { 2273 class HCallNew V8_FINAL : public HBinaryCall {
2272 public: 2274 public:
2273 HCallNew(HValue* context, HValue* constructor, int argument_count) 2275 HCallNew(HValue* context, HValue* constructor, int argument_count)
2274 : HBinaryCall(context, constructor, argument_count) { 2276 : HBinaryCall(context, constructor, argument_count) {}
2275 }
2276
2277 virtual Representation RequiredInputRepresentation(int index) {
2278 return Representation::Tagged();
2279 }
2280 2277
2281 HValue* context() { return first(); } 2278 HValue* context() { return first(); }
2282 HValue* constructor() { return second(); } 2279 HValue* constructor() { return second(); }
2283 2280
2284 DECLARE_CONCRETE_INSTRUCTION(CallNew) 2281 DECLARE_CONCRETE_INSTRUCTION(CallNew)
2285 }; 2282 };
2286 2283
2287 2284
2288 class HCallNewArray: public HCallNew { 2285 class HCallNewArray V8_FINAL : public HBinaryCall {
2289 public: 2286 public:
2290 HCallNewArray(HValue* context, HValue* constructor, int argument_count, 2287 HCallNewArray(HValue* context, HValue* constructor, int argument_count,
2291 Handle<Cell> type_cell, ElementsKind elements_kind) 2288 Handle<Cell> type_cell, ElementsKind elements_kind)
2292 : HCallNew(context, constructor, argument_count), 2289 : HBinaryCall(context, constructor, argument_count),
2293 elements_kind_(elements_kind), 2290 elements_kind_(elements_kind),
2294 type_cell_(type_cell) {} 2291 type_cell_(type_cell) {}
2295 2292
2296 virtual void PrintDataTo(StringStream* stream); 2293 HValue* context() { return first(); }
2294 HValue* constructor() { return second(); }
2295
2296 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2297 2297
2298 Handle<Cell> property_cell() const { 2298 Handle<Cell> property_cell() const {
2299 return type_cell_; 2299 return type_cell_;
2300 } 2300 }
2301 2301
2302 ElementsKind elements_kind() const { return elements_kind_; } 2302 ElementsKind elements_kind() const { return elements_kind_; }
2303 2303
2304 DECLARE_CONCRETE_INSTRUCTION(CallNewArray) 2304 DECLARE_CONCRETE_INSTRUCTION(CallNewArray)
2305 2305
2306 private: 2306 private:
2307 ElementsKind elements_kind_; 2307 ElementsKind elements_kind_;
2308 Handle<Cell> type_cell_; 2308 Handle<Cell> type_cell_;
2309 }; 2309 };
2310 2310
2311 2311
2312 class HCallRuntime: public HCall<1> { 2312 class HCallRuntime V8_FINAL : public HCall<1> {
2313 public: 2313 public:
2314 static HCallRuntime* New(Zone* zone, 2314 static HCallRuntime* New(Zone* zone,
2315 HValue* context, 2315 HValue* context,
2316 Handle<String> name, 2316 Handle<String> name,
2317 const Runtime::Function* c_function, 2317 const Runtime::Function* c_function,
2318 int argument_count) { 2318 int argument_count) {
2319 return new(zone) HCallRuntime(context, name, c_function, argument_count); 2319 return new(zone) HCallRuntime(context, name, c_function, argument_count);
2320 } 2320 }
2321 2321
2322 virtual void PrintDataTo(StringStream* stream); 2322 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2323 2323
2324 HValue* context() { return OperandAt(0); } 2324 HValue* context() { return OperandAt(0); }
2325 const Runtime::Function* function() const { return c_function_; } 2325 const Runtime::Function* function() const { return c_function_; }
2326 Handle<String> name() const { return name_; } 2326 Handle<String> name() const { return name_; }
2327 2327
2328 virtual Representation RequiredInputRepresentation(int index) { 2328 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2329 return Representation::Tagged(); 2329 return Representation::Tagged();
2330 } 2330 }
2331 2331
2332 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) 2332 DECLARE_CONCRETE_INSTRUCTION(CallRuntime)
2333 2333
2334 private: 2334 private:
2335 HCallRuntime(HValue* context, 2335 HCallRuntime(HValue* context,
2336 Handle<String> name, 2336 Handle<String> name,
2337 const Runtime::Function* c_function, 2337 const Runtime::Function* c_function,
2338 int argument_count) 2338 int argument_count)
2339 : HCall<1>(argument_count), c_function_(c_function), name_(name) { 2339 : HCall<1>(argument_count), c_function_(c_function), name_(name) {
2340 SetOperandAt(0, context); 2340 SetOperandAt(0, context);
2341 } 2341 }
2342 2342
2343 const Runtime::Function* c_function_; 2343 const Runtime::Function* c_function_;
2344 Handle<String> name_; 2344 Handle<String> name_;
2345 }; 2345 };
2346 2346
2347 2347
2348 class HMapEnumLength: public HUnaryOperation { 2348 class HMapEnumLength V8_FINAL : public HUnaryOperation {
2349 public: 2349 public:
2350 DECLARE_INSTRUCTION_FACTORY_P1(HMapEnumLength, HValue*); 2350 DECLARE_INSTRUCTION_FACTORY_P1(HMapEnumLength, HValue*);
2351 2351
2352 virtual Representation RequiredInputRepresentation(int index) { 2352 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2353 return Representation::Tagged(); 2353 return Representation::Tagged();
2354 } 2354 }
2355 2355
2356 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) 2356 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength)
2357 2357
2358 protected: 2358 protected:
2359 virtual bool DataEquals(HValue* other) { return true; } 2359 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2360 2360
2361 private: 2361 private:
2362 explicit HMapEnumLength(HValue* value) 2362 explicit HMapEnumLength(HValue* value)
2363 : HUnaryOperation(value, HType::Smi()) { 2363 : HUnaryOperation(value, HType::Smi()) {
2364 set_representation(Representation::Smi()); 2364 set_representation(Representation::Smi());
2365 SetFlag(kUseGVN); 2365 SetFlag(kUseGVN);
2366 SetGVNFlag(kDependsOnMaps); 2366 SetGVNFlag(kDependsOnMaps);
2367 } 2367 }
2368 2368
2369 virtual bool IsDeletable() const { return true; } 2369 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2370 }; 2370 };
2371 2371
2372 2372
2373 class HElementsKind: public HUnaryOperation { 2373 class HElementsKind V8_FINAL : public HUnaryOperation {
2374 public: 2374 public:
2375 explicit HElementsKind(HValue* value) : HUnaryOperation(value) { 2375 explicit HElementsKind(HValue* value) : HUnaryOperation(value) {
2376 set_representation(Representation::Integer32()); 2376 set_representation(Representation::Integer32());
2377 SetFlag(kUseGVN); 2377 SetFlag(kUseGVN);
2378 SetGVNFlag(kDependsOnElementsKind); 2378 SetGVNFlag(kDependsOnElementsKind);
2379 } 2379 }
2380 2380
2381 virtual Representation RequiredInputRepresentation(int index) { 2381 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2382 return Representation::Tagged(); 2382 return Representation::Tagged();
2383 } 2383 }
2384 2384
2385 DECLARE_CONCRETE_INSTRUCTION(ElementsKind) 2385 DECLARE_CONCRETE_INSTRUCTION(ElementsKind)
2386 2386
2387 protected: 2387 protected:
2388 virtual bool DataEquals(HValue* other) { return true; } 2388 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2389 2389
2390 private: 2390 private:
2391 virtual bool IsDeletable() const { return true; } 2391 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2392 }; 2392 };
2393 2393
2394 2394
2395 class HUnaryMathOperation: public HTemplateInstruction<2> { 2395 class HUnaryMathOperation V8_FINAL : public HTemplateInstruction<2> {
2396 public: 2396 public:
2397 static HInstruction* New(Zone* zone, 2397 static HInstruction* New(Zone* zone,
2398 HValue* context, 2398 HValue* context,
2399 HValue* value, 2399 HValue* value,
2400 BuiltinFunctionId op); 2400 BuiltinFunctionId op);
2401 2401
2402 HValue* context() { return OperandAt(0); } 2402 HValue* context() { return OperandAt(0); }
2403 HValue* value() { return OperandAt(1); } 2403 HValue* value() { return OperandAt(1); }
2404 2404
2405 virtual void PrintDataTo(StringStream* stream); 2405 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2406 2406
2407 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2407 virtual HValue* EnsureAndPropagateNotMinusZero(
2408 BitVector* visited) V8_OVERRIDE;
2408 2409
2409 virtual Representation RequiredInputRepresentation(int index) { 2410 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2410 if (index == 0) { 2411 if (index == 0) {
2411 return Representation::Tagged(); 2412 return Representation::Tagged();
2412 } else { 2413 } else {
2413 switch (op_) { 2414 switch (op_) {
2414 case kMathFloor: 2415 case kMathFloor:
2415 case kMathRound: 2416 case kMathRound:
2416 case kMathSqrt: 2417 case kMathSqrt:
2417 case kMathPowHalf: 2418 case kMathPowHalf:
2418 case kMathLog: 2419 case kMathLog:
2419 case kMathExp: 2420 case kMathExp:
2420 case kMathSin: 2421 case kMathSin:
2421 case kMathCos: 2422 case kMathCos:
2422 case kMathTan: 2423 case kMathTan:
2423 return Representation::Double(); 2424 return Representation::Double();
2424 case kMathAbs: 2425 case kMathAbs:
2425 return representation(); 2426 return representation();
2426 default: 2427 default:
2427 UNREACHABLE(); 2428 UNREACHABLE();
2428 return Representation::None(); 2429 return Representation::None();
2429 } 2430 }
2430 } 2431 }
2431 } 2432 }
2432 2433
2433 virtual Range* InferRange(Zone* zone); 2434 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
2434 2435
2435 virtual HValue* Canonicalize(); 2436 virtual HValue* Canonicalize() V8_OVERRIDE;
2436 virtual Representation RepresentationFromInputs(); 2437 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
2437 2438
2438 BuiltinFunctionId op() const { return op_; } 2439 BuiltinFunctionId op() const { return op_; }
2439 const char* OpName() const; 2440 const char* OpName() const;
2440 2441
2441 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) 2442 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation)
2442 2443
2443 protected: 2444 protected:
2444 virtual bool DataEquals(HValue* other) { 2445 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2445 HUnaryMathOperation* b = HUnaryMathOperation::cast(other); 2446 HUnaryMathOperation* b = HUnaryMathOperation::cast(other);
2446 return op_ == b->op(); 2447 return op_ == b->op();
2447 } 2448 }
2448 2449
2449 private: 2450 private:
2450 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op) 2451 HUnaryMathOperation(HValue* context, HValue* value, BuiltinFunctionId op)
2451 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) { 2452 : HTemplateInstruction<2>(HType::TaggedNumber()), op_(op) {
2452 SetOperandAt(0, context); 2453 SetOperandAt(0, context);
2453 SetOperandAt(1, value); 2454 SetOperandAt(1, value);
2454 switch (op) { 2455 switch (op) {
2455 case kMathFloor: 2456 case kMathFloor:
2456 case kMathRound: 2457 case kMathRound:
2457 // TODO(verwaest): Set representation to flexible int starting as smi.
2458 set_representation(Representation::Integer32()); 2458 set_representation(Representation::Integer32());
2459 break; 2459 break;
2460 case kMathAbs: 2460 case kMathAbs:
2461 // Not setting representation here: it is None intentionally. 2461 // Not setting representation here: it is None intentionally.
2462 SetFlag(kFlexibleRepresentation); 2462 SetFlag(kFlexibleRepresentation);
2463 // TODO(svenpanne) This flag is actually only needed if representation() 2463 // TODO(svenpanne) This flag is actually only needed if representation()
2464 // is tagged, and not when it is an unboxed double or unboxed integer. 2464 // is tagged, and not when it is an unboxed double or unboxed integer.
2465 SetGVNFlag(kChangesNewSpacePromotion); 2465 SetGVNFlag(kChangesNewSpacePromotion);
2466 break; 2466 break;
2467 case kMathLog: 2467 case kMathLog:
2468 case kMathSin: 2468 case kMathSin:
2469 case kMathCos: 2469 case kMathCos:
2470 case kMathTan: 2470 case kMathTan:
2471 set_representation(Representation::Double()); 2471 set_representation(Representation::Double());
2472 // These operations use the TranscendentalCache, so they may allocate. 2472 // These operations use the TranscendentalCache, so they may allocate.
2473 SetGVNFlag(kChangesNewSpacePromotion); 2473 SetGVNFlag(kChangesNewSpacePromotion);
2474 break; 2474 break;
2475 case kMathExp: 2475 case kMathExp:
2476 case kMathSqrt: 2476 case kMathSqrt:
2477 case kMathPowHalf: 2477 case kMathPowHalf:
2478 set_representation(Representation::Double()); 2478 set_representation(Representation::Double());
2479 break; 2479 break;
2480 default: 2480 default:
2481 UNREACHABLE(); 2481 UNREACHABLE();
2482 } 2482 }
2483 SetFlag(kUseGVN); 2483 SetFlag(kUseGVN);
2484 SetFlag(kAllowUndefinedAsNaN); 2484 SetFlag(kAllowUndefinedAsNaN);
2485 } 2485 }
2486 2486
2487 virtual bool IsDeletable() const { return true; } 2487 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2488 2488
2489 BuiltinFunctionId op_; 2489 BuiltinFunctionId op_;
2490 }; 2490 };
2491 2491
2492 2492
2493 class HLoadExternalArrayPointer: public HUnaryOperation { 2493 class HLoadExternalArrayPointer V8_FINAL : public HUnaryOperation {
2494 public: 2494 public:
2495 DECLARE_INSTRUCTION_FACTORY_P1(HLoadExternalArrayPointer, HValue*); 2495 DECLARE_INSTRUCTION_FACTORY_P1(HLoadExternalArrayPointer, HValue*);
2496 2496
2497 virtual Representation RequiredInputRepresentation(int index) { 2497 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2498 return Representation::Tagged(); 2498 return Representation::Tagged();
2499 } 2499 }
2500 2500
2501 virtual HType CalculateInferredType() { 2501 virtual HType CalculateInferredType() V8_OVERRIDE {
2502 return HType::None(); 2502 return HType::None();
2503 } 2503 }
2504 2504
2505 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) 2505 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer)
2506 2506
2507 protected: 2507 protected:
2508 virtual bool DataEquals(HValue* other) { return true; } 2508 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2509 2509
2510 private: 2510 private:
2511 explicit HLoadExternalArrayPointer(HValue* value) 2511 explicit HLoadExternalArrayPointer(HValue* value)
2512 : HUnaryOperation(value) { 2512 : HUnaryOperation(value) {
2513 set_representation(Representation::External()); 2513 set_representation(Representation::External());
2514 // The result of this instruction is idempotent as long as its inputs don't 2514 // The result of this instruction is idempotent as long as its inputs don't
2515 // change. The external array of a specialized array elements object cannot 2515 // change. The external array of a specialized array elements object cannot
2516 // change once set, so it's no necessary to introduce any additional 2516 // change once set, so it's no necessary to introduce any additional
2517 // dependencies on top of the inputs. 2517 // dependencies on top of the inputs.
2518 SetFlag(kUseGVN); 2518 SetFlag(kUseGVN);
2519 } 2519 }
2520 2520
2521 virtual bool IsDeletable() const { return true; } 2521 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
2522 }; 2522 };
2523 2523
2524 2524
2525 class HCheckMaps: public HTemplateInstruction<2> { 2525 class HCheckMaps V8_FINAL : public HTemplateInstruction<2> {
2526 public: 2526 public:
2527 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value, 2527 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value,
2528 Handle<Map> map, CompilationInfo* info, 2528 Handle<Map> map, CompilationInfo* info,
2529 HValue *typecheck = NULL); 2529 HValue *typecheck = NULL);
2530 static HCheckMaps* New(Zone* zone, HValue* context, 2530 static HCheckMaps* New(Zone* zone, HValue* context,
2531 HValue* value, SmallMapList* maps, 2531 HValue* value, SmallMapList* maps,
2532 HValue *typecheck = NULL) { 2532 HValue *typecheck = NULL) {
2533 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); 2533 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2534 for (int i = 0; i < maps->length(); i++) { 2534 for (int i = 0; i < maps->length(); i++) {
2535 check_map->map_set_.Add(maps->at(i), zone); 2535 check_map->Add(maps->at(i), zone);
2536 check_map->has_migration_target_ |= maps->at(i)->is_migration_target();
2537 } 2536 }
2538 check_map->map_set_.Sort(); 2537 check_map->map_set_.Sort();
2539 return check_map; 2538 return check_map;
2540 } 2539 }
2541 2540
2542 bool CanOmitMapChecks() { return omit_; } 2541 bool CanOmitMapChecks() { return omit_; }
2543 2542
2544 virtual bool HasEscapingOperandAt(int index) { return false; } 2543 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
2545 virtual Representation RequiredInputRepresentation(int index) { 2544 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2546 return Representation::Tagged(); 2545 return Representation::Tagged();
2547 } 2546 }
2548 virtual void HandleSideEffectDominator(GVNFlag side_effect, 2547 virtual void HandleSideEffectDominator(GVNFlag side_effect,
2549 HValue* dominator); 2548 HValue* dominator) V8_OVERRIDE;
2550 virtual void PrintDataTo(StringStream* stream); 2549 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2551 2550
2552 HValue* value() { return OperandAt(0); } 2551 HValue* value() { return OperandAt(0); }
2553 SmallMapList* map_set() { return &map_set_; } 2552 SmallMapList* map_set() { return &map_set_; }
2554 2553
2555 bool has_migration_target() { 2554 bool has_migration_target() {
2556 return has_migration_target_; 2555 return has_migration_target_;
2557 } 2556 }
2558 2557
2559 virtual void FinalizeUniqueValueId(); 2558 virtual void FinalizeUniqueValueId() V8_OVERRIDE;
2560 2559
2561 DECLARE_CONCRETE_INSTRUCTION(CheckMaps) 2560 DECLARE_CONCRETE_INSTRUCTION(CheckMaps)
2562 2561
2563 protected: 2562 protected:
2564 virtual bool DataEquals(HValue* other) { 2563 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2565 ASSERT_EQ(map_set_.length(), map_unique_ids_.length()); 2564 ASSERT_EQ(map_set_.length(), map_unique_ids_.length());
2566 HCheckMaps* b = HCheckMaps::cast(other); 2565 HCheckMaps* b = HCheckMaps::cast(other);
2567 // Relies on the fact that map_set has been sorted before. 2566 // Relies on the fact that map_set has been sorted before.
2568 if (map_unique_ids_.length() != b->map_unique_ids_.length()) { 2567 if (map_unique_ids_.length() != b->map_unique_ids_.length()) {
2569 return false; 2568 return false;
2570 } 2569 }
2571 for (int i = 0; i < map_unique_ids_.length(); i++) { 2570 for (int i = 0; i < map_unique_ids_.length(); i++) {
2572 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) { 2571 if (map_unique_ids_.at(i) != b->map_unique_ids_.at(i)) {
2573 return false; 2572 return false;
2574 } 2573 }
2575 } 2574 }
2576 return true; 2575 return true;
2577 } 2576 }
2578 2577
2579 private: 2578 private:
2579 void Add(Handle<Map> map, Zone* zone) {
2580 map_set_.Add(map, zone);
2581 if (!has_migration_target_ && map->is_migration_target()) {
2582 has_migration_target_ = true;
2583 SetGVNFlag(kChangesNewSpacePromotion);
2584 }
2585 }
2586
2580 // Clients should use one of the static New* methods above. 2587 // Clients should use one of the static New* methods above.
2581 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck) 2588 HCheckMaps(HValue* value, Zone *zone, HValue* typecheck)
2582 : HTemplateInstruction<2>(value->type()), 2589 : HTemplateInstruction<2>(value->type()),
2583 omit_(false), has_migration_target_(false), map_unique_ids_(0, zone) { 2590 omit_(false), has_migration_target_(false), map_unique_ids_(0, zone) {
2584 SetOperandAt(0, value); 2591 SetOperandAt(0, value);
2585 // Use the object value for the dependency if NULL is passed. 2592 // Use the object value for the dependency if NULL is passed.
2586 // TODO(titzer): do GVN flags already express this dependency? 2593 // TODO(titzer): do GVN flags already express this dependency?
2587 SetOperandAt(1, typecheck != NULL ? typecheck : value); 2594 SetOperandAt(1, typecheck != NULL ? typecheck : value);
2588 set_representation(Representation::Tagged()); 2595 set_representation(Representation::Tagged());
2589 SetFlag(kUseGVN); 2596 SetFlag(kUseGVN);
(...skipping 11 matching lines...) Expand all
2601 } 2608 }
2602 } 2609 }
2603 2610
2604 bool omit_; 2611 bool omit_;
2605 bool has_migration_target_; 2612 bool has_migration_target_;
2606 SmallMapList map_set_; 2613 SmallMapList map_set_;
2607 ZoneList<UniqueValueId> map_unique_ids_; 2614 ZoneList<UniqueValueId> map_unique_ids_;
2608 }; 2615 };
2609 2616
2610 2617
2611 class HCheckFunction: public HUnaryOperation { 2618 class HCheckFunction V8_FINAL : public HUnaryOperation {
2612 public: 2619 public:
2613 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>); 2620 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>);
2614 2621
2615 virtual Representation RequiredInputRepresentation(int index) { 2622 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2616 return Representation::Tagged(); 2623 return Representation::Tagged();
2617 } 2624 }
2618 virtual void PrintDataTo(StringStream* stream); 2625 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2619 2626
2620 virtual HValue* Canonicalize(); 2627 virtual HValue* Canonicalize() V8_OVERRIDE;
2621 2628
2622 #ifdef DEBUG 2629 #ifdef DEBUG
2623 virtual void Verify(); 2630 virtual void Verify() V8_OVERRIDE;
2624 #endif 2631 #endif
2625 2632
2626 virtual void FinalizeUniqueValueId() { 2633 virtual void FinalizeUniqueValueId() V8_OVERRIDE {
2627 target_unique_id_ = UniqueValueId(target_); 2634 target_unique_id_ = UniqueValueId(target_);
2628 } 2635 }
2629 2636
2630 Handle<JSFunction> target() const { return target_; } 2637 Handle<JSFunction> target() const { return target_; }
2631 bool target_in_new_space() const { return target_in_new_space_; } 2638 bool target_in_new_space() const { return target_in_new_space_; }
2632 2639
2633 DECLARE_CONCRETE_INSTRUCTION(CheckFunction) 2640 DECLARE_CONCRETE_INSTRUCTION(CheckFunction)
2634 2641
2635 protected: 2642 protected:
2636 virtual bool DataEquals(HValue* other) { 2643 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2637 HCheckFunction* b = HCheckFunction::cast(other); 2644 HCheckFunction* b = HCheckFunction::cast(other);
2638 return target_unique_id_ == b->target_unique_id_; 2645 return target_unique_id_ == b->target_unique_id_;
2639 } 2646 }
2640 2647
2641 private: 2648 private:
2642 HCheckFunction(HValue* value, Handle<JSFunction> function) 2649 HCheckFunction(HValue* value, Handle<JSFunction> function)
2643 : HUnaryOperation(value, value->type()), 2650 : HUnaryOperation(value, value->type()),
2644 target_(function), target_unique_id_() { 2651 target_(function), target_unique_id_() {
2645 set_representation(Representation::Tagged()); 2652 set_representation(Representation::Tagged());
2646 SetFlag(kUseGVN); 2653 SetFlag(kUseGVN);
2647 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function); 2654 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2648 } 2655 }
2649 2656
2650 Handle<JSFunction> target_; 2657 Handle<JSFunction> target_;
2651 UniqueValueId target_unique_id_; 2658 UniqueValueId target_unique_id_;
2652 bool target_in_new_space_; 2659 bool target_in_new_space_;
2653 }; 2660 };
2654 2661
2655 2662
2656 class HCheckInstanceType: public HUnaryOperation { 2663 class HCheckInstanceType V8_FINAL : public HUnaryOperation {
2657 public: 2664 public:
2658 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { 2665 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
2659 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); 2666 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
2660 } 2667 }
2661 static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) { 2668 static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) {
2662 return new(zone) HCheckInstanceType(value, IS_JS_ARRAY); 2669 return new(zone) HCheckInstanceType(value, IS_JS_ARRAY);
2663 } 2670 }
2664 static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) { 2671 static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) {
2665 return new(zone) HCheckInstanceType(value, IS_STRING); 2672 return new(zone) HCheckInstanceType(value, IS_STRING);
2666 } 2673 }
2667 static HCheckInstanceType* NewIsInternalizedString( 2674 static HCheckInstanceType* NewIsInternalizedString(
2668 HValue* value, Zone* zone) { 2675 HValue* value, Zone* zone) {
2669 return new(zone) HCheckInstanceType(value, IS_INTERNALIZED_STRING); 2676 return new(zone) HCheckInstanceType(value, IS_INTERNALIZED_STRING);
2670 } 2677 }
2671 2678
2672 virtual void PrintDataTo(StringStream* stream); 2679 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2673 2680
2674 virtual Representation RequiredInputRepresentation(int index) { 2681 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2675 return Representation::Tagged(); 2682 return Representation::Tagged();
2676 } 2683 }
2677 2684
2678 virtual HValue* Canonicalize(); 2685 virtual HValue* Canonicalize() V8_OVERRIDE;
2679 2686
2680 bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; } 2687 bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; }
2681 void GetCheckInterval(InstanceType* first, InstanceType* last); 2688 void GetCheckInterval(InstanceType* first, InstanceType* last);
2682 void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag); 2689 void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag);
2683 2690
2684 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) 2691 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType)
2685 2692
2686 protected: 2693 protected:
2687 // TODO(ager): It could be nice to allow the ommision of instance 2694 // TODO(ager): It could be nice to allow the ommision of instance
2688 // type checks if we have already performed an instance type check 2695 // type checks if we have already performed an instance type check
2689 // with a larger range. 2696 // with a larger range.
2690 virtual bool DataEquals(HValue* other) { 2697 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
2691 HCheckInstanceType* b = HCheckInstanceType::cast(other); 2698 HCheckInstanceType* b = HCheckInstanceType::cast(other);
2692 return check_ == b->check_; 2699 return check_ == b->check_;
2693 } 2700 }
2694 2701
2695 private: 2702 private:
2696 enum Check { 2703 enum Check {
2697 IS_SPEC_OBJECT, 2704 IS_SPEC_OBJECT,
2698 IS_JS_ARRAY, 2705 IS_JS_ARRAY,
2699 IS_STRING, 2706 IS_STRING,
2700 IS_INTERNALIZED_STRING, 2707 IS_INTERNALIZED_STRING,
2701 LAST_INTERVAL_CHECK = IS_JS_ARRAY 2708 LAST_INTERVAL_CHECK = IS_JS_ARRAY
2702 }; 2709 };
2703 2710
2704 const char* GetCheckName(); 2711 const char* GetCheckName();
2705 2712
2706 HCheckInstanceType(HValue* value, Check check) 2713 HCheckInstanceType(HValue* value, Check check)
2707 : HUnaryOperation(value), check_(check) { 2714 : HUnaryOperation(value), check_(check) {
2708 set_representation(Representation::Tagged()); 2715 set_representation(Representation::Tagged());
2709 SetFlag(kUseGVN); 2716 SetFlag(kUseGVN);
2710 } 2717 }
2711 2718
2712 const Check check_; 2719 const Check check_;
2713 }; 2720 };
2714 2721
2715 2722
2716 class HCheckSmi: public HUnaryOperation { 2723 class HCheckSmi V8_FINAL : public HUnaryOperation {
2717 public: 2724 public:
2718 DECLARE_INSTRUCTION_FACTORY_P1(HCheckSmi, HValue*); 2725 DECLARE_INSTRUCTION_FACTORY_P1(HCheckSmi, HValue*);
2719 2726
2720 virtual Representation RequiredInputRepresentation(int index) { 2727 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2721 return Representation::Tagged(); 2728 return Representation::Tagged();
2722 } 2729 }
2723 2730
2724 virtual HValue* Canonicalize() { 2731 virtual HValue* Canonicalize() V8_OVERRIDE {
2725 HType value_type = value()->type(); 2732 HType value_type = value()->type();
2726 if (value_type.IsSmi()) { 2733 if (value_type.IsSmi()) {
2727 return NULL; 2734 return NULL;
2728 } 2735 }
2729 return this; 2736 return this;
2730 } 2737 }
2731 2738
2732 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) 2739 DECLARE_CONCRETE_INSTRUCTION(CheckSmi)
2733 2740
2734 protected: 2741 protected:
2735 virtual bool DataEquals(HValue* other) { return true; } 2742 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2736 2743
2737 private: 2744 private:
2738 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) { 2745 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) {
2739 set_representation(Representation::Smi()); 2746 set_representation(Representation::Smi());
2740 SetFlag(kUseGVN); 2747 SetFlag(kUseGVN);
2741 } 2748 }
2742 }; 2749 };
2743 2750
2744 2751
2745 class HIsNumberAndBranch: public HUnaryControlInstruction { 2752 class HIsNumberAndBranch V8_FINAL : public HUnaryControlInstruction {
2746 public: 2753 public:
2747 explicit HIsNumberAndBranch(HValue* value) 2754 explicit HIsNumberAndBranch(HValue* value)
2748 : HUnaryControlInstruction(value, NULL, NULL) { 2755 : HUnaryControlInstruction(value, NULL, NULL) {
2749 SetFlag(kFlexibleRepresentation); 2756 SetFlag(kFlexibleRepresentation);
2750 } 2757 }
2751 2758
2752 virtual Representation RequiredInputRepresentation(int index) { 2759 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2753 return Representation::None(); 2760 return Representation::None();
2754 } 2761 }
2755 2762
2756 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) 2763 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch)
2757 }; 2764 };
2758 2765
2759 2766
2760 class HCheckHeapObject: public HUnaryOperation { 2767 class HCheckHeapObject V8_FINAL : public HUnaryOperation {
2761 public: 2768 public:
2762 DECLARE_INSTRUCTION_FACTORY_P1(HCheckHeapObject, HValue*); 2769 DECLARE_INSTRUCTION_FACTORY_P1(HCheckHeapObject, HValue*);
2763 2770
2764 virtual bool HasEscapingOperandAt(int index) { return false; } 2771 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
2765 virtual Representation RequiredInputRepresentation(int index) { 2772 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
2766 return Representation::Tagged(); 2773 return Representation::Tagged();
2767 } 2774 }
2768 2775
2769 #ifdef DEBUG 2776 #ifdef DEBUG
2770 virtual void Verify(); 2777 virtual void Verify() V8_OVERRIDE;
2771 #endif 2778 #endif
2772 2779
2773 virtual HValue* Canonicalize() { 2780 virtual HValue* Canonicalize() V8_OVERRIDE {
2774 return value()->type().IsHeapObject() ? NULL : this; 2781 return value()->type().IsHeapObject() ? NULL : this;
2775 } 2782 }
2776 2783
2777 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) 2784 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject)
2778 2785
2779 protected: 2786 protected:
2780 virtual bool DataEquals(HValue* other) { return true; } 2787 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
2781 2788
2782 private: 2789 private:
2783 explicit HCheckHeapObject(HValue* value) 2790 explicit HCheckHeapObject(HValue* value)
2784 : HUnaryOperation(value, HType::NonPrimitive()) { 2791 : HUnaryOperation(value, HType::NonPrimitive()) {
2785 set_representation(Representation::Tagged()); 2792 set_representation(Representation::Tagged());
2786 SetFlag(kUseGVN); 2793 SetFlag(kUseGVN);
2787 } 2794 }
2788 }; 2795 };
2789 2796
2790 2797
(...skipping 11 matching lines...) Expand all
2802 limit_is_upper(false), limit_is_included(false) {} 2809 limit_is_upper(false), limit_is_included(false) {}
2803 }; 2810 };
2804 2811
2805 2812
2806 class HBoundsCheck; 2813 class HBoundsCheck;
2807 class HPhi; 2814 class HPhi;
2808 class HConstant; 2815 class HConstant;
2809 class HBitwise; 2816 class HBitwise;
2810 2817
2811 2818
2812 class InductionVariableData : public ZoneObject { 2819 class InductionVariableData V8_FINAL : public ZoneObject {
2813 public: 2820 public:
2814 class InductionVariableCheck : public ZoneObject { 2821 class InductionVariableCheck : public ZoneObject {
2815 public: 2822 public:
2816 HBoundsCheck* check() { return check_; } 2823 HBoundsCheck* check() { return check_; }
2817 InductionVariableCheck* next() { return next_; } 2824 InductionVariableCheck* next() { return next_; }
2818 bool HasUpperLimit() { return upper_limit_ >= 0; } 2825 bool HasUpperLimit() { return upper_limit_ >= 0; }
2819 int32_t upper_limit() { 2826 int32_t upper_limit() {
2820 ASSERT(HasUpperLimit()); 2827 ASSERT(HasUpperLimit());
2821 return upper_limit_; 2828 return upper_limit_;
2822 } 2829 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 HBasicBlock* induction_exit_block_; 3009 HBasicBlock* induction_exit_block_;
3003 HBasicBlock* induction_exit_target_; 3010 HBasicBlock* induction_exit_target_;
3004 ChecksRelatedToLength* checks_; 3011 ChecksRelatedToLength* checks_;
3005 HValue* additional_upper_limit_; 3012 HValue* additional_upper_limit_;
3006 bool additional_upper_limit_is_included_; 3013 bool additional_upper_limit_is_included_;
3007 HValue* additional_lower_limit_; 3014 HValue* additional_lower_limit_;
3008 bool additional_lower_limit_is_included_; 3015 bool additional_lower_limit_is_included_;
3009 }; 3016 };
3010 3017
3011 3018
3012 class HPhi: public HValue { 3019 class HPhi V8_FINAL : public HValue {
3013 public: 3020 public:
3014 HPhi(int merged_index, Zone* zone) 3021 HPhi(int merged_index, Zone* zone)
3015 : inputs_(2, zone), 3022 : inputs_(2, zone),
3016 merged_index_(merged_index), 3023 merged_index_(merged_index),
3017 phi_id_(-1), 3024 phi_id_(-1),
3018 induction_variable_data_(NULL) { 3025 induction_variable_data_(NULL) {
3019 for (int i = 0; i < Representation::kNumRepresentations; i++) { 3026 for (int i = 0; i < Representation::kNumRepresentations; i++) {
3020 non_phi_uses_[i] = 0; 3027 non_phi_uses_[i] = 0;
3021 indirect_uses_[i] = 0; 3028 indirect_uses_[i] = 0;
3022 } 3029 }
3023 ASSERT(merged_index >= 0); 3030 ASSERT(merged_index >= 0 || merged_index == kInvalidMergedIndex);
3024 SetFlag(kFlexibleRepresentation); 3031 SetFlag(kFlexibleRepresentation);
3025 SetFlag(kAllowUndefinedAsNaN); 3032 SetFlag(kAllowUndefinedAsNaN);
3026 } 3033 }
3027 3034
3028 virtual Representation RepresentationFromInputs(); 3035 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
3029 3036
3030 virtual Range* InferRange(Zone* zone); 3037 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3031 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); 3038 virtual void InferRepresentation(
3032 virtual Representation RequiredInputRepresentation(int index) { 3039 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
3040 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3033 return representation(); 3041 return representation();
3034 } 3042 }
3035 virtual Representation KnownOptimalRepresentation() { 3043 virtual Representation KnownOptimalRepresentation() V8_OVERRIDE {
3036 return representation(); 3044 return representation();
3037 } 3045 }
3038 virtual HType CalculateInferredType(); 3046 virtual HType CalculateInferredType() V8_OVERRIDE;
3039 virtual int OperandCount() { return inputs_.length(); } 3047 virtual int OperandCount() V8_OVERRIDE { return inputs_.length(); }
3040 virtual HValue* OperandAt(int index) const { return inputs_[index]; } 3048 virtual HValue* OperandAt(int index) const V8_OVERRIDE {
3049 return inputs_[index];
3050 }
3041 HValue* GetRedundantReplacement(); 3051 HValue* GetRedundantReplacement();
3042 void AddInput(HValue* value); 3052 void AddInput(HValue* value);
3043 bool HasRealUses(); 3053 bool HasRealUses();
3044 3054
3045 bool IsReceiver() const { return merged_index_ == 0; } 3055 bool IsReceiver() const { return merged_index_ == 0; }
3056 bool HasMergedIndex() const { return merged_index_ != kInvalidMergedIndex; }
3046 3057
3047 int merged_index() const { return merged_index_; } 3058 int merged_index() const { return merged_index_; }
3048 3059
3049 InductionVariableData* induction_variable_data() { 3060 InductionVariableData* induction_variable_data() {
3050 return induction_variable_data_; 3061 return induction_variable_data_;
3051 } 3062 }
3052 bool IsInductionVariable() { 3063 bool IsInductionVariable() {
3053 return induction_variable_data_ != NULL; 3064 return induction_variable_data_ != NULL;
3054 } 3065 }
3055 bool IsLimitedInductionVariable() { 3066 bool IsLimitedInductionVariable() {
3056 return IsInductionVariable() && 3067 return IsInductionVariable() &&
3057 induction_variable_data_->limit() != NULL; 3068 induction_variable_data_->limit() != NULL;
3058 } 3069 }
3059 void DetectInductionVariable() { 3070 void DetectInductionVariable() {
3060 ASSERT(induction_variable_data_ == NULL); 3071 ASSERT(induction_variable_data_ == NULL);
3061 induction_variable_data_ = InductionVariableData::ExaminePhi(this); 3072 induction_variable_data_ = InductionVariableData::ExaminePhi(this);
3062 } 3073 }
3063 3074
3064 virtual void PrintTo(StringStream* stream); 3075 virtual void PrintTo(StringStream* stream) V8_OVERRIDE;
3065 3076
3066 #ifdef DEBUG 3077 #ifdef DEBUG
3067 virtual void Verify(); 3078 virtual void Verify() V8_OVERRIDE;
3068 #endif 3079 #endif
3069 3080
3070 void InitRealUses(int id); 3081 void InitRealUses(int id);
3071 void AddNonPhiUsesFrom(HPhi* other); 3082 void AddNonPhiUsesFrom(HPhi* other);
3072 void AddIndirectUsesTo(int* use_count); 3083 void AddIndirectUsesTo(int* use_count);
3073 3084
3074 int tagged_non_phi_uses() const { 3085 int tagged_non_phi_uses() const {
3075 return non_phi_uses_[Representation::kTagged]; 3086 return non_phi_uses_[Representation::kTagged];
3076 } 3087 }
3077 int smi_non_phi_uses() const { 3088 int smi_non_phi_uses() const {
(...skipping 16 matching lines...) Expand all
3094 } 3105 }
3095 int double_indirect_uses() const { 3106 int double_indirect_uses() const {
3096 return indirect_uses_[Representation::kDouble]; 3107 return indirect_uses_[Representation::kDouble];
3097 } 3108 }
3098 int phi_id() { return phi_id_; } 3109 int phi_id() { return phi_id_; }
3099 3110
3100 static HPhi* cast(HValue* value) { 3111 static HPhi* cast(HValue* value) {
3101 ASSERT(value->IsPhi()); 3112 ASSERT(value->IsPhi());
3102 return reinterpret_cast<HPhi*>(value); 3113 return reinterpret_cast<HPhi*>(value);
3103 } 3114 }
3104 virtual Opcode opcode() const { return HValue::kPhi; } 3115 virtual Opcode opcode() const V8_OVERRIDE { return HValue::kPhi; }
3105 3116
3106 void SimplifyConstantInputs(); 3117 void SimplifyConstantInputs();
3107 3118
3119 // Marker value representing an invalid merge index.
3120 static const int kInvalidMergedIndex = -1;
3121
3108 protected: 3122 protected:
3109 virtual void DeleteFromGraph(); 3123 virtual void DeleteFromGraph() V8_OVERRIDE;
3110 virtual void InternalSetOperandAt(int index, HValue* value) { 3124 virtual void InternalSetOperandAt(int index, HValue* value) V8_OVERRIDE {
3111 inputs_[index] = value; 3125 inputs_[index] = value;
3112 } 3126 }
3113 3127
3114 private: 3128 private:
3115 ZoneList<HValue*> inputs_; 3129 ZoneList<HValue*> inputs_;
3116 int merged_index_; 3130 int merged_index_;
3117 3131
3118 int non_phi_uses_[Representation::kNumRepresentations]; 3132 int non_phi_uses_[Representation::kNumRepresentations];
3119 int indirect_uses_[Representation::kNumRepresentations]; 3133 int indirect_uses_[Representation::kNumRepresentations];
3120 int phi_id_; 3134 int phi_id_;
3121 InductionVariableData* induction_variable_data_; 3135 InductionVariableData* induction_variable_data_;
3122 3136
3123 // TODO(titzer): we can't eliminate the receiver for generating backtraces 3137 // TODO(titzer): we can't eliminate the receiver for generating backtraces
3124 virtual bool IsDeletable() const { return !IsReceiver(); } 3138 virtual bool IsDeletable() const V8_OVERRIDE { return !IsReceiver(); }
3125 }; 3139 };
3126 3140
3127 3141
3128 // Common base class for HArgumentsObject and HCapturedObject. 3142 // Common base class for HArgumentsObject and HCapturedObject.
3129 class HDematerializedObject: public HTemplateInstruction<0> { 3143 class HDematerializedObject : public HInstruction {
3130 public: 3144 public:
3131 HDematerializedObject(int count, Zone* zone) : values_(count, zone) {} 3145 HDematerializedObject(int count, Zone* zone) : values_(count, zone) {}
3132 3146
3133 virtual int OperandCount() { return values_.length(); } 3147 virtual int OperandCount() V8_FINAL V8_OVERRIDE { return values_.length(); }
3134 virtual HValue* OperandAt(int index) const { return values_[index]; } 3148 virtual HValue* OperandAt(int index) const V8_FINAL V8_OVERRIDE {
3149 return values_[index];
3150 }
3135 3151
3136 virtual bool HasEscapingOperandAt(int index) { return false; } 3152 virtual bool HasEscapingOperandAt(int index) V8_FINAL V8_OVERRIDE {
3137 virtual Representation RequiredInputRepresentation(int index) { 3153 return false;
3154 }
3155 virtual Representation RequiredInputRepresentation(
3156 int index) V8_FINAL V8_OVERRIDE {
3138 return Representation::None(); 3157 return Representation::None();
3139 } 3158 }
3140 3159
3141 protected: 3160 protected:
3142 virtual void InternalSetOperandAt(int index, HValue* value) { 3161 virtual void InternalSetOperandAt(int index,
3162 HValue* value) V8_FINAL V8_OVERRIDE {
3143 values_[index] = value; 3163 values_[index] = value;
3144 } 3164 }
3145 3165
3146 // List of values tracked by this marker. 3166 // List of values tracked by this marker.
3147 ZoneList<HValue*> values_; 3167 ZoneList<HValue*> values_;
3148 3168
3149 private: 3169 private:
3150 virtual bool IsDeletable() const { return true; } 3170 virtual bool IsDeletable() const V8_FINAL V8_OVERRIDE { return true; }
3151 }; 3171 };
3152 3172
3153 3173
3154 class HArgumentsObject: public HDematerializedObject { 3174 class HArgumentsObject V8_FINAL : public HDematerializedObject {
3155 public: 3175 public:
3156 static HArgumentsObject* New(Zone* zone, HValue* context, int count) { 3176 static HArgumentsObject* New(Zone* zone, HValue* context, int count) {
3157 return new(zone) HArgumentsObject(count, zone); 3177 return new(zone) HArgumentsObject(count, zone);
3158 } 3178 }
3159 3179
3160 // The values contain a list of all elements in the arguments object 3180 // The values contain a list of all elements in the arguments object
3161 // including the receiver object, which is skipped when materializing. 3181 // including the receiver object, which is skipped when materializing.
3162 const ZoneList<HValue*>* arguments_values() const { return &values_; } 3182 const ZoneList<HValue*>* arguments_values() const { return &values_; }
3163 int arguments_count() const { return values_.length(); } 3183 int arguments_count() const { return values_.length(); }
3164 3184
3165 void AddArgument(HValue* argument, Zone* zone) { 3185 void AddArgument(HValue* argument, Zone* zone) {
3166 values_.Add(NULL, zone); // Resize list. 3186 values_.Add(NULL, zone); // Resize list.
3167 SetOperandAt(values_.length() - 1, argument); 3187 SetOperandAt(values_.length() - 1, argument);
3168 } 3188 }
3169 3189
3170 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) 3190 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject)
3171 3191
3172 private: 3192 private:
3173 HArgumentsObject(int count, Zone* zone) 3193 HArgumentsObject(int count, Zone* zone)
3174 : HDematerializedObject(count, zone) { 3194 : HDematerializedObject(count, zone) {
3175 set_representation(Representation::Tagged()); 3195 set_representation(Representation::Tagged());
3176 SetFlag(kIsArguments); 3196 SetFlag(kIsArguments);
3177 } 3197 }
3178 }; 3198 };
3179 3199
3180 3200
3181 class HCapturedObject: public HDematerializedObject { 3201 class HCapturedObject V8_FINAL : public HDematerializedObject {
3182 public: 3202 public:
3183 HCapturedObject(int length, Zone* zone) 3203 HCapturedObject(int length, Zone* zone)
3184 : HDematerializedObject(length, zone) { 3204 : HDematerializedObject(length, zone) {
3185 set_representation(Representation::Tagged()); 3205 set_representation(Representation::Tagged());
3186 values_.AddBlock(NULL, length, zone); // Resize list. 3206 values_.AddBlock(NULL, length, zone); // Resize list.
3187 } 3207 }
3188 3208
3189 // The values contain a list of all in-object properties inside the 3209 // The values contain a list of all in-object properties inside the
3190 // captured object and is index by field index. Properties in the 3210 // captured object and is index by field index. Properties in the
3191 // properties or elements backing store are not tracked here. 3211 // properties or elements backing store are not tracked here.
3192 const ZoneList<HValue*>* values() const { return &values_; } 3212 const ZoneList<HValue*>* values() const { return &values_; }
3193 int length() const { return values_.length(); } 3213 int length() const { return values_.length(); }
3194 3214
3195 DECLARE_CONCRETE_INSTRUCTION(CapturedObject) 3215 DECLARE_CONCRETE_INSTRUCTION(CapturedObject)
3196 }; 3216 };
3197 3217
3198 3218
3199 class HConstant: public HTemplateInstruction<0> { 3219 class HConstant V8_FINAL : public HTemplateInstruction<0> {
3200 public: 3220 public:
3201 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t); 3221 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t);
3202 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation); 3222 DECLARE_INSTRUCTION_FACTORY_P2(HConstant, int32_t, Representation);
3203 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double); 3223 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double);
3204 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>); 3224 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>);
3205 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference); 3225 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference);
3206 3226
3207 Handle<Object> handle() { 3227 Handle<Object> handle() {
3208 if (handle_.is_null()) { 3228 if (handle_.is_null()) {
3209 Factory* factory = Isolate::Current()->factory(); 3229 Factory* factory = Isolate::Current()->factory();
3210 // Default arguments to is_not_in_new_space depend on this heap number 3230 // Default arguments to is_not_in_new_space depend on this heap number
3211 // to be tenured so that it's guaranteed not be be located in new space. 3231 // to be tenured so that it's guaranteed not be be located in new space.
3212 handle_ = factory->NewNumber(double_value_, TENURED); 3232 handle_ = factory->NewNumber(double_value_, TENURED);
3213 } 3233 }
3214 AllowDeferredHandleDereference smi_check; 3234 AllowDeferredHandleDereference smi_check;
3215 ASSERT(has_int32_value_ || !handle_->IsSmi()); 3235 ASSERT(has_int32_value_ || !handle_->IsSmi());
3216 return handle_; 3236 return handle_;
3217 } 3237 }
3218 3238
3219 bool InstanceOf(Handle<Map> map) { 3239 bool InstanceOf(Handle<Map> map) {
3220 return handle_->IsJSObject() && 3240 Handle<Object> constant_object = handle();
3221 Handle<JSObject>::cast(handle_)->map() == *map; 3241 return constant_object->IsJSObject() &&
3242 Handle<JSObject>::cast(constant_object)->map() == *map;
3222 } 3243 }
3223 3244
3224 bool IsSpecialDouble() const { 3245 bool IsSpecialDouble() const {
3225 return has_double_value_ && 3246 return has_double_value_ &&
3226 (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) || 3247 (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) ||
3227 FixedDoubleArray::is_the_hole_nan(double_value_) || 3248 FixedDoubleArray::is_the_hole_nan(double_value_) ||
3228 std::isnan(double_value_)); 3249 std::isnan(double_value_));
3229 } 3250 }
3230 3251
3231 bool NotInNewSpace() const { 3252 bool NotInNewSpace() const {
(...skipping 23 matching lines...) Expand all
3255 unique_id_ == UniqueValueId(heap->true_value()) || 3276 unique_id_ == UniqueValueId(heap->true_value()) ||
3256 unique_id_ == UniqueValueId(heap->false_value()) || 3277 unique_id_ == UniqueValueId(heap->false_value()) ||
3257 unique_id_ == UniqueValueId(heap->the_hole_value()) || 3278 unique_id_ == UniqueValueId(heap->the_hole_value()) ||
3258 unique_id_ == UniqueValueId(heap->empty_string()); 3279 unique_id_ == UniqueValueId(heap->empty_string());
3259 } 3280 }
3260 3281
3261 bool IsCell() const { 3282 bool IsCell() const {
3262 return is_cell_; 3283 return is_cell_;
3263 } 3284 }
3264 3285
3265 virtual Representation RequiredInputRepresentation(int index) { 3286 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3266 return Representation::None(); 3287 return Representation::None();
3267 } 3288 }
3268 3289
3269 virtual Representation KnownOptimalRepresentation() { 3290 virtual Representation KnownOptimalRepresentation() V8_OVERRIDE {
3270 if (HasSmiValue() && kSmiValueSize == 31) return Representation::Smi(); 3291 if (HasSmiValue() && kSmiValueSize == 31) return Representation::Smi();
3271 if (HasInteger32Value()) return Representation::Integer32(); 3292 if (HasInteger32Value()) return Representation::Integer32();
3272 if (HasNumberValue()) return Representation::Double(); 3293 if (HasNumberValue()) return Representation::Double();
3273 if (HasExternalReferenceValue()) return Representation::External(); 3294 if (HasExternalReferenceValue()) return Representation::External();
3274 return Representation::Tagged(); 3295 return Representation::Tagged();
3275 } 3296 }
3276 3297
3277 virtual bool EmitAtUses(); 3298 virtual bool EmitAtUses() V8_OVERRIDE;
3278 virtual void PrintDataTo(StringStream* stream); 3299 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3279 bool IsInteger() { return handle()->IsSmi(); } 3300 bool IsInteger() { return handle()->IsSmi(); }
3280 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 3301 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
3281 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone); 3302 Maybe<HConstant*> CopyToTruncatedInt32(Zone* zone);
3282 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone); 3303 Maybe<HConstant*> CopyToTruncatedNumber(Zone* zone);
3283 bool HasInteger32Value() const { return has_int32_value_; } 3304 bool HasInteger32Value() const { return has_int32_value_; }
3284 int32_t Integer32Value() const { 3305 int32_t Integer32Value() const {
3285 ASSERT(HasInteger32Value()); 3306 ASSERT(HasInteger32Value());
3286 return int32_value_; 3307 return int32_value_;
3287 } 3308 }
3288 bool HasSmiValue() const { return has_smi_value_; } 3309 bool HasSmiValue() const { return has_smi_value_; }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3322 return HasStringValue() && is_internalized_string_; 3343 return HasStringValue() && is_internalized_string_;
3323 } 3344 }
3324 3345
3325 bool HasExternalReferenceValue() const { 3346 bool HasExternalReferenceValue() const {
3326 return has_external_reference_value_; 3347 return has_external_reference_value_;
3327 } 3348 }
3328 ExternalReference ExternalReferenceValue() const { 3349 ExternalReference ExternalReferenceValue() const {
3329 return external_reference_value_; 3350 return external_reference_value_;
3330 } 3351 }
3331 3352
3353 bool HasBooleanValue() const { return type_.IsBoolean(); }
3332 bool BooleanValue() const { return boolean_value_; } 3354 bool BooleanValue() const { return boolean_value_; }
3333 3355
3334 virtual intptr_t Hashcode() { 3356 virtual intptr_t Hashcode() V8_OVERRIDE {
3335 if (has_int32_value_) { 3357 if (has_int32_value_) {
3336 return static_cast<intptr_t>(int32_value_); 3358 return static_cast<intptr_t>(int32_value_);
3337 } else if (has_double_value_) { 3359 } else if (has_double_value_) {
3338 return static_cast<intptr_t>(BitCast<int64_t>(double_value_)); 3360 return static_cast<intptr_t>(BitCast<int64_t>(double_value_));
3339 } else if (has_external_reference_value_) { 3361 } else if (has_external_reference_value_) {
3340 return reinterpret_cast<intptr_t>(external_reference_value_.address()); 3362 return reinterpret_cast<intptr_t>(external_reference_value_.address());
3341 } else { 3363 } else {
3342 ASSERT(!handle_.is_null()); 3364 ASSERT(!handle_.is_null());
3343 return unique_id_.Hashcode(); 3365 return unique_id_.Hashcode();
3344 } 3366 }
3345 } 3367 }
3346 3368
3347 virtual void FinalizeUniqueValueId() { 3369 virtual void FinalizeUniqueValueId() V8_OVERRIDE {
3348 if (!has_double_value_ && !has_external_reference_value_) { 3370 if (!has_double_value_ && !has_external_reference_value_) {
3349 ASSERT(!handle_.is_null()); 3371 ASSERT(!handle_.is_null());
3350 unique_id_ = UniqueValueId(handle_); 3372 unique_id_ = UniqueValueId(handle_);
3351 } 3373 }
3352 } 3374 }
3353 3375
3354 bool UniqueValueIdsMatch(UniqueValueId other) { 3376 bool UniqueValueIdsMatch(UniqueValueId other) {
3355 return !has_double_value_ && !has_external_reference_value_ && 3377 return !has_double_value_ && !has_external_reference_value_ &&
3356 unique_id_ == other; 3378 unique_id_ == other;
3357 } 3379 }
3358 3380
3359 #ifdef DEBUG 3381 #ifdef DEBUG
3360 virtual void Verify() { } 3382 virtual void Verify() V8_OVERRIDE { }
3361 #endif 3383 #endif
3362 3384
3363 DECLARE_CONCRETE_INSTRUCTION(Constant) 3385 DECLARE_CONCRETE_INSTRUCTION(Constant)
3364 3386
3365 protected: 3387 protected:
3366 virtual Range* InferRange(Zone* zone); 3388 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
3367 3389
3368 virtual bool DataEquals(HValue* other) { 3390 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
3369 HConstant* other_constant = HConstant::cast(other); 3391 HConstant* other_constant = HConstant::cast(other);
3370 if (has_int32_value_) { 3392 if (has_int32_value_) {
3371 return other_constant->has_int32_value_ && 3393 return other_constant->has_int32_value_ &&
3372 int32_value_ == other_constant->int32_value_; 3394 int32_value_ == other_constant->int32_value_;
3373 } else if (has_double_value_) { 3395 } else if (has_double_value_) {
3374 return other_constant->has_double_value_ && 3396 return other_constant->has_double_value_ &&
3375 BitCast<int64_t>(double_value_) == 3397 BitCast<int64_t>(double_value_) ==
3376 BitCast<int64_t>(other_constant->double_value_); 3398 BitCast<int64_t>(other_constant->double_value_);
3377 } else if (has_external_reference_value_) { 3399 } else if (has_external_reference_value_) {
3378 return other_constant->has_external_reference_value_ && 3400 return other_constant->has_external_reference_value_ &&
(...skipping 22 matching lines...) Expand all
3401 Representation r, 3423 Representation r,
3402 HType type, 3424 HType type,
3403 bool is_internalized_string, 3425 bool is_internalized_string,
3404 bool is_not_in_new_space, 3426 bool is_not_in_new_space,
3405 bool is_cell, 3427 bool is_cell,
3406 bool boolean_value); 3428 bool boolean_value);
3407 explicit HConstant(ExternalReference reference); 3429 explicit HConstant(ExternalReference reference);
3408 3430
3409 void Initialize(Representation r); 3431 void Initialize(Representation r);
3410 3432
3411 virtual bool IsDeletable() const { return true; } 3433 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3412 3434
3413 // If this is a numerical constant, handle_ either points to to the 3435 // If this is a numerical constant, handle_ either points to to the
3414 // HeapObject the constant originated from or is null. If the 3436 // HeapObject the constant originated from or is null. If the
3415 // constant is non-numeric, handle_ always points to a valid 3437 // constant is non-numeric, handle_ always points to a valid
3416 // constant HeapObject. 3438 // constant HeapObject.
3417 Handle<Object> handle_; 3439 Handle<Object> handle_;
3418 UniqueValueId unique_id_; 3440 UniqueValueId unique_id_;
3419 3441
3420 // We store the HConstant in the most specific form safely possible. 3442 // We store the HConstant in the most specific form safely possible.
3421 // The two flags, has_int32_value_ and has_double_value_ tell us if 3443 // The two flags, has_int32_value_ and has_double_value_ tell us if
3422 // int32_value_ and double_value_ hold valid, safe representations 3444 // int32_value_ and double_value_ hold valid, safe representations
3423 // of the constant. has_int32_value_ implies has_double_value_ but 3445 // of the constant. has_int32_value_ implies has_double_value_ but
3424 // not the converse. 3446 // not the converse.
3425 bool has_smi_value_ : 1; 3447 bool has_smi_value_ : 1;
3426 bool has_int32_value_ : 1; 3448 bool has_int32_value_ : 1;
3427 bool has_double_value_ : 1; 3449 bool has_double_value_ : 1;
3428 bool has_external_reference_value_ : 1; 3450 bool has_external_reference_value_ : 1;
3429 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. 3451 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType.
3430 bool is_not_in_new_space_ : 1; 3452 bool is_not_in_new_space_ : 1;
3431 bool is_cell_ : 1; 3453 bool is_cell_ : 1;
3432 bool boolean_value_ : 1; 3454 bool boolean_value_ : 1;
3433 int32_t int32_value_; 3455 int32_t int32_value_;
3434 double double_value_; 3456 double double_value_;
3435 ExternalReference external_reference_value_; 3457 ExternalReference external_reference_value_;
3436 }; 3458 };
3437 3459
3438 3460
3439 class HBinaryOperation: public HTemplateInstruction<3> { 3461 class HBinaryOperation : public HTemplateInstruction<3> {
3440 public: 3462 public:
3441 HBinaryOperation(HValue* context, HValue* left, HValue* right, 3463 HBinaryOperation(HValue* context, HValue* left, HValue* right,
3442 HType type = HType::Tagged()) 3464 HType type = HType::Tagged())
3443 : HTemplateInstruction<3>(type), 3465 : HTemplateInstruction<3>(type),
3444 observed_output_representation_(Representation::None()) { 3466 observed_output_representation_(Representation::None()) {
3445 ASSERT(left != NULL && right != NULL); 3467 ASSERT(left != NULL && right != NULL);
3446 SetOperandAt(0, context); 3468 SetOperandAt(0, context);
3447 SetOperandAt(1, left); 3469 SetOperandAt(1, left);
3448 SetOperandAt(2, right); 3470 SetOperandAt(2, right);
3449 observed_input_representation_[0] = Representation::None(); 3471 observed_input_representation_[0] = Representation::None();
(...skipping 29 matching lines...) Expand all
3479 3501
3480 void set_observed_input_representation(int index, Representation rep) { 3502 void set_observed_input_representation(int index, Representation rep) {
3481 ASSERT(index >= 1 && index <= 2); 3503 ASSERT(index >= 1 && index <= 2);
3482 observed_input_representation_[index - 1] = rep; 3504 observed_input_representation_[index - 1] = rep;
3483 } 3505 }
3484 3506
3485 virtual void initialize_output_representation(Representation observed) { 3507 virtual void initialize_output_representation(Representation observed) {
3486 observed_output_representation_ = observed; 3508 observed_output_representation_ = observed;
3487 } 3509 }
3488 3510
3489 virtual Representation observed_input_representation(int index) { 3511 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
3490 if (index == 0) return Representation::Tagged(); 3512 if (index == 0) return Representation::Tagged();
3491 return observed_input_representation_[index - 1]; 3513 return observed_input_representation_[index - 1];
3492 } 3514 }
3493 3515
3494 virtual void UpdateRepresentation(Representation new_rep, 3516 virtual void UpdateRepresentation(Representation new_rep,
3495 HInferRepresentationPhase* h_infer, 3517 HInferRepresentationPhase* h_infer,
3496 const char* reason) { 3518 const char* reason) V8_OVERRIDE {
3497 Representation rep = !FLAG_smi_binop && new_rep.IsSmi() 3519 Representation rep = !FLAG_smi_binop && new_rep.IsSmi()
3498 ? Representation::Integer32() : new_rep; 3520 ? Representation::Integer32() : new_rep;
3499 HValue::UpdateRepresentation(rep, h_infer, reason); 3521 HValue::UpdateRepresentation(rep, h_infer, reason);
3500 } 3522 }
3501 3523
3502 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); 3524 virtual void InferRepresentation(
3503 virtual Representation RepresentationFromInputs(); 3525 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
3526 virtual Representation RepresentationFromInputs() V8_OVERRIDE;
3504 Representation RepresentationFromOutput(); 3527 Representation RepresentationFromOutput();
3505 virtual void AssumeRepresentation(Representation r); 3528 virtual void AssumeRepresentation(Representation r) V8_OVERRIDE;
3506 3529
3507 virtual bool IsCommutative() const { return false; } 3530 virtual bool IsCommutative() const { return false; }
3508 3531
3509 virtual void PrintDataTo(StringStream* stream); 3532 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3510 3533
3511 virtual Representation RequiredInputRepresentation(int index) { 3534 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3512 if (index == 0) return Representation::Tagged(); 3535 if (index == 0) return Representation::Tagged();
3513 return representation(); 3536 return representation();
3514 } 3537 }
3515 3538
3516 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) 3539 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
3517 3540
3518 private: 3541 private:
3519 bool IgnoreObservedOutputRepresentation(Representation current_rep); 3542 bool IgnoreObservedOutputRepresentation(Representation current_rep);
3520 3543
3521 Representation observed_input_representation_[2]; 3544 Representation observed_input_representation_[2];
3522 Representation observed_output_representation_; 3545 Representation observed_output_representation_;
3523 }; 3546 };
3524 3547
3525 3548
3526 class HWrapReceiver: public HTemplateInstruction<2> { 3549 class HWrapReceiver V8_FINAL : public HTemplateInstruction<2> {
3527 public: 3550 public:
3528 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*); 3551 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*);
3529 3552
3530 virtual Representation RequiredInputRepresentation(int index) { 3553 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3531 return Representation::Tagged(); 3554 return Representation::Tagged();
3532 } 3555 }
3533 3556
3534 HValue* receiver() { return OperandAt(0); } 3557 HValue* receiver() { return OperandAt(0); }
3535 HValue* function() { return OperandAt(1); } 3558 HValue* function() { return OperandAt(1); }
3536 3559
3537 virtual HValue* Canonicalize(); 3560 virtual HValue* Canonicalize() V8_OVERRIDE;
3538 3561
3539 virtual void PrintDataTo(StringStream* stream); 3562 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3540 3563
3541 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) 3564 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
3542 3565
3543 private: 3566 private:
3544 HWrapReceiver(HValue* receiver, HValue* function) { 3567 HWrapReceiver(HValue* receiver, HValue* function) {
3545 set_representation(Representation::Tagged()); 3568 set_representation(Representation::Tagged());
3546 SetOperandAt(0, receiver); 3569 SetOperandAt(0, receiver);
3547 SetOperandAt(1, function); 3570 SetOperandAt(1, function);
3548 } 3571 }
3549 }; 3572 };
3550 3573
3551 3574
3552 class HApplyArguments: public HTemplateInstruction<4> { 3575 class HApplyArguments V8_FINAL : public HTemplateInstruction<4> {
3553 public: 3576 public:
3554 HApplyArguments(HValue* function, 3577 HApplyArguments(HValue* function,
3555 HValue* receiver, 3578 HValue* receiver,
3556 HValue* length, 3579 HValue* length,
3557 HValue* elements) { 3580 HValue* elements) {
3558 set_representation(Representation::Tagged()); 3581 set_representation(Representation::Tagged());
3559 SetOperandAt(0, function); 3582 SetOperandAt(0, function);
3560 SetOperandAt(1, receiver); 3583 SetOperandAt(1, receiver);
3561 SetOperandAt(2, length); 3584 SetOperandAt(2, length);
3562 SetOperandAt(3, elements); 3585 SetOperandAt(3, elements);
3563 SetAllSideEffects(); 3586 SetAllSideEffects();
3564 } 3587 }
3565 3588
3566 virtual Representation RequiredInputRepresentation(int index) { 3589 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3567 // The length is untagged, all other inputs are tagged. 3590 // The length is untagged, all other inputs are tagged.
3568 return (index == 2) 3591 return (index == 2)
3569 ? Representation::Integer32() 3592 ? Representation::Integer32()
3570 : Representation::Tagged(); 3593 : Representation::Tagged();
3571 } 3594 }
3572 3595
3573 HValue* function() { return OperandAt(0); } 3596 HValue* function() { return OperandAt(0); }
3574 HValue* receiver() { return OperandAt(1); } 3597 HValue* receiver() { return OperandAt(1); }
3575 HValue* length() { return OperandAt(2); } 3598 HValue* length() { return OperandAt(2); }
3576 HValue* elements() { return OperandAt(3); } 3599 HValue* elements() { return OperandAt(3); }
3577 3600
3578 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) 3601 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments)
3579 }; 3602 };
3580 3603
3581 3604
3582 class HArgumentsElements: public HTemplateInstruction<0> { 3605 class HArgumentsElements V8_FINAL : public HTemplateInstruction<0> {
3583 public: 3606 public:
3584 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsElements, bool); 3607 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsElements, bool);
3585 3608
3586 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) 3609 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements)
3587 3610
3588 virtual Representation RequiredInputRepresentation(int index) { 3611 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3589 return Representation::None(); 3612 return Representation::None();
3590 } 3613 }
3591 3614
3592 bool from_inlined() const { return from_inlined_; } 3615 bool from_inlined() const { return from_inlined_; }
3593 3616
3594 protected: 3617 protected:
3595 virtual bool DataEquals(HValue* other) { return true; } 3618 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
3596 3619
3597 private: 3620 private:
3598 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) { 3621 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) {
3599 // The value produced by this instruction is a pointer into the stack 3622 // The value produced by this instruction is a pointer into the stack
3600 // that looks as if it was a smi because of alignment. 3623 // that looks as if it was a smi because of alignment.
3601 set_representation(Representation::Tagged()); 3624 set_representation(Representation::Tagged());
3602 SetFlag(kUseGVN); 3625 SetFlag(kUseGVN);
3603 } 3626 }
3604 3627
3605 virtual bool IsDeletable() const { return true; } 3628 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3606 3629
3607 bool from_inlined_; 3630 bool from_inlined_;
3608 }; 3631 };
3609 3632
3610 3633
3611 class HArgumentsLength: public HUnaryOperation { 3634 class HArgumentsLength V8_FINAL : public HUnaryOperation {
3612 public: 3635 public:
3613 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsLength, HValue*); 3636 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsLength, HValue*);
3614 3637
3615 virtual Representation RequiredInputRepresentation(int index) { 3638 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3616 return Representation::Tagged(); 3639 return Representation::Tagged();
3617 } 3640 }
3618 3641
3619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) 3642 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength)
3620 3643
3621 protected: 3644 protected:
3622 virtual bool DataEquals(HValue* other) { return true; } 3645 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
3623 3646
3624 private: 3647 private:
3625 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { 3648 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) {
3626 set_representation(Representation::Integer32()); 3649 set_representation(Representation::Integer32());
3627 SetFlag(kUseGVN); 3650 SetFlag(kUseGVN);
3628 } 3651 }
3629 3652
3630 virtual bool IsDeletable() const { return true; } 3653 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3631 }; 3654 };
3632 3655
3633 3656
3634 class HAccessArgumentsAt: public HTemplateInstruction<3> { 3657 class HAccessArgumentsAt V8_FINAL : public HTemplateInstruction<3> {
3635 public: 3658 public:
3636 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { 3659 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
3637 set_representation(Representation::Tagged()); 3660 set_representation(Representation::Tagged());
3638 SetFlag(kUseGVN); 3661 SetFlag(kUseGVN);
3639 SetOperandAt(0, arguments); 3662 SetOperandAt(0, arguments);
3640 SetOperandAt(1, length); 3663 SetOperandAt(1, length);
3641 SetOperandAt(2, index); 3664 SetOperandAt(2, index);
3642 } 3665 }
3643 3666
3644 virtual void PrintDataTo(StringStream* stream); 3667 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3645 3668
3646 virtual Representation RequiredInputRepresentation(int index) { 3669 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3647 // The arguments elements is considered tagged. 3670 // The arguments elements is considered tagged.
3648 return index == 0 3671 return index == 0
3649 ? Representation::Tagged() 3672 ? Representation::Tagged()
3650 : Representation::Integer32(); 3673 : Representation::Integer32();
3651 } 3674 }
3652 3675
3653 HValue* arguments() { return OperandAt(0); } 3676 HValue* arguments() { return OperandAt(0); }
3654 HValue* length() { return OperandAt(1); } 3677 HValue* length() { return OperandAt(1); }
3655 HValue* index() { return OperandAt(2); } 3678 HValue* index() { return OperandAt(2); }
3656 3679
3657 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt) 3680 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt)
3658 3681
3659 virtual bool DataEquals(HValue* other) { return true; } 3682 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
3660 }; 3683 };
3661 3684
3662 3685
3663 class HBoundsCheckBaseIndexInformation; 3686 class HBoundsCheckBaseIndexInformation;
3664 3687
3665 3688
3666 class HBoundsCheck: public HTemplateInstruction<2> { 3689 class HBoundsCheck V8_FINAL : public HTemplateInstruction<2> {
3667 public: 3690 public:
3668 DECLARE_INSTRUCTION_FACTORY_P2(HBoundsCheck, HValue*, HValue*); 3691 DECLARE_INSTRUCTION_FACTORY_P2(HBoundsCheck, HValue*, HValue*);
3669 3692
3670 bool skip_check() const { return skip_check_; } 3693 bool skip_check() const { return skip_check_; }
3671 void set_skip_check() { skip_check_ = true; } 3694 void set_skip_check() { skip_check_ = true; }
3672 3695
3673 HValue* base() { return base_; } 3696 HValue* base() { return base_; }
3674 int offset() { return offset_; } 3697 int offset() { return offset_; }
3675 int scale() { return scale_; } 3698 int scale() { return scale_; }
3676 3699
3677 void ApplyIndexChange(); 3700 void ApplyIndexChange();
3678 bool DetectCompoundIndex() { 3701 bool DetectCompoundIndex() {
3679 ASSERT(base() == NULL); 3702 ASSERT(base() == NULL);
3680 3703
3681 DecompositionResult decomposition; 3704 DecompositionResult decomposition;
3682 if (index()->TryDecompose(&decomposition)) { 3705 if (index()->TryDecompose(&decomposition)) {
3683 base_ = decomposition.base(); 3706 base_ = decomposition.base();
3684 offset_ = decomposition.offset(); 3707 offset_ = decomposition.offset();
3685 scale_ = decomposition.scale(); 3708 scale_ = decomposition.scale();
3686 return true; 3709 return true;
3687 } else { 3710 } else {
3688 base_ = index(); 3711 base_ = index();
3689 offset_ = 0; 3712 offset_ = 0;
3690 scale_ = 0; 3713 scale_ = 0;
3691 return false; 3714 return false;
3692 } 3715 }
3693 } 3716 }
3694 3717
3695 virtual Representation RequiredInputRepresentation(int arg_index) { 3718 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3696 return representation(); 3719 return representation();
3697 } 3720 }
3698 3721
3699 virtual void PrintDataTo(StringStream* stream); 3722 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3700 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); 3723 virtual void InferRepresentation(
3724 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
3701 3725
3702 HValue* index() { return OperandAt(0); } 3726 HValue* index() { return OperandAt(0); }
3703 HValue* length() { return OperandAt(1); } 3727 HValue* length() { return OperandAt(1); }
3704 bool allow_equality() { return allow_equality_; } 3728 bool allow_equality() { return allow_equality_; }
3705 void set_allow_equality(bool v) { allow_equality_ = v; } 3729 void set_allow_equality(bool v) { allow_equality_ = v; }
3706 3730
3707 virtual int RedefinedOperandIndex() { return 0; } 3731 virtual int RedefinedOperandIndex() V8_OVERRIDE { return 0; }
3708 virtual bool IsPurelyInformativeDefinition() { return skip_check(); } 3732 virtual bool IsPurelyInformativeDefinition() V8_OVERRIDE {
3733 return skip_check();
3734 }
3709 3735
3710 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) 3736 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
3711 3737
3712 protected: 3738 protected:
3713 friend class HBoundsCheckBaseIndexInformation; 3739 friend class HBoundsCheckBaseIndexInformation;
3714 3740
3715 virtual bool DataEquals(HValue* other) { return true; } 3741 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
3716 bool skip_check_; 3742 bool skip_check_;
3717 HValue* base_; 3743 HValue* base_;
3718 int offset_; 3744 int offset_;
3719 int scale_; 3745 int scale_;
3720 bool allow_equality_; 3746 bool allow_equality_;
3721 3747
3722 private: 3748 private:
3723 // Normally HBoundsCheck should be created using the 3749 // Normally HBoundsCheck should be created using the
3724 // HGraphBuilder::AddBoundsCheck() helper. 3750 // HGraphBuilder::AddBoundsCheck() helper.
3725 // However when building stubs, where we know that the arguments are Int32, 3751 // However when building stubs, where we know that the arguments are Int32,
3726 // it makes sense to invoke this constructor directly. 3752 // it makes sense to invoke this constructor directly.
3727 HBoundsCheck(HValue* index, HValue* length) 3753 HBoundsCheck(HValue* index, HValue* length)
3728 : skip_check_(false), 3754 : skip_check_(false),
3729 base_(NULL), offset_(0), scale_(0), 3755 base_(NULL), offset_(0), scale_(0),
3730 allow_equality_(false) { 3756 allow_equality_(false) {
3731 SetOperandAt(0, index); 3757 SetOperandAt(0, index);
3732 SetOperandAt(1, length); 3758 SetOperandAt(1, length);
3733 SetFlag(kFlexibleRepresentation); 3759 SetFlag(kFlexibleRepresentation);
3734 SetFlag(kUseGVN); 3760 SetFlag(kUseGVN);
3735 } 3761 }
3736 3762
3737 virtual bool IsDeletable() const { 3763 virtual bool IsDeletable() const V8_OVERRIDE {
3738 return skip_check() && !FLAG_debug_code; 3764 return skip_check() && !FLAG_debug_code;
3739 } 3765 }
3740 }; 3766 };
3741 3767
3742 3768
3743 class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> { 3769 class HBoundsCheckBaseIndexInformation V8_FINAL
3770 : public HTemplateInstruction<2> {
3744 public: 3771 public:
3745 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) { 3772 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) {
3746 DecompositionResult decomposition; 3773 DecompositionResult decomposition;
3747 if (check->index()->TryDecompose(&decomposition)) { 3774 if (check->index()->TryDecompose(&decomposition)) {
3748 SetOperandAt(0, decomposition.base()); 3775 SetOperandAt(0, decomposition.base());
3749 SetOperandAt(1, check); 3776 SetOperandAt(1, check);
3750 } else { 3777 } else {
3751 UNREACHABLE(); 3778 UNREACHABLE();
3752 } 3779 }
3753 } 3780 }
3754 3781
3755 HValue* base_index() { return OperandAt(0); } 3782 HValue* base_index() { return OperandAt(0); }
3756 HBoundsCheck* bounds_check() { return HBoundsCheck::cast(OperandAt(1)); } 3783 HBoundsCheck* bounds_check() { return HBoundsCheck::cast(OperandAt(1)); }
3757 3784
3758 DECLARE_CONCRETE_INSTRUCTION(BoundsCheckBaseIndexInformation) 3785 DECLARE_CONCRETE_INSTRUCTION(BoundsCheckBaseIndexInformation)
3759 3786
3760 virtual Representation RequiredInputRepresentation(int arg_index) { 3787 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3761 return representation(); 3788 return representation();
3762 } 3789 }
3763 3790
3764 virtual void PrintDataTo(StringStream* stream); 3791 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3765 3792
3766 virtual int RedefinedOperandIndex() { return 0; } 3793 virtual int RedefinedOperandIndex() V8_OVERRIDE { return 0; }
3767 virtual bool IsPurelyInformativeDefinition() { return true; } 3794 virtual bool IsPurelyInformativeDefinition() V8_OVERRIDE { return true; }
3768 }; 3795 };
3769 3796
3770 3797
3771 class HBitwiseBinaryOperation: public HBinaryOperation { 3798 class HBitwiseBinaryOperation : public HBinaryOperation {
3772 public: 3799 public:
3773 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right, 3800 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right,
3774 HType type = HType::Tagged()) 3801 HType type = HType::Tagged())
3775 : HBinaryOperation(context, left, right, type) { 3802 : HBinaryOperation(context, left, right, type) {
3776 SetFlag(kFlexibleRepresentation); 3803 SetFlag(kFlexibleRepresentation);
3777 SetFlag(kTruncatingToInt32); 3804 SetFlag(kTruncatingToInt32);
3778 SetFlag(kAllowUndefinedAsNaN); 3805 SetFlag(kAllowUndefinedAsNaN);
3779 SetAllSideEffects(); 3806 SetAllSideEffects();
3780 } 3807 }
3781 3808
3782 virtual void RepresentationChanged(Representation to) { 3809 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
3783 if (!to.IsTagged()) { 3810 if (!to.IsTagged()) {
3784 ASSERT(to.IsSmiOrInteger32()); 3811 ASSERT(to.IsSmiOrInteger32());
3785 ClearAllSideEffects(); 3812 ClearAllSideEffects();
3786 SetFlag(kUseGVN); 3813 SetFlag(kUseGVN);
3787 } else { 3814 } else {
3788 SetAllSideEffects(); 3815 SetAllSideEffects();
3789 ClearFlag(kUseGVN); 3816 ClearFlag(kUseGVN);
3790 } 3817 }
3791 } 3818 }
3792 3819
3793 virtual void UpdateRepresentation(Representation new_rep, 3820 virtual void UpdateRepresentation(Representation new_rep,
3794 HInferRepresentationPhase* h_infer, 3821 HInferRepresentationPhase* h_infer,
3795 const char* reason) { 3822 const char* reason) V8_OVERRIDE {
3796 // We only generate either int32 or generic tagged bitwise operations. 3823 // We only generate either int32 or generic tagged bitwise operations.
3797 if (new_rep.IsDouble()) new_rep = Representation::Integer32(); 3824 if (new_rep.IsDouble()) new_rep = Representation::Integer32();
3798 HBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 3825 HBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
3799 } 3826 }
3800 3827
3801 virtual Representation observed_input_representation(int index) { 3828 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
3802 Representation r = HBinaryOperation::observed_input_representation(index); 3829 Representation r = HBinaryOperation::observed_input_representation(index);
3803 if (r.IsDouble()) return Representation::Integer32(); 3830 if (r.IsDouble()) return Representation::Integer32();
3804 return r; 3831 return r;
3805 } 3832 }
3806 3833
3807 virtual void initialize_output_representation(Representation observed) { 3834 virtual void initialize_output_representation(Representation observed) {
3808 if (observed.IsDouble()) observed = Representation::Integer32(); 3835 if (observed.IsDouble()) observed = Representation::Integer32();
3809 HBinaryOperation::initialize_output_representation(observed); 3836 HBinaryOperation::initialize_output_representation(observed);
3810 } 3837 }
3811 3838
3812 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) 3839 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
3813 3840
3814 private: 3841 private:
3815 virtual bool IsDeletable() const { return true; } 3842 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3816 }; 3843 };
3817 3844
3818 3845
3819 class HMathFloorOfDiv: public HBinaryOperation { 3846 class HMathFloorOfDiv V8_FINAL : public HBinaryOperation {
3820 public: 3847 public:
3821 static HMathFloorOfDiv* New(Zone* zone, 3848 static HMathFloorOfDiv* New(Zone* zone,
3822 HValue* context, 3849 HValue* context,
3823 HValue* left, 3850 HValue* left,
3824 HValue* right) { 3851 HValue* right) {
3825 return new(zone) HMathFloorOfDiv(context, left, right); 3852 return new(zone) HMathFloorOfDiv(context, left, right);
3826 } 3853 }
3827 3854
3828 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 3855 virtual HValue* EnsureAndPropagateNotMinusZero(
3829 3856 BitVector* visited) V8_OVERRIDE;
3830 virtual Representation RequiredInputRepresentation(int index) {
3831 return Representation::Integer32();
3832 }
3833 3857
3834 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) 3858 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv)
3835 3859
3836 protected: 3860 protected:
3837 virtual bool DataEquals(HValue* other) { return true; } 3861 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
3838 3862
3839 private: 3863 private:
3840 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) 3864 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right)
3841 : HBinaryOperation(context, left, right) { 3865 : HBinaryOperation(context, left, right) {
3842 set_representation(Representation::Integer32()); 3866 set_representation(Representation::Integer32());
3843 SetFlag(kUseGVN); 3867 SetFlag(kUseGVN);
3844 SetFlag(kCanOverflow); 3868 SetFlag(kCanOverflow);
3845 if (!right->IsConstant()) { 3869 if (!right->IsConstant()) {
3846 SetFlag(kCanBeDivByZero); 3870 SetFlag(kCanBeDivByZero);
3847 } 3871 }
3848 SetFlag(kAllowUndefinedAsNaN); 3872 SetFlag(kAllowUndefinedAsNaN);
3849 } 3873 }
3850 3874
3851 virtual bool IsDeletable() const { return true; } 3875 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3852 }; 3876 };
3853 3877
3854 3878
3855 class HArithmeticBinaryOperation: public HBinaryOperation { 3879 class HArithmeticBinaryOperation : public HBinaryOperation {
3856 public: 3880 public:
3857 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) 3881 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
3858 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { 3882 : HBinaryOperation(context, left, right, HType::TaggedNumber()) {
3859 SetAllSideEffects(); 3883 SetAllSideEffects();
3860 SetFlag(kFlexibleRepresentation); 3884 SetFlag(kFlexibleRepresentation);
3861 SetFlag(kAllowUndefinedAsNaN); 3885 SetFlag(kAllowUndefinedAsNaN);
3862 } 3886 }
3863 3887
3864 virtual void RepresentationChanged(Representation to) { 3888 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
3865 if (to.IsTagged()) { 3889 if (to.IsTagged()) {
3866 SetAllSideEffects(); 3890 SetAllSideEffects();
3867 ClearFlag(kUseGVN); 3891 ClearFlag(kUseGVN);
3868 } else { 3892 } else {
3869 ClearAllSideEffects(); 3893 ClearAllSideEffects();
3870 SetFlag(kUseGVN); 3894 SetFlag(kUseGVN);
3871 } 3895 }
3872 } 3896 }
3873 3897
3874 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) 3898 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation)
3875 3899
3876 private: 3900 private:
3877 virtual bool IsDeletable() const { return true; } 3901 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
3878 }; 3902 };
3879 3903
3880 3904
3881 class HCompareGeneric: public HBinaryOperation { 3905 class HCompareGeneric V8_FINAL : public HBinaryOperation {
3882 public: 3906 public:
3883 HCompareGeneric(HValue* context, 3907 HCompareGeneric(HValue* context,
3884 HValue* left, 3908 HValue* left,
3885 HValue* right, 3909 HValue* right,
3886 Token::Value token) 3910 Token::Value token)
3887 : HBinaryOperation(context, left, right, HType::Boolean()), 3911 : HBinaryOperation(context, left, right, HType::Boolean()),
3888 token_(token) { 3912 token_(token) {
3889 ASSERT(Token::IsCompareOp(token)); 3913 ASSERT(Token::IsCompareOp(token));
3890 set_representation(Representation::Tagged()); 3914 set_representation(Representation::Tagged());
3891 SetAllSideEffects(); 3915 SetAllSideEffects();
3892 } 3916 }
3893 3917
3894 virtual Representation RequiredInputRepresentation(int index) { 3918 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3895 return index == 0 3919 return index == 0
3896 ? Representation::Tagged() 3920 ? Representation::Tagged()
3897 : representation(); 3921 : representation();
3898 } 3922 }
3899 3923
3900 Token::Value token() const { return token_; } 3924 Token::Value token() const { return token_; }
3901 virtual void PrintDataTo(StringStream* stream); 3925 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3902 3926
3903 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) 3927 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric)
3904 3928
3905 private: 3929 private:
3906 Token::Value token_; 3930 Token::Value token_;
3907 }; 3931 };
3908 3932
3909 3933
3910 class HCompareNumericAndBranch: public HTemplateControlInstruction<2, 2> { 3934 class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
3911 public: 3935 public:
3912 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token) 3936 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token)
3913 : token_(token) { 3937 : token_(token) {
3914 SetFlag(kFlexibleRepresentation); 3938 SetFlag(kFlexibleRepresentation);
3915 ASSERT(Token::IsCompareOp(token)); 3939 ASSERT(Token::IsCompareOp(token));
3916 SetOperandAt(0, left); 3940 SetOperandAt(0, left);
3917 SetOperandAt(1, right); 3941 SetOperandAt(1, right);
3918 } 3942 }
3919 3943
3920 HValue* left() { return OperandAt(0); } 3944 HValue* left() { return OperandAt(0); }
3921 HValue* right() { return OperandAt(1); } 3945 HValue* right() { return OperandAt(1); }
3922 Token::Value token() const { return token_; } 3946 Token::Value token() const { return token_; }
3923 3947
3924 void set_observed_input_representation(Representation left, 3948 void set_observed_input_representation(Representation left,
3925 Representation right) { 3949 Representation right) {
3926 observed_input_representation_[0] = left; 3950 observed_input_representation_[0] = left;
3927 observed_input_representation_[1] = right; 3951 observed_input_representation_[1] = right;
3928 } 3952 }
3929 3953
3930 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); 3954 virtual void InferRepresentation(
3955 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
3931 3956
3932 virtual Representation RequiredInputRepresentation(int index) { 3957 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3933 return representation(); 3958 return representation();
3934 } 3959 }
3935 virtual Representation observed_input_representation(int index) { 3960 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
3936 return observed_input_representation_[index]; 3961 return observed_input_representation_[index];
3937 } 3962 }
3938 virtual void PrintDataTo(StringStream* stream); 3963 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3939 3964
3940 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) 3965 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
3941 3966
3942 private: 3967 private:
3943 Representation observed_input_representation_[2]; 3968 Representation observed_input_representation_[2];
3944 Token::Value token_; 3969 Token::Value token_;
3945 }; 3970 };
3946 3971
3947 3972
3948 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { 3973 class HCompareHoleAndBranch V8_FINAL
3974 : public HTemplateControlInstruction<2, 1> {
3949 public: 3975 public:
3950 // TODO(danno): make this private when the IfBuilder properly constructs 3976 // TODO(danno): make this private when the IfBuilder properly constructs
3951 // control flow instructions. 3977 // control flow instructions.
3978 explicit HCompareHoleAndBranch(HValue* object) {
3979 SetFlag(kFlexibleRepresentation);
3980 SetFlag(kAllowUndefinedAsNaN);
3981 SetOperandAt(0, object);
3982 }
3983
3984 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*);
3985
3986 HValue* object() { return OperandAt(0); }
3987
3988 virtual void InferRepresentation(
3989 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
3990
3991 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3992 return representation();
3993 }
3994
3995 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3996
3997 DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch)
3998 };
3999
4000
4001 class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
4002 public:
4003 // TODO(danno): make this private when the IfBuilder properly constructs
4004 // control flow instructions.
3952 HCompareObjectEqAndBranch(HValue* left, 4005 HCompareObjectEqAndBranch(HValue* left,
3953 HValue* right) { 4006 HValue* right) {
3954 SetOperandAt(0, left); 4007 SetOperandAt(0, left);
3955 SetOperandAt(1, right); 4008 SetOperandAt(1, right);
3956 } 4009 }
3957 4010
3958 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*); 4011 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
3959 4012
3960 HValue* left() { return OperandAt(0); } 4013 HValue* left() { return OperandAt(0); }
3961 HValue* right() { return OperandAt(1); } 4014 HValue* right() { return OperandAt(1); }
3962 4015
3963 virtual void PrintDataTo(StringStream* stream); 4016 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
3964 4017
3965 virtual Representation RequiredInputRepresentation(int index) { 4018 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3966 return Representation::Tagged(); 4019 return Representation::Tagged();
3967 } 4020 }
3968 4021
3969 virtual Representation observed_input_representation(int index) { 4022 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
3970 return Representation::Tagged(); 4023 return Representation::Tagged();
3971 } 4024 }
3972 4025
3973 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) 4026 DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
3974 }; 4027 };
3975 4028
3976 4029
3977 class HIsObjectAndBranch: public HUnaryControlInstruction { 4030 class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
3978 public: 4031 public:
3979 explicit HIsObjectAndBranch(HValue* value) 4032 explicit HIsObjectAndBranch(HValue* value)
3980 : HUnaryControlInstruction(value, NULL, NULL) { } 4033 : HUnaryControlInstruction(value, NULL, NULL) { }
3981 4034
3982 virtual Representation RequiredInputRepresentation(int index) { 4035 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3983 return Representation::Tagged(); 4036 return Representation::Tagged();
3984 } 4037 }
3985 4038
3986 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) 4039 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch)
3987 }; 4040 };
3988 4041
3989 class HIsStringAndBranch: public HUnaryControlInstruction { 4042 class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction {
3990 public: 4043 public:
3991 explicit HIsStringAndBranch(HValue* value) 4044 explicit HIsStringAndBranch(HValue* value)
3992 : HUnaryControlInstruction(value, NULL, NULL) { } 4045 : HUnaryControlInstruction(value, NULL, NULL) { }
3993 4046
3994 virtual Representation RequiredInputRepresentation(int index) { 4047 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
3995 return Representation::Tagged(); 4048 return Representation::Tagged();
3996 } 4049 }
3997 4050
3998 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch) 4051 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch)
3999 }; 4052 };
4000 4053
4001 4054
4002 class HIsSmiAndBranch: public HUnaryControlInstruction { 4055 class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
4003 public: 4056 public:
4004 explicit HIsSmiAndBranch(HValue* value) 4057 explicit HIsSmiAndBranch(HValue* value)
4005 : HUnaryControlInstruction(value, NULL, NULL) { } 4058 : HUnaryControlInstruction(value, NULL, NULL) { }
4006 4059
4007 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) 4060 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch)
4008 4061
4009 virtual Representation RequiredInputRepresentation(int index) { 4062 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4010 return Representation::Tagged(); 4063 return Representation::Tagged();
4011 } 4064 }
4012 4065
4013 protected: 4066 protected:
4014 virtual bool DataEquals(HValue* other) { return true; } 4067 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4015 }; 4068 };
4016 4069
4017 4070
4018 class HIsUndetectableAndBranch: public HUnaryControlInstruction { 4071 class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction {
4019 public: 4072 public:
4020 explicit HIsUndetectableAndBranch(HValue* value) 4073 explicit HIsUndetectableAndBranch(HValue* value)
4021 : HUnaryControlInstruction(value, NULL, NULL) { } 4074 : HUnaryControlInstruction(value, NULL, NULL) { }
4022 4075
4023 virtual Representation RequiredInputRepresentation(int index) { 4076 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4024 return Representation::Tagged(); 4077 return Representation::Tagged();
4025 } 4078 }
4026 4079
4027 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) 4080 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch)
4028 }; 4081 };
4029 4082
4030 4083
4031 class HStringCompareAndBranch: public HTemplateControlInstruction<2, 3> { 4084 class HStringCompareAndBranch : public HTemplateControlInstruction<2, 3> {
4032 public: 4085 public:
4033 HStringCompareAndBranch(HValue* context, 4086 HStringCompareAndBranch(HValue* context,
4034 HValue* left, 4087 HValue* left,
4035 HValue* right, 4088 HValue* right,
4036 Token::Value token) 4089 Token::Value token)
4037 : token_(token) { 4090 : token_(token) {
4038 ASSERT(Token::IsCompareOp(token)); 4091 ASSERT(Token::IsCompareOp(token));
4039 SetOperandAt(0, context); 4092 SetOperandAt(0, context);
4040 SetOperandAt(1, left); 4093 SetOperandAt(1, left);
4041 SetOperandAt(2, right); 4094 SetOperandAt(2, right);
4042 set_representation(Representation::Tagged()); 4095 set_representation(Representation::Tagged());
4096 SetGVNFlag(kChangesNewSpacePromotion);
4043 } 4097 }
4044 4098
4045 HValue* context() { return OperandAt(0); } 4099 HValue* context() { return OperandAt(0); }
4046 HValue* left() { return OperandAt(1); } 4100 HValue* left() { return OperandAt(1); }
4047 HValue* right() { return OperandAt(2); } 4101 HValue* right() { return OperandAt(2); }
4048 Token::Value token() const { return token_; } 4102 Token::Value token() const { return token_; }
4049 4103
4050 virtual void PrintDataTo(StringStream* stream); 4104 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4051 4105
4052 virtual Representation RequiredInputRepresentation(int index) { 4106 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4053 return Representation::Tagged(); 4107 return Representation::Tagged();
4054 } 4108 }
4055 4109
4056 Representation GetInputRepresentation() const { 4110 Representation GetInputRepresentation() const {
4057 return Representation::Tagged(); 4111 return Representation::Tagged();
4058 } 4112 }
4059 4113
4060 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch) 4114 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch)
4061 4115
4062 private: 4116 private:
4063 Token::Value token_; 4117 Token::Value token_;
4064 }; 4118 };
4065 4119
4066 4120
4067 class HIsConstructCallAndBranch: public HTemplateControlInstruction<2, 0> { 4121 class HIsConstructCallAndBranch : public HTemplateControlInstruction<2, 0> {
4068 public: 4122 public:
4069 virtual Representation RequiredInputRepresentation(int index) { 4123 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4070 return Representation::None(); 4124 return Representation::None();
4071 } 4125 }
4072 4126
4073 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch) 4127 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch)
4074 }; 4128 };
4075 4129
4076 4130
4077 class HHasInstanceTypeAndBranch: public HUnaryControlInstruction { 4131 class HHasInstanceTypeAndBranch V8_FINAL : public HUnaryControlInstruction {
4078 public: 4132 public:
4079 HHasInstanceTypeAndBranch(HValue* value, InstanceType type) 4133 HHasInstanceTypeAndBranch(HValue* value, InstanceType type)
4080 : HUnaryControlInstruction(value, NULL, NULL), from_(type), to_(type) { } 4134 : HUnaryControlInstruction(value, NULL, NULL), from_(type), to_(type) { }
4081 HHasInstanceTypeAndBranch(HValue* value, InstanceType from, InstanceType to) 4135 HHasInstanceTypeAndBranch(HValue* value, InstanceType from, InstanceType to)
4082 : HUnaryControlInstruction(value, NULL, NULL), from_(from), to_(to) { 4136 : HUnaryControlInstruction(value, NULL, NULL), from_(from), to_(to) {
4083 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. 4137 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend.
4084 } 4138 }
4085 4139
4086 InstanceType from() { return from_; } 4140 InstanceType from() { return from_; }
4087 InstanceType to() { return to_; } 4141 InstanceType to() { return to_; }
4088 4142
4089 virtual void PrintDataTo(StringStream* stream); 4143 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4090 4144
4091 virtual Representation RequiredInputRepresentation(int index) { 4145 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4092 return Representation::Tagged(); 4146 return Representation::Tagged();
4093 } 4147 }
4094 4148
4095 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch) 4149 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch)
4096 4150
4097 private: 4151 private:
4098 InstanceType from_; 4152 InstanceType from_;
4099 InstanceType to_; // Inclusive range, not all combinations work. 4153 InstanceType to_; // Inclusive range, not all combinations work.
4100 }; 4154 };
4101 4155
4102 4156
4103 class HHasCachedArrayIndexAndBranch: public HUnaryControlInstruction { 4157 class HHasCachedArrayIndexAndBranch V8_FINAL : public HUnaryControlInstruction {
4104 public: 4158 public:
4105 explicit HHasCachedArrayIndexAndBranch(HValue* value) 4159 explicit HHasCachedArrayIndexAndBranch(HValue* value)
4106 : HUnaryControlInstruction(value, NULL, NULL) { } 4160 : HUnaryControlInstruction(value, NULL, NULL) { }
4107 4161
4108 virtual Representation RequiredInputRepresentation(int index) { 4162 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4109 return Representation::Tagged(); 4163 return Representation::Tagged();
4110 } 4164 }
4111 4165
4112 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch) 4166 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch)
4113 }; 4167 };
4114 4168
4115 4169
4116 class HGetCachedArrayIndex: public HUnaryOperation { 4170 class HGetCachedArrayIndex V8_FINAL : public HUnaryOperation {
4117 public: 4171 public:
4118 explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) { 4172 explicit HGetCachedArrayIndex(HValue* value) : HUnaryOperation(value) {
4119 set_representation(Representation::Tagged()); 4173 set_representation(Representation::Tagged());
4120 SetFlag(kUseGVN); 4174 SetFlag(kUseGVN);
4121 } 4175 }
4122 4176
4123 virtual Representation RequiredInputRepresentation(int index) { 4177 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4124 return Representation::Tagged(); 4178 return Representation::Tagged();
4125 } 4179 }
4126 4180
4127 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex) 4181 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex)
4128 4182
4129 protected: 4183 protected:
4130 virtual bool DataEquals(HValue* other) { return true; } 4184 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4131 4185
4132 private: 4186 private:
4133 virtual bool IsDeletable() const { return true; } 4187 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
4134 }; 4188 };
4135 4189
4136 4190
4137 class HClassOfTestAndBranch: public HUnaryControlInstruction { 4191 class HClassOfTestAndBranch V8_FINAL : public HUnaryControlInstruction {
4138 public: 4192 public:
4139 HClassOfTestAndBranch(HValue* value, Handle<String> class_name) 4193 HClassOfTestAndBranch(HValue* value, Handle<String> class_name)
4140 : HUnaryControlInstruction(value, NULL, NULL), 4194 : HUnaryControlInstruction(value, NULL, NULL),
4141 class_name_(class_name) { } 4195 class_name_(class_name) { }
4142 4196
4143 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch) 4197 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch)
4144 4198
4145 virtual Representation RequiredInputRepresentation(int index) { 4199 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4146 return Representation::Tagged(); 4200 return Representation::Tagged();
4147 } 4201 }
4148 4202
4149 virtual void PrintDataTo(StringStream* stream); 4203 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4150 4204
4151 Handle<String> class_name() const { return class_name_; } 4205 Handle<String> class_name() const { return class_name_; }
4152 4206
4153 private: 4207 private:
4154 Handle<String> class_name_; 4208 Handle<String> class_name_;
4155 }; 4209 };
4156 4210
4157 4211
4158 class HTypeofIsAndBranch: public HUnaryControlInstruction { 4212 class HTypeofIsAndBranch V8_FINAL : public HUnaryControlInstruction {
4159 public: 4213 public:
4160 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal) 4214 HTypeofIsAndBranch(HValue* value, Handle<String> type_literal)
4161 : HUnaryControlInstruction(value, NULL, NULL), 4215 : HUnaryControlInstruction(value, NULL, NULL),
4162 type_literal_(type_literal) { } 4216 type_literal_(type_literal) { }
4163 4217
4164 Handle<String> type_literal() { return type_literal_; } 4218 Handle<String> type_literal() { return type_literal_; }
4165 virtual void PrintDataTo(StringStream* stream); 4219 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4166 4220
4167 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch) 4221 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch)
4168 4222
4169 virtual Representation RequiredInputRepresentation(int index) { 4223 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4170 return Representation::Tagged(); 4224 return Representation::Tagged();
4171 } 4225 }
4172 4226
4173 private: 4227 private:
4174 Handle<String> type_literal_; 4228 Handle<String> type_literal_;
4175 }; 4229 };
4176 4230
4177 4231
4178 class HInstanceOf: public HBinaryOperation { 4232 class HInstanceOf V8_FINAL : public HBinaryOperation {
4179 public: 4233 public:
4180 HInstanceOf(HValue* context, HValue* left, HValue* right) 4234 HInstanceOf(HValue* context, HValue* left, HValue* right)
4181 : HBinaryOperation(context, left, right, HType::Boolean()) { 4235 : HBinaryOperation(context, left, right, HType::Boolean()) {
4182 set_representation(Representation::Tagged()); 4236 set_representation(Representation::Tagged());
4183 SetAllSideEffects(); 4237 SetAllSideEffects();
4184 } 4238 }
4185 4239
4186 virtual Representation RequiredInputRepresentation(int index) { 4240 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4187 return Representation::Tagged(); 4241 return Representation::Tagged();
4188 } 4242 }
4189 4243
4190 virtual void PrintDataTo(StringStream* stream); 4244 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4191 4245
4192 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) 4246 DECLARE_CONCRETE_INSTRUCTION(InstanceOf)
4193 }; 4247 };
4194 4248
4195 4249
4196 class HInstanceOfKnownGlobal: public HTemplateInstruction<2> { 4250 class HInstanceOfKnownGlobal V8_FINAL : public HTemplateInstruction<2> {
4197 public: 4251 public:
4198 HInstanceOfKnownGlobal(HValue* context, 4252 HInstanceOfKnownGlobal(HValue* context,
4199 HValue* left, 4253 HValue* left,
4200 Handle<JSFunction> right) 4254 Handle<JSFunction> right)
4201 : HTemplateInstruction<2>(HType::Boolean()), function_(right) { 4255 : HTemplateInstruction<2>(HType::Boolean()), function_(right) {
4202 SetOperandAt(0, context); 4256 SetOperandAt(0, context);
4203 SetOperandAt(1, left); 4257 SetOperandAt(1, left);
4204 set_representation(Representation::Tagged()); 4258 set_representation(Representation::Tagged());
4205 SetAllSideEffects(); 4259 SetAllSideEffects();
4206 } 4260 }
4207 4261
4208 HValue* context() { return OperandAt(0); } 4262 HValue* context() { return OperandAt(0); }
4209 HValue* left() { return OperandAt(1); } 4263 HValue* left() { return OperandAt(1); }
4210 Handle<JSFunction> function() { return function_; } 4264 Handle<JSFunction> function() { return function_; }
4211 4265
4212 virtual Representation RequiredInputRepresentation(int index) { 4266 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4213 return Representation::Tagged(); 4267 return Representation::Tagged();
4214 } 4268 }
4215 4269
4216 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) 4270 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal)
4217 4271
4218 private: 4272 private:
4219 Handle<JSFunction> function_; 4273 Handle<JSFunction> function_;
4220 }; 4274 };
4221 4275
4222 4276
4223 // TODO(mstarzinger): This instruction should be modeled as a load of the map 4277 // TODO(mstarzinger): This instruction should be modeled as a load of the map
4224 // field followed by a load of the instance size field once HLoadNamedField is 4278 // field followed by a load of the instance size field once HLoadNamedField is
4225 // flexible enough to accommodate byte-field loads. 4279 // flexible enough to accommodate byte-field loads.
4226 class HInstanceSize: public HTemplateInstruction<1> { 4280 class HInstanceSize V8_FINAL : public HTemplateInstruction<1> {
4227 public: 4281 public:
4228 explicit HInstanceSize(HValue* object) { 4282 explicit HInstanceSize(HValue* object) {
4229 SetOperandAt(0, object); 4283 SetOperandAt(0, object);
4230 set_representation(Representation::Integer32()); 4284 set_representation(Representation::Integer32());
4231 } 4285 }
4232 4286
4233 HValue* object() { return OperandAt(0); } 4287 HValue* object() { return OperandAt(0); }
4234 4288
4235 virtual Representation RequiredInputRepresentation(int index) { 4289 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4236 return Representation::Tagged(); 4290 return Representation::Tagged();
4237 } 4291 }
4238 4292
4239 DECLARE_CONCRETE_INSTRUCTION(InstanceSize) 4293 DECLARE_CONCRETE_INSTRUCTION(InstanceSize)
4240 }; 4294 };
4241 4295
4242 4296
4243 class HPower: public HTemplateInstruction<2> { 4297 class HPower V8_FINAL : public HTemplateInstruction<2> {
4244 public: 4298 public:
4245 static HInstruction* New(Zone* zone, 4299 static HInstruction* New(Zone* zone,
4246 HValue* context, 4300 HValue* context,
4247 HValue* left, 4301 HValue* left,
4248 HValue* right); 4302 HValue* right);
4249 4303
4250 HValue* left() { return OperandAt(0); } 4304 HValue* left() { return OperandAt(0); }
4251 HValue* right() const { return OperandAt(1); } 4305 HValue* right() const { return OperandAt(1); }
4252 4306
4253 virtual Representation RequiredInputRepresentation(int index) { 4307 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4254 return index == 0 4308 return index == 0
4255 ? Representation::Double() 4309 ? Representation::Double()
4256 : Representation::None(); 4310 : Representation::None();
4257 } 4311 }
4258 virtual Representation observed_input_representation(int index) { 4312 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4259 return RequiredInputRepresentation(index); 4313 return RequiredInputRepresentation(index);
4260 } 4314 }
4261 4315
4262 DECLARE_CONCRETE_INSTRUCTION(Power) 4316 DECLARE_CONCRETE_INSTRUCTION(Power)
4263 4317
4264 protected: 4318 protected:
4265 virtual bool DataEquals(HValue* other) { return true; } 4319 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4266 4320
4267 private: 4321 private:
4268 HPower(HValue* left, HValue* right) { 4322 HPower(HValue* left, HValue* right) {
4269 SetOperandAt(0, left); 4323 SetOperandAt(0, left);
4270 SetOperandAt(1, right); 4324 SetOperandAt(1, right);
4271 set_representation(Representation::Double()); 4325 set_representation(Representation::Double());
4272 SetFlag(kUseGVN); 4326 SetFlag(kUseGVN);
4273 SetGVNFlag(kChangesNewSpacePromotion); 4327 SetGVNFlag(kChangesNewSpacePromotion);
4274 } 4328 }
4275 4329
4276 virtual bool IsDeletable() const { 4330 virtual bool IsDeletable() const V8_OVERRIDE {
4277 return !right()->representation().IsTagged(); 4331 return !right()->representation().IsTagged();
4278 } 4332 }
4279 }; 4333 };
4280 4334
4281 4335
4282 class HRandom: public HTemplateInstruction<1> { 4336 class HRandom V8_FINAL : public HTemplateInstruction<1> {
4283 public: 4337 public:
4284 explicit HRandom(HValue* global_object) { 4338 explicit HRandom(HValue* global_object) {
4285 SetOperandAt(0, global_object); 4339 SetOperandAt(0, global_object);
4286 set_representation(Representation::Double()); 4340 set_representation(Representation::Double());
4287 } 4341 }
4288 4342
4289 HValue* global_object() { return OperandAt(0); } 4343 HValue* global_object() { return OperandAt(0); }
4290 4344
4291 virtual Representation RequiredInputRepresentation(int index) { 4345 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4292 return Representation::Tagged(); 4346 return Representation::Tagged();
4293 } 4347 }
4294 4348
4295 DECLARE_CONCRETE_INSTRUCTION(Random) 4349 DECLARE_CONCRETE_INSTRUCTION(Random)
4296 4350
4297 private: 4351 private:
4298 virtual bool IsDeletable() const { return true; } 4352 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
4299 }; 4353 };
4300 4354
4301 4355
4302 class HAdd: public HArithmeticBinaryOperation { 4356 class HAdd V8_FINAL : public HArithmeticBinaryOperation {
4303 public: 4357 public:
4304 static HInstruction* New(Zone* zone, 4358 static HInstruction* New(Zone* zone,
4305 HValue* context, 4359 HValue* context,
4306 HValue* left, 4360 HValue* left,
4307 HValue* right); 4361 HValue* right);
4308 4362
4309 // Add is only commutative if two integer values are added and not if two 4363 // Add is only commutative if two integer values are added and not if two
4310 // tagged values are added (because it might be a String concatenation). 4364 // tagged values are added (because it might be a String concatenation).
4311 virtual bool IsCommutative() const { 4365 virtual bool IsCommutative() const V8_OVERRIDE {
4312 return !representation().IsTagged(); 4366 return !representation().IsTagged();
4313 } 4367 }
4314 4368
4315 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4369 virtual HValue* EnsureAndPropagateNotMinusZero(
4370 BitVector* visited) V8_OVERRIDE;
4316 4371
4317 virtual HValue* Canonicalize(); 4372 virtual HValue* Canonicalize() V8_OVERRIDE;
4318 4373
4319 virtual bool TryDecompose(DecompositionResult* decomposition) { 4374 virtual bool TryDecompose(DecompositionResult* decomposition) V8_OVERRIDE {
4320 if (left()->IsInteger32Constant()) { 4375 if (left()->IsInteger32Constant()) {
4321 decomposition->Apply(right(), left()->GetInteger32Constant()); 4376 decomposition->Apply(right(), left()->GetInteger32Constant());
4322 return true; 4377 return true;
4323 } else if (right()->IsInteger32Constant()) { 4378 } else if (right()->IsInteger32Constant()) {
4324 decomposition->Apply(left(), right()->GetInteger32Constant()); 4379 decomposition->Apply(left(), right()->GetInteger32Constant());
4325 return true; 4380 return true;
4326 } else { 4381 } else {
4327 return false; 4382 return false;
4328 } 4383 }
4329 } 4384 }
4330 4385
4386 virtual void RepresentationChanged(Representation to) V8_OVERRIDE {
4387 if (to.IsTagged()) ClearFlag(kAllowUndefinedAsNaN);
4388 HArithmeticBinaryOperation::RepresentationChanged(to);
4389 }
4390
4331 DECLARE_CONCRETE_INSTRUCTION(Add) 4391 DECLARE_CONCRETE_INSTRUCTION(Add)
4332 4392
4333 protected: 4393 protected:
4334 virtual bool DataEquals(HValue* other) { return true; } 4394 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4335 4395
4336 virtual Range* InferRange(Zone* zone); 4396 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4337 4397
4338 private: 4398 private:
4339 HAdd(HValue* context, HValue* left, HValue* right) 4399 HAdd(HValue* context, HValue* left, HValue* right)
4340 : HArithmeticBinaryOperation(context, left, right) { 4400 : HArithmeticBinaryOperation(context, left, right) {
4341 SetFlag(kCanOverflow); 4401 SetFlag(kCanOverflow);
4342 } 4402 }
4343 }; 4403 };
4344 4404
4345 4405
4346 class HSub: public HArithmeticBinaryOperation { 4406 class HSub V8_FINAL : public HArithmeticBinaryOperation {
4347 public: 4407 public:
4348 static HInstruction* New(Zone* zone, 4408 static HInstruction* New(Zone* zone,
4349 HValue* context, 4409 HValue* context,
4350 HValue* left, 4410 HValue* left,
4351 HValue* right); 4411 HValue* right);
4352 4412
4353 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4413 virtual HValue* EnsureAndPropagateNotMinusZero(
4414 BitVector* visited) V8_OVERRIDE;
4354 4415
4355 virtual HValue* Canonicalize(); 4416 virtual HValue* Canonicalize() V8_OVERRIDE;
4356 4417
4357 virtual bool TryDecompose(DecompositionResult* decomposition) { 4418 virtual bool TryDecompose(DecompositionResult* decomposition) V8_OVERRIDE {
4358 if (right()->IsInteger32Constant()) { 4419 if (right()->IsInteger32Constant()) {
4359 decomposition->Apply(left(), -right()->GetInteger32Constant()); 4420 decomposition->Apply(left(), -right()->GetInteger32Constant());
4360 return true; 4421 return true;
4361 } else { 4422 } else {
4362 return false; 4423 return false;
4363 } 4424 }
4364 } 4425 }
4365 4426
4366 DECLARE_CONCRETE_INSTRUCTION(Sub) 4427 DECLARE_CONCRETE_INSTRUCTION(Sub)
4367 4428
4368 protected: 4429 protected:
4369 virtual bool DataEquals(HValue* other) { return true; } 4430 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4370 4431
4371 virtual Range* InferRange(Zone* zone); 4432 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4372 4433
4373 private: 4434 private:
4374 HSub(HValue* context, HValue* left, HValue* right) 4435 HSub(HValue* context, HValue* left, HValue* right)
4375 : HArithmeticBinaryOperation(context, left, right) { 4436 : HArithmeticBinaryOperation(context, left, right) {
4376 SetFlag(kCanOverflow); 4437 SetFlag(kCanOverflow);
4377 } 4438 }
4378 }; 4439 };
4379 4440
4380 4441
4381 class HMul: public HArithmeticBinaryOperation { 4442 class HMul V8_FINAL : public HArithmeticBinaryOperation {
4382 public: 4443 public:
4383 static HInstruction* New(Zone* zone, 4444 static HInstruction* New(Zone* zone,
4384 HValue* context, 4445 HValue* context,
4385 HValue* left, 4446 HValue* left,
4386 HValue* right); 4447 HValue* right);
4387 4448
4388 static HInstruction* NewImul(Zone* zone, 4449 static HInstruction* NewImul(Zone* zone,
4389 HValue* context, 4450 HValue* context,
4390 HValue* left, 4451 HValue* left,
4391 HValue* right) { 4452 HValue* right) {
4392 HMul* mul = new(zone) HMul(context, left, right); 4453 HMul* mul = new(zone) HMul(context, left, right);
4393 // TODO(mstarzinger): Prevent bailout on minus zero for imul. 4454 // TODO(mstarzinger): Prevent bailout on minus zero for imul.
4394 mul->AssumeRepresentation(Representation::Integer32()); 4455 mul->AssumeRepresentation(Representation::Integer32());
4395 mul->ClearFlag(HValue::kCanOverflow); 4456 mul->ClearFlag(HValue::kCanOverflow);
4396 return mul; 4457 return mul;
4397 } 4458 }
4398 4459
4399 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4460 virtual HValue* EnsureAndPropagateNotMinusZero(
4461 BitVector* visited) V8_OVERRIDE;
4400 4462
4401 virtual HValue* Canonicalize(); 4463 virtual HValue* Canonicalize() V8_OVERRIDE;
4402 4464
4403 // Only commutative if it is certain that not two objects are multiplicated. 4465 // Only commutative if it is certain that not two objects are multiplicated.
4404 virtual bool IsCommutative() const { 4466 virtual bool IsCommutative() const V8_OVERRIDE {
4405 return !representation().IsTagged(); 4467 return !representation().IsTagged();
4406 } 4468 }
4407 4469
4408 virtual void UpdateRepresentation(Representation new_rep, 4470 virtual void UpdateRepresentation(Representation new_rep,
4409 HInferRepresentationPhase* h_infer, 4471 HInferRepresentationPhase* h_infer,
4410 const char* reason) { 4472 const char* reason) V8_OVERRIDE {
4411 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4473 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4412 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4474 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4413 } 4475 }
4414 4476
4415 DECLARE_CONCRETE_INSTRUCTION(Mul) 4477 DECLARE_CONCRETE_INSTRUCTION(Mul)
4416 4478
4417 protected: 4479 protected:
4418 virtual bool DataEquals(HValue* other) { return true; } 4480 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4419 4481
4420 virtual Range* InferRange(Zone* zone); 4482 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4421 4483
4422 private: 4484 private:
4423 HMul(HValue* context, HValue* left, HValue* right) 4485 HMul(HValue* context, HValue* left, HValue* right)
4424 : HArithmeticBinaryOperation(context, left, right) { 4486 : HArithmeticBinaryOperation(context, left, right) {
4425 SetFlag(kCanOverflow); 4487 SetFlag(kCanOverflow);
4426 } 4488 }
4427 }; 4489 };
4428 4490
4429 4491
4430 class HMod: public HArithmeticBinaryOperation { 4492 class HMod V8_FINAL : public HArithmeticBinaryOperation {
4431 public: 4493 public:
4432 static HInstruction* New(Zone* zone, 4494 static HInstruction* New(Zone* zone,
4433 HValue* context, 4495 HValue* context,
4434 HValue* left, 4496 HValue* left,
4435 HValue* right, 4497 HValue* right,
4436 Maybe<int> fixed_right_arg); 4498 Maybe<int> fixed_right_arg);
4437 4499
4438 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } 4500 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
4439 4501
4440 bool HasPowerOf2Divisor() { 4502 bool HasPowerOf2Divisor() {
4441 if (right()->IsConstant() && 4503 if (right()->IsConstant() &&
4442 HConstant::cast(right())->HasInteger32Value()) { 4504 HConstant::cast(right())->HasInteger32Value()) {
4443 int32_t value = HConstant::cast(right())->Integer32Value(); 4505 int32_t value = HConstant::cast(right())->Integer32Value();
4444 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); 4506 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
4445 } 4507 }
4446 4508
4447 return false; 4509 return false;
4448 } 4510 }
4449 4511
4450 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4512 virtual HValue* EnsureAndPropagateNotMinusZero(
4513 BitVector* visited) V8_OVERRIDE;
4451 4514
4452 virtual HValue* Canonicalize(); 4515 virtual HValue* Canonicalize() V8_OVERRIDE;
4453 4516
4454 virtual void UpdateRepresentation(Representation new_rep, 4517 virtual void UpdateRepresentation(Representation new_rep,
4455 HInferRepresentationPhase* h_infer, 4518 HInferRepresentationPhase* h_infer,
4456 const char* reason) { 4519 const char* reason) V8_OVERRIDE {
4457 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4520 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4458 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4521 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4459 } 4522 }
4460 4523
4461 DECLARE_CONCRETE_INSTRUCTION(Mod) 4524 DECLARE_CONCRETE_INSTRUCTION(Mod)
4462 4525
4463 protected: 4526 protected:
4464 virtual bool DataEquals(HValue* other) { return true; } 4527 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4465 4528
4466 virtual Range* InferRange(Zone* zone); 4529 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4467 4530
4468 private: 4531 private:
4469 HMod(HValue* context, 4532 HMod(HValue* context,
4470 HValue* left, 4533 HValue* left,
4471 HValue* right, 4534 HValue* right,
4472 Maybe<int> fixed_right_arg) 4535 Maybe<int> fixed_right_arg)
4473 : HArithmeticBinaryOperation(context, left, right), 4536 : HArithmeticBinaryOperation(context, left, right),
4474 fixed_right_arg_(fixed_right_arg) { 4537 fixed_right_arg_(fixed_right_arg) {
4475 SetFlag(kCanBeDivByZero); 4538 SetFlag(kCanBeDivByZero);
4476 SetFlag(kCanOverflow); 4539 SetFlag(kCanOverflow);
4477 } 4540 }
4478 4541
4479 const Maybe<int> fixed_right_arg_; 4542 const Maybe<int> fixed_right_arg_;
4480 }; 4543 };
4481 4544
4482 4545
4483 class HDiv: public HArithmeticBinaryOperation { 4546 class HDiv V8_FINAL : public HArithmeticBinaryOperation {
4484 public: 4547 public:
4485 static HInstruction* New(Zone* zone, 4548 static HInstruction* New(Zone* zone,
4486 HValue* context, 4549 HValue* context,
4487 HValue* left, 4550 HValue* left,
4488 HValue* right); 4551 HValue* right);
4489 4552
4490 bool HasPowerOf2Divisor() { 4553 bool HasPowerOf2Divisor() {
4491 if (right()->IsInteger32Constant()) { 4554 if (right()->IsInteger32Constant()) {
4492 int32_t value = right()->GetInteger32Constant(); 4555 int32_t value = right()->GetInteger32Constant();
4493 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); 4556 return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
4494 } 4557 }
4495 4558
4496 return false; 4559 return false;
4497 } 4560 }
4498 4561
4499 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4562 virtual HValue* EnsureAndPropagateNotMinusZero(
4563 BitVector* visited) V8_OVERRIDE;
4500 4564
4501 virtual HValue* Canonicalize(); 4565 virtual HValue* Canonicalize() V8_OVERRIDE;
4502 4566
4503 virtual void UpdateRepresentation(Representation new_rep, 4567 virtual void UpdateRepresentation(Representation new_rep,
4504 HInferRepresentationPhase* h_infer, 4568 HInferRepresentationPhase* h_infer,
4505 const char* reason) { 4569 const char* reason) V8_OVERRIDE {
4506 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4570 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4507 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4571 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4508 } 4572 }
4509 4573
4510 DECLARE_CONCRETE_INSTRUCTION(Div) 4574 DECLARE_CONCRETE_INSTRUCTION(Div)
4511 4575
4512 protected: 4576 protected:
4513 virtual bool DataEquals(HValue* other) { return true; } 4577 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4514 4578
4515 virtual Range* InferRange(Zone* zone); 4579 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4516 4580
4517 private: 4581 private:
4518 HDiv(HValue* context, HValue* left, HValue* right) 4582 HDiv(HValue* context, HValue* left, HValue* right)
4519 : HArithmeticBinaryOperation(context, left, right) { 4583 : HArithmeticBinaryOperation(context, left, right) {
4520 SetFlag(kCanBeDivByZero); 4584 SetFlag(kCanBeDivByZero);
4521 SetFlag(kCanOverflow); 4585 SetFlag(kCanOverflow);
4522 } 4586 }
4523 }; 4587 };
4524 4588
4525 4589
4526 class HMathMinMax: public HArithmeticBinaryOperation { 4590 class HMathMinMax V8_FINAL : public HArithmeticBinaryOperation {
4527 public: 4591 public:
4528 enum Operation { kMathMin, kMathMax }; 4592 enum Operation { kMathMin, kMathMax };
4529 4593
4530 static HInstruction* New(Zone* zone, 4594 static HInstruction* New(Zone* zone,
4531 HValue* context, 4595 HValue* context,
4532 HValue* left, 4596 HValue* left,
4533 HValue* right, 4597 HValue* right,
4534 Operation op); 4598 Operation op);
4535 4599
4536 virtual Representation RequiredInputRepresentation(int index) { 4600 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
4537 return index == 0 ? Representation::Tagged()
4538 : representation();
4539 }
4540
4541 virtual Representation observed_input_representation(int index) {
4542 return RequiredInputRepresentation(index); 4601 return RequiredInputRepresentation(index);
4543 } 4602 }
4544 4603
4545 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); 4604 virtual void InferRepresentation(
4605 HInferRepresentationPhase* h_infer) V8_OVERRIDE;
4546 4606
4547 virtual Representation RepresentationFromInputs() { 4607 virtual Representation RepresentationFromInputs() V8_OVERRIDE {
4548 Representation left_rep = left()->representation(); 4608 Representation left_rep = left()->representation();
4549 Representation right_rep = right()->representation(); 4609 Representation right_rep = right()->representation();
4550 Representation result = Representation::Smi(); 4610 Representation result = Representation::Smi();
4551 result = result.generalize(left_rep); 4611 result = result.generalize(left_rep);
4552 result = result.generalize(right_rep); 4612 result = result.generalize(right_rep);
4553 if (result.IsTagged()) return Representation::Double(); 4613 if (result.IsTagged()) return Representation::Double();
4554 return result; 4614 return result;
4555 } 4615 }
4556 4616
4557 virtual bool IsCommutative() const { return true; } 4617 virtual bool IsCommutative() const V8_OVERRIDE { return true; }
4558 4618
4559 Operation operation() { return operation_; } 4619 Operation operation() { return operation_; }
4560 4620
4561 DECLARE_CONCRETE_INSTRUCTION(MathMinMax) 4621 DECLARE_CONCRETE_INSTRUCTION(MathMinMax)
4562 4622
4563 protected: 4623 protected:
4564 virtual bool DataEquals(HValue* other) { 4624 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
4565 return other->IsMathMinMax() && 4625 return other->IsMathMinMax() &&
4566 HMathMinMax::cast(other)->operation_ == operation_; 4626 HMathMinMax::cast(other)->operation_ == operation_;
4567 } 4627 }
4568 4628
4569 virtual Range* InferRange(Zone* zone); 4629 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4570 4630
4571 private: 4631 private:
4572 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) 4632 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op)
4573 : HArithmeticBinaryOperation(context, left, right), 4633 : HArithmeticBinaryOperation(context, left, right),
4574 operation_(op) { } 4634 operation_(op) { }
4575 4635
4576 Operation operation_; 4636 Operation operation_;
4577 }; 4637 };
4578 4638
4579 4639
4580 class HBitwise: public HBitwiseBinaryOperation { 4640 class HBitwise V8_FINAL : public HBitwiseBinaryOperation {
4581 public: 4641 public:
4582 static HInstruction* New(Zone* zone, 4642 static HInstruction* New(Zone* zone,
4583 HValue* context, 4643 HValue* context,
4584 Token::Value op, 4644 Token::Value op,
4585 HValue* left, 4645 HValue* left,
4586 HValue* right); 4646 HValue* right);
4587 4647
4588 Token::Value op() const { return op_; } 4648 Token::Value op() const { return op_; }
4589 4649
4590 virtual bool IsCommutative() const { return true; } 4650 virtual bool IsCommutative() const V8_OVERRIDE { return true; }
4591 4651
4592 virtual HValue* Canonicalize(); 4652 virtual HValue* Canonicalize() V8_OVERRIDE;
4593 4653
4594 virtual void PrintDataTo(StringStream* stream); 4654 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4595 4655
4596 DECLARE_CONCRETE_INSTRUCTION(Bitwise) 4656 DECLARE_CONCRETE_INSTRUCTION(Bitwise)
4597 4657
4598 protected: 4658 protected:
4599 virtual bool DataEquals(HValue* other) { 4659 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
4600 return op() == HBitwise::cast(other)->op(); 4660 return op() == HBitwise::cast(other)->op();
4601 } 4661 }
4602 4662
4603 virtual Range* InferRange(Zone* zone); 4663 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4604 4664
4605 private: 4665 private:
4606 HBitwise(HValue* context, 4666 HBitwise(HValue* context,
4607 Token::Value op, 4667 Token::Value op,
4608 HValue* left, 4668 HValue* left,
4609 HValue* right) 4669 HValue* right)
4610 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()), 4670 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()),
4611 op_(op) { 4671 op_(op) {
4612 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); 4672 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR);
4613 // BIT_AND with a smi-range positive value will always unset the 4673 // BIT_AND with a smi-range positive value will always unset the
(...skipping 16 matching lines...) Expand all
4630 right->representation().IsSmi() && 4690 right->representation().IsSmi() &&
4631 HConstant::cast(right)->Integer32Value() < 0))) { 4691 HConstant::cast(right)->Integer32Value() < 0))) {
4632 SetFlag(kTruncatingToSmi); 4692 SetFlag(kTruncatingToSmi);
4633 } 4693 }
4634 } 4694 }
4635 4695
4636 Token::Value op_; 4696 Token::Value op_;
4637 }; 4697 };
4638 4698
4639 4699
4640 class HShl: public HBitwiseBinaryOperation { 4700 class HShl V8_FINAL : public HBitwiseBinaryOperation {
4641 public: 4701 public:
4642 static HInstruction* New(Zone* zone, 4702 static HInstruction* New(Zone* zone,
4643 HValue* context, 4703 HValue* context,
4644 HValue* left, 4704 HValue* left,
4645 HValue* right); 4705 HValue* right);
4646 4706
4647 virtual Range* InferRange(Zone* zone); 4707 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4648 4708
4649 virtual void UpdateRepresentation(Representation new_rep, 4709 virtual void UpdateRepresentation(Representation new_rep,
4650 HInferRepresentationPhase* h_infer, 4710 HInferRepresentationPhase* h_infer,
4651 const char* reason) { 4711 const char* reason) V8_OVERRIDE {
4652 if (new_rep.IsSmi() && 4712 if (new_rep.IsSmi() &&
4653 !(right()->IsInteger32Constant() && 4713 !(right()->IsInteger32Constant() &&
4654 right()->GetInteger32Constant() >= 0)) { 4714 right()->GetInteger32Constant() >= 0)) {
4655 new_rep = Representation::Integer32(); 4715 new_rep = Representation::Integer32();
4656 } 4716 }
4657 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4717 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4658 } 4718 }
4659 4719
4660 DECLARE_CONCRETE_INSTRUCTION(Shl) 4720 DECLARE_CONCRETE_INSTRUCTION(Shl)
4661 4721
4662 protected: 4722 protected:
4663 virtual bool DataEquals(HValue* other) { return true; } 4723 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4664 4724
4665 private: 4725 private:
4666 HShl(HValue* context, HValue* left, HValue* right) 4726 HShl(HValue* context, HValue* left, HValue* right)
4667 : HBitwiseBinaryOperation(context, left, right) { } 4727 : HBitwiseBinaryOperation(context, left, right) { }
4668 }; 4728 };
4669 4729
4670 4730
4671 class HShr: public HBitwiseBinaryOperation { 4731 class HShr V8_FINAL : public HBitwiseBinaryOperation {
4672 public: 4732 public:
4673 static HInstruction* New(Zone* zone, 4733 static HInstruction* New(Zone* zone,
4674 HValue* context, 4734 HValue* context,
4675 HValue* left, 4735 HValue* left,
4676 HValue* right); 4736 HValue* right);
4677 4737
4678 virtual bool TryDecompose(DecompositionResult* decomposition) { 4738 virtual bool TryDecompose(DecompositionResult* decomposition) V8_OVERRIDE {
4679 if (right()->IsInteger32Constant()) { 4739 if (right()->IsInteger32Constant()) {
4680 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { 4740 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) {
4681 // This is intended to look for HAdd and HSub, to handle compounds 4741 // This is intended to look for HAdd and HSub, to handle compounds
4682 // like ((base + offset) >> scale) with one single decomposition. 4742 // like ((base + offset) >> scale) with one single decomposition.
4683 left()->TryDecompose(decomposition); 4743 left()->TryDecompose(decomposition);
4684 return true; 4744 return true;
4685 } 4745 }
4686 } 4746 }
4687 return false; 4747 return false;
4688 } 4748 }
4689 4749
4690 virtual Range* InferRange(Zone* zone); 4750 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4691 4751
4692 virtual void UpdateRepresentation(Representation new_rep, 4752 virtual void UpdateRepresentation(Representation new_rep,
4693 HInferRepresentationPhase* h_infer, 4753 HInferRepresentationPhase* h_infer,
4694 const char* reason) { 4754 const char* reason) V8_OVERRIDE {
4695 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4755 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4696 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4756 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4697 } 4757 }
4698 4758
4699 DECLARE_CONCRETE_INSTRUCTION(Shr) 4759 DECLARE_CONCRETE_INSTRUCTION(Shr)
4700 4760
4701 protected: 4761 protected:
4702 virtual bool DataEquals(HValue* other) { return true; } 4762 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4703 4763
4704 private: 4764 private:
4705 HShr(HValue* context, HValue* left, HValue* right) 4765 HShr(HValue* context, HValue* left, HValue* right)
4706 : HBitwiseBinaryOperation(context, left, right) { } 4766 : HBitwiseBinaryOperation(context, left, right) { }
4707 }; 4767 };
4708 4768
4709 4769
4710 class HSar: public HBitwiseBinaryOperation { 4770 class HSar V8_FINAL : public HBitwiseBinaryOperation {
4711 public: 4771 public:
4712 static HInstruction* New(Zone* zone, 4772 static HInstruction* New(Zone* zone,
4713 HValue* context, 4773 HValue* context,
4714 HValue* left, 4774 HValue* left,
4715 HValue* right); 4775 HValue* right);
4716 4776
4717 virtual bool TryDecompose(DecompositionResult* decomposition) { 4777 virtual bool TryDecompose(DecompositionResult* decomposition) V8_OVERRIDE {
4718 if (right()->IsInteger32Constant()) { 4778 if (right()->IsInteger32Constant()) {
4719 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { 4779 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) {
4720 // This is intended to look for HAdd and HSub, to handle compounds 4780 // This is intended to look for HAdd and HSub, to handle compounds
4721 // like ((base + offset) >> scale) with one single decomposition. 4781 // like ((base + offset) >> scale) with one single decomposition.
4722 left()->TryDecompose(decomposition); 4782 left()->TryDecompose(decomposition);
4723 return true; 4783 return true;
4724 } 4784 }
4725 } 4785 }
4726 return false; 4786 return false;
4727 } 4787 }
4728 4788
4729 virtual Range* InferRange(Zone* zone); 4789 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
4730 4790
4731 virtual void UpdateRepresentation(Representation new_rep, 4791 virtual void UpdateRepresentation(Representation new_rep,
4732 HInferRepresentationPhase* h_infer, 4792 HInferRepresentationPhase* h_infer,
4733 const char* reason) { 4793 const char* reason) V8_OVERRIDE {
4734 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4794 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4735 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4795 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4736 } 4796 }
4737 4797
4738 DECLARE_CONCRETE_INSTRUCTION(Sar) 4798 DECLARE_CONCRETE_INSTRUCTION(Sar)
4739 4799
4740 protected: 4800 protected:
4741 virtual bool DataEquals(HValue* other) { return true; } 4801 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4742 4802
4743 private: 4803 private:
4744 HSar(HValue* context, HValue* left, HValue* right) 4804 HSar(HValue* context, HValue* left, HValue* right)
4745 : HBitwiseBinaryOperation(context, left, right) { } 4805 : HBitwiseBinaryOperation(context, left, right) { }
4746 }; 4806 };
4747 4807
4748 4808
4749 class HRor: public HBitwiseBinaryOperation { 4809 class HRor V8_FINAL : public HBitwiseBinaryOperation {
4750 public: 4810 public:
4751 HRor(HValue* context, HValue* left, HValue* right) 4811 HRor(HValue* context, HValue* left, HValue* right)
4752 : HBitwiseBinaryOperation(context, left, right) { 4812 : HBitwiseBinaryOperation(context, left, right) {
4753 ChangeRepresentation(Representation::Integer32()); 4813 ChangeRepresentation(Representation::Integer32());
4754 } 4814 }
4755 4815
4756 virtual void UpdateRepresentation(Representation new_rep, 4816 virtual void UpdateRepresentation(Representation new_rep,
4757 HInferRepresentationPhase* h_infer, 4817 HInferRepresentationPhase* h_infer,
4758 const char* reason) { 4818 const char* reason) V8_OVERRIDE {
4759 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); 4819 if (new_rep.IsSmi()) new_rep = Representation::Integer32();
4760 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); 4820 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason);
4761 } 4821 }
4762 4822
4763 DECLARE_CONCRETE_INSTRUCTION(Ror) 4823 DECLARE_CONCRETE_INSTRUCTION(Ror)
4764 4824
4765 protected: 4825 protected:
4766 virtual bool DataEquals(HValue* other) { return true; } 4826 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
4767 }; 4827 };
4768 4828
4769 4829
4770 class HOsrEntry: public HTemplateInstruction<0> { 4830 class HOsrEntry V8_FINAL : public HTemplateInstruction<0> {
4771 public: 4831 public:
4772 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId); 4832 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId);
4773 4833
4774 BailoutId ast_id() const { return ast_id_; } 4834 BailoutId ast_id() const { return ast_id_; }
4775 4835
4776 virtual Representation RequiredInputRepresentation(int index) { 4836 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4777 return Representation::None(); 4837 return Representation::None();
4778 } 4838 }
4779 4839
4780 DECLARE_CONCRETE_INSTRUCTION(OsrEntry) 4840 DECLARE_CONCRETE_INSTRUCTION(OsrEntry)
4781 4841
4782 private: 4842 private:
4783 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) { 4843 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) {
4784 SetGVNFlag(kChangesOsrEntries); 4844 SetGVNFlag(kChangesOsrEntries);
4785 SetGVNFlag(kChangesNewSpacePromotion); 4845 SetGVNFlag(kChangesNewSpacePromotion);
4786 } 4846 }
4787 4847
4788 BailoutId ast_id_; 4848 BailoutId ast_id_;
4789 }; 4849 };
4790 4850
4791 4851
4792 class HParameter: public HTemplateInstruction<0> { 4852 class HParameter V8_FINAL : public HTemplateInstruction<0> {
4793 public: 4853 public:
4794 enum ParameterKind { 4854 enum ParameterKind {
4795 STACK_PARAMETER, 4855 STACK_PARAMETER,
4796 REGISTER_PARAMETER 4856 REGISTER_PARAMETER
4797 }; 4857 };
4798 4858
4799 DECLARE_INSTRUCTION_FACTORY_P1(HParameter, unsigned); 4859 DECLARE_INSTRUCTION_FACTORY_P1(HParameter, unsigned);
4800 DECLARE_INSTRUCTION_FACTORY_P2(HParameter, unsigned, ParameterKind); 4860 DECLARE_INSTRUCTION_FACTORY_P2(HParameter, unsigned, ParameterKind);
4801 DECLARE_INSTRUCTION_FACTORY_P3(HParameter, unsigned, ParameterKind, 4861 DECLARE_INSTRUCTION_FACTORY_P3(HParameter, unsigned, ParameterKind,
4802 Representation); 4862 Representation);
4803 4863
4804 unsigned index() const { return index_; } 4864 unsigned index() const { return index_; }
4805 ParameterKind kind() const { return kind_; } 4865 ParameterKind kind() const { return kind_; }
4806 4866
4807 virtual void PrintDataTo(StringStream* stream); 4867 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4808 4868
4809 virtual Representation RequiredInputRepresentation(int index) { 4869 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4810 return Representation::None(); 4870 return Representation::None();
4811 } 4871 }
4812 4872
4813 DECLARE_CONCRETE_INSTRUCTION(Parameter) 4873 DECLARE_CONCRETE_INSTRUCTION(Parameter)
4814 4874
4815 private: 4875 private:
4816 explicit HParameter(unsigned index, 4876 explicit HParameter(unsigned index,
4817 ParameterKind kind = STACK_PARAMETER) 4877 ParameterKind kind = STACK_PARAMETER)
4818 : index_(index), 4878 : index_(index),
4819 kind_(kind) { 4879 kind_(kind) {
4820 set_representation(Representation::Tagged()); 4880 set_representation(Representation::Tagged());
4821 } 4881 }
4822 4882
4823 explicit HParameter(unsigned index, 4883 explicit HParameter(unsigned index,
4824 ParameterKind kind, 4884 ParameterKind kind,
4825 Representation r) 4885 Representation r)
4826 : index_(index), 4886 : index_(index),
4827 kind_(kind) { 4887 kind_(kind) {
4828 set_representation(r); 4888 set_representation(r);
4829 } 4889 }
4830 4890
4831 unsigned index_; 4891 unsigned index_;
4832 ParameterKind kind_; 4892 ParameterKind kind_;
4833 }; 4893 };
4834 4894
4835 4895
4836 class HCallStub: public HUnaryCall { 4896 class HCallStub V8_FINAL : public HUnaryCall {
4837 public: 4897 public:
4838 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) 4898 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count)
4839 : HUnaryCall(context, argument_count), 4899 : HUnaryCall(context, argument_count),
4840 major_key_(major_key), 4900 major_key_(major_key),
4841 transcendental_type_(TranscendentalCache::kNumberOfCaches) { 4901 transcendental_type_(TranscendentalCache::kNumberOfCaches) {
4842 } 4902 }
4843 4903
4844 CodeStub::Major major_key() { return major_key_; } 4904 CodeStub::Major major_key() { return major_key_; }
4845 4905
4846 HValue* context() { return value(); } 4906 HValue* context() { return value(); }
4847 4907
4848 void set_transcendental_type(TranscendentalCache::Type transcendental_type) { 4908 void set_transcendental_type(TranscendentalCache::Type transcendental_type) {
4849 transcendental_type_ = transcendental_type; 4909 transcendental_type_ = transcendental_type;
4850 } 4910 }
4851 TranscendentalCache::Type transcendental_type() { 4911 TranscendentalCache::Type transcendental_type() {
4852 return transcendental_type_; 4912 return transcendental_type_;
4853 } 4913 }
4854 4914
4855 virtual void PrintDataTo(StringStream* stream); 4915 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4856
4857 virtual Representation RequiredInputRepresentation(int index) {
4858 return Representation::Tagged();
4859 }
4860 4916
4861 DECLARE_CONCRETE_INSTRUCTION(CallStub) 4917 DECLARE_CONCRETE_INSTRUCTION(CallStub)
4862 4918
4863 private: 4919 private:
4864 CodeStub::Major major_key_; 4920 CodeStub::Major major_key_;
4865 TranscendentalCache::Type transcendental_type_; 4921 TranscendentalCache::Type transcendental_type_;
4866 }; 4922 };
4867 4923
4868 4924
4869 class HUnknownOSRValue: public HTemplateInstruction<0> { 4925 class HUnknownOSRValue V8_FINAL : public HTemplateInstruction<0> {
4870 public: 4926 public:
4871 DECLARE_INSTRUCTION_FACTORY_P0(HUnknownOSRValue) 4927 DECLARE_INSTRUCTION_FACTORY_P0(HUnknownOSRValue)
4872 4928
4873 virtual Representation RequiredInputRepresentation(int index) { 4929 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4874 return Representation::None(); 4930 return Representation::None();
4875 } 4931 }
4876 4932
4877 void set_incoming_value(HPhi* value) { 4933 void set_incoming_value(HPhi* value) {
4878 incoming_value_ = value; 4934 incoming_value_ = value;
4879 } 4935 }
4880 4936
4881 HPhi* incoming_value() { 4937 HPhi* incoming_value() {
4882 return incoming_value_; 4938 return incoming_value_;
4883 } 4939 }
4884 4940
4885 virtual Representation KnownOptimalRepresentation() { 4941 virtual Representation KnownOptimalRepresentation() V8_OVERRIDE {
4886 if (incoming_value_ == NULL) return Representation::None(); 4942 if (incoming_value_ == NULL) return Representation::None();
4887 return incoming_value_->KnownOptimalRepresentation(); 4943 return incoming_value_->KnownOptimalRepresentation();
4888 } 4944 }
4889 4945
4890 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) 4946 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue)
4891 4947
4892 private: 4948 private:
4893 HUnknownOSRValue() 4949 HUnknownOSRValue()
4894 : incoming_value_(NULL) { 4950 : incoming_value_(NULL) {
4895 set_representation(Representation::Tagged()); 4951 set_representation(Representation::Tagged());
4896 } 4952 }
4897 4953
4898 HPhi* incoming_value_; 4954 HPhi* incoming_value_;
4899 }; 4955 };
4900 4956
4901 4957
4902 class HLoadGlobalCell: public HTemplateInstruction<0> { 4958 class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> {
4903 public: 4959 public:
4904 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details) 4960 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details)
4905 : cell_(cell), details_(details), unique_id_() { 4961 : cell_(cell), details_(details), unique_id_() {
4906 set_representation(Representation::Tagged()); 4962 set_representation(Representation::Tagged());
4907 SetFlag(kUseGVN); 4963 SetFlag(kUseGVN);
4908 SetGVNFlag(kDependsOnGlobalVars); 4964 SetGVNFlag(kDependsOnGlobalVars);
4909 } 4965 }
4910 4966
4911 Handle<Cell> cell() const { return cell_; } 4967 Handle<Cell> cell() const { return cell_; }
4912 bool RequiresHoleCheck() const; 4968 bool RequiresHoleCheck() const;
4913 4969
4914 virtual void PrintDataTo(StringStream* stream); 4970 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4915 4971
4916 virtual intptr_t Hashcode() { 4972 virtual intptr_t Hashcode() V8_OVERRIDE {
4917 return unique_id_.Hashcode(); 4973 return unique_id_.Hashcode();
4918 } 4974 }
4919 4975
4920 virtual void FinalizeUniqueValueId() { 4976 virtual void FinalizeUniqueValueId() V8_OVERRIDE {
4921 unique_id_ = UniqueValueId(cell_); 4977 unique_id_ = UniqueValueId(cell_);
4922 } 4978 }
4923 4979
4924 virtual Representation RequiredInputRepresentation(int index) { 4980 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4925 return Representation::None(); 4981 return Representation::None();
4926 } 4982 }
4927 4983
4928 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) 4984 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell)
4929 4985
4930 protected: 4986 protected:
4931 virtual bool DataEquals(HValue* other) { 4987 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
4932 HLoadGlobalCell* b = HLoadGlobalCell::cast(other); 4988 HLoadGlobalCell* b = HLoadGlobalCell::cast(other);
4933 return unique_id_ == b->unique_id_; 4989 return unique_id_ == b->unique_id_;
4934 } 4990 }
4935 4991
4936 private: 4992 private:
4937 virtual bool IsDeletable() const { return !RequiresHoleCheck(); } 4993 virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); }
4938 4994
4939 Handle<Cell> cell_; 4995 Handle<Cell> cell_;
4940 PropertyDetails details_; 4996 PropertyDetails details_;
4941 UniqueValueId unique_id_; 4997 UniqueValueId unique_id_;
4942 }; 4998 };
4943 4999
4944 5000
4945 class HLoadGlobalGeneric: public HTemplateInstruction<2> { 5001 class HLoadGlobalGeneric V8_FINAL : public HTemplateInstruction<2> {
4946 public: 5002 public:
4947 HLoadGlobalGeneric(HValue* context, 5003 HLoadGlobalGeneric(HValue* context,
4948 HValue* global_object, 5004 HValue* global_object,
4949 Handle<Object> name, 5005 Handle<Object> name,
4950 bool for_typeof) 5006 bool for_typeof)
4951 : name_(name), 5007 : name_(name),
4952 for_typeof_(for_typeof) { 5008 for_typeof_(for_typeof) {
4953 SetOperandAt(0, context); 5009 SetOperandAt(0, context);
4954 SetOperandAt(1, global_object); 5010 SetOperandAt(1, global_object);
4955 set_representation(Representation::Tagged()); 5011 set_representation(Representation::Tagged());
4956 SetAllSideEffects(); 5012 SetAllSideEffects();
4957 } 5013 }
4958 5014
4959 HValue* context() { return OperandAt(0); } 5015 HValue* context() { return OperandAt(0); }
4960 HValue* global_object() { return OperandAt(1); } 5016 HValue* global_object() { return OperandAt(1); }
4961 Handle<Object> name() const { return name_; } 5017 Handle<Object> name() const { return name_; }
4962 bool for_typeof() const { return for_typeof_; } 5018 bool for_typeof() const { return for_typeof_; }
4963 5019
4964 virtual void PrintDataTo(StringStream* stream); 5020 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
4965 5021
4966 virtual Representation RequiredInputRepresentation(int index) { 5022 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4967 return Representation::Tagged(); 5023 return Representation::Tagged();
4968 } 5024 }
4969 5025
4970 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) 5026 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
4971 5027
4972 private: 5028 private:
4973 Handle<Object> name_; 5029 Handle<Object> name_;
4974 bool for_typeof_; 5030 bool for_typeof_;
4975 }; 5031 };
4976 5032
4977 5033
4978 class HAllocate: public HTemplateInstruction<2> { 5034 class HAllocate V8_FINAL : public HTemplateInstruction<2> {
4979 public: 5035 public:
4980 static HAllocate* New(Zone* zone, 5036 static HAllocate* New(Zone* zone,
4981 HValue* context, 5037 HValue* context,
4982 HValue* size, 5038 HValue* size,
4983 HType type, 5039 HType type,
4984 PretenureFlag pretenure_flag, 5040 PretenureFlag pretenure_flag,
4985 InstanceType instance_type) { 5041 InstanceType instance_type) {
4986 return new(zone) HAllocate(context, size, type, pretenure_flag, 5042 return new(zone) HAllocate(context, size, type, pretenure_flag,
4987 instance_type); 5043 instance_type);
4988 } 5044 }
4989 5045
4990 // Maximum instance size for which allocations will be inlined. 5046 // Maximum instance size for which allocations will be inlined.
4991 static const int kMaxInlineSize = 64 * kPointerSize; 5047 static const int kMaxInlineSize = 64 * kPointerSize;
4992 5048
4993 HValue* context() { return OperandAt(0); } 5049 HValue* context() { return OperandAt(0); }
4994 HValue* size() { return OperandAt(1); } 5050 HValue* size() { return OperandAt(1); }
4995 5051
4996 virtual Representation RequiredInputRepresentation(int index) { 5052 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
4997 if (index == 0) { 5053 if (index == 0) {
4998 return Representation::Tagged(); 5054 return Representation::Tagged();
4999 } else { 5055 } else {
5000 return Representation::Integer32(); 5056 return Representation::Integer32();
5001 } 5057 }
5002 } 5058 }
5003 5059
5004 virtual Handle<Map> GetMonomorphicJSObjectMap() { 5060 virtual Handle<Map> GetMonomorphicJSObjectMap() {
5005 return known_initial_map_; 5061 return known_initial_map_;
5006 } 5062 }
(...skipping 28 matching lines...) Expand all
5035 5091
5036 void MakeDoubleAligned() { 5092 void MakeDoubleAligned() {
5037 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED); 5093 flags_ = static_cast<HAllocate::Flags>(flags_ | ALLOCATE_DOUBLE_ALIGNED);
5038 } 5094 }
5039 5095
5040 void UpdateSize(HValue* size) { 5096 void UpdateSize(HValue* size) {
5041 SetOperandAt(1, size); 5097 SetOperandAt(1, size);
5042 } 5098 }
5043 5099
5044 virtual void HandleSideEffectDominator(GVNFlag side_effect, 5100 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5045 HValue* dominator); 5101 HValue* dominator) V8_OVERRIDE;
5046 5102
5047 virtual void PrintDataTo(StringStream* stream); 5103 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5048 5104
5049 DECLARE_CONCRETE_INSTRUCTION(Allocate) 5105 DECLARE_CONCRETE_INSTRUCTION(Allocate)
5050 5106
5051 private: 5107 private:
5052 enum Flags { 5108 enum Flags {
5053 ALLOCATE_IN_NEW_SPACE = 1 << 0, 5109 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5054 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5110 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5055 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5111 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5056 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5112 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5057 PREFILL_WITH_FILLER = 1 << 4 5113 PREFILL_WITH_FILLER = 1 << 4
(...skipping 19 matching lines...) Expand all
5077 flags_ = static_cast<HAllocate::Flags>(flags_ | 5133 flags_ = static_cast<HAllocate::Flags>(flags_ |
5078 ALLOCATE_DOUBLE_ALIGNED); 5134 ALLOCATE_DOUBLE_ALIGNED);
5079 } 5135 }
5080 } 5136 }
5081 5137
5082 Flags flags_; 5138 Flags flags_;
5083 Handle<Map> known_initial_map_; 5139 Handle<Map> known_initial_map_;
5084 }; 5140 };
5085 5141
5086 5142
5087 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5143 class HInnerAllocatedObject V8_FINAL : public HTemplateInstruction<1> {
5088 public: 5144 public:
5089 static HInnerAllocatedObject* New(Zone* zone, 5145 static HInnerAllocatedObject* New(Zone* zone,
5090 HValue* context, 5146 HValue* context,
5091 HValue* value, 5147 HValue* value,
5092 int offset, 5148 int offset,
5093 HType type = HType::Tagged()) { 5149 HType type = HType::Tagged()) {
5094 return new(zone) HInnerAllocatedObject(value, offset, type); 5150 return new(zone) HInnerAllocatedObject(value, offset, type);
5095 } 5151 }
5096 5152
5097 HValue* base_object() { return OperandAt(0); } 5153 HValue* base_object() { return OperandAt(0); }
5098 int offset() { return offset_; } 5154 int offset() { return offset_; }
5099 5155
5100 virtual Representation RequiredInputRepresentation(int index) { 5156 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5101 return Representation::Tagged(); 5157 return Representation::Tagged();
5102 } 5158 }
5103 5159
5104 virtual void PrintDataTo(StringStream* stream); 5160 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5105 5161
5106 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) 5162 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
5107 5163
5108 private: 5164 private:
5109 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) 5165 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
5110 : HTemplateInstruction<1>(type), offset_(offset) { 5166 : HTemplateInstruction<1>(type), offset_(offset) {
5111 ASSERT(value->IsAllocate()); 5167 ASSERT(value->IsAllocate());
5112 SetOperandAt(0, value); 5168 SetOperandAt(0, value);
5113 set_type(type); 5169 set_type(type);
5114 set_representation(Representation::Tagged()); 5170 set_representation(Representation::Tagged());
(...skipping 26 matching lines...) Expand all
5141 return false; 5197 return false;
5142 } 5198 }
5143 if (object != new_space_dominator) return true; 5199 if (object != new_space_dominator) return true;
5144 if (object->IsAllocate()) { 5200 if (object->IsAllocate()) {
5145 return !HAllocate::cast(object)->IsNewSpaceAllocation(); 5201 return !HAllocate::cast(object)->IsNewSpaceAllocation();
5146 } 5202 }
5147 return true; 5203 return true;
5148 } 5204 }
5149 5205
5150 5206
5151 class HStoreGlobalCell: public HUnaryOperation { 5207 class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
5152 public: 5208 public:
5153 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*, 5209 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*,
5154 Handle<PropertyCell>, PropertyDetails); 5210 Handle<PropertyCell>, PropertyDetails);
5155 5211
5156 Handle<PropertyCell> cell() const { return cell_; } 5212 Handle<PropertyCell> cell() const { return cell_; }
5157 bool RequiresHoleCheck() { 5213 bool RequiresHoleCheck() {
5158 return !details_.IsDontDelete() || details_.IsReadOnly(); 5214 return !details_.IsDontDelete() || details_.IsReadOnly();
5159 } 5215 }
5160 bool NeedsWriteBarrier() { 5216 bool NeedsWriteBarrier() {
5161 return StoringValueNeedsWriteBarrier(value()); 5217 return StoringValueNeedsWriteBarrier(value());
5162 } 5218 }
5163 5219
5164 virtual Representation RequiredInputRepresentation(int index) { 5220 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5165 return Representation::Tagged(); 5221 return Representation::Tagged();
5166 } 5222 }
5167 virtual void PrintDataTo(StringStream* stream); 5223 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5168 5224
5169 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) 5225 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
5170 5226
5171 private: 5227 private:
5172 HStoreGlobalCell(HValue* value, 5228 HStoreGlobalCell(HValue* value,
5173 Handle<PropertyCell> cell, 5229 Handle<PropertyCell> cell,
5174 PropertyDetails details) 5230 PropertyDetails details)
5175 : HUnaryOperation(value), 5231 : HUnaryOperation(value),
5176 cell_(cell), 5232 cell_(cell),
5177 details_(details) { 5233 details_(details) {
5178 SetGVNFlag(kChangesGlobalVars); 5234 SetGVNFlag(kChangesGlobalVars);
5179 } 5235 }
5180 5236
5181 Handle<PropertyCell> cell_; 5237 Handle<PropertyCell> cell_;
5182 PropertyDetails details_; 5238 PropertyDetails details_;
5183 }; 5239 };
5184 5240
5185 5241
5186 class HStoreGlobalGeneric: public HTemplateInstruction<3> { 5242 class HStoreGlobalGeneric : public HTemplateInstruction<3> {
5187 public: 5243 public:
5188 inline static HStoreGlobalGeneric* New(Zone* zone, 5244 inline static HStoreGlobalGeneric* New(Zone* zone,
5189 HValue* context, 5245 HValue* context,
5190 HValue* global_object, 5246 HValue* global_object,
5191 Handle<Object> name, 5247 Handle<Object> name,
5192 HValue* value, 5248 HValue* value,
5193 StrictModeFlag strict_mode_flag) { 5249 StrictModeFlag strict_mode_flag) {
5194 return new(zone) HStoreGlobalGeneric(context, global_object, 5250 return new(zone) HStoreGlobalGeneric(context, global_object,
5195 name, value, strict_mode_flag); 5251 name, value, strict_mode_flag);
5196 } 5252 }
5197 5253
5198 HValue* context() { return OperandAt(0); } 5254 HValue* context() { return OperandAt(0); }
5199 HValue* global_object() { return OperandAt(1); } 5255 HValue* global_object() { return OperandAt(1); }
5200 Handle<Object> name() const { return name_; } 5256 Handle<Object> name() const { return name_; }
5201 HValue* value() { return OperandAt(2); } 5257 HValue* value() { return OperandAt(2); }
5202 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } 5258 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
5203 5259
5204 virtual void PrintDataTo(StringStream* stream); 5260 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5205 5261
5206 virtual Representation RequiredInputRepresentation(int index) { 5262 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5207 return Representation::Tagged(); 5263 return Representation::Tagged();
5208 } 5264 }
5209 5265
5210 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) 5266 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric)
5211 5267
5212 private: 5268 private:
5213 HStoreGlobalGeneric(HValue* context, 5269 HStoreGlobalGeneric(HValue* context,
5214 HValue* global_object, 5270 HValue* global_object,
5215 Handle<Object> name, 5271 Handle<Object> name,
5216 HValue* value, 5272 HValue* value,
5217 StrictModeFlag strict_mode_flag) 5273 StrictModeFlag strict_mode_flag)
5218 : name_(name), 5274 : name_(name),
5219 strict_mode_flag_(strict_mode_flag) { 5275 strict_mode_flag_(strict_mode_flag) {
5220 SetOperandAt(0, context); 5276 SetOperandAt(0, context);
5221 SetOperandAt(1, global_object); 5277 SetOperandAt(1, global_object);
5222 SetOperandAt(2, value); 5278 SetOperandAt(2, value);
5223 set_representation(Representation::Tagged()); 5279 set_representation(Representation::Tagged());
5224 SetAllSideEffects(); 5280 SetAllSideEffects();
5225 } 5281 }
5226 5282
5227 Handle<Object> name_; 5283 Handle<Object> name_;
5228 StrictModeFlag strict_mode_flag_; 5284 StrictModeFlag strict_mode_flag_;
5229 }; 5285 };
5230 5286
5231 5287
5232 class HLoadContextSlot: public HUnaryOperation { 5288 class HLoadContextSlot V8_FINAL : public HUnaryOperation {
5233 public: 5289 public:
5234 enum Mode { 5290 enum Mode {
5235 // Perform a normal load of the context slot without checking its value. 5291 // Perform a normal load of the context slot without checking its value.
5236 kNoCheck, 5292 kNoCheck,
5237 // Load and check the value of the context slot. Deoptimize if it's the 5293 // Load and check the value of the context slot. Deoptimize if it's the
5238 // hole value. This is used for checking for loading of uninitialized 5294 // hole value. This is used for checking for loading of uninitialized
5239 // harmony bindings where we deoptimize into full-codegen generated code 5295 // harmony bindings where we deoptimize into full-codegen generated code
5240 // which will subsequently throw a reference error. 5296 // which will subsequently throw a reference error.
5241 kCheckDeoptimize, 5297 kCheckDeoptimize,
5242 // Load and check the value of the context slot. Return undefined if it's 5298 // Load and check the value of the context slot. Return undefined if it's
(...skipping 24 matching lines...) Expand all
5267 Mode mode() const { return mode_; } 5323 Mode mode() const { return mode_; }
5268 5324
5269 bool DeoptimizesOnHole() { 5325 bool DeoptimizesOnHole() {
5270 return mode_ == kCheckDeoptimize; 5326 return mode_ == kCheckDeoptimize;
5271 } 5327 }
5272 5328
5273 bool RequiresHoleCheck() const { 5329 bool RequiresHoleCheck() const {
5274 return mode_ != kNoCheck; 5330 return mode_ != kNoCheck;
5275 } 5331 }
5276 5332
5277 virtual Representation RequiredInputRepresentation(int index) { 5333 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5278 return Representation::Tagged(); 5334 return Representation::Tagged();
5279 } 5335 }
5280 5336
5281 virtual void PrintDataTo(StringStream* stream); 5337 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5282 5338
5283 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) 5339 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot)
5284 5340
5285 protected: 5341 protected:
5286 virtual bool DataEquals(HValue* other) { 5342 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
5287 HLoadContextSlot* b = HLoadContextSlot::cast(other); 5343 HLoadContextSlot* b = HLoadContextSlot::cast(other);
5288 return (slot_index() == b->slot_index()); 5344 return (slot_index() == b->slot_index());
5289 } 5345 }
5290 5346
5291 private: 5347 private:
5292 virtual bool IsDeletable() const { return !RequiresHoleCheck(); } 5348 virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); }
5293 5349
5294 int slot_index_; 5350 int slot_index_;
5295 Mode mode_; 5351 Mode mode_;
5296 }; 5352 };
5297 5353
5298 5354
5299 class HStoreContextSlot: public HTemplateInstruction<2> { 5355 class HStoreContextSlot V8_FINAL : public HTemplateInstruction<2> {
5300 public: 5356 public:
5301 enum Mode { 5357 enum Mode {
5302 // Perform a normal store to the context slot without checking its previous 5358 // Perform a normal store to the context slot without checking its previous
5303 // value. 5359 // value.
5304 kNoCheck, 5360 kNoCheck,
5305 // Check the previous value of the context slot and deoptimize if it's the 5361 // Check the previous value of the context slot and deoptimize if it's the
5306 // hole value. This is used for checking for assignments to uninitialized 5362 // hole value. This is used for checking for assignments to uninitialized
5307 // harmony bindings where we deoptimize into full-codegen generated code 5363 // harmony bindings where we deoptimize into full-codegen generated code
5308 // which will subsequently throw a reference error. 5364 // which will subsequently throw a reference error.
5309 kCheckDeoptimize, 5365 kCheckDeoptimize,
(...skipping 14 matching lines...) Expand all
5324 } 5380 }
5325 5381
5326 bool DeoptimizesOnHole() { 5382 bool DeoptimizesOnHole() {
5327 return mode_ == kCheckDeoptimize; 5383 return mode_ == kCheckDeoptimize;
5328 } 5384 }
5329 5385
5330 bool RequiresHoleCheck() { 5386 bool RequiresHoleCheck() {
5331 return mode_ != kNoCheck; 5387 return mode_ != kNoCheck;
5332 } 5388 }
5333 5389
5334 virtual Representation RequiredInputRepresentation(int index) { 5390 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5335 return Representation::Tagged(); 5391 return Representation::Tagged();
5336 } 5392 }
5337 5393
5338 virtual void PrintDataTo(StringStream* stream); 5394 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5339 5395
5340 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) 5396 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
5341 5397
5342 private: 5398 private:
5343 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) 5399 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value)
5344 : slot_index_(slot_index), mode_(mode) { 5400 : slot_index_(slot_index), mode_(mode) {
5345 SetOperandAt(0, context); 5401 SetOperandAt(0, context);
5346 SetOperandAt(1, value); 5402 SetOperandAt(1, value);
5347 SetGVNFlag(kChangesContextSlots); 5403 SetGVNFlag(kChangesContextSlots);
5348 } 5404 }
5349 5405
5350 int slot_index_; 5406 int slot_index_;
5351 Mode mode_; 5407 Mode mode_;
5352 }; 5408 };
5353 5409
5354 5410
5355 // Represents an access to a portion of an object, such as the map pointer, 5411 // Represents an access to a portion of an object, such as the map pointer,
5356 // array elements pointer, etc, but not accesses to array elements themselves. 5412 // array elements pointer, etc, but not accesses to array elements themselves.
5357 class HObjectAccess { 5413 class HObjectAccess V8_FINAL {
5358 public: 5414 public:
5359 inline bool IsInobject() const { 5415 inline bool IsInobject() const {
5360 return portion() != kBackingStore && portion() != kExternalMemory; 5416 return portion() != kBackingStore && portion() != kExternalMemory;
5361 } 5417 }
5362 5418
5363 inline bool IsExternalMemory() const { 5419 inline bool IsExternalMemory() const {
5364 return portion() == kExternalMemory; 5420 return portion() == kExternalMemory;
5365 } 5421 }
5366 5422
5367 inline bool IsStringLength() const { 5423 inline bool IsStringLength() const {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5522 5578
5523 friend class HLoadNamedField; 5579 friend class HLoadNamedField;
5524 friend class HStoreNamedField; 5580 friend class HStoreNamedField;
5525 5581
5526 inline Portion portion() const { 5582 inline Portion portion() const {
5527 return PortionField::decode(value_); 5583 return PortionField::decode(value_);
5528 } 5584 }
5529 }; 5585 };
5530 5586
5531 5587
5532 class HLoadNamedField: public HTemplateInstruction<2> { 5588 class HLoadNamedField V8_FINAL : public HTemplateInstruction<2> {
5533 public: 5589 public:
5534 DECLARE_INSTRUCTION_FACTORY_P2(HLoadNamedField, HValue*, HObjectAccess); 5590 DECLARE_INSTRUCTION_FACTORY_P2(HLoadNamedField, HValue*, HObjectAccess);
5535 DECLARE_INSTRUCTION_FACTORY_P3(HLoadNamedField, HValue*, HObjectAccess, 5591 DECLARE_INSTRUCTION_FACTORY_P3(HLoadNamedField, HValue*, HObjectAccess,
5536 HValue*); 5592 HValue*);
5537 5593
5538 HValue* object() { return OperandAt(0); } 5594 HValue* object() { return OperandAt(0); }
5539 HValue* typecheck() { 5595 HValue* typecheck() {
5540 ASSERT(HasTypeCheck()); 5596 ASSERT(HasTypeCheck());
5541 return OperandAt(1); 5597 return OperandAt(1);
5542 } 5598 }
5543 5599
5544 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } 5600 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
5601 void ClearTypeCheck() { SetOperandAt(1, object()); }
5545 HObjectAccess access() const { return access_; } 5602 HObjectAccess access() const { return access_; }
5546 Representation field_representation() const { 5603 Representation field_representation() const {
5547 return access_.representation(); 5604 return access_.representation();
5548 } 5605 }
5549 5606
5550 virtual bool HasEscapingOperandAt(int index) { return false; } 5607 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
5551 virtual Representation RequiredInputRepresentation(int index) { 5608 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5552 if (index == 0 && access().IsExternalMemory()) { 5609 if (index == 0 && access().IsExternalMemory()) {
5553 // object must be external in case of external memory access 5610 // object must be external in case of external memory access
5554 return Representation::External(); 5611 return Representation::External();
5555 } 5612 }
5556 return Representation::Tagged(); 5613 return Representation::Tagged();
5557 } 5614 }
5558 virtual Range* InferRange(Zone* zone); 5615 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
5559 virtual void PrintDataTo(StringStream* stream); 5616 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5560 5617
5561 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) 5618 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField)
5562 5619
5563 protected: 5620 protected:
5564 virtual bool DataEquals(HValue* other) { 5621 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
5565 HLoadNamedField* b = HLoadNamedField::cast(other); 5622 HLoadNamedField* b = HLoadNamedField::cast(other);
5566 return access_.Equals(b->access_); 5623 return access_.Equals(b->access_);
5567 } 5624 }
5568 5625
5569 private: 5626 private:
5570 HLoadNamedField(HValue* object, 5627 HLoadNamedField(HValue* object,
5571 HObjectAccess access, 5628 HObjectAccess access,
5572 HValue* typecheck = NULL) 5629 HValue* typecheck = NULL)
5573 : access_(access) { 5630 : access_(access) {
5574 ASSERT(object != NULL); 5631 ASSERT(object != NULL);
(...skipping 11 matching lines...) Expand all
5586 } else if (FLAG_track_heap_object_fields && 5643 } else if (FLAG_track_heap_object_fields &&
5587 representation.IsHeapObject()) { 5644 representation.IsHeapObject()) {
5588 set_type(HType::NonPrimitive()); 5645 set_type(HType::NonPrimitive());
5589 set_representation(Representation::Tagged()); 5646 set_representation(Representation::Tagged());
5590 } else { 5647 } else {
5591 set_representation(Representation::Tagged()); 5648 set_representation(Representation::Tagged());
5592 } 5649 }
5593 access.SetGVNFlags(this, false); 5650 access.SetGVNFlags(this, false);
5594 } 5651 }
5595 5652
5596 virtual bool IsDeletable() const { return true; } 5653 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
5597 5654
5598 HObjectAccess access_; 5655 HObjectAccess access_;
5599 }; 5656 };
5600 5657
5601 5658
5602 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 5659 class HLoadNamedGeneric V8_FINAL : public HTemplateInstruction<2> {
5603 public:
5604 HLoadNamedFieldPolymorphic(HValue* context,
5605 HValue* object,
5606 SmallMapList* types,
5607 Handle<String> name,
5608 Zone* zone);
5609
5610 HValue* context() { return OperandAt(0); }
5611 HValue* object() { return OperandAt(1); }
5612 SmallMapList* types() { return &types_; }
5613 Handle<String> name() { return name_; }
5614 bool need_generic() { return need_generic_; }
5615
5616 virtual Representation RequiredInputRepresentation(int index) {
5617 return Representation::Tagged();
5618 }
5619
5620 virtual void PrintDataTo(StringStream* stream);
5621
5622 DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic)
5623
5624 static const int kMaxLoadPolymorphism = 4;
5625
5626 virtual void FinalizeUniqueValueId();
5627
5628 protected:
5629 virtual bool DataEquals(HValue* value);
5630
5631 private:
5632 SmallMapList types_;
5633 Handle<String> name_;
5634 ZoneList<UniqueValueId> types_unique_ids_;
5635 UniqueValueId name_unique_id_;
5636 bool need_generic_;
5637 };
5638
5639
5640
5641 class HLoadNamedGeneric: public HTemplateInstruction<2> {
5642 public: 5660 public:
5643 HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) 5661 HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name)
5644 : name_(name) { 5662 : name_(name) {
5645 SetOperandAt(0, context); 5663 SetOperandAt(0, context);
5646 SetOperandAt(1, object); 5664 SetOperandAt(1, object);
5647 set_representation(Representation::Tagged()); 5665 set_representation(Representation::Tagged());
5648 SetAllSideEffects(); 5666 SetAllSideEffects();
5649 } 5667 }
5650 5668
5651 HValue* context() { return OperandAt(0); } 5669 HValue* context() { return OperandAt(0); }
5652 HValue* object() { return OperandAt(1); } 5670 HValue* object() { return OperandAt(1); }
5653 Handle<Object> name() const { return name_; } 5671 Handle<Object> name() const { return name_; }
5654 5672
5655 virtual Representation RequiredInputRepresentation(int index) { 5673 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5656 return Representation::Tagged(); 5674 return Representation::Tagged();
5657 } 5675 }
5658 5676
5659 virtual void PrintDataTo(StringStream* stream); 5677 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5660 5678
5661 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) 5679 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric)
5662 5680
5663 private: 5681 private:
5664 Handle<Object> name_; 5682 Handle<Object> name_;
5665 }; 5683 };
5666 5684
5667 5685
5668 class HLoadFunctionPrototype: public HUnaryOperation { 5686 class HLoadFunctionPrototype V8_FINAL : public HUnaryOperation {
5669 public: 5687 public:
5670 explicit HLoadFunctionPrototype(HValue* function) 5688 explicit HLoadFunctionPrototype(HValue* function)
5671 : HUnaryOperation(function) { 5689 : HUnaryOperation(function) {
5672 set_representation(Representation::Tagged()); 5690 set_representation(Representation::Tagged());
5673 SetFlag(kUseGVN); 5691 SetFlag(kUseGVN);
5674 SetGVNFlag(kDependsOnCalls); 5692 SetGVNFlag(kDependsOnCalls);
5675 } 5693 }
5676 5694
5677 HValue* function() { return OperandAt(0); } 5695 HValue* function() { return OperandAt(0); }
5678 5696
5679 virtual Representation RequiredInputRepresentation(int index) { 5697 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5680 return Representation::Tagged(); 5698 return Representation::Tagged();
5681 } 5699 }
5682 5700
5683 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype) 5701 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype)
5684 5702
5685 protected: 5703 protected:
5686 virtual bool DataEquals(HValue* other) { return true; } 5704 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
5687 }; 5705 };
5688 5706
5689 class ArrayInstructionInterface { 5707 class ArrayInstructionInterface {
5690 public: 5708 public:
5691 virtual HValue* GetKey() = 0; 5709 virtual HValue* GetKey() = 0;
5692 virtual void SetKey(HValue* key) = 0; 5710 virtual void SetKey(HValue* key) = 0;
5693 virtual void SetIndexOffset(uint32_t index_offset) = 0; 5711 virtual void SetIndexOffset(uint32_t index_offset) = 0;
5694 virtual bool IsDehoisted() = 0; 5712 virtual bool IsDehoisted() = 0;
5695 virtual void SetDehoisted(bool is_dehoisted) = 0; 5713 virtual void SetDehoisted(bool is_dehoisted) = 0;
5696 virtual ~ArrayInstructionInterface() { }; 5714 virtual ~ArrayInstructionInterface() { };
5697 5715
5698 static Representation KeyedAccessIndexRequirement(Representation r) { 5716 static Representation KeyedAccessIndexRequirement(Representation r) {
5699 return r.IsInteger32() || kSmiValueSize != 31 5717 return r.IsInteger32() || kSmiValueSize != 31
5700 ? Representation::Integer32() : Representation::Smi(); 5718 ? Representation::Integer32() : Representation::Smi();
5701 } 5719 }
5702 }; 5720 };
5703 5721
5704 5722
5705 enum LoadKeyedHoleMode { 5723 enum LoadKeyedHoleMode {
5706 NEVER_RETURN_HOLE, 5724 NEVER_RETURN_HOLE,
5707 ALLOW_RETURN_HOLE 5725 ALLOW_RETURN_HOLE
5708 }; 5726 };
5709 5727
5710 5728
5711 class HLoadKeyed 5729 class HLoadKeyed V8_FINAL
5712 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 5730 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
5713 public: 5731 public:
5714 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*, 5732 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
5715 ElementsKind); 5733 ElementsKind);
5716 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*, 5734 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
5717 ElementsKind, LoadKeyedHoleMode); 5735 ElementsKind, LoadKeyedHoleMode);
5718 5736
5719 bool is_external() const { 5737 bool is_external() const {
5720 return IsExternalArrayElementsKind(elements_kind()); 5738 return IsExternalArrayElementsKind(elements_kind());
5721 } 5739 }
(...skipping 14 matching lines...) Expand all
5736 void SetDehoisted(bool is_dehoisted) { 5754 void SetDehoisted(bool is_dehoisted) {
5737 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); 5755 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
5738 } 5756 }
5739 ElementsKind elements_kind() const { 5757 ElementsKind elements_kind() const {
5740 return ElementsKindField::decode(bit_field_); 5758 return ElementsKindField::decode(bit_field_);
5741 } 5759 }
5742 LoadKeyedHoleMode hole_mode() const { 5760 LoadKeyedHoleMode hole_mode() const {
5743 return HoleModeField::decode(bit_field_); 5761 return HoleModeField::decode(bit_field_);
5744 } 5762 }
5745 5763
5746 virtual Representation RequiredInputRepresentation(int index) { 5764 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5747 // kind_fast: tagged[int32] (none) 5765 // kind_fast: tagged[int32] (none)
5748 // kind_double: tagged[int32] (none) 5766 // kind_double: tagged[int32] (none)
5749 // kind_external: external[int32] (none) 5767 // kind_external: external[int32] (none)
5750 if (index == 0) { 5768 if (index == 0) {
5751 return is_external() ? Representation::External() 5769 return is_external() ? Representation::External()
5752 : Representation::Tagged(); 5770 : Representation::Tagged();
5753 } 5771 }
5754 if (index == 1) { 5772 if (index == 1) {
5755 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 5773 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
5756 OperandAt(1)->representation()); 5774 OperandAt(1)->representation());
5757 } 5775 }
5758 return Representation::None(); 5776 return Representation::None();
5759 } 5777 }
5760 5778
5761 virtual Representation observed_input_representation(int index) { 5779 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
5762 return RequiredInputRepresentation(index); 5780 return RequiredInputRepresentation(index);
5763 } 5781 }
5764 5782
5765 virtual void PrintDataTo(StringStream* stream); 5783 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5766 5784
5767 bool UsesMustHandleHole() const; 5785 bool UsesMustHandleHole() const;
5768 bool AllUsesCanTreatHoleAsNaN() const; 5786 bool AllUsesCanTreatHoleAsNaN() const;
5769 bool RequiresHoleCheck() const; 5787 bool RequiresHoleCheck() const;
5770 5788
5771 virtual Range* InferRange(Zone* zone); 5789 virtual Range* InferRange(Zone* zone) V8_OVERRIDE;
5772 5790
5773 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed) 5791 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed)
5774 5792
5775 protected: 5793 protected:
5776 virtual bool DataEquals(HValue* other) { 5794 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
5777 if (!other->IsLoadKeyed()) return false; 5795 if (!other->IsLoadKeyed()) return false;
5778 HLoadKeyed* other_load = HLoadKeyed::cast(other); 5796 HLoadKeyed* other_load = HLoadKeyed::cast(other);
5779 5797
5780 if (IsDehoisted() && index_offset() != other_load->index_offset()) 5798 if (IsDehoisted() && index_offset() != other_load->index_offset())
5781 return false; 5799 return false;
5782 return elements_kind() == other_load->elements_kind(); 5800 return elements_kind() == other_load->elements_kind();
5783 } 5801 }
5784 5802
5785 private: 5803 private:
5786 HLoadKeyed(HValue* obj, 5804 HLoadKeyed(HValue* obj,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5826 } 5844 }
5827 5845
5828 SetGVNFlag(kDependsOnExternalMemory); 5846 SetGVNFlag(kDependsOnExternalMemory);
5829 // Native code could change the specialized array. 5847 // Native code could change the specialized array.
5830 SetGVNFlag(kDependsOnCalls); 5848 SetGVNFlag(kDependsOnCalls);
5831 } 5849 }
5832 5850
5833 SetFlag(kUseGVN); 5851 SetFlag(kUseGVN);
5834 } 5852 }
5835 5853
5836 virtual bool IsDeletable() const { 5854 virtual bool IsDeletable() const V8_OVERRIDE {
5837 return !RequiresHoleCheck(); 5855 return !RequiresHoleCheck();
5838 } 5856 }
5839 5857
5840 // Establish some checks around our packed fields 5858 // Establish some checks around our packed fields
5841 enum LoadKeyedBits { 5859 enum LoadKeyedBits {
5842 kBitsForElementsKind = 5, 5860 kBitsForElementsKind = 5,
5843 kBitsForHoleMode = 1, 5861 kBitsForHoleMode = 1,
5844 kBitsForIndexOffset = 25, 5862 kBitsForIndexOffset = 25,
5845 kBitsForIsDehoisted = 1, 5863 kBitsForIsDehoisted = 1,
5846 5864
(...skipping 15 matching lines...) Expand all
5862 class IndexOffsetField: 5880 class IndexOffsetField:
5863 public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset> 5881 public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset>
5864 {}; // NOLINT 5882 {}; // NOLINT
5865 class IsDehoistedField: 5883 class IsDehoistedField:
5866 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted> 5884 public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted>
5867 {}; // NOLINT 5885 {}; // NOLINT
5868 uint32_t bit_field_; 5886 uint32_t bit_field_;
5869 }; 5887 };
5870 5888
5871 5889
5872 class HLoadKeyedGeneric: public HTemplateInstruction<3> { 5890 class HLoadKeyedGeneric V8_FINAL : public HTemplateInstruction<3> {
5873 public: 5891 public:
5874 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { 5892 HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) {
5875 set_representation(Representation::Tagged()); 5893 set_representation(Representation::Tagged());
5876 SetOperandAt(0, obj); 5894 SetOperandAt(0, obj);
5877 SetOperandAt(1, key); 5895 SetOperandAt(1, key);
5878 SetOperandAt(2, context); 5896 SetOperandAt(2, context);
5879 SetAllSideEffects(); 5897 SetAllSideEffects();
5880 } 5898 }
5881 5899
5882 HValue* object() { return OperandAt(0); } 5900 HValue* object() { return OperandAt(0); }
5883 HValue* key() { return OperandAt(1); } 5901 HValue* key() { return OperandAt(1); }
5884 HValue* context() { return OperandAt(2); } 5902 HValue* context() { return OperandAt(2); }
5885 5903
5886 virtual void PrintDataTo(StringStream* stream); 5904 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5887 5905
5888 virtual Representation RequiredInputRepresentation(int index) { 5906 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5889 // tagged[tagged] 5907 // tagged[tagged]
5890 return Representation::Tagged(); 5908 return Representation::Tagged();
5891 } 5909 }
5892 5910
5893 virtual HValue* Canonicalize(); 5911 virtual HValue* Canonicalize() V8_OVERRIDE;
5894 5912
5895 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) 5913 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
5896 }; 5914 };
5897 5915
5898 5916
5899 class HStoreNamedField: public HTemplateInstruction<3> { 5917 class HStoreNamedField V8_FINAL : public HTemplateInstruction<3> {
5900 public: 5918 public:
5901 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*, 5919 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*,
5902 HObjectAccess, HValue*); 5920 HObjectAccess, HValue*);
5903 5921
5904 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 5922 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
5905 5923
5906 virtual bool HasEscapingOperandAt(int index) { return index == 1; } 5924 virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE {
5907 virtual Representation RequiredInputRepresentation(int index) { 5925 return index == 1;
5926 }
5927 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
5908 if (index == 0 && access().IsExternalMemory()) { 5928 if (index == 0 && access().IsExternalMemory()) {
5909 // object must be external in case of external memory access 5929 // object must be external in case of external memory access
5910 return Representation::External(); 5930 return Representation::External();
5911 } else if (index == 1 && 5931 } else if (index == 1 &&
5912 (field_representation().IsDouble() || 5932 (field_representation().IsDouble() ||
5913 field_representation().IsSmi() || 5933 field_representation().IsSmi() ||
5914 field_representation().IsInteger32())) { 5934 field_representation().IsInteger32())) {
5915 return field_representation(); 5935 return field_representation();
5916 } 5936 }
5917 return Representation::Tagged(); 5937 return Representation::Tagged();
5918 } 5938 }
5919 virtual void HandleSideEffectDominator(GVNFlag side_effect, 5939 virtual void HandleSideEffectDominator(GVNFlag side_effect,
5920 HValue* dominator) { 5940 HValue* dominator) V8_OVERRIDE {
5921 ASSERT(side_effect == kChangesNewSpacePromotion); 5941 ASSERT(side_effect == kChangesNewSpacePromotion);
5922 new_space_dominator_ = dominator; 5942 new_space_dominator_ = dominator;
5923 } 5943 }
5924 virtual void PrintDataTo(StringStream* stream); 5944 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
5925 5945
5926 void SkipWriteBarrier() { write_barrier_mode_ = SKIP_WRITE_BARRIER; } 5946 void SkipWriteBarrier() { write_barrier_mode_ = SKIP_WRITE_BARRIER; }
5927 bool IsSkipWriteBarrier() const { 5947 bool IsSkipWriteBarrier() const {
5928 return write_barrier_mode_ == SKIP_WRITE_BARRIER; 5948 return write_barrier_mode_ == SKIP_WRITE_BARRIER;
5929 } 5949 }
5930 5950
5931 HValue* object() const { return OperandAt(0); } 5951 HValue* object() const { return OperandAt(0); }
5932 HValue* value() const { return OperandAt(1); } 5952 HValue* value() const { return OperandAt(1); }
5933 HValue* transition() const { return OperandAt(2); } 5953 HValue* transition() const { return OperandAt(2); }
5934 5954
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5989 access.SetGVNFlags(this, true); 6009 access.SetGVNFlags(this, true);
5990 } 6010 }
5991 6011
5992 HObjectAccess access_; 6012 HObjectAccess access_;
5993 HValue* new_space_dominator_; 6013 HValue* new_space_dominator_;
5994 WriteBarrierMode write_barrier_mode_ : 1; 6014 WriteBarrierMode write_barrier_mode_ : 1;
5995 bool has_transition_ : 1; 6015 bool has_transition_ : 1;
5996 }; 6016 };
5997 6017
5998 6018
5999 class HStoreNamedGeneric: public HTemplateInstruction<3> { 6019 class HStoreNamedGeneric V8_FINAL : public HTemplateInstruction<3> {
6000 public: 6020 public:
6001 HStoreNamedGeneric(HValue* context, 6021 HStoreNamedGeneric(HValue* context,
6002 HValue* object, 6022 HValue* object,
6003 Handle<String> name, 6023 Handle<String> name,
6004 HValue* value, 6024 HValue* value,
6005 StrictModeFlag strict_mode_flag) 6025 StrictModeFlag strict_mode_flag)
6006 : name_(name), 6026 : name_(name),
6007 strict_mode_flag_(strict_mode_flag) { 6027 strict_mode_flag_(strict_mode_flag) {
6008 SetOperandAt(0, object); 6028 SetOperandAt(0, object);
6009 SetOperandAt(1, value); 6029 SetOperandAt(1, value);
6010 SetOperandAt(2, context); 6030 SetOperandAt(2, context);
6011 SetAllSideEffects(); 6031 SetAllSideEffects();
6012 } 6032 }
6013 6033
6014 HValue* object() { return OperandAt(0); } 6034 HValue* object() { return OperandAt(0); }
6015 HValue* value() { return OperandAt(1); } 6035 HValue* value() { return OperandAt(1); }
6016 HValue* context() { return OperandAt(2); } 6036 HValue* context() { return OperandAt(2); }
6017 Handle<String> name() { return name_; } 6037 Handle<String> name() { return name_; }
6018 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } 6038 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
6019 6039
6020 virtual void PrintDataTo(StringStream* stream); 6040 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6021 6041
6022 virtual Representation RequiredInputRepresentation(int index) { 6042 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6023 return Representation::Tagged(); 6043 return Representation::Tagged();
6024 } 6044 }
6025 6045
6026 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) 6046 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric)
6027 6047
6028 private: 6048 private:
6029 Handle<String> name_; 6049 Handle<String> name_;
6030 StrictModeFlag strict_mode_flag_; 6050 StrictModeFlag strict_mode_flag_;
6031 }; 6051 };
6032 6052
6033 6053
6034 class HStoreKeyed 6054 class HStoreKeyed V8_FINAL
6035 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6055 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
6036 public: 6056 public:
6037 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*, 6057 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*,
6038 ElementsKind); 6058 ElementsKind);
6039 6059
6040 virtual Representation RequiredInputRepresentation(int index) { 6060 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6041 // kind_fast: tagged[int32] = tagged 6061 // kind_fast: tagged[int32] = tagged
6042 // kind_double: tagged[int32] = double 6062 // kind_double: tagged[int32] = double
6043 // kind_smi : tagged[int32] = smi 6063 // kind_smi : tagged[int32] = smi
6044 // kind_external: external[int32] = (double | int32) 6064 // kind_external: external[int32] = (double | int32)
6045 if (index == 0) { 6065 if (index == 0) {
6046 return is_external() ? Representation::External() 6066 return is_external() ? Representation::External()
6047 : Representation::Tagged(); 6067 : Representation::Tagged();
6048 } else if (index == 1) { 6068 } else if (index == 1) {
6049 return ArrayInstructionInterface::KeyedAccessIndexRequirement( 6069 return ArrayInstructionInterface::KeyedAccessIndexRequirement(
6050 OperandAt(1)->representation()); 6070 OperandAt(1)->representation());
6051 } 6071 }
6052 6072
6053 ASSERT_EQ(index, 2); 6073 ASSERT_EQ(index, 2);
6054 if (IsDoubleOrFloatElementsKind(elements_kind())) { 6074 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6055 return Representation::Double(); 6075 return Representation::Double();
6056 } 6076 }
6057 6077
6058 if (IsFastSmiElementsKind(elements_kind())) { 6078 if (IsFastSmiElementsKind(elements_kind())) {
6059 return Representation::Smi(); 6079 return Representation::Smi();
6060 } 6080 }
6061 6081
6062 return is_external() ? Representation::Integer32() 6082 return is_external() ? Representation::Integer32()
6063 : Representation::Tagged(); 6083 : Representation::Tagged();
6064 } 6084 }
6065 6085
6066 bool is_external() const { 6086 bool is_external() const {
6067 return IsExternalArrayElementsKind(elements_kind()); 6087 return IsExternalArrayElementsKind(elements_kind());
6068 } 6088 }
6069 6089
6070 virtual Representation observed_input_representation(int index) { 6090 virtual Representation observed_input_representation(int index) V8_OVERRIDE {
6071 if (index < 2) return RequiredInputRepresentation(index); 6091 if (index < 2) return RequiredInputRepresentation(index);
6072 if (IsUninitialized()) { 6092 if (IsUninitialized()) {
6073 return Representation::None(); 6093 return Representation::None();
6074 } 6094 }
6075 if (IsFastSmiElementsKind(elements_kind())) { 6095 if (IsFastSmiElementsKind(elements_kind())) {
6076 return Representation::Smi(); 6096 return Representation::Smi();
6077 } 6097 }
6078 if (IsDoubleOrFloatElementsKind(elements_kind())) { 6098 if (IsDoubleOrFloatElementsKind(elements_kind())) {
6079 return Representation::Double(); 6099 return Representation::Double();
6080 } 6100 }
(...skipping 20 matching lines...) Expand all
6101 bool IsUninitialized() { return is_uninitialized_; } 6121 bool IsUninitialized() { return is_uninitialized_; }
6102 void SetUninitialized(bool is_uninitialized) { 6122 void SetUninitialized(bool is_uninitialized) {
6103 is_uninitialized_ = is_uninitialized; 6123 is_uninitialized_ = is_uninitialized;
6104 } 6124 }
6105 6125
6106 bool IsConstantHoleStore() { 6126 bool IsConstantHoleStore() {
6107 return value()->IsConstant() && HConstant::cast(value())->IsTheHole(); 6127 return value()->IsConstant() && HConstant::cast(value())->IsTheHole();
6108 } 6128 }
6109 6129
6110 virtual void HandleSideEffectDominator(GVNFlag side_effect, 6130 virtual void HandleSideEffectDominator(GVNFlag side_effect,
6111 HValue* dominator) { 6131 HValue* dominator) V8_OVERRIDE {
6112 ASSERT(side_effect == kChangesNewSpacePromotion); 6132 ASSERT(side_effect == kChangesNewSpacePromotion);
6113 new_space_dominator_ = dominator; 6133 new_space_dominator_ = dominator;
6114 } 6134 }
6115 6135
6116 HValue* new_space_dominator() const { return new_space_dominator_; } 6136 HValue* new_space_dominator() const { return new_space_dominator_; }
6117 6137
6118 bool NeedsWriteBarrier() { 6138 bool NeedsWriteBarrier() {
6119 if (value_is_smi()) { 6139 if (value_is_smi()) {
6120 return false; 6140 return false;
6121 } else { 6141 } else {
6122 return StoringValueNeedsWriteBarrier(value()) && 6142 return StoringValueNeedsWriteBarrier(value()) &&
6123 ReceiverObjectNeedsWriteBarrier(elements(), new_space_dominator()); 6143 ReceiverObjectNeedsWriteBarrier(elements(), new_space_dominator());
6124 } 6144 }
6125 } 6145 }
6126 6146
6127 bool NeedsCanonicalization(); 6147 bool NeedsCanonicalization();
6128 6148
6129 virtual void PrintDataTo(StringStream* stream); 6149 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6130 6150
6131 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) 6151 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
6132 6152
6133 private: 6153 private:
6134 HStoreKeyed(HValue* obj, HValue* key, HValue* val, 6154 HStoreKeyed(HValue* obj, HValue* key, HValue* val,
6135 ElementsKind elements_kind) 6155 ElementsKind elements_kind)
6136 : elements_kind_(elements_kind), 6156 : elements_kind_(elements_kind),
6137 index_offset_(0), 6157 index_offset_(0),
6138 is_dehoisted_(false), 6158 is_dehoisted_(false),
6139 is_uninitialized_(false), 6159 is_uninitialized_(false),
(...skipping 25 matching lines...) Expand all
6165 } 6185 }
6166 6186
6167 ElementsKind elements_kind_; 6187 ElementsKind elements_kind_;
6168 uint32_t index_offset_; 6188 uint32_t index_offset_;
6169 bool is_dehoisted_ : 1; 6189 bool is_dehoisted_ : 1;
6170 bool is_uninitialized_ : 1; 6190 bool is_uninitialized_ : 1;
6171 HValue* new_space_dominator_; 6191 HValue* new_space_dominator_;
6172 }; 6192 };
6173 6193
6174 6194
6175 class HStoreKeyedGeneric: public HTemplateInstruction<4> { 6195 class HStoreKeyedGeneric V8_FINAL : public HTemplateInstruction<4> {
6176 public: 6196 public:
6177 HStoreKeyedGeneric(HValue* context, 6197 HStoreKeyedGeneric(HValue* context,
6178 HValue* object, 6198 HValue* object,
6179 HValue* key, 6199 HValue* key,
6180 HValue* value, 6200 HValue* value,
6181 StrictModeFlag strict_mode_flag) 6201 StrictModeFlag strict_mode_flag)
6182 : strict_mode_flag_(strict_mode_flag) { 6202 : strict_mode_flag_(strict_mode_flag) {
6183 SetOperandAt(0, object); 6203 SetOperandAt(0, object);
6184 SetOperandAt(1, key); 6204 SetOperandAt(1, key);
6185 SetOperandAt(2, value); 6205 SetOperandAt(2, value);
6186 SetOperandAt(3, context); 6206 SetOperandAt(3, context);
6187 SetAllSideEffects(); 6207 SetAllSideEffects();
6188 } 6208 }
6189 6209
6190 HValue* object() { return OperandAt(0); } 6210 HValue* object() { return OperandAt(0); }
6191 HValue* key() { return OperandAt(1); } 6211 HValue* key() { return OperandAt(1); }
6192 HValue* value() { return OperandAt(2); } 6212 HValue* value() { return OperandAt(2); }
6193 HValue* context() { return OperandAt(3); } 6213 HValue* context() { return OperandAt(3); }
6194 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } 6214 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
6195 6215
6196 virtual Representation RequiredInputRepresentation(int index) { 6216 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6197 // tagged[tagged] = tagged 6217 // tagged[tagged] = tagged
6198 return Representation::Tagged(); 6218 return Representation::Tagged();
6199 } 6219 }
6200 6220
6201 virtual void PrintDataTo(StringStream* stream); 6221 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6202 6222
6203 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) 6223 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
6204 6224
6205 private: 6225 private:
6206 StrictModeFlag strict_mode_flag_; 6226 StrictModeFlag strict_mode_flag_;
6207 }; 6227 };
6208 6228
6209 6229
6210 class HTransitionElementsKind: public HTemplateInstruction<2> { 6230 class HTransitionElementsKind V8_FINAL : public HTemplateInstruction<2> {
6211 public: 6231 public:
6212 inline static HTransitionElementsKind* New(Zone* zone, 6232 inline static HTransitionElementsKind* New(Zone* zone,
6213 HValue* context, 6233 HValue* context,
6214 HValue* object, 6234 HValue* object,
6215 Handle<Map> original_map, 6235 Handle<Map> original_map,
6216 Handle<Map> transitioned_map) { 6236 Handle<Map> transitioned_map) {
6217 return new(zone) HTransitionElementsKind(context, object, 6237 return new(zone) HTransitionElementsKind(context, object,
6218 original_map, transitioned_map); 6238 original_map, transitioned_map);
6219 } 6239 }
6220 6240
6221 virtual Representation RequiredInputRepresentation(int index) { 6241 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6222 return Representation::Tagged(); 6242 return Representation::Tagged();
6223 } 6243 }
6224 6244
6225 HValue* object() { return OperandAt(0); } 6245 HValue* object() { return OperandAt(0); }
6226 HValue* context() { return OperandAt(1); } 6246 HValue* context() { return OperandAt(1); }
6227 Handle<Map> original_map() { return original_map_; } 6247 Handle<Map> original_map() { return original_map_; }
6228 Handle<Map> transitioned_map() { return transitioned_map_; } 6248 Handle<Map> transitioned_map() { return transitioned_map_; }
6229 ElementsKind from_kind() { return from_kind_; } 6249 ElementsKind from_kind() { return from_kind_; }
6230 ElementsKind to_kind() { return to_kind_; } 6250 ElementsKind to_kind() { return to_kind_; }
6231 6251
6232 virtual void PrintDataTo(StringStream* stream); 6252 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6233 6253
6234 virtual void FinalizeUniqueValueId() { 6254 virtual void FinalizeUniqueValueId() V8_OVERRIDE {
6235 original_map_unique_id_ = UniqueValueId(original_map_); 6255 original_map_unique_id_ = UniqueValueId(original_map_);
6236 transitioned_map_unique_id_ = UniqueValueId(transitioned_map_); 6256 transitioned_map_unique_id_ = UniqueValueId(transitioned_map_);
6237 } 6257 }
6238 6258
6239 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) 6259 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
6240 6260
6241 protected: 6261 protected:
6242 virtual bool DataEquals(HValue* other) { 6262 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
6243 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other); 6263 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other);
6244 return original_map_unique_id_ == instr->original_map_unique_id_ && 6264 return original_map_unique_id_ == instr->original_map_unique_id_ &&
6245 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_; 6265 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_;
6246 } 6266 }
6247 6267
6248 private: 6268 private:
6249 HTransitionElementsKind(HValue* context, 6269 HTransitionElementsKind(HValue* context,
6250 HValue* object, 6270 HValue* object,
6251 Handle<Map> original_map, 6271 Handle<Map> original_map,
6252 Handle<Map> transitioned_map) 6272 Handle<Map> transitioned_map)
6253 : original_map_(original_map), 6273 : original_map_(original_map),
6254 transitioned_map_(transitioned_map), 6274 transitioned_map_(transitioned_map),
6255 original_map_unique_id_(), 6275 original_map_unique_id_(),
6256 transitioned_map_unique_id_(), 6276 transitioned_map_unique_id_(),
6257 from_kind_(original_map->elements_kind()), 6277 from_kind_(original_map->elements_kind()),
6258 to_kind_(transitioned_map->elements_kind()) { 6278 to_kind_(transitioned_map->elements_kind()) {
6259 SetOperandAt(0, object); 6279 SetOperandAt(0, object);
6260 SetOperandAt(1, context); 6280 SetOperandAt(1, context);
6261 SetFlag(kUseGVN); 6281 SetFlag(kUseGVN);
6262 SetGVNFlag(kChangesElementsKind); 6282 SetGVNFlag(kChangesElementsKind);
6263 if (original_map->has_fast_double_elements()) { 6283 if (!IsSimpleMapChangeTransition(from_kind_, to_kind_)) {
6264 SetGVNFlag(kChangesElementsPointer); 6284 SetGVNFlag(kChangesElementsPointer);
6265 SetGVNFlag(kChangesNewSpacePromotion); 6285 SetGVNFlag(kChangesNewSpacePromotion);
6266 } 6286 }
6267 if (transitioned_map->has_fast_double_elements()) {
6268 SetGVNFlag(kChangesElementsPointer);
6269 SetGVNFlag(kChangesNewSpacePromotion);
6270 }
6271 set_representation(Representation::Tagged()); 6287 set_representation(Representation::Tagged());
6272 } 6288 }
6273 6289
6274 Handle<Map> original_map_; 6290 Handle<Map> original_map_;
6275 Handle<Map> transitioned_map_; 6291 Handle<Map> transitioned_map_;
6276 UniqueValueId original_map_unique_id_; 6292 UniqueValueId original_map_unique_id_;
6277 UniqueValueId transitioned_map_unique_id_; 6293 UniqueValueId transitioned_map_unique_id_;
6278 ElementsKind from_kind_; 6294 ElementsKind from_kind_;
6279 ElementsKind to_kind_; 6295 ElementsKind to_kind_;
6280 }; 6296 };
6281 6297
6282 6298
6283 class HStringAdd: public HBinaryOperation { 6299 class HStringAdd V8_FINAL : public HBinaryOperation {
6284 public: 6300 public:
6285 static HInstruction* New(Zone* zone, 6301 static HInstruction* New(Zone* zone,
6286 HValue* context, 6302 HValue* context,
6287 HValue* left, 6303 HValue* left,
6288 HValue* right, 6304 HValue* right,
6289 StringAddFlags flags = STRING_ADD_CHECK_NONE); 6305 StringAddFlags flags = STRING_ADD_CHECK_NONE);
6290 6306
6291 StringAddFlags flags() const { return flags_; } 6307 StringAddFlags flags() const { return flags_; }
6292 6308
6293 virtual Representation RequiredInputRepresentation(int index) { 6309 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6294 return Representation::Tagged(); 6310 return Representation::Tagged();
6295 } 6311 }
6296 6312
6297 DECLARE_CONCRETE_INSTRUCTION(StringAdd) 6313 DECLARE_CONCRETE_INSTRUCTION(StringAdd)
6298 6314
6299 protected: 6315 protected:
6300 virtual bool DataEquals(HValue* other) { return true; } 6316 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
6301 6317
6302 private: 6318 private:
6303 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags) 6319 HStringAdd(HValue* context, HValue* left, HValue* right, StringAddFlags flags)
6304 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) { 6320 : HBinaryOperation(context, left, right, HType::String()), flags_(flags) {
6305 set_representation(Representation::Tagged()); 6321 set_representation(Representation::Tagged());
6306 SetFlag(kUseGVN); 6322 SetFlag(kUseGVN);
6307 SetGVNFlag(kDependsOnMaps); 6323 SetGVNFlag(kDependsOnMaps);
6308 SetGVNFlag(kChangesNewSpacePromotion); 6324 SetGVNFlag(kChangesNewSpacePromotion);
6309 } 6325 }
6310 6326
6311 // No side-effects except possible allocation. 6327 // No side-effects except possible allocation.
6312 // NOTE: this instruction _does not_ call ToString() on its inputs. 6328 // NOTE: this instruction _does not_ call ToString() on its inputs.
6313 virtual bool IsDeletable() const { return true; } 6329 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6314 6330
6315 const StringAddFlags flags_; 6331 const StringAddFlags flags_;
6316 }; 6332 };
6317 6333
6318 6334
6319 class HStringCharCodeAt: public HTemplateInstruction<3> { 6335 class HStringCharCodeAt V8_FINAL : public HTemplateInstruction<3> {
6320 public: 6336 public:
6321 static HStringCharCodeAt* New(Zone* zone, 6337 static HStringCharCodeAt* New(Zone* zone,
6322 HValue* context, 6338 HValue* context,
6323 HValue* string, 6339 HValue* string,
6324 HValue* index) { 6340 HValue* index) {
6325 return new(zone) HStringCharCodeAt(context, string, index); 6341 return new(zone) HStringCharCodeAt(context, string, index);
6326 } 6342 }
6327 6343
6328 virtual Representation RequiredInputRepresentation(int index) { 6344 virtual Representation RequiredInputRepresentation(int index) {
6329 // The index is supposed to be Integer32. 6345 // The index is supposed to be Integer32.
6330 return index == 2 6346 return index == 2
6331 ? Representation::Integer32() 6347 ? Representation::Integer32()
6332 : Representation::Tagged(); 6348 : Representation::Tagged();
6333 } 6349 }
6334 6350
6335 HValue* context() const { return OperandAt(0); } 6351 HValue* context() const { return OperandAt(0); }
6336 HValue* string() const { return OperandAt(1); } 6352 HValue* string() const { return OperandAt(1); }
6337 HValue* index() const { return OperandAt(2); } 6353 HValue* index() const { return OperandAt(2); }
6338 6354
6339 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) 6355 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt)
6340 6356
6341 protected: 6357 protected:
6342 virtual bool DataEquals(HValue* other) { return true; } 6358 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
6343 6359
6344 virtual Range* InferRange(Zone* zone) { 6360 virtual Range* InferRange(Zone* zone) V8_OVERRIDE {
6345 return new(zone) Range(0, String::kMaxUtf16CodeUnit); 6361 return new(zone) Range(0, String::kMaxUtf16CodeUnit);
6346 } 6362 }
6347 6363
6348 private: 6364 private:
6349 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) { 6365 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) {
6350 SetOperandAt(0, context); 6366 SetOperandAt(0, context);
6351 SetOperandAt(1, string); 6367 SetOperandAt(1, string);
6352 SetOperandAt(2, index); 6368 SetOperandAt(2, index);
6353 set_representation(Representation::Integer32()); 6369 set_representation(Representation::Integer32());
6354 SetFlag(kUseGVN); 6370 SetFlag(kUseGVN);
6355 SetGVNFlag(kDependsOnMaps); 6371 SetGVNFlag(kDependsOnMaps);
6356 SetGVNFlag(kChangesNewSpacePromotion); 6372 SetGVNFlag(kChangesNewSpacePromotion);
6357 } 6373 }
6358 6374
6359 // No side effects: runtime function assumes string + number inputs. 6375 // No side effects: runtime function assumes string + number inputs.
6360 virtual bool IsDeletable() const { return true; } 6376 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6361 }; 6377 };
6362 6378
6363 6379
6364 class HStringCharFromCode: public HTemplateInstruction<2> { 6380 class HStringCharFromCode V8_FINAL : public HTemplateInstruction<2> {
6365 public: 6381 public:
6366 static HInstruction* New(Zone* zone, 6382 static HInstruction* New(Zone* zone,
6367 HValue* context, 6383 HValue* context,
6368 HValue* char_code); 6384 HValue* char_code);
6369 6385
6370 virtual Representation RequiredInputRepresentation(int index) { 6386 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6371 return index == 0 6387 return index == 0
6372 ? Representation::Tagged() 6388 ? Representation::Tagged()
6373 : Representation::Integer32(); 6389 : Representation::Integer32();
6374 } 6390 }
6375 6391
6376 HValue* context() const { return OperandAt(0); } 6392 HValue* context() const { return OperandAt(0); }
6377 HValue* value() const { return OperandAt(1); } 6393 HValue* value() const { return OperandAt(1); }
6378 6394
6379 virtual bool DataEquals(HValue* other) { return true; } 6395 virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
6380 6396
6381 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) 6397 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode)
6382 6398
6383 private: 6399 private:
6384 HStringCharFromCode(HValue* context, HValue* char_code) 6400 HStringCharFromCode(HValue* context, HValue* char_code)
6385 : HTemplateInstruction<2>(HType::String()) { 6401 : HTemplateInstruction<2>(HType::String()) {
6386 SetOperandAt(0, context); 6402 SetOperandAt(0, context);
6387 SetOperandAt(1, char_code); 6403 SetOperandAt(1, char_code);
6388 set_representation(Representation::Tagged()); 6404 set_representation(Representation::Tagged());
6389 SetFlag(kUseGVN); 6405 SetFlag(kUseGVN);
6390 SetGVNFlag(kChangesNewSpacePromotion); 6406 SetGVNFlag(kChangesNewSpacePromotion);
6391 } 6407 }
6392 6408
6393 virtual bool IsDeletable() const { 6409 virtual bool IsDeletable() const V8_OVERRIDE {
6394 return !value()->ToNumberCanBeObserved(); 6410 return !value()->ToNumberCanBeObserved();
6395 } 6411 }
6396 }; 6412 };
6397 6413
6398 6414
6399 template <int V> 6415 template <int V>
6400 class HMaterializedLiteral: public HTemplateInstruction<V> { 6416 class HMaterializedLiteral : public HTemplateInstruction<V> {
6401 public: 6417 public:
6402 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) 6418 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode)
6403 : literal_index_(index), depth_(depth), allocation_site_mode_(mode) { 6419 : literal_index_(index), depth_(depth), allocation_site_mode_(mode) {
6404 this->set_representation(Representation::Tagged()); 6420 this->set_representation(Representation::Tagged());
6405 } 6421 }
6406 6422
6407 HMaterializedLiteral<V>(int index, int depth) 6423 HMaterializedLiteral<V>(int index, int depth)
6408 : literal_index_(index), depth_(depth), 6424 : literal_index_(index), depth_(depth),
6409 allocation_site_mode_(DONT_TRACK_ALLOCATION_SITE) { 6425 allocation_site_mode_(DONT_TRACK_ALLOCATION_SITE) {
6410 this->set_representation(Representation::Tagged()); 6426 this->set_representation(Representation::Tagged());
6411 } 6427 }
6412 6428
6413 int literal_index() const { return literal_index_; } 6429 int literal_index() const { return literal_index_; }
6414 int depth() const { return depth_; } 6430 int depth() const { return depth_; }
6415 AllocationSiteMode allocation_site_mode() const { 6431 AllocationSiteMode allocation_site_mode() const {
6416 return allocation_site_mode_; 6432 return allocation_site_mode_;
6417 } 6433 }
6418 6434
6419 private: 6435 private:
6420 virtual bool IsDeletable() const { return true; } 6436 virtual bool IsDeletable() const V8_FINAL V8_OVERRIDE { return true; }
6421 6437
6422 int literal_index_; 6438 int literal_index_;
6423 int depth_; 6439 int depth_;
6424 AllocationSiteMode allocation_site_mode_; 6440 AllocationSiteMode allocation_site_mode_;
6425 }; 6441 };
6426 6442
6427 6443
6428 class HRegExpLiteral: public HMaterializedLiteral<1> { 6444 class HRegExpLiteral V8_FINAL : public HMaterializedLiteral<1> {
6429 public: 6445 public:
6430 HRegExpLiteral(HValue* context, 6446 HRegExpLiteral(HValue* context,
6431 Handle<FixedArray> literals, 6447 Handle<FixedArray> literals,
6432 Handle<String> pattern, 6448 Handle<String> pattern,
6433 Handle<String> flags, 6449 Handle<String> flags,
6434 int literal_index) 6450 int literal_index)
6435 : HMaterializedLiteral<1>(literal_index, 0), 6451 : HMaterializedLiteral<1>(literal_index, 0),
6436 literals_(literals), 6452 literals_(literals),
6437 pattern_(pattern), 6453 pattern_(pattern),
6438 flags_(flags) { 6454 flags_(flags) {
6439 SetOperandAt(0, context); 6455 SetOperandAt(0, context);
6440 SetAllSideEffects(); 6456 SetAllSideEffects();
6441 set_type(HType::JSObject()); 6457 set_type(HType::JSObject());
6442 } 6458 }
6443 6459
6444 HValue* context() { return OperandAt(0); } 6460 HValue* context() { return OperandAt(0); }
6445 Handle<FixedArray> literals() { return literals_; } 6461 Handle<FixedArray> literals() { return literals_; }
6446 Handle<String> pattern() { return pattern_; } 6462 Handle<String> pattern() { return pattern_; }
6447 Handle<String> flags() { return flags_; } 6463 Handle<String> flags() { return flags_; }
6448 6464
6449 virtual Representation RequiredInputRepresentation(int index) { 6465 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6450 return Representation::Tagged(); 6466 return Representation::Tagged();
6451 } 6467 }
6452 6468
6453 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) 6469 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral)
6454 6470
6455 private: 6471 private:
6456 Handle<FixedArray> literals_; 6472 Handle<FixedArray> literals_;
6457 Handle<String> pattern_; 6473 Handle<String> pattern_;
6458 Handle<String> flags_; 6474 Handle<String> flags_;
6459 }; 6475 };
6460 6476
6461 6477
6462 class HFunctionLiteral: public HTemplateInstruction<1> { 6478 class HFunctionLiteral V8_FINAL : public HTemplateInstruction<1> {
6463 public: 6479 public:
6464 HFunctionLiteral(HValue* context, 6480 HFunctionLiteral(HValue* context,
6465 Handle<SharedFunctionInfo> shared, 6481 Handle<SharedFunctionInfo> shared,
6466 bool pretenure) 6482 bool pretenure)
6467 : HTemplateInstruction<1>(HType::JSObject()), 6483 : HTemplateInstruction<1>(HType::JSObject()),
6468 shared_info_(shared), 6484 shared_info_(shared),
6469 pretenure_(pretenure), 6485 pretenure_(pretenure),
6470 has_no_literals_(shared->num_literals() == 0), 6486 has_no_literals_(shared->num_literals() == 0),
6471 is_generator_(shared->is_generator()), 6487 is_generator_(shared->is_generator()),
6472 language_mode_(shared->language_mode()) { 6488 language_mode_(shared->language_mode()) {
6473 SetOperandAt(0, context); 6489 SetOperandAt(0, context);
6474 set_representation(Representation::Tagged()); 6490 set_representation(Representation::Tagged());
6475 SetGVNFlag(kChangesNewSpacePromotion); 6491 SetGVNFlag(kChangesNewSpacePromotion);
6476 } 6492 }
6477 6493
6478 HValue* context() { return OperandAt(0); } 6494 HValue* context() { return OperandAt(0); }
6479 6495
6480 virtual Representation RequiredInputRepresentation(int index) { 6496 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6481 return Representation::Tagged(); 6497 return Representation::Tagged();
6482 } 6498 }
6483 6499
6484 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) 6500 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral)
6485 6501
6486 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } 6502 Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
6487 bool pretenure() const { return pretenure_; } 6503 bool pretenure() const { return pretenure_; }
6488 bool has_no_literals() const { return has_no_literals_; } 6504 bool has_no_literals() const { return has_no_literals_; }
6489 bool is_generator() const { return is_generator_; } 6505 bool is_generator() const { return is_generator_; }
6490 LanguageMode language_mode() const { return language_mode_; } 6506 LanguageMode language_mode() const { return language_mode_; }
6491 6507
6492 private: 6508 private:
6493 virtual bool IsDeletable() const { return true; } 6509 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6494 6510
6495 Handle<SharedFunctionInfo> shared_info_; 6511 Handle<SharedFunctionInfo> shared_info_;
6496 bool pretenure_ : 1; 6512 bool pretenure_ : 1;
6497 bool has_no_literals_ : 1; 6513 bool has_no_literals_ : 1;
6498 bool is_generator_ : 1; 6514 bool is_generator_ : 1;
6499 LanguageMode language_mode_; 6515 LanguageMode language_mode_;
6500 }; 6516 };
6501 6517
6502 6518
6503 class HTypeof: public HTemplateInstruction<2> { 6519 class HTypeof V8_FINAL : public HTemplateInstruction<2> {
6504 public: 6520 public:
6505 explicit HTypeof(HValue* context, HValue* value) { 6521 explicit HTypeof(HValue* context, HValue* value) {
6506 SetOperandAt(0, context); 6522 SetOperandAt(0, context);
6507 SetOperandAt(1, value); 6523 SetOperandAt(1, value);
6508 set_representation(Representation::Tagged()); 6524 set_representation(Representation::Tagged());
6509 } 6525 }
6510 6526
6511 HValue* context() { return OperandAt(0); } 6527 HValue* context() { return OperandAt(0); }
6512 HValue* value() { return OperandAt(1); } 6528 HValue* value() { return OperandAt(1); }
6513 6529
6514 virtual void PrintDataTo(StringStream* stream); 6530 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6515 6531
6516 virtual Representation RequiredInputRepresentation(int index) { 6532 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6517 return Representation::Tagged(); 6533 return Representation::Tagged();
6518 } 6534 }
6519 6535
6520 DECLARE_CONCRETE_INSTRUCTION(Typeof) 6536 DECLARE_CONCRETE_INSTRUCTION(Typeof)
6521 6537
6522 private: 6538 private:
6523 virtual bool IsDeletable() const { return true; } 6539 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6524 }; 6540 };
6525 6541
6526 6542
6527 class HTrapAllocationMemento : public HTemplateInstruction<1> { 6543 class HTrapAllocationMemento V8_FINAL : public HTemplateInstruction<1> {
6528 public: 6544 public:
6529 DECLARE_INSTRUCTION_FACTORY_P1(HTrapAllocationMemento, HValue*); 6545 DECLARE_INSTRUCTION_FACTORY_P1(HTrapAllocationMemento, HValue*);
6530 6546
6531 virtual Representation RequiredInputRepresentation(int index) { 6547 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6532 return Representation::Tagged(); 6548 return Representation::Tagged();
6533 } 6549 }
6534 6550
6535 HValue* object() { return OperandAt(0); } 6551 HValue* object() { return OperandAt(0); }
6536 6552
6537 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento) 6553 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento)
6538 6554
6539 private: 6555 private:
6540 explicit HTrapAllocationMemento(HValue* obj) { 6556 explicit HTrapAllocationMemento(HValue* obj) {
6541 SetOperandAt(0, obj); 6557 SetOperandAt(0, obj);
6542 } 6558 }
6543 }; 6559 };
6544 6560
6545 6561
6546 class HToFastProperties: public HUnaryOperation { 6562 class HToFastProperties V8_FINAL : public HUnaryOperation {
6547 public: 6563 public:
6548 DECLARE_INSTRUCTION_FACTORY_P1(HToFastProperties, HValue*); 6564 DECLARE_INSTRUCTION_FACTORY_P1(HToFastProperties, HValue*);
6549 6565
6550 virtual Representation RequiredInputRepresentation(int index) { 6566 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6551 return Representation::Tagged(); 6567 return Representation::Tagged();
6552 } 6568 }
6553 6569
6554 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties) 6570 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties)
6555 6571
6556 private: 6572 private:
6557 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { 6573 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) {
6558 // This instruction is not marked as having side effects, but 6574 set_representation(Representation::Tagged());
6559 // changes the map of the input operand. Use it only when creating 6575 SetGVNFlag(kChangesNewSpacePromotion);
6576
6577 // This instruction is not marked as kChangesMaps, but does
6578 // change the map of the input operand. Use it only when creating
6560 // object literals via a runtime call. 6579 // object literals via a runtime call.
6561 ASSERT(value->IsCallRuntime()); 6580 ASSERT(value->IsCallRuntime());
6562 #ifdef DEBUG 6581 #ifdef DEBUG
6563 const Runtime::Function* function = HCallRuntime::cast(value)->function(); 6582 const Runtime::Function* function = HCallRuntime::cast(value)->function();
6564 ASSERT(function->function_id == Runtime::kCreateObjectLiteral || 6583 ASSERT(function->function_id == Runtime::kCreateObjectLiteral ||
6565 function->function_id == Runtime::kCreateObjectLiteralShallow); 6584 function->function_id == Runtime::kCreateObjectLiteralShallow);
6566 #endif 6585 #endif
6567 set_representation(Representation::Tagged());
6568 } 6586 }
6569 6587
6570 virtual bool IsDeletable() const { return true; } 6588 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6571 }; 6589 };
6572 6590
6573 6591
6574 class HValueOf: public HUnaryOperation { 6592 class HValueOf V8_FINAL : public HUnaryOperation {
6575 public: 6593 public:
6576 explicit HValueOf(HValue* value) : HUnaryOperation(value) { 6594 explicit HValueOf(HValue* value) : HUnaryOperation(value) {
6577 set_representation(Representation::Tagged()); 6595 set_representation(Representation::Tagged());
6578 } 6596 }
6579 6597
6580 virtual Representation RequiredInputRepresentation(int index) { 6598 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6581 return Representation::Tagged(); 6599 return Representation::Tagged();
6582 } 6600 }
6583 6601
6584 DECLARE_CONCRETE_INSTRUCTION(ValueOf) 6602 DECLARE_CONCRETE_INSTRUCTION(ValueOf)
6585 6603
6586 private: 6604 private:
6587 virtual bool IsDeletable() const { return true; } 6605 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6588 }; 6606 };
6589 6607
6590 6608
6591 class HDateField: public HUnaryOperation { 6609 class HDateField V8_FINAL : public HUnaryOperation {
6592 public: 6610 public:
6593 HDateField(HValue* date, Smi* index) 6611 HDateField(HValue* date, Smi* index)
6594 : HUnaryOperation(date), index_(index) { 6612 : HUnaryOperation(date), index_(index) {
6595 set_representation(Representation::Tagged()); 6613 set_representation(Representation::Tagged());
6596 } 6614 }
6597 6615
6598 Smi* index() const { return index_; } 6616 Smi* index() const { return index_; }
6599 6617
6600 virtual Representation RequiredInputRepresentation(int index) { 6618 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6601 return Representation::Tagged(); 6619 return Representation::Tagged();
6602 } 6620 }
6603 6621
6604 DECLARE_CONCRETE_INSTRUCTION(DateField) 6622 DECLARE_CONCRETE_INSTRUCTION(DateField)
6605 6623
6606 private: 6624 private:
6607 Smi* index_; 6625 Smi* index_;
6608 }; 6626 };
6609 6627
6610 6628
6611 class HSeqStringSetChar: public HTemplateInstruction<3> { 6629 class HSeqStringSetChar V8_FINAL : public HTemplateInstruction<3> {
6612 public: 6630 public:
6613 HSeqStringSetChar(String::Encoding encoding, 6631 HSeqStringSetChar(String::Encoding encoding,
6614 HValue* string, 6632 HValue* string,
6615 HValue* index, 6633 HValue* index,
6616 HValue* value) : encoding_(encoding) { 6634 HValue* value) : encoding_(encoding) {
6617 SetOperandAt(0, string); 6635 SetOperandAt(0, string);
6618 SetOperandAt(1, index); 6636 SetOperandAt(1, index);
6619 SetOperandAt(2, value); 6637 SetOperandAt(2, value);
6620 set_representation(Representation::Tagged()); 6638 set_representation(Representation::Tagged());
6621 } 6639 }
6622 6640
6623 String::Encoding encoding() { return encoding_; } 6641 String::Encoding encoding() { return encoding_; }
6624 HValue* string() { return OperandAt(0); } 6642 HValue* string() { return OperandAt(0); }
6625 HValue* index() { return OperandAt(1); } 6643 HValue* index() { return OperandAt(1); }
6626 HValue* value() { return OperandAt(2); } 6644 HValue* value() { return OperandAt(2); }
6627 6645
6628 virtual Representation RequiredInputRepresentation(int index) { 6646 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6629 return (index == 0) ? Representation::Tagged() 6647 return (index == 0) ? Representation::Tagged()
6630 : Representation::Integer32(); 6648 : Representation::Integer32();
6631 } 6649 }
6632 6650
6633 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) 6651 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar)
6634 6652
6635 private: 6653 private:
6636 String::Encoding encoding_; 6654 String::Encoding encoding_;
6637 }; 6655 };
6638 6656
6639 6657
6640 class HCheckMapValue: public HTemplateInstruction<2> { 6658 class HCheckMapValue V8_FINAL : public HTemplateInstruction<2> {
6641 public: 6659 public:
6642 DECLARE_INSTRUCTION_FACTORY_P2(HCheckMapValue, HValue*, HValue*); 6660 DECLARE_INSTRUCTION_FACTORY_P2(HCheckMapValue, HValue*, HValue*);
6643 6661
6644 virtual Representation RequiredInputRepresentation(int index) { 6662 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6645 return Representation::Tagged(); 6663 return Representation::Tagged();
6646 } 6664 }
6647 6665
6648 virtual void PrintDataTo(StringStream* stream); 6666 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6649 6667
6650 virtual HType CalculateInferredType() { 6668 virtual HType CalculateInferredType() V8_OVERRIDE {
6651 return HType::Tagged(); 6669 return HType::Tagged();
6652 } 6670 }
6653 6671
6654 HValue* value() { return OperandAt(0); } 6672 HValue* value() { return OperandAt(0); }
6655 HValue* map() { return OperandAt(1); } 6673 HValue* map() { return OperandAt(1); }
6656 6674
6657 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) 6675 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue)
6658 6676
6659 protected: 6677 protected:
6660 virtual bool DataEquals(HValue* other) { 6678 virtual bool DataEquals(HValue* other) V8_OVERRIDE {
6661 return true; 6679 return true;
6662 } 6680 }
6663 6681
6664 private: 6682 private:
6665 HCheckMapValue(HValue* value, 6683 HCheckMapValue(HValue* value,
6666 HValue* map) { 6684 HValue* map) {
6667 SetOperandAt(0, value); 6685 SetOperandAt(0, value);
6668 SetOperandAt(1, map); 6686 SetOperandAt(1, map);
6669 set_representation(Representation::Tagged()); 6687 set_representation(Representation::Tagged());
6670 SetFlag(kUseGVN); 6688 SetFlag(kUseGVN);
6671 SetGVNFlag(kDependsOnMaps); 6689 SetGVNFlag(kDependsOnMaps);
6672 SetGVNFlag(kDependsOnElementsKind); 6690 SetGVNFlag(kDependsOnElementsKind);
6673 } 6691 }
6674 }; 6692 };
6675 6693
6676 6694
6677 class HForInPrepareMap : public HTemplateInstruction<2> { 6695 class HForInPrepareMap V8_FINAL : public HTemplateInstruction<2> {
6678 public: 6696 public:
6679 static HForInPrepareMap* New(Zone* zone, 6697 static HForInPrepareMap* New(Zone* zone,
6680 HValue* context, 6698 HValue* context,
6681 HValue* object) { 6699 HValue* object) {
6682 return new(zone) HForInPrepareMap(context, object); 6700 return new(zone) HForInPrepareMap(context, object);
6683 } 6701 }
6684 6702
6685 virtual Representation RequiredInputRepresentation(int index) { 6703 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6686 return Representation::Tagged(); 6704 return Representation::Tagged();
6687 } 6705 }
6688 6706
6689 HValue* context() { return OperandAt(0); } 6707 HValue* context() { return OperandAt(0); }
6690 HValue* enumerable() { return OperandAt(1); } 6708 HValue* enumerable() { return OperandAt(1); }
6691 6709
6692 virtual void PrintDataTo(StringStream* stream); 6710 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6693 6711
6694 virtual HType CalculateInferredType() { 6712 virtual HType CalculateInferredType() V8_OVERRIDE {
6695 return HType::Tagged(); 6713 return HType::Tagged();
6696 } 6714 }
6697 6715
6698 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap); 6716 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap);
6699 6717
6700 private: 6718 private:
6701 HForInPrepareMap(HValue* context, 6719 HForInPrepareMap(HValue* context,
6702 HValue* object) { 6720 HValue* object) {
6703 SetOperandAt(0, context); 6721 SetOperandAt(0, context);
6704 SetOperandAt(1, object); 6722 SetOperandAt(1, object);
6705 set_representation(Representation::Tagged()); 6723 set_representation(Representation::Tagged());
6706 SetAllSideEffects(); 6724 SetAllSideEffects();
6707 } 6725 }
6708 }; 6726 };
6709 6727
6710 6728
6711 class HForInCacheArray : public HTemplateInstruction<2> { 6729 class HForInCacheArray V8_FINAL : public HTemplateInstruction<2> {
6712 public: 6730 public:
6713 DECLARE_INSTRUCTION_FACTORY_P3(HForInCacheArray, HValue*, HValue*, int); 6731 DECLARE_INSTRUCTION_FACTORY_P3(HForInCacheArray, HValue*, HValue*, int);
6714 6732
6715 virtual Representation RequiredInputRepresentation(int index) { 6733 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6716 return Representation::Tagged(); 6734 return Representation::Tagged();
6717 } 6735 }
6718 6736
6719 HValue* enumerable() { return OperandAt(0); } 6737 HValue* enumerable() { return OperandAt(0); }
6720 HValue* map() { return OperandAt(1); } 6738 HValue* map() { return OperandAt(1); }
6721 int idx() { return idx_; } 6739 int idx() { return idx_; }
6722 6740
6723 HForInCacheArray* index_cache() { 6741 HForInCacheArray* index_cache() {
6724 return index_cache_; 6742 return index_cache_;
6725 } 6743 }
6726 6744
6727 void set_index_cache(HForInCacheArray* index_cache) { 6745 void set_index_cache(HForInCacheArray* index_cache) {
6728 index_cache_ = index_cache; 6746 index_cache_ = index_cache;
6729 } 6747 }
6730 6748
6731 virtual void PrintDataTo(StringStream* stream); 6749 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6732 6750
6733 virtual HType CalculateInferredType() { 6751 virtual HType CalculateInferredType() V8_OVERRIDE {
6734 return HType::Tagged(); 6752 return HType::Tagged();
6735 } 6753 }
6736 6754
6737 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray); 6755 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray);
6738 6756
6739 private: 6757 private:
6740 HForInCacheArray(HValue* enumerable, 6758 HForInCacheArray(HValue* enumerable,
6741 HValue* keys, 6759 HValue* keys,
6742 int idx) : idx_(idx) { 6760 int idx) : idx_(idx) {
6743 SetOperandAt(0, enumerable); 6761 SetOperandAt(0, enumerable);
6744 SetOperandAt(1, keys); 6762 SetOperandAt(1, keys);
6745 set_representation(Representation::Tagged()); 6763 set_representation(Representation::Tagged());
6746 } 6764 }
6747 6765
6748 int idx_; 6766 int idx_;
6749 HForInCacheArray* index_cache_; 6767 HForInCacheArray* index_cache_;
6750 }; 6768 };
6751 6769
6752 6770
6753 class HLoadFieldByIndex : public HTemplateInstruction<2> { 6771 class HLoadFieldByIndex V8_FINAL : public HTemplateInstruction<2> {
6754 public: 6772 public:
6755 HLoadFieldByIndex(HValue* object, 6773 HLoadFieldByIndex(HValue* object,
6756 HValue* index) { 6774 HValue* index) {
6757 SetOperandAt(0, object); 6775 SetOperandAt(0, object);
6758 SetOperandAt(1, index); 6776 SetOperandAt(1, index);
6759 set_representation(Representation::Tagged()); 6777 set_representation(Representation::Tagged());
6760 } 6778 }
6761 6779
6762 virtual Representation RequiredInputRepresentation(int index) { 6780 virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
6763 return Representation::Tagged(); 6781 return Representation::Tagged();
6764 } 6782 }
6765 6783
6766 HValue* object() { return OperandAt(0); } 6784 HValue* object() { return OperandAt(0); }
6767 HValue* index() { return OperandAt(1); } 6785 HValue* index() { return OperandAt(1); }
6768 6786
6769 virtual void PrintDataTo(StringStream* stream); 6787 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
6770 6788
6771 virtual HType CalculateInferredType() { 6789 virtual HType CalculateInferredType() V8_OVERRIDE {
6772 return HType::Tagged(); 6790 return HType::Tagged();
6773 } 6791 }
6774 6792
6775 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); 6793 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
6776 6794
6777 private: 6795 private:
6778 virtual bool IsDeletable() const { return true; } 6796 virtual bool IsDeletable() const V8_OVERRIDE { return true; }
6779 }; 6797 };
6780 6798
6781 6799
6782 #undef DECLARE_INSTRUCTION 6800 #undef DECLARE_INSTRUCTION
6783 #undef DECLARE_CONCRETE_INSTRUCTION 6801 #undef DECLARE_CONCRETE_INSTRUCTION
6784 6802
6785 } } // namespace v8::internal 6803 } } // namespace v8::internal
6786 6804
6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6805 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-gvn.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698