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

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

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 27 matching lines...) Expand all
39 // Forward declarations. 39 // Forward declarations.
40 class HBasicBlock; 40 class HBasicBlock;
41 class HEnvironment; 41 class HEnvironment;
42 class HInstruction; 42 class HInstruction;
43 class HLoopInformation; 43 class HLoopInformation;
44 class HValue; 44 class HValue;
45 class LInstruction; 45 class LInstruction;
46 class LChunkBuilder; 46 class LChunkBuilder;
47 47
48 48
49 // Type hierarchy:
50 //
51 // HValue
52 // HInstruction
53 // HAccessArgumentsAt
54 // HApplyArguments
55 // HArgumentsElements
56 // HArgumentsLength
57 // HArgumentsObject
58 // HBinaryOperation
59 // HArithmeticBinaryOperation
60 // HAdd
61 // HDiv
62 // HMod
63 // HMul
64 // HSub
65 // HBitwiseBinaryOperation
66 // HBitAnd
67 // HBitOr
68 // HBitXor
69 // HSar
70 // HShl
71 // HShr
72 // HBoundsCheck
73 // HCompare
74 // HCompareJSObjectEq
75 // HInstanceOf
76 // HLoadKeyed
77 // HLoadKeyedFastElement
78 // HLoadKeyedGeneric
79 // HPower
80 // HStoreNamed
81 // HStoreNamedField
82 // HStoreNamedGeneric
83 // HBlockEntry
84 // HCall
85 // HCallConstantFunction
86 // HCallFunction
87 // HCallGlobal
88 // HCallKeyed
89 // HCallKnownGlobal
90 // HCallNamed
91 // HCallNew
92 // HCallRuntime
93 // HCallStub
94 // HConstant
95 // HControlInstruction
96 // HDeoptimize
97 // HGoto
98 // HUnaryControlInstruction
99 // HBranch
100 // HCompareMapAndBranch
101 // HReturn
102 // HThrow
103 // HEnterInlined
104 // HFunctionLiteral
105 // HGlobalObject
106 // HGlobalReceiver
107 // HLeaveInlined
108 // HLoadGlobal
109 // HMaterializedLiteral
110 // HArrayLiteral
111 // HObjectLiteral
112 // HRegExpLiteral
113 // HOsrEntry
114 // HParameter
115 // HSimulate
116 // HStackCheck
117 // HStoreKeyed
118 // HStoreKeyedFastElement
119 // HStoreKeyedGeneric
120 // HUnaryOperation
121 // HBitNot
122 // HChange
123 // HCheckFunction
124 // HCheckInstanceType
125 // HCheckMap
126 // HCheckNonSmi
127 // HCheckPrototypeMaps
128 // HCheckSmi
129 // HDeleteProperty
130 // HFixedArrayLength
131 // HJSArrayLength
132 // HLoadElements
133 // HTypeofIs
134 // HLoadNamedField
135 // HLoadNamedGeneric
136 // HLoadFunctionPrototype
137 // HPushArgument
138 // HTypeof
139 // HUnaryMathOperation
140 // HUnaryPredicate
141 // HClassOfTest
142 // HHasCachedArrayIndex
143 // HHasInstanceType
144 // HIsNull
145 // HIsObject
146 // HIsSmi
147 // HValueOf
148 // HUnknownOSRValue
149 // HPhi
150
151 #define HYDROGEN_ALL_INSTRUCTION_LIST(V) \ 49 #define HYDROGEN_ALL_INSTRUCTION_LIST(V) \
152 V(ArithmeticBinaryOperation) \ 50 V(ArithmeticBinaryOperation) \
51 V(BinaryCall) \
153 V(BinaryOperation) \ 52 V(BinaryOperation) \
154 V(BitwiseBinaryOperation) \ 53 V(BitwiseBinaryOperation) \
155 V(Call) \ 54 V(Call) \
156 V(ControlInstruction) \ 55 V(ControlInstruction) \
157 V(Instruction) \ 56 V(Instruction) \
158 V(LoadKeyed) \ 57 V(LoadKeyed) \
159 V(MaterializedLiteral) \ 58 V(MaterializedLiteral) \
160 V(Phi) \ 59 V(Phi) \
161 V(StoreKeyed) \ 60 V(StoreKeyed) \
162 V(StoreNamed) \ 61 V(StoreNamed) \
62 V(UnaryCall) \
163 V(UnaryControlInstruction) \ 63 V(UnaryControlInstruction) \
164 V(UnaryOperation) \ 64 V(UnaryOperation) \
165 HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) 65 HYDROGEN_CONCRETE_INSTRUCTION_LIST(V)
166 66
167 67
168 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ 68 #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \
69 V(AbnormalExit) \
169 V(AccessArgumentsAt) \ 70 V(AccessArgumentsAt) \
170 V(Add) \ 71 V(Add) \
171 V(ApplyArguments) \ 72 V(ApplyArguments) \
172 V(ArgumentsElements) \ 73 V(ArgumentsElements) \
173 V(ArgumentsLength) \ 74 V(ArgumentsLength) \
174 V(ArgumentsObject) \ 75 V(ArgumentsObject) \
175 V(ArrayLiteral) \ 76 V(ArrayLiteral) \
176 V(BitAnd) \ 77 V(BitAnd) \
177 V(BitNot) \ 78 V(BitNot) \
178 V(BitOr) \ 79 V(BitOr) \
179 V(BitXor) \ 80 V(BitXor) \
180 V(BlockEntry) \ 81 V(BlockEntry) \
181 V(BoundsCheck) \ 82 V(BoundsCheck) \
182 V(Branch) \
183 V(CallConstantFunction) \ 83 V(CallConstantFunction) \
184 V(CallFunction) \ 84 V(CallFunction) \
185 V(CallGlobal) \ 85 V(CallGlobal) \
186 V(CallKeyed) \ 86 V(CallKeyed) \
187 V(CallKnownGlobal) \ 87 V(CallKnownGlobal) \
188 V(CallNamed) \ 88 V(CallNamed) \
189 V(CallNew) \ 89 V(CallNew) \
190 V(CallRuntime) \ 90 V(CallRuntime) \
191 V(CallStub) \ 91 V(CallStub) \
192 V(Change) \ 92 V(Change) \
193 V(CheckFunction) \ 93 V(CheckFunction) \
194 V(CheckInstanceType) \ 94 V(CheckInstanceType) \
195 V(CheckMap) \ 95 V(CheckMap) \
196 V(CheckNonSmi) \ 96 V(CheckNonSmi) \
197 V(CheckPrototypeMaps) \ 97 V(CheckPrototypeMaps) \
198 V(CheckSmi) \ 98 V(CheckSmi) \
199 V(Compare) \ 99 V(Compare) \
200 V(CompareJSObjectEq) \ 100 V(CompareJSObjectEq) \
201 V(CompareMapAndBranch) \ 101 V(CompareMap) \
202 V(Constant) \ 102 V(Constant) \
103 V(Context) \
203 V(DeleteProperty) \ 104 V(DeleteProperty) \
204 V(Deoptimize) \ 105 V(Deoptimize) \
205 V(Div) \ 106 V(Div) \
206 V(EnterInlined) \ 107 V(EnterInlined) \
207 V(FixedArrayLength) \ 108 V(FixedArrayLength) \
208 V(FunctionLiteral) \ 109 V(FunctionLiteral) \
209 V(GlobalObject) \ 110 V(GlobalObject) \
210 V(GlobalReceiver) \ 111 V(GlobalReceiver) \
211 V(Goto) \ 112 V(Goto) \
212 V(InstanceOf) \ 113 V(InstanceOf) \
114 V(InstanceOfKnownGlobal) \
213 V(IsNull) \ 115 V(IsNull) \
214 V(IsObject) \ 116 V(IsObject) \
215 V(IsSmi) \ 117 V(IsSmi) \
118 V(IsConstructCall) \
216 V(HasInstanceType) \ 119 V(HasInstanceType) \
217 V(HasCachedArrayIndex) \ 120 V(HasCachedArrayIndex) \
218 V(JSArrayLength) \ 121 V(JSArrayLength) \
219 V(ClassOfTest) \ 122 V(ClassOfTest) \
220 V(LeaveInlined) \ 123 V(LeaveInlined) \
124 V(LoadContextSlot) \
221 V(LoadElements) \ 125 V(LoadElements) \
126 V(LoadFunctionPrototype) \
222 V(LoadGlobal) \ 127 V(LoadGlobal) \
223 V(LoadKeyedFastElement) \ 128 V(LoadKeyedFastElement) \
224 V(LoadKeyedGeneric) \ 129 V(LoadKeyedGeneric) \
225 V(LoadNamedField) \ 130 V(LoadNamedField) \
226 V(LoadNamedGeneric) \ 131 V(LoadNamedGeneric) \
227 V(LoadFunctionPrototype) \ 132 V(LoadPixelArrayElement) \
133 V(LoadPixelArrayExternalPointer) \
228 V(Mod) \ 134 V(Mod) \
229 V(Mul) \ 135 V(Mul) \
230 V(ObjectLiteral) \ 136 V(ObjectLiteral) \
231 V(OsrEntry) \ 137 V(OsrEntry) \
138 V(OuterContext) \
232 V(Parameter) \ 139 V(Parameter) \
140 V(PixelArrayLength) \
233 V(Power) \ 141 V(Power) \
234 V(PushArgument) \ 142 V(PushArgument) \
235 V(RegExpLiteral) \ 143 V(RegExpLiteral) \
236 V(Return) \ 144 V(Return) \
237 V(Sar) \ 145 V(Sar) \
238 V(Shl) \ 146 V(Shl) \
239 V(Shr) \ 147 V(Shr) \
240 V(Simulate) \ 148 V(Simulate) \
241 V(StackCheck) \ 149 V(StackCheck) \
150 V(StoreContextSlot) \
242 V(StoreGlobal) \ 151 V(StoreGlobal) \
243 V(StoreKeyedFastElement) \ 152 V(StoreKeyedFastElement) \
244 V(StoreKeyedGeneric) \ 153 V(StoreKeyedGeneric) \
245 V(StoreNamedField) \ 154 V(StoreNamedField) \
246 V(StoreNamedGeneric) \ 155 V(StoreNamedGeneric) \
156 V(StringCharCodeAt) \
157 V(StringLength) \
247 V(Sub) \ 158 V(Sub) \
159 V(Test) \
248 V(Throw) \ 160 V(Throw) \
249 V(Typeof) \ 161 V(Typeof) \
250 V(TypeofIs) \ 162 V(TypeofIs) \
251 V(UnaryMathOperation) \ 163 V(UnaryMathOperation) \
252 V(UnknownOSRValue) \ 164 V(UnknownOSRValue) \
253 V(ValueOf) 165 V(ValueOf)
254 166
255 #define GVN_FLAG_LIST(V) \ 167 #define GVN_FLAG_LIST(V) \
256 V(Calls) \ 168 V(Calls) \
257 V(InobjectFields) \ 169 V(InobjectFields) \
258 V(BackingStoreFields) \ 170 V(BackingStoreFields) \
259 V(ArrayElements) \ 171 V(ArrayElements) \
172 V(PixelArrayElements) \
260 V(GlobalVars) \ 173 V(GlobalVars) \
261 V(Maps) \ 174 V(Maps) \
262 V(ArrayLengths) \ 175 V(ArrayLengths) \
263 V(FunctionPrototypes) \ 176 V(ContextSlots) \
264 V(OsrEntries) 177 V(OsrEntries)
265 178
266 #define DECLARE_INSTRUCTION(type) \ 179 #define DECLARE_INSTRUCTION(type) \
267 virtual bool Is##type() const { return true; } \ 180 virtual bool Is##type() const { return true; } \
268 static H##type* cast(HValue* value) { \ 181 static H##type* cast(HValue* value) { \
269 ASSERT(value->Is##type()); \ 182 ASSERT(value->Is##type()); \
270 return reinterpret_cast<H##type*>(value); \ 183 return reinterpret_cast<H##type*>(value); \
271 } \ 184 } \
272 Opcode opcode() const { return HValue::k##type; } 185 Opcode opcode() const { return HValue::k##type; }
273 186
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 }; 288 };
376 289
377 290
378 class Representation { 291 class Representation {
379 public: 292 public:
380 enum Kind { 293 enum Kind {
381 kNone, 294 kNone,
382 kTagged, 295 kTagged,
383 kDouble, 296 kDouble,
384 kInteger32, 297 kInteger32,
298 kExternal,
385 kNumRepresentations 299 kNumRepresentations
386 }; 300 };
387 301
388 Representation() : kind_(kNone) { } 302 Representation() : kind_(kNone) { }
389 303
390 static Representation None() { return Representation(kNone); } 304 static Representation None() { return Representation(kNone); }
391 static Representation Tagged() { return Representation(kTagged); } 305 static Representation Tagged() { return Representation(kTagged); }
392 static Representation Integer32() { return Representation(kInteger32); } 306 static Representation Integer32() { return Representation(kInteger32); }
393 static Representation Double() { return Representation(kDouble); } 307 static Representation Double() { return Representation(kDouble); }
308 static Representation External() { return Representation(kExternal); }
394 309
395 bool Equals(const Representation& other) const { 310 bool Equals(const Representation& other) const {
396 return kind_ == other.kind_; 311 return kind_ == other.kind_;
397 } 312 }
398 313
399 Kind kind() const { return kind_; } 314 Kind kind() const { return kind_; }
400 bool IsNone() const { return kind_ == kNone; } 315 bool IsNone() const { return kind_ == kNone; }
401 bool IsTagged() const { return kind_ == kTagged; } 316 bool IsTagged() const { return kind_ == kTagged; }
402 bool IsInteger32() const { return kind_ == kInteger32; } 317 bool IsInteger32() const { return kind_ == kInteger32; }
403 bool IsDouble() const { return kind_ == kDouble; } 318 bool IsDouble() const { return kind_ == kDouble; }
319 bool IsExternal() const { return kind_ == kExternal; }
404 bool IsSpecialization() const { 320 bool IsSpecialization() const {
405 return kind_ == kInteger32 || kind_ == kDouble; 321 return kind_ == kInteger32 || kind_ == kDouble;
406 } 322 }
407 const char* Mnemonic() const; 323 const char* Mnemonic() const;
408 324
409 private: 325 private:
410 explicit Representation(Kind k) : kind_(k) { } 326 explicit Representation(Kind k) : kind_(k) { }
411 327
412 Kind kind_; 328 Kind kind_;
413 }; 329 };
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 474 }
559 475
560 static int DependsFlagsMask() { 476 static int DependsFlagsMask() {
561 return ConvertChangesToDependsFlags(ChangesFlagsMask()); 477 return ConvertChangesToDependsFlags(ChangesFlagsMask());
562 } 478 }
563 479
564 static int ConvertChangesToDependsFlags(int flags) { 480 static int ConvertChangesToDependsFlags(int flags) {
565 return flags << kChangesToDependsFlagsLeftShift; 481 return flags << kChangesToDependsFlagsLeftShift;
566 } 482 }
567 483
568 // A flag mask to mark an instruction as having arbitrary side effects.
569 static int AllSideEffects() {
570 return ChangesFlagsMask() & ~(1 << kChangesOsrEntries);
571 }
572
573 static HValue* cast(HValue* value) { return value; } 484 static HValue* cast(HValue* value) { return value; }
574 485
575 enum Opcode { 486 enum Opcode {
576 // Declare a unique enum value for each hydrogen instruction. 487 // Declare a unique enum value for each hydrogen instruction.
577 #define DECLARE_DO(type) k##type, 488 #define DECLARE_DO(type) k##type,
578 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO) 489 HYDROGEN_ALL_INSTRUCTION_LIST(DECLARE_DO)
579 #undef DECLARE_DO 490 #undef DECLARE_DO
580 kMaxInstructionClass 491 kMaxInstructionClass
581 }; 492 };
582 493
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // If the operation also exists in a form that takes int32 and outputs int32 532 // If the operation also exists in a form that takes int32 and outputs int32
622 // then the operation should return its input value so that we can propagate 533 // then the operation should return its input value so that we can propagate
623 // back. There are two operations that need to propagate back to more than 534 // back. There are two operations that need to propagate back to more than
624 // one input. They are phi and binary add. They always return NULL and 535 // one input. They are phi and binary add. They always return NULL and
625 // expect the caller to take care of things. 536 // expect the caller to take care of things.
626 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited) { 537 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited) {
627 visited->Add(id()); 538 visited->Add(id());
628 return NULL; 539 return NULL;
629 } 540 }
630 541
631 bool HasSideEffects() const {
632 return (flags_ & AllSideEffects()) != 0;
633 }
634 bool IsDefinedAfter(HBasicBlock* other) const; 542 bool IsDefinedAfter(HBasicBlock* other) const;
635 543
636 // Operands. 544 // Operands.
637 virtual int OperandCount() const { return 0; } 545 virtual int OperandCount() const { return 0; }
638 virtual HValue* OperandAt(int index) const { 546 virtual HValue* OperandAt(int index) const {
639 UNREACHABLE(); 547 UNREACHABLE();
640 return NULL; 548 return NULL;
641 } 549 }
642 void SetOperandAt(int index, HValue* value); 550 void SetOperandAt(int index, HValue* value);
643 551
644 int LookupOperandIndex(int occurrence_index, HValue* op) const; 552 int LookupOperandIndex(int occurrence_index, HValue* op) const;
645 bool UsesMultipleTimes(HValue* op) const; 553 bool UsesMultipleTimes(HValue* op) const;
646 554
647 void ReplaceAndDelete(HValue* other); 555 void ReplaceAndDelete(HValue* other);
648 void ReplaceValue(HValue* other); 556 void ReplaceValue(HValue* other);
649 void ReplaceAtUse(HValue* use, HValue* other); 557 void ReplaceAtUse(HValue* use, HValue* other);
650 void ReplaceFirstAtUse(HValue* use, HValue* other, Representation r); 558 void ReplaceFirstAtUse(HValue* use, HValue* other, Representation r);
651 bool HasNoUses() const { return uses_.is_empty(); } 559 bool HasNoUses() const { return uses_.is_empty(); }
652 void ClearOperands(); 560 void ClearOperands();
653 void Delete(); 561 void Delete();
654 562
655 int flags() const { return flags_; } 563 int flags() const { return flags_; }
656 void SetFlagMask(int mask) { flags_ |= mask; } 564 void SetFlag(Flag f) { flags_ |= (1 << f); }
657 void SetFlag(Flag f) { SetFlagMask(1 << f); } 565 void ClearFlag(Flag f) { flags_ &= ~(1 << f); }
658 void ClearFlagMask(int mask) { flags_ &= ~mask; } 566 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; }
659 void ClearFlag(Flag f) { ClearFlagMask(1 << f); } 567
660 bool CheckFlag(Flag f) const { return CheckFlagMask(1 << f); } 568 void SetAllSideEffects() { flags_ |= AllSideEffects(); }
661 bool CheckFlagMask(int mask) const { return (flags_ & mask) != 0; } 569 void ClearAllSideEffects() { flags_ &= ~AllSideEffects(); }
570 bool HasSideEffects() const { return (flags_ & AllSideEffects()) != 0; }
662 571
663 Range* range() const { return range_; } 572 Range* range() const { return range_; }
664 bool HasRange() const { return range_ != NULL; } 573 bool HasRange() const { return range_ != NULL; }
665 void AddNewRange(Range* r); 574 void AddNewRange(Range* r);
666 void RemoveLastAddedRange(); 575 void RemoveLastAddedRange();
667 void ComputeInitialRange(); 576 void ComputeInitialRange();
668 577
669 // Representation helpers. 578 // Representation helpers.
670 virtual Representation RequiredInputRepresentation(int index) const { 579 virtual Representation RequiredInputRepresentation(int index) const {
671 return Representation::None(); 580 return Representation::None();
(...skipping 23 matching lines...) Expand all
695 604
696 virtual const char* Mnemonic() const = 0; 605 virtual const char* Mnemonic() const = 0;
697 virtual Opcode opcode() const = 0; 606 virtual Opcode opcode() const = 0;
698 607
699 // Updated the inferred type of this instruction and returns true if 608 // Updated the inferred type of this instruction and returns true if
700 // it has changed. 609 // it has changed.
701 bool UpdateInferredType(); 610 bool UpdateInferredType();
702 611
703 virtual HType CalculateInferredType() const; 612 virtual HType CalculateInferredType() const;
704 613
705 // Helper for type conversions used by normal and phi instructions.
706 void InsertInputConversion(HInstruction* previous, int index, HType type);
707
708 #ifdef DEBUG 614 #ifdef DEBUG
709 virtual void Verify() const = 0; 615 virtual void Verify() = 0;
710 #endif 616 #endif
711 617
712 protected: 618 protected:
713 virtual bool DataEquals(HValue* other) const { return true; } 619 // This function must be overridden for instructions with flag kUseGVN, to
620 // compare the non-Operand parts of the instruction.
621 virtual bool DataEquals(HValue* other) const {
622 UNREACHABLE();
623 return false;
624 }
714 virtual void RepresentationChanged(Representation to) { } 625 virtual void RepresentationChanged(Representation to) { }
715 virtual Range* InferRange(); 626 virtual Range* InferRange();
716 virtual void DeleteFromGraph() = 0; 627 virtual void DeleteFromGraph() = 0;
717 virtual void InternalSetOperandAt(int index, HValue* value) { UNREACHABLE(); } 628 virtual void InternalSetOperandAt(int index, HValue* value) { UNREACHABLE(); }
718 void clear_block() { 629 void clear_block() {
719 ASSERT(block_ != NULL); 630 ASSERT(block_ != NULL);
720 block_ = NULL; 631 block_ = NULL;
721 } 632 }
722 633
723 void set_representation(Representation r) { 634 void set_representation(Representation r) {
724 // Representation is set-once. 635 // Representation is set-once.
725 ASSERT(representation_.IsNone() && !r.IsNone()); 636 ASSERT(representation_.IsNone() && !r.IsNone());
726 representation_ = r; 637 representation_ = r;
727 } 638 }
728 639
729 private: 640 private:
641 // A flag mask to mark an instruction as having arbitrary side effects.
642 static int AllSideEffects() {
643 return ChangesFlagsMask() & ~(1 << kChangesOsrEntries);
644 }
645
730 void InternalReplaceAtUse(HValue* use, HValue* other); 646 void InternalReplaceAtUse(HValue* use, HValue* other);
731 void RegisterUse(int index, HValue* new_value); 647 void RegisterUse(int index, HValue* new_value);
732 648
733 HBasicBlock* block_; 649 HBasicBlock* block_;
734 650
735 // The id of this instruction in the hydrogen graph, assigned when first 651 // The id of this instruction in the hydrogen graph, assigned when first
736 // added to the graph. Reflects creation order. 652 // added to the graph. Reflects creation order.
737 int id_; 653 int id_;
738 654
739 Representation representation_; 655 Representation representation_;
(...skipping 19 matching lines...) Expand all
759 void InsertBefore(HInstruction* next); 675 void InsertBefore(HInstruction* next);
760 void InsertAfter(HInstruction* previous); 676 void InsertAfter(HInstruction* previous);
761 677
762 int position() const { return position_; } 678 int position() const { return position_; }
763 bool has_position() const { return position_ != RelocInfo::kNoPosition; } 679 bool has_position() const { return position_ != RelocInfo::kNoPosition; }
764 void set_position(int position) { position_ = position; } 680 void set_position(int position) { position_ = position; }
765 681
766 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; 682 virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0;
767 683
768 #ifdef DEBUG 684 #ifdef DEBUG
769 virtual void Verify() const; 685 virtual void Verify();
770 #endif 686 #endif
771 687
688 // Returns whether this is some kind of deoptimizing check
689 // instruction.
690 virtual bool IsCheckInstruction() const { return false; }
691
772 DECLARE_INSTRUCTION(Instruction) 692 DECLARE_INSTRUCTION(Instruction)
773 693
774 protected: 694 protected:
775 HInstruction() 695 HInstruction()
776 : next_(NULL), 696 : next_(NULL),
777 previous_(NULL), 697 previous_(NULL),
778 position_(RelocInfo::kNoPosition) { 698 position_(RelocInfo::kNoPosition) {
779 SetFlag(kDependsOnOsrEntries); 699 SetFlag(kDependsOnOsrEntries);
780 } 700 }
781 701
(...skipping 14 matching lines...) Expand all
796 716
797 717
798 class HBlockEntry: public HInstruction { 718 class HBlockEntry: public HInstruction {
799 public: 719 public:
800 DECLARE_CONCRETE_INSTRUCTION(BlockEntry, "block_entry") 720 DECLARE_CONCRETE_INSTRUCTION(BlockEntry, "block_entry")
801 }; 721 };
802 722
803 723
804 class HControlInstruction: public HInstruction { 724 class HControlInstruction: public HInstruction {
805 public: 725 public:
806 virtual HBasicBlock* FirstSuccessor() const { return NULL; } 726 HControlInstruction(HBasicBlock* first, HBasicBlock* second)
807 virtual HBasicBlock* SecondSuccessor() const { return NULL; } 727 : first_successor_(first), second_successor_(second) {
728 }
729
730 HBasicBlock* FirstSuccessor() const { return first_successor_; }
731 HBasicBlock* SecondSuccessor() const { return second_successor_; }
732
733 virtual void PrintDataTo(StringStream* stream) const;
808 734
809 DECLARE_INSTRUCTION(ControlInstruction) 735 DECLARE_INSTRUCTION(ControlInstruction)
736
737 private:
738 HBasicBlock* first_successor_;
739 HBasicBlock* second_successor_;
810 }; 740 };
811 741
812 742
813 class HDeoptimize: public HControlInstruction { 743 class HDeoptimize: public HControlInstruction {
814 public: 744 public:
745 HDeoptimize() : HControlInstruction(NULL, NULL) { }
746
815 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize") 747 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
816 }; 748 };
817 749
818 750
819 class HGoto: public HControlInstruction { 751 class HGoto: public HControlInstruction {
820 public: 752 public:
821 explicit HGoto(HBasicBlock* destination) 753 explicit HGoto(HBasicBlock* target)
822 : destination_(destination), 754 : HControlInstruction(target, NULL), include_stack_check_(false) {
823 include_stack_check_(false) {} 755 }
824 756
825 virtual HBasicBlock* FirstSuccessor() const { return destination_; }
826 void set_include_stack_check(bool include_stack_check) { 757 void set_include_stack_check(bool include_stack_check) {
827 include_stack_check_ = include_stack_check; 758 include_stack_check_ = include_stack_check;
828 } 759 }
829 bool include_stack_check() const { return include_stack_check_; } 760 bool include_stack_check() const { return include_stack_check_; }
830 761
831 virtual void PrintDataTo(StringStream* stream) const;
832
833 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto") 762 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
834 763
835 private: 764 private:
836 HBasicBlock* destination_;
837 bool include_stack_check_; 765 bool include_stack_check_;
838 }; 766 };
839 767
840 768
841 class HUnaryControlInstruction: public HControlInstruction { 769 class HUnaryControlInstruction: public HControlInstruction {
842 public: 770 public:
843 explicit HUnaryControlInstruction(HValue* value) { 771 explicit HUnaryControlInstruction(HValue* value,
772 HBasicBlock* true_target,
773 HBasicBlock* false_target)
774 : HControlInstruction(true_target, false_target) {
844 SetOperandAt(0, value); 775 SetOperandAt(0, value);
845 } 776 }
846 777
847 virtual Representation RequiredInputRepresentation(int index) const { 778 virtual Representation RequiredInputRepresentation(int index) const {
848 return Representation::Tagged(); 779 return Representation::Tagged();
849 } 780 }
850 781
782 virtual void PrintDataTo(StringStream* stream) const;
783
851 HValue* value() const { return OperandAt(0); } 784 HValue* value() const { return OperandAt(0); }
852 virtual int OperandCount() const { return 1; } 785 virtual int OperandCount() const { return 1; }
853 virtual HValue* OperandAt(int index) const { return operands_[index]; } 786 virtual HValue* OperandAt(int index) const { return operands_[index]; }
854 787
855 DECLARE_INSTRUCTION(UnaryControlInstruction) 788 DECLARE_INSTRUCTION(UnaryControlInstruction)
856 789
857 protected: 790 protected:
858 virtual void InternalSetOperandAt(int index, HValue* value) { 791 virtual void InternalSetOperandAt(int index, HValue* value) {
859 operands_[index] = value; 792 operands_[index] = value;
860 } 793 }
861 794
862 private: 795 private:
863 HOperandVector<1> operands_; 796 HOperandVector<1> operands_;
864 }; 797 };
865 798
866 799
867 class HBranch: public HUnaryControlInstruction { 800 class HTest: public HUnaryControlInstruction {
868 public: 801 public:
869 HBranch(HBasicBlock* true_destination, 802 HTest(HValue* value, HBasicBlock* true_target, HBasicBlock* false_target)
870 HBasicBlock* false_destination, 803 : HUnaryControlInstruction(value, true_target, false_target) {
871 HValue* boolean_value) 804 ASSERT(true_target != NULL && false_target != NULL);
872 : HUnaryControlInstruction(boolean_value),
873 true_destination_(true_destination),
874 false_destination_(false_destination) {
875 ASSERT(true_destination != NULL && false_destination != NULL);
876 } 805 }
877 806
878 virtual Representation RequiredInputRepresentation(int index) const { 807 virtual Representation RequiredInputRepresentation(int index) const {
879 return Representation::None(); 808 return Representation::None();
880 } 809 }
881 810
882 virtual HBasicBlock* FirstSuccessor() const { return true_destination_; } 811 DECLARE_CONCRETE_INSTRUCTION(Test, "test")
883 virtual HBasicBlock* SecondSuccessor() const { return false_destination_; }
884
885 virtual void PrintDataTo(StringStream* stream) const;
886
887 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
888
889 private:
890 HBasicBlock* true_destination_;
891 HBasicBlock* false_destination_;
892 }; 812 };
893 813
894 814
895 class HCompareMapAndBranch: public HUnaryControlInstruction { 815 class HCompareMap: public HUnaryControlInstruction {
896 public: 816 public:
897 HCompareMapAndBranch(HValue* result, 817 HCompareMap(HValue* value,
898 Handle<Map> map, 818 Handle<Map> map,
899 HBasicBlock* true_destination, 819 HBasicBlock* true_target,
900 HBasicBlock* false_destination) 820 HBasicBlock* false_target)
901 : HUnaryControlInstruction(result), 821 : HUnaryControlInstruction(value, true_target, false_target),
902 map_(map), 822 map_(map) {
903 true_destination_(true_destination), 823 ASSERT(true_target != NULL);
904 false_destination_(false_destination) { 824 ASSERT(false_target != NULL);
905 ASSERT(true_destination != NULL);
906 ASSERT(false_destination != NULL);
907 ASSERT(!map.is_null()); 825 ASSERT(!map.is_null());
908 } 826 }
909 827
910 virtual HBasicBlock* FirstSuccessor() const { return true_destination_; }
911 virtual HBasicBlock* SecondSuccessor() const { return false_destination_; }
912
913 HBasicBlock* true_destination() const { return true_destination_; }
914 HBasicBlock* false_destination() const { return false_destination_; }
915
916 virtual void PrintDataTo(StringStream* stream) const; 828 virtual void PrintDataTo(StringStream* stream) const;
917 829
918 Handle<Map> map() const { return map_; } 830 Handle<Map> map() const { return map_; }
919 831
920 DECLARE_CONCRETE_INSTRUCTION(CompareMapAndBranch, "compare_map_and_branch") 832 DECLARE_CONCRETE_INSTRUCTION(CompareMap, "compare_map")
921 833
922 private: 834 private:
923 Handle<Map> map_; 835 Handle<Map> map_;
924 HBasicBlock* true_destination_;
925 HBasicBlock* false_destination_;
926 }; 836 };
927 837
928 838
929 class HReturn: public HUnaryControlInstruction { 839 class HReturn: public HUnaryControlInstruction {
930 public: 840 public:
931 explicit HReturn(HValue* result) : HUnaryControlInstruction(result) { } 841 explicit HReturn(HValue* value)
932 842 : HUnaryControlInstruction(value, NULL, NULL) {
933 virtual void PrintDataTo(StringStream* stream) const; 843 }
934 844
935 DECLARE_CONCRETE_INSTRUCTION(Return, "return") 845 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
936 }; 846 };
937 847
938 848
939 class HThrow: public HUnaryControlInstruction { 849 class HAbnormalExit: public HControlInstruction {
940 public: 850 public:
941 explicit HThrow(HValue* value) : HUnaryControlInstruction(value) { } 851 HAbnormalExit() : HControlInstruction(NULL, NULL) { }
942 852
943 virtual void PrintDataTo(StringStream* stream) const; 853 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit, "abnormal_exit")
944
945 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
946 }; 854 };
947 855
948 856
949 class HUnaryOperation: public HInstruction { 857 class HUnaryOperation: public HInstruction {
950 public: 858 public:
951 explicit HUnaryOperation(HValue* value) { 859 explicit HUnaryOperation(HValue* value) {
952 SetOperandAt(0, value); 860 SetOperandAt(0, value);
953 } 861 }
954 862
955 HValue* value() const { return OperandAt(0); } 863 HValue* value() const { return OperandAt(0); }
956 virtual void PrintDataTo(StringStream* stream) const; 864 virtual void PrintDataTo(StringStream* stream) const;
957 virtual int OperandCount() const { return 1; } 865 virtual int OperandCount() const { return 1; }
958 virtual HValue* OperandAt(int index) const { return operands_[index]; } 866 virtual HValue* OperandAt(int index) const { return operands_[index]; }
959 867
960 DECLARE_INSTRUCTION(UnaryOperation) 868 DECLARE_INSTRUCTION(UnaryOperation)
961 869
962 protected: 870 protected:
963 virtual void InternalSetOperandAt(int index, HValue* value) { 871 virtual void InternalSetOperandAt(int index, HValue* value) {
964 operands_[index] = value; 872 operands_[index] = value;
965 } 873 }
966 874
967 private: 875 private:
968 HOperandVector<1> operands_; 876 HOperandVector<1> operands_;
969 }; 877 };
970 878
971 879
880 class HThrow: public HUnaryOperation {
881 public:
882 explicit HThrow(HValue* value) : HUnaryOperation(value) {
883 SetAllSideEffects();
884 }
885
886 virtual Representation RequiredInputRepresentation(int index) const {
887 return Representation::Tagged();
888 }
889
890 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
891 };
892
893
972 class HChange: public HUnaryOperation { 894 class HChange: public HUnaryOperation {
973 public: 895 public:
974 HChange(HValue* value, 896 HChange(HValue* value,
975 Representation from, 897 Representation from,
976 Representation to) 898 Representation to)
977 : HUnaryOperation(value), from_(from), to_(to) { 899 : HUnaryOperation(value), from_(from), to_(to) {
978 ASSERT(!from.IsNone() && !to.IsNone()); 900 ASSERT(!from.IsNone() && !to.IsNone());
979 ASSERT(!from.Equals(to)); 901 ASSERT(!from.Equals(to));
980 set_representation(to); 902 set_representation(to);
981 SetFlag(kUseGVN); 903 SetFlag(kUseGVN);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } 977 }
1056 void AddPushedValue(HValue* value) { 978 void AddPushedValue(HValue* value) {
1057 AddValue(kNoIndex, value); 979 AddValue(kNoIndex, value);
1058 } 980 }
1059 virtual int OperandCount() const { return values_.length(); } 981 virtual int OperandCount() const { return values_.length(); }
1060 virtual HValue* OperandAt(int index) const { return values_[index]; } 982 virtual HValue* OperandAt(int index) const { return values_[index]; }
1061 983
1062 DECLARE_CONCRETE_INSTRUCTION(Simulate, "simulate") 984 DECLARE_CONCRETE_INSTRUCTION(Simulate, "simulate")
1063 985
1064 #ifdef DEBUG 986 #ifdef DEBUG
1065 virtual void Verify() const; 987 virtual void Verify();
1066 #endif 988 #endif
1067 989
1068 protected: 990 protected:
1069 virtual void InternalSetOperandAt(int index, HValue* value) { 991 virtual void InternalSetOperandAt(int index, HValue* value) {
1070 values_[index] = value; 992 values_[index] = value;
1071 } 993 }
1072 994
1073 private: 995 private:
1074 static const int kNoIndex = -1; 996 static const int kNoIndex = -1;
1075 void AddValue(int index, HValue* value) { 997 void AddValue(int index, HValue* value) {
1076 assigned_indexes_.Add(index); 998 assigned_indexes_.Add(index);
1077 // Resize the list of pushed values. 999 // Resize the list of pushed values.
1078 values_.Add(NULL); 1000 values_.Add(NULL);
1079 // Set the operand through the base method in HValue to make sure that the 1001 // Set the operand through the base method in HValue to make sure that the
1080 // use lists are correctly updated. 1002 // use lists are correctly updated.
1081 SetOperandAt(values_.length() - 1, value); 1003 SetOperandAt(values_.length() - 1, value);
1082 } 1004 }
1083 int ast_id_; 1005 int ast_id_;
1084 int pop_count_; 1006 int pop_count_;
1085 int environment_length_; 1007 int environment_length_;
1086 ZoneList<HValue*> values_; 1008 ZoneList<HValue*> values_;
1087 ZoneList<int> assigned_indexes_; 1009 ZoneList<int> assigned_indexes_;
1088 }; 1010 };
1089 1011
1090 1012
1091 class HStackCheck: public HInstruction { 1013 class HStackCheck: public HInstruction {
1092 public: 1014 public:
1093 HStackCheck() { } 1015 HStackCheck() { }
1094 1016
1095 DECLARE_CONCRETE_INSTRUCTION(Throw, "stack_check") 1017 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack_check")
1096 }; 1018 };
1097 1019
1098 1020
1099 class HEnterInlined: public HInstruction { 1021 class HEnterInlined: public HInstruction {
1100 public: 1022 public:
1101 HEnterInlined(Handle<JSFunction> closure, FunctionLiteral* function) 1023 HEnterInlined(Handle<JSFunction> closure, FunctionLiteral* function)
1102 : closure_(closure), function_(function) { 1024 : closure_(closure), function_(function) {
1103 } 1025 }
1104 1026
1105 virtual void PrintDataTo(StringStream* stream) const; 1027 virtual void PrintDataTo(StringStream* stream) const;
(...skipping 12 matching lines...) Expand all
1118 class HLeaveInlined: public HInstruction { 1040 class HLeaveInlined: public HInstruction {
1119 public: 1041 public:
1120 HLeaveInlined() {} 1042 HLeaveInlined() {}
1121 1043
1122 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined, "leave_inlined") 1044 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined, "leave_inlined")
1123 }; 1045 };
1124 1046
1125 1047
1126 class HPushArgument: public HUnaryOperation { 1048 class HPushArgument: public HUnaryOperation {
1127 public: 1049 public:
1128 explicit HPushArgument(HValue* value) 1050 explicit HPushArgument(HValue* value) : HUnaryOperation(value) { }
1129 : HUnaryOperation(value), argument_index_(-1) {
1130 set_representation(Representation::Tagged());
1131 }
1132 1051
1133 virtual Representation RequiredInputRepresentation(int index) const { 1052 virtual Representation RequiredInputRepresentation(int index) const {
1134 return Representation::Tagged(); 1053 return Representation::Tagged();
1135 } 1054 }
1136 1055
1137 virtual void PrintDataTo(StringStream* stream) const;
1138 HValue* argument() const { return OperandAt(0); } 1056 HValue* argument() const { return OperandAt(0); }
1139 int argument_index() const { return argument_index_; }
1140 void set_argument_index(int index) {
1141 ASSERT(argument_index_ == -1 || index == argument_index_);
1142 argument_index_ = index;
1143 }
1144 1057
1145 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument") 1058 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push_argument")
1146
1147 private:
1148 int argument_index_;
1149 }; 1059 };
1150 1060
1151 1061
1152 class HGlobalObject: public HInstruction { 1062 class HContext: public HInstruction {
1153 public: 1063 public:
1154 HGlobalObject() { 1064 HContext() {
1155 set_representation(Representation::Tagged()); 1065 set_representation(Representation::Tagged());
1156 SetFlag(kUseGVN); 1066 SetFlag(kUseGVN);
1157 SetFlag(kDependsOnCalls); 1067 }
1068
1069 DECLARE_CONCRETE_INSTRUCTION(Context, "context");
1070
1071 protected:
1072 virtual bool DataEquals(HValue* other) const { return true; }
1073 };
1074
1075
1076 class HOuterContext: public HUnaryOperation {
1077 public:
1078 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) {
1079 set_representation(Representation::Tagged());
1080 SetFlag(kUseGVN);
1081 }
1082
1083 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer_context");
1084
1085 protected:
1086 virtual bool DataEquals(HValue* other) const { return true; }
1087 };
1088
1089
1090 class HGlobalObject: public HUnaryOperation {
1091 public:
1092 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
1093 set_representation(Representation::Tagged());
1094 SetFlag(kUseGVN);
1158 } 1095 }
1159 1096
1160 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object") 1097 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global_object")
1098
1099 protected:
1100 virtual bool DataEquals(HValue* other) const { return true; }
1161 }; 1101 };
1162 1102
1163 1103
1164 class HGlobalReceiver: public HInstruction { 1104 class HGlobalReceiver: public HUnaryOperation {
1165 public: 1105 public:
1166 HGlobalReceiver() { 1106 explicit HGlobalReceiver(HValue* global_object)
1107 : HUnaryOperation(global_object) {
1167 set_representation(Representation::Tagged()); 1108 set_representation(Representation::Tagged());
1168 SetFlag(kUseGVN); 1109 SetFlag(kUseGVN);
1169 SetFlag(kDependsOnCalls);
1170 } 1110 }
1171 1111
1172 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver") 1112 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global_receiver")
1113
1114 protected:
1115 virtual bool DataEquals(HValue* other) const { return true; }
1173 }; 1116 };
1174 1117
1175 1118
1176 class HCall: public HInstruction { 1119 class HCall: public HInstruction {
1177 public: 1120 public:
1178 // Construct a call with uninitialized arguments. The argument count 1121 // The argument count includes the receiver.
1179 // includes the receiver. 1122 explicit HCall(int argument_count) : argument_count_(argument_count) {
1180 explicit HCall(int count); 1123 set_representation(Representation::Tagged());
1124 SetAllSideEffects();
1125 }
1181 1126
1182 virtual HType CalculateInferredType() const { return HType::Tagged(); } 1127 virtual HType CalculateInferredType() const { return HType::Tagged(); }
1183 1128
1184 // TODO(3190496): This needs a cleanup. We don't want the arguments 1129 virtual int argument_count() const { return argument_count_; }
1185 // be operands of the call instruction. This results in bad code quality.
1186 virtual int argument_count() const { return arguments_.length(); }
1187 virtual int OperandCount() const { return argument_count(); }
1188 virtual HValue* OperandAt(int index) const { return arguments_[index]; }
1189 virtual HPushArgument* PushArgumentAt(int index) const {
1190 return HPushArgument::cast(OperandAt(index));
1191 }
1192 virtual HValue* ArgumentAt(int index) const {
1193 return PushArgumentAt(index)->argument();
1194 }
1195 virtual void SetArgumentAt(int index, HPushArgument* push_argument);
1196 1130
1197 virtual void PrintDataTo(StringStream* stream) const; 1131 virtual void PrintDataTo(StringStream* stream) const;
1198 1132
1199 DECLARE_INSTRUCTION(Call) 1133 DECLARE_INSTRUCTION(Call)
1200 1134
1201 protected: 1135 private:
1202 virtual void InternalSetOperandAt(int index, HValue* value) {
1203 arguments_[index] = value;
1204 }
1205
1206 int argument_count_; 1136 int argument_count_;
1207 Vector<HValue*> arguments_;
1208 }; 1137 };
1209 1138
1210 1139
1140 class HUnaryCall: public HCall {
1141 public:
1142 HUnaryCall(HValue* value, int argument_count)
1143 : HCall(argument_count), value_(NULL) {
1144 SetOperandAt(0, value);
1145 }
1146
1147 virtual void PrintDataTo(StringStream* stream) const;
1148
1149 HValue* value() const { return value_; }
1150
1151 virtual int OperandCount() const { return 1; }
1152 virtual HValue* OperandAt(int index) const {
1153 ASSERT(index == 0);
1154 return value_;
1155 }
1156
1157 DECLARE_INSTRUCTION(UnaryCall)
1158
1159 protected:
1160 virtual void InternalSetOperandAt(int index, HValue* value) {
1161 ASSERT(index == 0);
1162 value_ = value;
1163 }
1164
1165 private:
1166 HValue* value_;
1167 };
1168
1169
1170 class HBinaryCall: public HCall {
1171 public:
1172 HBinaryCall(HValue* first, HValue* second, int argument_count)
1173 : HCall(argument_count) {
1174 SetOperandAt(0, first);
1175 SetOperandAt(1, second);
1176 }
1177
1178 virtual void PrintDataTo(StringStream* stream) const;
1179
1180 HValue* first() const { return operands_[0]; }
1181 HValue* second() const { return operands_[1]; }
1182
1183 virtual int OperandCount() const { return 2; }
1184 virtual HValue* OperandAt(int index) const { return operands_[index]; }
1185
1186 DECLARE_INSTRUCTION(BinaryCall)
1187
1188 protected:
1189 virtual void InternalSetOperandAt(int index, HValue* value) {
1190 operands_[index] = value;
1191 }
1192
1193 private:
1194 HOperandVector<2> operands_;
1195 };
1196
1197
1211 class HCallConstantFunction: public HCall { 1198 class HCallConstantFunction: public HCall {
1212 public: 1199 public:
1213 HCallConstantFunction(Handle<JSFunction> function, int argument_count) 1200 HCallConstantFunction(Handle<JSFunction> function, int argument_count)
1214 : HCall(argument_count), function_(function) { } 1201 : HCall(argument_count), function_(function) { }
1215 1202
1216 Handle<JSFunction> function() const { return function_; } 1203 Handle<JSFunction> function() const { return function_; }
1204
1217 bool IsApplyFunction() const { 1205 bool IsApplyFunction() const {
1218 return function_->code() == Builtins::builtin(Builtins::FunctionApply); 1206 return function_->code() == Builtins::builtin(Builtins::FunctionApply);
1219 } 1207 }
1220 1208
1221 virtual void PrintDataTo(StringStream* stream) const; 1209 virtual void PrintDataTo(StringStream* stream) const;
1222 1210
1223 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call_constant_function") 1211 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call_constant_function")
1224 1212
1225 private: 1213 private:
1226 Handle<JSFunction> function_; 1214 Handle<JSFunction> function_;
1227 }; 1215 };
1228 1216
1229 1217
1230 class HCallKeyed: public HCall { 1218 class HCallKeyed: public HBinaryCall {
1231 public: 1219 public:
1232 HCallKeyed(HValue* key, int argument_count) 1220 HCallKeyed(HValue* context, HValue* key, int argument_count)
1233 : HCall(argument_count + 1) { 1221 : HBinaryCall(context, key, argument_count) {
1234 SetOperandAt(0, key);
1235 } 1222 }
1236 1223
1237 virtual Representation RequiredInputRepresentation(int index) const { 1224 virtual Representation RequiredInputRepresentation(int index) const {
1238 return Representation::Tagged(); 1225 return Representation::Tagged();
1239 } 1226 }
1240 1227
1241 // TODO(3190496): This is a hack to get an additional operand that 1228 HValue* context() const { return first(); }
1242 // is not an argument to work with the current setup. This _needs_ a cleanup. 1229 HValue* key() const { return second(); }
1243 // (see HCall)
1244 virtual void PrintDataTo(StringStream* stream) const;
1245 HValue* key() const { return OperandAt(0); }
1246 virtual int argument_count() const { return arguments_.length() - 1; }
1247 virtual int OperandCount() const { return arguments_.length(); }
1248 virtual HValue* OperandAt(int index) const { return arguments_[index]; }
1249 virtual HPushArgument* PushArgumentAt(int index) const {
1250 return HPushArgument::cast(OperandAt(index + 1));
1251 }
1252 virtual void SetArgumentAt(int index, HPushArgument* push_argument) {
1253 HCall::SetArgumentAt(index + 1, push_argument);
1254 }
1255 1230
1256 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call_keyed") 1231 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call_keyed")
1257 }; 1232 };
1258 1233
1259 1234
1260 class HCallNamed: public HCall { 1235 class HCallNamed: public HUnaryCall {
1261 public: 1236 public:
1262 HCallNamed(Handle<String> name, int argument_count) 1237 HCallNamed(HValue* context, Handle<String> name, int argument_count)
1263 : HCall(argument_count), name_(name) { } 1238 : HUnaryCall(context, argument_count), name_(name) {
1239 }
1240
1264 virtual void PrintDataTo(StringStream* stream) const; 1241 virtual void PrintDataTo(StringStream* stream) const;
1265 1242
1243 HValue* context() const { return value(); }
1266 Handle<String> name() const { return name_; } 1244 Handle<String> name() const { return name_; }
1267 1245
1268 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call_named") 1246 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call_named")
1269 1247
1270 private: 1248 private:
1271 Handle<String> name_; 1249 Handle<String> name_;
1272 }; 1250 };
1273 1251
1274 1252
1275 class HCallFunction: public HCall { 1253 class HCallFunction: public HUnaryCall {
1276 public: 1254 public:
1277 explicit HCallFunction(int argument_count) : HCall(argument_count) { } 1255 HCallFunction(HValue* context, int argument_count)
1256 : HUnaryCall(context, argument_count) {
1257 }
1258
1259 HValue* context() const { return value(); }
1278 1260
1279 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call_function") 1261 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call_function")
1280 }; 1262 };
1281 1263
1282 1264
1283 class HCallGlobal: public HCall { 1265 class HCallGlobal: public HUnaryCall {
1284 public: 1266 public:
1285 HCallGlobal(Handle<String> name, int argument_count) 1267 HCallGlobal(HValue* context, Handle<String> name, int argument_count)
1286 : HCall(argument_count), name_(name) { } 1268 : HUnaryCall(context, argument_count), name_(name) {
1269 }
1287 1270
1288 virtual void PrintDataTo(StringStream* stream) const; 1271 virtual void PrintDataTo(StringStream* stream) const;
1289 1272
1273 HValue* context() const { return value(); }
1290 Handle<String> name() const { return name_; } 1274 Handle<String> name() const { return name_; }
1291 1275
1292 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call_global") 1276 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call_global")
1293 1277
1294 private: 1278 private:
1295 Handle<String> name_; 1279 Handle<String> name_;
1296 }; 1280 };
1297 1281
1298 1282
1299 class HCallKnownGlobal: public HCall { 1283 class HCallKnownGlobal: public HCall {
1300 public: 1284 public:
1301 HCallKnownGlobal(Handle<JSFunction> target, 1285 HCallKnownGlobal(Handle<JSFunction> target, int argument_count)
1302 int argument_count)
1303 : HCall(argument_count), target_(target) { } 1286 : HCall(argument_count), target_(target) { }
1304 1287
1288 virtual void PrintDataTo(StringStream* stream) const;
1289
1305 Handle<JSFunction> target() const { return target_; } 1290 Handle<JSFunction> target() const { return target_; }
1306 1291
1307 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call_known_global") 1292 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call_known_global")
1308 1293
1309 private: 1294 private:
1310 Handle<JSFunction> target_; 1295 Handle<JSFunction> target_;
1311 }; 1296 };
1312 1297
1313 1298
1314 class HCallNew: public HCall { 1299 class HCallNew: public HBinaryCall {
1315 public: 1300 public:
1316 explicit HCallNew(int argument_count) : HCall(argument_count) { } 1301 HCallNew(HValue* context, HValue* constructor, int argument_count)
1302 : HBinaryCall(context, constructor, argument_count) {
1303 }
1317 1304
1318 virtual Representation RequiredInputRepresentation(int index) const { 1305 virtual Representation RequiredInputRepresentation(int index) const {
1319 return Representation::Tagged(); 1306 return Representation::Tagged();
1320 } 1307 }
1321 1308
1322 HValue* constructor() const { return ArgumentAt(0); } 1309 HValue* context() const { return first(); }
1310 HValue* constructor() const { return second(); }
1323 1311
1324 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call_new") 1312 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call_new")
1325 }; 1313 };
1326 1314
1327 1315
1328 class HCallRuntime: public HCall { 1316 class HCallRuntime: public HCall {
1329 public: 1317 public:
1330 HCallRuntime(Handle<String> name, 1318 HCallRuntime(Handle<String> name,
1331 Runtime::Function* c_function, 1319 Runtime::Function* c_function,
1332 int argument_count) 1320 int argument_count)
(...skipping 20 matching lines...) Expand all
1353 set_representation(Representation::Tagged()); 1341 set_representation(Representation::Tagged());
1354 SetFlag(kDependsOnArrayLengths); 1342 SetFlag(kDependsOnArrayLengths);
1355 SetFlag(kUseGVN); 1343 SetFlag(kUseGVN);
1356 } 1344 }
1357 1345
1358 virtual Representation RequiredInputRepresentation(int index) const { 1346 virtual Representation RequiredInputRepresentation(int index) const {
1359 return Representation::Tagged(); 1347 return Representation::Tagged();
1360 } 1348 }
1361 1349
1362 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js_array_length") 1350 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js_array_length")
1351
1352 protected:
1353 virtual bool DataEquals(HValue* other) const { return true; }
1363 }; 1354 };
1364 1355
1365 1356
1366 class HFixedArrayLength: public HUnaryOperation { 1357 class HFixedArrayLength: public HUnaryOperation {
1367 public: 1358 public:
1368 explicit HFixedArrayLength(HValue* value) : HUnaryOperation(value) { 1359 explicit HFixedArrayLength(HValue* value) : HUnaryOperation(value) {
1369 set_representation(Representation::Tagged()); 1360 set_representation(Representation::Tagged());
1370 SetFlag(kDependsOnArrayLengths); 1361 SetFlag(kDependsOnArrayLengths);
1371 SetFlag(kUseGVN); 1362 SetFlag(kUseGVN);
1372 } 1363 }
1373 1364
1374 virtual Representation RequiredInputRepresentation(int index) const { 1365 virtual Representation RequiredInputRepresentation(int index) const {
1375 return Representation::Tagged(); 1366 return Representation::Tagged();
1376 } 1367 }
1377 1368
1378 DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength, "fixed_array_length") 1369 DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength, "fixed_array_length")
1370
1371 protected:
1372 virtual bool DataEquals(HValue* other) const { return true; }
1373 };
1374
1375
1376 class HPixelArrayLength: public HUnaryOperation {
1377 public:
1378 explicit HPixelArrayLength(HValue* value) : HUnaryOperation(value) {
1379 set_representation(Representation::Integer32());
1380 // The result of this instruction is idempotent as long as its inputs don't
1381 // change. The length of a pixel array cannot change once set, so it's not
1382 // necessary to introduce a kDependsOnArrayLengths or any other dependency.
1383 SetFlag(kUseGVN);
1384 }
1385
1386 virtual Representation RequiredInputRepresentation(int index) const {
1387 return Representation::Tagged();
1388 }
1389
1390 DECLARE_CONCRETE_INSTRUCTION(PixelArrayLength, "pixel_array_length")
1391
1392 protected:
1393 virtual bool DataEquals(HValue* other) const { return true; }
1379 }; 1394 };
1380 1395
1381 1396
1382 class HBitNot: public HUnaryOperation { 1397 class HBitNot: public HUnaryOperation {
1383 public: 1398 public:
1384 explicit HBitNot(HValue* value) : HUnaryOperation(value) { 1399 explicit HBitNot(HValue* value) : HUnaryOperation(value) {
1385 set_representation(Representation::Integer32()); 1400 set_representation(Representation::Integer32());
1386 SetFlag(kUseGVN); 1401 SetFlag(kUseGVN);
1387 SetFlag(kTruncatingToInt32); 1402 SetFlag(kTruncatingToInt32);
1388 } 1403 }
1389 1404
1390 virtual Representation RequiredInputRepresentation(int index) const { 1405 virtual Representation RequiredInputRepresentation(int index) const {
1391 return Representation::Integer32(); 1406 return Representation::Integer32();
1392 } 1407 }
1393 virtual HType CalculateInferredType() const; 1408 virtual HType CalculateInferredType() const;
1394 1409
1395 DECLARE_CONCRETE_INSTRUCTION(BitNot, "bit_not") 1410 DECLARE_CONCRETE_INSTRUCTION(BitNot, "bit_not")
1411
1412 protected:
1413 virtual bool DataEquals(HValue* other) const { return true; }
1396 }; 1414 };
1397 1415
1398 1416
1399 class HUnaryMathOperation: public HUnaryOperation { 1417 class HUnaryMathOperation: public HUnaryOperation {
1400 public: 1418 public:
1401 HUnaryMathOperation(HValue* value, BuiltinFunctionId op) 1419 HUnaryMathOperation(HValue* value, BuiltinFunctionId op)
1402 : HUnaryOperation(value), op_(op) { 1420 : HUnaryOperation(value), op_(op) {
1403 switch (op) { 1421 switch (op) {
1404 case kMathFloor: 1422 case kMathFloor:
1405 case kMathRound: 1423 case kMathRound:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 set_representation(Representation::Tagged()); 1499 set_representation(Representation::Tagged());
1482 SetFlag(kUseGVN); 1500 SetFlag(kUseGVN);
1483 SetFlag(kDependsOnMaps); 1501 SetFlag(kDependsOnMaps);
1484 } 1502 }
1485 1503
1486 virtual Representation RequiredInputRepresentation(int index) const { 1504 virtual Representation RequiredInputRepresentation(int index) const {
1487 return Representation::Tagged(); 1505 return Representation::Tagged();
1488 } 1506 }
1489 1507
1490 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements") 1508 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1509
1510 protected:
1511 virtual bool DataEquals(HValue* other) const { return true; }
1512 };
1513
1514
1515 class HLoadPixelArrayExternalPointer: public HUnaryOperation {
1516 public:
1517 explicit HLoadPixelArrayExternalPointer(HValue* value)
1518 : HUnaryOperation(value) {
1519 set_representation(Representation::External());
1520 // The result of this instruction is idempotent as long as its inputs don't
1521 // change. The external array of a pixel array elements object cannot
1522 // change once set, so it's no necessary to introduce any additional
1523 // dependencies on top of the inputs.
1524 SetFlag(kUseGVN);
1525 }
1526
1527 virtual Representation RequiredInputRepresentation(int index) const {
1528 return Representation::Tagged();
1529 }
1530
1531 DECLARE_CONCRETE_INSTRUCTION(LoadPixelArrayExternalPointer,
1532 "load-pixel-array-external-pointer")
1533
1534 protected:
1535 virtual bool DataEquals(HValue* other) const { return true; }
1491 }; 1536 };
1492 1537
1493 1538
1494 class HCheckMap: public HUnaryOperation { 1539 class HCheckMap: public HUnaryOperation {
1495 public: 1540 public:
1496 HCheckMap(HValue* value, Handle<Map> map) 1541 HCheckMap(HValue* value, Handle<Map> map)
1497 : HUnaryOperation(value), map_(map) { 1542 : HUnaryOperation(value), map_(map) {
1498 set_representation(Representation::Tagged()); 1543 set_representation(Representation::Tagged());
1499 SetFlag(kUseGVN); 1544 SetFlag(kUseGVN);
1500 SetFlag(kDependsOnMaps); 1545 SetFlag(kDependsOnMaps);
1501 } 1546 }
1502 1547
1548 virtual bool IsCheckInstruction() const { return true; }
1549
1503 virtual Representation RequiredInputRepresentation(int index) const { 1550 virtual Representation RequiredInputRepresentation(int index) const {
1504 return Representation::Tagged(); 1551 return Representation::Tagged();
1505 } 1552 }
1506 virtual void PrintDataTo(StringStream* stream) const; 1553 virtual void PrintDataTo(StringStream* stream) const;
1507 virtual HType CalculateInferredType() const; 1554 virtual HType CalculateInferredType() const;
1508 1555
1509 #ifdef DEBUG 1556 #ifdef DEBUG
1510 virtual void Verify() const; 1557 virtual void Verify();
1511 #endif 1558 #endif
1512 1559
1513 Handle<Map> map() const { return map_; } 1560 Handle<Map> map() const { return map_; }
1514 1561
1515 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check_map") 1562 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check_map")
1516 1563
1517 protected: 1564 protected:
1518 virtual bool DataEquals(HValue* other) const { 1565 virtual bool DataEquals(HValue* other) const {
1519 HCheckMap* b = HCheckMap::cast(other); 1566 HCheckMap* b = HCheckMap::cast(other);
1520 return map_.is_identical_to(b->map()); 1567 return map_.is_identical_to(b->map());
1521 } 1568 }
1522 1569
1523 private: 1570 private:
1524 Handle<Map> map_; 1571 Handle<Map> map_;
1525 }; 1572 };
1526 1573
1527 1574
1528 class HCheckFunction: public HUnaryOperation { 1575 class HCheckFunction: public HUnaryOperation {
1529 public: 1576 public:
1530 HCheckFunction(HValue* value, Handle<JSFunction> function) 1577 HCheckFunction(HValue* value, Handle<JSFunction> function)
1531 : HUnaryOperation(value), target_(function) { 1578 : HUnaryOperation(value), target_(function) {
1532 set_representation(Representation::Tagged()); 1579 set_representation(Representation::Tagged());
1533 SetFlag(kUseGVN); 1580 SetFlag(kUseGVN);
1534 } 1581 }
1535 1582
1583 virtual bool IsCheckInstruction() const { return true; }
1584
1536 virtual Representation RequiredInputRepresentation(int index) const { 1585 virtual Representation RequiredInputRepresentation(int index) const {
1537 return Representation::Tagged(); 1586 return Representation::Tagged();
1538 } 1587 }
1539 virtual void PrintDataTo(StringStream* stream) const; 1588 virtual void PrintDataTo(StringStream* stream) const;
1540 virtual HType CalculateInferredType() const; 1589 virtual HType CalculateInferredType() const;
1541 1590
1542 #ifdef DEBUG 1591 #ifdef DEBUG
1543 virtual void Verify() const; 1592 virtual void Verify();
1544 #endif 1593 #endif
1545 1594
1546 Handle<JSFunction> target() const { return target_; } 1595 Handle<JSFunction> target() const { return target_; }
1547 1596
1548 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check_function") 1597 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check_function")
1549 1598
1550 protected: 1599 protected:
1551 virtual bool DataEquals(HValue* other) const { 1600 virtual bool DataEquals(HValue* other) const {
1552 HCheckFunction* b = HCheckFunction::cast(other); 1601 HCheckFunction* b = HCheckFunction::cast(other);
1553 return target_.is_identical_to(b->target()); 1602 return target_.is_identical_to(b->target());
1554 } 1603 }
1555 1604
1556 private: 1605 private:
1557 Handle<JSFunction> target_; 1606 Handle<JSFunction> target_;
1558 }; 1607 };
1559 1608
1560 1609
1561 class HCheckInstanceType: public HUnaryOperation { 1610 class HCheckInstanceType: public HUnaryOperation {
1562 public: 1611 public:
1563 // Check that the instance type is in the range [first, last] where 1612 // Check that the instance type is in the range [first, last] where
1564 // both first and last are included. 1613 // both first and last are included.
1565 HCheckInstanceType(HValue* value, InstanceType first, InstanceType last) 1614 HCheckInstanceType(HValue* value, InstanceType first, InstanceType last)
1566 : HUnaryOperation(value), first_(first), last_(last) { 1615 : HUnaryOperation(value), first_(first), last_(last) {
1567 ASSERT(first <= last); 1616 ASSERT(first <= last);
1568 set_representation(Representation::Tagged()); 1617 set_representation(Representation::Tagged());
1569 SetFlag(kUseGVN); 1618 SetFlag(kUseGVN);
1619 if ((FIRST_STRING_TYPE < first && last <= LAST_STRING_TYPE) ||
1620 (FIRST_STRING_TYPE <= first && last < LAST_STRING_TYPE)) {
1621 // A particular string instance type can change because of GC or
1622 // externalization, but the value still remains a string.
1623 SetFlag(kDependsOnMaps);
1624 }
1570 } 1625 }
1571 1626
1627 virtual bool IsCheckInstruction() const { return true; }
1628
1572 virtual Representation RequiredInputRepresentation(int index) const { 1629 virtual Representation RequiredInputRepresentation(int index) const {
1573 return Representation::Tagged(); 1630 return Representation::Tagged();
1574 } 1631 }
1575 1632
1576 #ifdef DEBUG 1633 #ifdef DEBUG
1577 virtual void Verify() const; 1634 virtual void Verify();
1578 #endif 1635 #endif
1579 1636
1580 static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value); 1637 static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value);
1581 1638
1582 InstanceType first() const { return first_; } 1639 InstanceType first() const { return first_; }
1583 InstanceType last() const { return last_; } 1640 InstanceType last() const { return last_; }
1584 1641
1585 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check_instance_type") 1642 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check_instance_type")
1586 1643
1587 protected: 1644 protected:
(...skipping 11 matching lines...) Expand all
1599 }; 1656 };
1600 1657
1601 1658
1602 class HCheckNonSmi: public HUnaryOperation { 1659 class HCheckNonSmi: public HUnaryOperation {
1603 public: 1660 public:
1604 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { 1661 explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) {
1605 set_representation(Representation::Tagged()); 1662 set_representation(Representation::Tagged());
1606 SetFlag(kUseGVN); 1663 SetFlag(kUseGVN);
1607 } 1664 }
1608 1665
1666 virtual bool IsCheckInstruction() const { return true; }
1667
1609 virtual Representation RequiredInputRepresentation(int index) const { 1668 virtual Representation RequiredInputRepresentation(int index) const {
1610 return Representation::Tagged(); 1669 return Representation::Tagged();
1611 } 1670 }
1612 1671
1613 virtual HType CalculateInferredType() const; 1672 virtual HType CalculateInferredType() const;
1614 1673
1615 #ifdef DEBUG 1674 #ifdef DEBUG
1616 virtual void Verify() const; 1675 virtual void Verify();
1617 #endif 1676 #endif
1618 1677
1619 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check_non_smi") 1678 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check_non_smi")
1679
1680 protected:
1681 virtual bool DataEquals(HValue* other) const { return true; }
1620 }; 1682 };
1621 1683
1622 1684
1623 class HCheckPrototypeMaps: public HUnaryOperation { 1685 class HCheckPrototypeMaps: public HInstruction {
1624 public: 1686 public:
1625 HCheckPrototypeMaps(HValue* value, 1687 HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder)
1626 Handle<JSObject> holder, 1688 : prototype_(prototype), holder_(holder) {
1627 Handle<Map> receiver_map)
1628 : HUnaryOperation(value),
1629 holder_(holder),
1630 receiver_map_(receiver_map) {
1631 set_representation(Representation::Tagged());
1632 SetFlag(kUseGVN); 1689 SetFlag(kUseGVN);
1633 SetFlag(kDependsOnMaps); 1690 SetFlag(kDependsOnMaps);
1634 } 1691 }
1635 1692
1636 virtual Representation RequiredInputRepresentation(int index) const { 1693 virtual bool IsCheckInstruction() const { return true; }
1637 return Representation::Tagged();
1638 }
1639 1694
1640 #ifdef DEBUG 1695 #ifdef DEBUG
1641 virtual void Verify() const; 1696 virtual void Verify();
1642 #endif 1697 #endif
1643 1698
1699 Handle<JSObject> prototype() const { return prototype_; }
1644 Handle<JSObject> holder() const { return holder_; } 1700 Handle<JSObject> holder() const { return holder_; }
1645 Handle<Map> receiver_map() const { return receiver_map_; }
1646 1701
1647 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check_prototype_maps") 1702 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check_prototype_maps")
1648 1703
1704 virtual intptr_t Hashcode() const {
1705 ASSERT(!Heap::IsAllocationAllowed());
1706 intptr_t hash = reinterpret_cast<intptr_t>(*prototype());
1707 hash = 17 * hash + reinterpret_cast<intptr_t>(*holder());
1708 return hash;
1709 }
1710
1649 protected: 1711 protected:
1650 virtual bool DataEquals(HValue* other) const { 1712 virtual bool DataEquals(HValue* other) const {
1651 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); 1713 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other);
1652 return holder_.is_identical_to(b->holder()) && 1714 return prototype_.is_identical_to(b->prototype()) &&
1653 receiver_map_.is_identical_to(b->receiver_map()); 1715 holder_.is_identical_to(b->holder());
1654 } 1716 }
1655 1717
1656 private: 1718 private:
1719 Handle<JSObject> prototype_;
1657 Handle<JSObject> holder_; 1720 Handle<JSObject> holder_;
1658 Handle<Map> receiver_map_;
1659 }; 1721 };
1660 1722
1661 1723
1662 class HCheckSmi: public HUnaryOperation { 1724 class HCheckSmi: public HUnaryOperation {
1663 public: 1725 public:
1664 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { 1726 explicit HCheckSmi(HValue* value) : HUnaryOperation(value) {
1665 set_representation(Representation::Tagged()); 1727 set_representation(Representation::Tagged());
1666 SetFlag(kUseGVN); 1728 SetFlag(kUseGVN);
1667 } 1729 }
1668 1730
1731 virtual bool IsCheckInstruction() const { return true; }
1732
1669 virtual Representation RequiredInputRepresentation(int index) const { 1733 virtual Representation RequiredInputRepresentation(int index) const {
1670 return Representation::Tagged(); 1734 return Representation::Tagged();
1671 } 1735 }
1672 virtual HType CalculateInferredType() const; 1736 virtual HType CalculateInferredType() const;
1673 1737
1674 #ifdef DEBUG 1738 #ifdef DEBUG
1675 virtual void Verify() const; 1739 virtual void Verify();
1676 #endif 1740 #endif
1677 1741
1678 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check_smi") 1742 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check_smi")
1743
1744 protected:
1745 virtual bool DataEquals(HValue* other) const { return true; }
1679 }; 1746 };
1680 1747
1681 1748
1682 class HPhi: public HValue { 1749 class HPhi: public HValue {
1683 public: 1750 public:
1684 explicit HPhi(int merged_index) 1751 explicit HPhi(int merged_index)
1685 : inputs_(2), 1752 : inputs_(2),
1686 merged_index_(merged_index), 1753 merged_index_(merged_index),
1687 phi_id_(-1) { 1754 phi_id_(-1) {
1688 for (int i = 0; i < Representation::kNumRepresentations; i++) { 1755 for (int i = 0; i < Representation::kNumRepresentations; i++) {
(...skipping 23 matching lines...) Expand all
1712 virtual Range* InferRange(); 1779 virtual Range* InferRange();
1713 virtual Representation RequiredInputRepresentation(int index) const { 1780 virtual Representation RequiredInputRepresentation(int index) const {
1714 return representation(); 1781 return representation();
1715 } 1782 }
1716 virtual HType CalculateInferredType() const; 1783 virtual HType CalculateInferredType() const;
1717 virtual int OperandCount() const { return inputs_.length(); } 1784 virtual int OperandCount() const { return inputs_.length(); }
1718 virtual HValue* OperandAt(int index) const { return inputs_[index]; } 1785 virtual HValue* OperandAt(int index) const { return inputs_[index]; }
1719 HValue* GetRedundantReplacement() const; 1786 HValue* GetRedundantReplacement() const;
1720 void AddInput(HValue* value); 1787 void AddInput(HValue* value);
1721 1788
1722 bool HasReceiverOperand(); 1789 bool IsReceiver() { return merged_index_ == 0; }
1723 1790
1724 int merged_index() const { return merged_index_; } 1791 int merged_index() const { return merged_index_; }
1725 1792
1726 virtual const char* Mnemonic() const { return "phi"; } 1793 virtual const char* Mnemonic() const { return "phi"; }
1727 1794
1728 virtual void PrintTo(StringStream* stream) const; 1795 virtual void PrintTo(StringStream* stream) const;
1729 1796
1730 #ifdef DEBUG 1797 #ifdef DEBUG
1731 virtual void Verify() const; 1798 virtual void Verify();
1732 #endif 1799 #endif
1733 1800
1734 DECLARE_INSTRUCTION(Phi) 1801 DECLARE_INSTRUCTION(Phi)
1735 1802
1736 void InitRealUses(int id); 1803 void InitRealUses(int id);
1737 void AddNonPhiUsesFrom(HPhi* other); 1804 void AddNonPhiUsesFrom(HPhi* other);
1738 void AddIndirectUsesTo(int* use_count); 1805 void AddIndirectUsesTo(int* use_count);
1739 1806
1740 int tagged_non_phi_uses() const { 1807 int tagged_non_phi_uses() const {
1741 return non_phi_uses_[Representation::kTagged]; 1808 return non_phi_uses_[Representation::kTagged];
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 return double_value_; 1876 return double_value_;
1810 } 1877 }
1811 bool HasStringValue() const { return handle_->IsString(); } 1878 bool HasStringValue() const { return handle_->IsString(); }
1812 1879
1813 virtual intptr_t Hashcode() const { 1880 virtual intptr_t Hashcode() const {
1814 ASSERT(!Heap::allow_allocation(false)); 1881 ASSERT(!Heap::allow_allocation(false));
1815 return reinterpret_cast<intptr_t>(*handle()); 1882 return reinterpret_cast<intptr_t>(*handle());
1816 } 1883 }
1817 1884
1818 #ifdef DEBUG 1885 #ifdef DEBUG
1819 virtual void Verify() const { } 1886 virtual void Verify() { }
1820 #endif 1887 #endif
1821 1888
1822 DECLARE_CONCRETE_INSTRUCTION(Constant, "constant") 1889 DECLARE_CONCRETE_INSTRUCTION(Constant, "constant")
1823 1890
1824 protected: 1891 protected:
1825 virtual Range* InferRange(); 1892 virtual Range* InferRange();
1826 1893
1827 virtual bool DataEquals(HValue* other) const { 1894 virtual bool DataEquals(HValue* other) const {
1828 HConstant* other_constant = HConstant::cast(other); 1895 HConstant* other_constant = HConstant::cast(other);
1829 return handle().is_identical_to(other_constant->handle()); 1896 return handle().is_identical_to(other_constant->handle());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 virtual int OperandCount() const { return operands_.length(); } 1938 virtual int OperandCount() const { return operands_.length(); }
1872 virtual HValue* OperandAt(int index) const { return operands_[index]; } 1939 virtual HValue* OperandAt(int index) const { return operands_[index]; }
1873 1940
1874 DECLARE_INSTRUCTION(BinaryOperation) 1941 DECLARE_INSTRUCTION(BinaryOperation)
1875 1942
1876 protected: 1943 protected:
1877 virtual void InternalSetOperandAt(int index, HValue* value) { 1944 virtual void InternalSetOperandAt(int index, HValue* value) {
1878 operands_[index] = value; 1945 operands_[index] = value;
1879 } 1946 }
1880 1947
1881 private:
1882 HOperandVector<2> operands_; 1948 HOperandVector<2> operands_;
1883 }; 1949 };
1884 1950
1885 1951
1886 class HApplyArguments: public HInstruction { 1952 class HApplyArguments: public HInstruction {
1887 public: 1953 public:
1888 HApplyArguments(HValue* function, 1954 HApplyArguments(HValue* function,
1889 HValue* receiver, 1955 HValue* receiver,
1890 HValue* length, 1956 HValue* length,
1891 HValue* elements) { 1957 HValue* elements) {
1892 set_representation(Representation::Tagged()); 1958 set_representation(Representation::Tagged());
1893 SetOperandAt(0, function); 1959 SetOperandAt(0, function);
1894 SetOperandAt(1, receiver); 1960 SetOperandAt(1, receiver);
1895 SetOperandAt(2, length); 1961 SetOperandAt(2, length);
1896 SetOperandAt(3, elements); 1962 SetOperandAt(3, elements);
1963 SetAllSideEffects();
1897 } 1964 }
1898 1965
1899 virtual Representation RequiredInputRepresentation(int index) const { 1966 virtual Representation RequiredInputRepresentation(int index) const {
1900 // The length is untagged, all other inputs are tagged. 1967 // The length is untagged, all other inputs are tagged.
1901 return (index == 2) 1968 return (index == 2)
1902 ? Representation::Integer32() 1969 ? Representation::Integer32()
1903 : Representation::Tagged(); 1970 : Representation::Tagged();
1904 } 1971 }
1905 1972
1906 HValue* function() const { return OperandAt(0); } 1973 HValue* function() const { return OperandAt(0); }
1907 HValue* receiver() const { return OperandAt(1); } 1974 HValue* receiver() const { return OperandAt(1); }
1908 HValue* length() const { return OperandAt(2); } 1975 HValue* length() const { return OperandAt(2); }
1909 HValue* elements() const { return OperandAt(3); } 1976 HValue* elements() const { return OperandAt(3); }
1910 1977
1911 virtual int OperandCount() const { return operands_.length(); } 1978 virtual int OperandCount() const { return operands_.length(); }
1912 virtual HValue* OperandAt(int index) const { return operands_[index]; } 1979 virtual HValue* OperandAt(int index) const { return operands_[index]; }
1913 1980
1914 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply_arguments") 1981 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply_arguments")
1915 1982
1916
1917
1918 protected: 1983 protected:
1919 virtual void InternalSetOperandAt(int index, HValue* value) { 1984 virtual void InternalSetOperandAt(int index, HValue* value) {
1920 operands_[index] = value; 1985 operands_[index] = value;
1921 } 1986 }
1922 1987
1923 private: 1988 private:
1924 HOperandVector<4> operands_; 1989 HOperandVector<4> operands_;
1925 }; 1990 };
1926 1991
1927 1992
1928 class HArgumentsElements: public HInstruction { 1993 class HArgumentsElements: public HInstruction {
1929 public: 1994 public:
1930 HArgumentsElements() { 1995 HArgumentsElements() {
1931 // The value produced by this instruction is a pointer into the stack 1996 // The value produced by this instruction is a pointer into the stack
1932 // that looks as if it was a smi because of alignment. 1997 // that looks as if it was a smi because of alignment.
1933 set_representation(Representation::Tagged()); 1998 set_representation(Representation::Tagged());
1934 SetFlag(kUseGVN); 1999 SetFlag(kUseGVN);
1935 } 2000 }
1936 2001
1937 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments_elements") 2002 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments_elements")
2003
2004 protected:
2005 virtual bool DataEquals(HValue* other) const { return true; }
1938 }; 2006 };
1939 2007
1940 2008
1941 class HArgumentsLength: public HUnaryOperation { 2009 class HArgumentsLength: public HUnaryOperation {
1942 public: 2010 public:
1943 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { 2011 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) {
1944 set_representation(Representation::Integer32()); 2012 set_representation(Representation::Integer32());
1945 SetFlag(kUseGVN); 2013 SetFlag(kUseGVN);
1946 } 2014 }
1947 2015
1948 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments_length") 2016 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments_length")
2017
2018 protected:
2019 virtual bool DataEquals(HValue* other) const { return true; }
1949 }; 2020 };
1950 2021
1951 2022
1952 class HAccessArgumentsAt: public HInstruction { 2023 class HAccessArgumentsAt: public HInstruction {
1953 public: 2024 public:
1954 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { 2025 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
1955 set_representation(Representation::Tagged()); 2026 set_representation(Representation::Tagged());
1956 SetFlag(kUseGVN); 2027 SetFlag(kUseGVN);
1957 SetOperandAt(0, arguments); 2028 SetOperandAt(0, arguments);
1958 SetOperandAt(1, length); 2029 SetOperandAt(1, length);
(...skipping 16 matching lines...) Expand all
1975 virtual int OperandCount() const { return operands_.length(); } 2046 virtual int OperandCount() const { return operands_.length(); }
1976 virtual HValue* OperandAt(int index) const { return operands_[index]; } 2047 virtual HValue* OperandAt(int index) const { return operands_[index]; }
1977 2048
1978 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access_arguments_at") 2049 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access_arguments_at")
1979 2050
1980 protected: 2051 protected:
1981 virtual void InternalSetOperandAt(int index, HValue* value) { 2052 virtual void InternalSetOperandAt(int index, HValue* value) {
1982 operands_[index] = value; 2053 operands_[index] = value;
1983 } 2054 }
1984 2055
2056 virtual bool DataEquals(HValue* other) const { return true; }
2057
1985 private: 2058 private:
1986 HOperandVector<3> operands_; 2059 HOperandVector<3> operands_;
1987 }; 2060 };
1988 2061
1989 2062
1990 class HBoundsCheck: public HBinaryOperation { 2063 class HBoundsCheck: public HBinaryOperation {
1991 public: 2064 public:
1992 HBoundsCheck(HValue* index, HValue* length) 2065 HBoundsCheck(HValue* index, HValue* length)
1993 : HBinaryOperation(index, length) { 2066 : HBinaryOperation(index, length) {
1994 SetFlag(kUseGVN); 2067 SetFlag(kUseGVN);
1995 } 2068 }
1996 2069
2070 virtual bool IsCheckInstruction() const { return true; }
2071
1997 virtual Representation RequiredInputRepresentation(int index) const { 2072 virtual Representation RequiredInputRepresentation(int index) const {
1998 return Representation::Integer32(); 2073 return Representation::Integer32();
1999 } 2074 }
2000 2075
2001 #ifdef DEBUG 2076 #ifdef DEBUG
2002 virtual void Verify() const; 2077 virtual void Verify();
2003 #endif 2078 #endif
2004 2079
2005 HValue* index() const { return left(); } 2080 HValue* index() const { return left(); }
2006 HValue* length() const { return right(); } 2081 HValue* length() const { return right(); }
2007 2082
2008 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds_check") 2083 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds_check")
2084
2085 protected:
2086 virtual bool DataEquals(HValue* other) const { return true; }
2009 }; 2087 };
2010 2088
2011 2089
2012 class HBitwiseBinaryOperation: public HBinaryOperation { 2090 class HBitwiseBinaryOperation: public HBinaryOperation {
2013 public: 2091 public:
2014 HBitwiseBinaryOperation(HValue* left, HValue* right) 2092 HBitwiseBinaryOperation(HValue* left, HValue* right)
2015 : HBinaryOperation(left, right) { 2093 : HBinaryOperation(left, right) {
2016 // Default to truncating, Integer32, UseGVN. 2094 set_representation(Representation::Tagged());
2017 set_representation(Representation::Integer32()); 2095 SetFlag(kFlexibleRepresentation);
2018 SetFlag(kTruncatingToInt32); 2096 SetAllSideEffects();
2019 SetFlag(kUseGVN);
2020 } 2097 }
2021 2098
2022 virtual Representation RequiredInputRepresentation(int index) const { 2099 virtual Representation RequiredInputRepresentation(int index) const {
2023 return Representation::Integer32(); 2100 return representation();
2024 } 2101 }
2025 2102
2103 virtual void RepresentationChanged(Representation to) {
2104 if (!to.IsTagged()) {
2105 ASSERT(to.IsInteger32());
2106 ClearAllSideEffects();
2107 SetFlag(kTruncatingToInt32);
2108 SetFlag(kUseGVN);
2109 }
2110 }
2111
2112 HType CalculateInferredType() const;
2113
2026 DECLARE_INSTRUCTION(BitwiseBinaryOperation) 2114 DECLARE_INSTRUCTION(BitwiseBinaryOperation)
2027 }; 2115 };
2028 2116
2029 2117
2030 class HArithmeticBinaryOperation: public HBinaryOperation { 2118 class HArithmeticBinaryOperation: public HBinaryOperation {
2031 public: 2119 public:
2032 HArithmeticBinaryOperation(HValue* left, HValue* right) 2120 HArithmeticBinaryOperation(HValue* left, HValue* right)
2033 : HBinaryOperation(left, right) { 2121 : HBinaryOperation(left, right) {
2034 set_representation(Representation::Tagged()); 2122 set_representation(Representation::Tagged());
2035 SetFlag(kFlexibleRepresentation); 2123 SetFlag(kFlexibleRepresentation);
2036 SetFlagMask(AllSideEffects()); 2124 SetAllSideEffects();
2037 } 2125 }
2038 2126
2039 virtual void RepresentationChanged(Representation to) { 2127 virtual void RepresentationChanged(Representation to) {
2040 if (!to.IsTagged()) { 2128 if (!to.IsTagged()) {
2041 ClearFlagMask(AllSideEffects()); 2129 ClearAllSideEffects();
2042 SetFlag(kUseGVN); 2130 SetFlag(kUseGVN);
2043 } 2131 }
2044 } 2132 }
2045 2133
2046 virtual HType CalculateInferredType() const; 2134 virtual HType CalculateInferredType() const;
2047 virtual Representation RequiredInputRepresentation(int index) const { 2135 virtual Representation RequiredInputRepresentation(int index) const {
2048 return representation(); 2136 return representation();
2049 } 2137 }
2050 virtual Representation InferredRepresentation() const { 2138 virtual Representation InferredRepresentation() const {
2051 if (left()->representation().Equals(right()->representation())) { 2139 if (left()->representation().Equals(right()->representation())) {
2052 return left()->representation(); 2140 return left()->representation();
2053 } 2141 }
2054 return HValue::InferredRepresentation(); 2142 return HValue::InferredRepresentation();
2055 } 2143 }
2056 2144
2057 DECLARE_INSTRUCTION(ArithmeticBinaryOperation) 2145 DECLARE_INSTRUCTION(ArithmeticBinaryOperation)
2058 }; 2146 };
2059 2147
2060 2148
2061 class HCompare: public HBinaryOperation { 2149 class HCompare: public HBinaryOperation {
2062 public: 2150 public:
2063 HCompare(HValue* left, HValue* right, Token::Value token) 2151 HCompare(HValue* left, HValue* right, Token::Value token)
2064 : HBinaryOperation(left, right), token_(token) { 2152 : HBinaryOperation(left, right), token_(token) {
2065 ASSERT(Token::IsCompareOp(token)); 2153 ASSERT(Token::IsCompareOp(token));
2066 set_representation(Representation::Tagged()); 2154 set_representation(Representation::Tagged());
2067 SetFlagMask(AllSideEffects()); 2155 SetAllSideEffects();
2068 } 2156 }
2069 2157
2070 void SetInputRepresentation(Representation r); 2158 void SetInputRepresentation(Representation r);
2071 virtual bool EmitAtUses() const { return uses()->length() <= 1; } 2159
2160 virtual bool EmitAtUses() const {
2161 return !HasSideEffects() && (uses()->length() <= 1);
2162 }
2163
2072 virtual Representation RequiredInputRepresentation(int index) const { 2164 virtual Representation RequiredInputRepresentation(int index) const {
2073 return input_representation_; 2165 return input_representation_;
2074 } 2166 }
2075 Representation GetInputRepresentation() const { 2167 Representation GetInputRepresentation() const {
2076 return input_representation_; 2168 return input_representation_;
2077 } 2169 }
2078 Token::Value token() const { return token_; } 2170 Token::Value token() const { return token_; }
2079 virtual void PrintDataTo(StringStream* stream) const; 2171 virtual void PrintDataTo(StringStream* stream) const;
2080 2172
2081 virtual HType CalculateInferredType() const; 2173 virtual HType CalculateInferredType() const;
(...skipping 17 matching lines...) Expand all
2099 2191
2100 2192
2101 class HCompareJSObjectEq: public HBinaryOperation { 2193 class HCompareJSObjectEq: public HBinaryOperation {
2102 public: 2194 public:
2103 HCompareJSObjectEq(HValue* left, HValue* right) 2195 HCompareJSObjectEq(HValue* left, HValue* right)
2104 : HBinaryOperation(left, right) { 2196 : HBinaryOperation(left, right) {
2105 set_representation(Representation::Tagged()); 2197 set_representation(Representation::Tagged());
2106 SetFlag(kUseGVN); 2198 SetFlag(kUseGVN);
2107 } 2199 }
2108 2200
2109 virtual bool EmitAtUses() const { return uses()->length() <= 1; } 2201 virtual bool EmitAtUses() const {
2202 return !HasSideEffects() && (uses()->length() <= 1);
2203 }
2204
2110 virtual Representation RequiredInputRepresentation(int index) const { 2205 virtual Representation RequiredInputRepresentation(int index) const {
2111 return Representation::Tagged(); 2206 return Representation::Tagged();
2112 } 2207 }
2113 virtual HType CalculateInferredType() const; 2208 virtual HType CalculateInferredType() const;
2114 2209
2115 DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq, "compare-js-object-eq") 2210 DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq, "compare-js-object-eq")
2211
2212 protected:
2213 virtual bool DataEquals(HValue* other) const { return true; }
2116 }; 2214 };
2117 2215
2118 2216
2119 class HUnaryPredicate: public HUnaryOperation { 2217 class HUnaryPredicate: public HUnaryOperation {
2120 public: 2218 public:
2121 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { 2219 explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) {
2122 set_representation(Representation::Tagged()); 2220 set_representation(Representation::Tagged());
2123 SetFlag(kUseGVN); 2221 SetFlag(kUseGVN);
2124 } 2222 }
2125 virtual bool EmitAtUses() const { return uses()->length() <= 1; } 2223
2224 virtual bool EmitAtUses() const {
2225 return !HasSideEffects() && (uses()->length() <= 1);
2226 }
2227
2126 virtual Representation RequiredInputRepresentation(int index) const { 2228 virtual Representation RequiredInputRepresentation(int index) const {
2127 return Representation::Tagged(); 2229 return Representation::Tagged();
2128 } 2230 }
2129 virtual HType CalculateInferredType() const; 2231 virtual HType CalculateInferredType() const;
2130 }; 2232 };
2131 2233
2132 2234
2133 class HIsNull: public HUnaryPredicate { 2235 class HIsNull: public HUnaryPredicate {
2134 public: 2236 public:
2135 HIsNull(HValue* value, bool is_strict) 2237 HIsNull(HValue* value, bool is_strict)
(...skipping 12 matching lines...) Expand all
2148 private: 2250 private:
2149 bool is_strict_; 2251 bool is_strict_;
2150 }; 2252 };
2151 2253
2152 2254
2153 class HIsObject: public HUnaryPredicate { 2255 class HIsObject: public HUnaryPredicate {
2154 public: 2256 public:
2155 explicit HIsObject(HValue* value) : HUnaryPredicate(value) { } 2257 explicit HIsObject(HValue* value) : HUnaryPredicate(value) { }
2156 2258
2157 DECLARE_CONCRETE_INSTRUCTION(IsObject, "is_object") 2259 DECLARE_CONCRETE_INSTRUCTION(IsObject, "is_object")
2260
2261 protected:
2262 virtual bool DataEquals(HValue* other) const { return true; }
2158 }; 2263 };
2159 2264
2160 2265
2161 class HIsSmi: public HUnaryPredicate { 2266 class HIsSmi: public HUnaryPredicate {
2162 public: 2267 public:
2163 explicit HIsSmi(HValue* value) : HUnaryPredicate(value) { } 2268 explicit HIsSmi(HValue* value) : HUnaryPredicate(value) { }
2164 2269
2165 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is_smi") 2270 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is_smi")
2271
2272 protected:
2273 virtual bool DataEquals(HValue* other) const { return true; }
2274 };
2275
2276
2277 class HIsConstructCall: public HInstruction {
2278 public:
2279 HIsConstructCall() {
2280 set_representation(Representation::Tagged());
2281 SetFlag(kUseGVN);
2282 }
2283
2284 virtual bool EmitAtUses() const {
2285 return !HasSideEffects() && (uses()->length() <= 1);
2286 }
2287
2288 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is_construct_call")
2289
2290 protected:
2291 virtual bool DataEquals(HValue* other) const { return true; }
2166 }; 2292 };
2167 2293
2168 2294
2169 class HHasInstanceType: public HUnaryPredicate { 2295 class HHasInstanceType: public HUnaryPredicate {
2170 public: 2296 public:
2171 HHasInstanceType(HValue* value, InstanceType type) 2297 HHasInstanceType(HValue* value, InstanceType type)
2172 : HUnaryPredicate(value), from_(type), to_(type) { } 2298 : HUnaryPredicate(value), from_(type), to_(type) { }
2173 HHasInstanceType(HValue* value, InstanceType from, InstanceType to) 2299 HHasInstanceType(HValue* value, InstanceType from, InstanceType to)
2174 : HUnaryPredicate(value), from_(from), to_(to) { 2300 : HUnaryPredicate(value), from_(from), to_(to) {
2175 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. 2301 ASSERT(to == LAST_TYPE); // Others not implemented yet in backend.
(...skipping 16 matching lines...) Expand all
2192 InstanceType from_; 2318 InstanceType from_;
2193 InstanceType to_; // Inclusive range, not all combinations work. 2319 InstanceType to_; // Inclusive range, not all combinations work.
2194 }; 2320 };
2195 2321
2196 2322
2197 class HHasCachedArrayIndex: public HUnaryPredicate { 2323 class HHasCachedArrayIndex: public HUnaryPredicate {
2198 public: 2324 public:
2199 explicit HHasCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { } 2325 explicit HHasCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { }
2200 2326
2201 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has_cached_array_index") 2327 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has_cached_array_index")
2328
2329 protected:
2330 virtual bool DataEquals(HValue* other) const { return true; }
2202 }; 2331 };
2203 2332
2204 2333
2205 class HClassOfTest: public HUnaryPredicate { 2334 class HClassOfTest: public HUnaryPredicate {
2206 public: 2335 public:
2207 HClassOfTest(HValue* value, Handle<String> class_name) 2336 HClassOfTest(HValue* value, Handle<String> class_name)
2208 : HUnaryPredicate(value), class_name_(class_name) { } 2337 : HUnaryPredicate(value), class_name_(class_name) { }
2209 2338
2210 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class_of_test") 2339 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class_of_test")
2211 2340
(...skipping 26 matching lines...) Expand all
2238 virtual bool DataEquals(HValue* other) const { 2367 virtual bool DataEquals(HValue* other) const {
2239 HTypeofIs* b = HTypeofIs::cast(other); 2368 HTypeofIs* b = HTypeofIs::cast(other);
2240 return type_literal_.is_identical_to(b->type_literal_); 2369 return type_literal_.is_identical_to(b->type_literal_);
2241 } 2370 }
2242 2371
2243 private: 2372 private:
2244 Handle<String> type_literal_; 2373 Handle<String> type_literal_;
2245 }; 2374 };
2246 2375
2247 2376
2248 class HInstanceOf: public HBinaryOperation { 2377 class HInstanceOf: public HInstruction {
2249 public: 2378 public:
2250 HInstanceOf(HValue* left, HValue* right) : HBinaryOperation(left, right) { 2379 HInstanceOf(HValue* context, HValue* left, HValue* right) {
2380 SetOperandAt(0, context);
2381 SetOperandAt(1, left);
2382 SetOperandAt(2, right);
2251 set_representation(Representation::Tagged()); 2383 set_representation(Representation::Tagged());
2252 SetFlagMask(AllSideEffects()); 2384 SetAllSideEffects();
2253 } 2385 }
2254 2386
2255 virtual bool EmitAtUses() const { return uses()->length() <= 1; } 2387 HValue* context() const { return operands_[0]; }
2388 HValue* left() const { return operands_[1]; }
2389 HValue* right() const { return operands_[2]; }
2390
2391 virtual bool EmitAtUses() const {
2392 return !HasSideEffects() && (uses()->length() <= 1);
2393 }
2256 2394
2257 virtual Representation RequiredInputRepresentation(int index) const { 2395 virtual Representation RequiredInputRepresentation(int index) const {
2258 return Representation::Tagged(); 2396 return Representation::Tagged();
2259 } 2397 }
2260 2398
2399 virtual void PrintDataTo(StringStream* stream) const;
2400
2401 virtual int OperandCount() const { return 3; }
2402 virtual HValue* OperandAt(int index) const { return operands_[index]; }
2403
2261 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance_of") 2404 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance_of")
2405
2406 protected:
2407 virtual void InternalSetOperandAt(int index, HValue* value) {
2408 operands_[index] = value;
2409 }
2410
2411 private:
2412 HOperandVector<3> operands_;
2413 };
2414
2415
2416 class HInstanceOfKnownGlobal: public HUnaryOperation {
2417 public:
2418 HInstanceOfKnownGlobal(HValue* left, Handle<JSFunction> right)
2419 : HUnaryOperation(left), function_(right) {
2420 set_representation(Representation::Tagged());
2421 SetAllSideEffects();
2422 }
2423
2424 Handle<JSFunction> function() { return function_; }
2425
2426 virtual Representation RequiredInputRepresentation(int index) const {
2427 return Representation::Tagged();
2428 }
2429
2430 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
2431 "instance_of_known_global")
2432
2433 private:
2434 Handle<JSFunction> function_;
2262 }; 2435 };
2263 2436
2264 2437
2265 class HPower: public HBinaryOperation { 2438 class HPower: public HBinaryOperation {
2266 public: 2439 public:
2267 HPower(HValue* left, HValue* right) 2440 HPower(HValue* left, HValue* right)
2268 : HBinaryOperation(left, right) { 2441 : HBinaryOperation(left, right) {
2269 set_representation(Representation::Double()); 2442 set_representation(Representation::Double());
2270 SetFlag(kUseGVN); 2443 SetFlag(kUseGVN);
2271 } 2444 }
2272 2445
2273 virtual Representation RequiredInputRepresentation(int index) const { 2446 virtual Representation RequiredInputRepresentation(int index) const {
2274 return (index == 1) ? Representation::None() : Representation::Double(); 2447 return (index == 1) ? Representation::None() : Representation::Double();
2275 } 2448 }
2276 2449
2277 DECLARE_CONCRETE_INSTRUCTION(Power, "power") 2450 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
2451
2452 protected:
2453 virtual bool DataEquals(HValue* other) const { return true; }
2278 }; 2454 };
2279 2455
2280 2456
2281 class HAdd: public HArithmeticBinaryOperation { 2457 class HAdd: public HArithmeticBinaryOperation {
2282 public: 2458 public:
2283 HAdd(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2459 HAdd(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2284 SetFlag(kCanOverflow); 2460 SetFlag(kCanOverflow);
2285 } 2461 }
2286 2462
2287 // Add is only commutative if two integer values are added and not if two 2463 // Add is only commutative if two integer values are added and not if two
2288 // tagged values are added (because it might be a String concatenation). 2464 // tagged values are added (because it might be a String concatenation).
2289 virtual bool IsCommutative() const { 2465 virtual bool IsCommutative() const {
2290 return !representation().IsTagged(); 2466 return !representation().IsTagged();
2291 } 2467 }
2292 2468
2293 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2469 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2294 2470
2295 virtual HType CalculateInferredType() const; 2471 virtual HType CalculateInferredType() const;
2296 2472
2297 DECLARE_CONCRETE_INSTRUCTION(Add, "add") 2473 DECLARE_CONCRETE_INSTRUCTION(Add, "add")
2298 2474
2299 protected: 2475 protected:
2476 virtual bool DataEquals(HValue* other) const { return true; }
2477
2300 virtual Range* InferRange(); 2478 virtual Range* InferRange();
2301 }; 2479 };
2302 2480
2303 2481
2304 class HSub: public HArithmeticBinaryOperation { 2482 class HSub: public HArithmeticBinaryOperation {
2305 public: 2483 public:
2306 HSub(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2484 HSub(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2307 SetFlag(kCanOverflow); 2485 SetFlag(kCanOverflow);
2308 } 2486 }
2309 2487
2310 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2488 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2311 2489
2312 DECLARE_CONCRETE_INSTRUCTION(Sub, "sub") 2490 DECLARE_CONCRETE_INSTRUCTION(Sub, "sub")
2313 2491
2314 protected: 2492 protected:
2493 virtual bool DataEquals(HValue* other) const { return true; }
2494
2315 virtual Range* InferRange(); 2495 virtual Range* InferRange();
2316 }; 2496 };
2317 2497
2318 2498
2319 class HMul: public HArithmeticBinaryOperation { 2499 class HMul: public HArithmeticBinaryOperation {
2320 public: 2500 public:
2321 HMul(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2501 HMul(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2322 SetFlag(kCanOverflow); 2502 SetFlag(kCanOverflow);
2323 } 2503 }
2324 2504
2325 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2505 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2326 2506
2327 // Only commutative if it is certain that not two objects are multiplicated. 2507 // Only commutative if it is certain that not two objects are multiplicated.
2328 virtual bool IsCommutative() const { 2508 virtual bool IsCommutative() const {
2329 return !representation().IsTagged(); 2509 return !representation().IsTagged();
2330 } 2510 }
2331 2511
2332 DECLARE_CONCRETE_INSTRUCTION(Mul, "mul") 2512 DECLARE_CONCRETE_INSTRUCTION(Mul, "mul")
2333 2513
2334 protected: 2514 protected:
2515 virtual bool DataEquals(HValue* other) const { return true; }
2516
2335 virtual Range* InferRange(); 2517 virtual Range* InferRange();
2336 }; 2518 };
2337 2519
2338 2520
2339 class HMod: public HArithmeticBinaryOperation { 2521 class HMod: public HArithmeticBinaryOperation {
2340 public: 2522 public:
2341 HMod(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2523 HMod(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2342 SetFlag(kCanBeDivByZero); 2524 SetFlag(kCanBeDivByZero);
2343 } 2525 }
2344 2526
2345 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2527 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2346 2528
2347 DECLARE_CONCRETE_INSTRUCTION(Mod, "mod") 2529 DECLARE_CONCRETE_INSTRUCTION(Mod, "mod")
2348 2530
2349 protected: 2531 protected:
2532 virtual bool DataEquals(HValue* other) const { return true; }
2533
2350 virtual Range* InferRange(); 2534 virtual Range* InferRange();
2351 }; 2535 };
2352 2536
2353 2537
2354 class HDiv: public HArithmeticBinaryOperation { 2538 class HDiv: public HArithmeticBinaryOperation {
2355 public: 2539 public:
2356 HDiv(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { 2540 HDiv(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) {
2357 SetFlag(kCanBeDivByZero); 2541 SetFlag(kCanBeDivByZero);
2358 SetFlag(kCanOverflow); 2542 SetFlag(kCanOverflow);
2359 } 2543 }
2360 2544
2361 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 2545 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
2362 2546
2363 DECLARE_CONCRETE_INSTRUCTION(Div, "div") 2547 DECLARE_CONCRETE_INSTRUCTION(Div, "div")
2364 2548
2365 protected: 2549 protected:
2550 virtual bool DataEquals(HValue* other) const { return true; }
2551
2366 virtual Range* InferRange(); 2552 virtual Range* InferRange();
2367 }; 2553 };
2368 2554
2369 2555
2370 class HBitAnd: public HBitwiseBinaryOperation { 2556 class HBitAnd: public HBitwiseBinaryOperation {
2371 public: 2557 public:
2372 HBitAnd(HValue* left, HValue* right) 2558 HBitAnd(HValue* left, HValue* right)
2373 : HBitwiseBinaryOperation(left, right) { } 2559 : HBitwiseBinaryOperation(left, right) { }
2374 2560
2375 virtual bool IsCommutative() const { return true; } 2561 virtual bool IsCommutative() const { return true; }
2376 virtual HType CalculateInferredType() const; 2562 virtual HType CalculateInferredType() const;
2377 2563
2378 DECLARE_CONCRETE_INSTRUCTION(BitAnd, "bit_and") 2564 DECLARE_CONCRETE_INSTRUCTION(BitAnd, "bit_and")
2379 2565
2380 protected: 2566 protected:
2567 virtual bool DataEquals(HValue* other) const { return true; }
2568
2381 virtual Range* InferRange(); 2569 virtual Range* InferRange();
2382 }; 2570 };
2383 2571
2384 2572
2385 class HBitXor: public HBitwiseBinaryOperation { 2573 class HBitXor: public HBitwiseBinaryOperation {
2386 public: 2574 public:
2387 HBitXor(HValue* left, HValue* right) 2575 HBitXor(HValue* left, HValue* right)
2388 : HBitwiseBinaryOperation(left, right) { } 2576 : HBitwiseBinaryOperation(left, right) { }
2389 2577
2390 virtual bool IsCommutative() const { return true; } 2578 virtual bool IsCommutative() const { return true; }
2391 virtual HType CalculateInferredType() const; 2579 virtual HType CalculateInferredType() const;
2392 2580
2393 DECLARE_CONCRETE_INSTRUCTION(BitXor, "bit_xor") 2581 DECLARE_CONCRETE_INSTRUCTION(BitXor, "bit_xor")
2582
2583 protected:
2584 virtual bool DataEquals(HValue* other) const { return true; }
2394 }; 2585 };
2395 2586
2396 2587
2397 class HBitOr: public HBitwiseBinaryOperation { 2588 class HBitOr: public HBitwiseBinaryOperation {
2398 public: 2589 public:
2399 HBitOr(HValue* left, HValue* right) 2590 HBitOr(HValue* left, HValue* right)
2400 : HBitwiseBinaryOperation(left, right) { } 2591 : HBitwiseBinaryOperation(left, right) { }
2401 2592
2402 virtual bool IsCommutative() const { return true; } 2593 virtual bool IsCommutative() const { return true; }
2403 virtual HType CalculateInferredType() const; 2594 virtual HType CalculateInferredType() const;
2404 2595
2405 DECLARE_CONCRETE_INSTRUCTION(BitOr, "bit_or") 2596 DECLARE_CONCRETE_INSTRUCTION(BitOr, "bit_or")
2406 2597
2407 protected: 2598 protected:
2599 virtual bool DataEquals(HValue* other) const { return true; }
2600
2408 virtual Range* InferRange(); 2601 virtual Range* InferRange();
2409 }; 2602 };
2410 2603
2411 2604
2412 class HShl: public HBitwiseBinaryOperation { 2605 class HShl: public HBitwiseBinaryOperation {
2413 public: 2606 public:
2414 HShl(HValue* left, HValue* right) 2607 HShl(HValue* left, HValue* right)
2415 : HBitwiseBinaryOperation(left, right) { } 2608 : HBitwiseBinaryOperation(left, right) { }
2416 2609
2417 virtual Range* InferRange(); 2610 virtual Range* InferRange();
2418 virtual HType CalculateInferredType() const; 2611 virtual HType CalculateInferredType() const;
2419 2612
2420 DECLARE_CONCRETE_INSTRUCTION(Shl, "shl") 2613 DECLARE_CONCRETE_INSTRUCTION(Shl, "shl")
2614
2615 protected:
2616 virtual bool DataEquals(HValue* other) const { return true; }
2421 }; 2617 };
2422 2618
2423 2619
2424 class HShr: public HBitwiseBinaryOperation { 2620 class HShr: public HBitwiseBinaryOperation {
2425 public: 2621 public:
2426 HShr(HValue* left, HValue* right) 2622 HShr(HValue* left, HValue* right)
2427 : HBitwiseBinaryOperation(left, right) { } 2623 : HBitwiseBinaryOperation(left, right) { }
2428 2624
2429 virtual HType CalculateInferredType() const; 2625 virtual HType CalculateInferredType() const;
2430 2626
2431 DECLARE_CONCRETE_INSTRUCTION(Shr, "shr") 2627 DECLARE_CONCRETE_INSTRUCTION(Shr, "shr")
2628
2629 protected:
2630 virtual bool DataEquals(HValue* other) const { return true; }
2432 }; 2631 };
2433 2632
2434 2633
2435 class HSar: public HBitwiseBinaryOperation { 2634 class HSar: public HBitwiseBinaryOperation {
2436 public: 2635 public:
2437 HSar(HValue* left, HValue* right) 2636 HSar(HValue* left, HValue* right)
2438 : HBitwiseBinaryOperation(left, right) { } 2637 : HBitwiseBinaryOperation(left, right) { }
2439 2638
2440 virtual Range* InferRange(); 2639 virtual Range* InferRange();
2441 virtual HType CalculateInferredType() const; 2640 virtual HType CalculateInferredType() const;
2442 2641
2443 DECLARE_CONCRETE_INSTRUCTION(Sar, "sar") 2642 DECLARE_CONCRETE_INSTRUCTION(Sar, "sar")
2643
2644 protected:
2645 virtual bool DataEquals(HValue* other) const { return true; }
2444 }; 2646 };
2445 2647
2446 2648
2447 class HOsrEntry: public HInstruction { 2649 class HOsrEntry: public HInstruction {
2448 public: 2650 public:
2449 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) { 2651 explicit HOsrEntry(int ast_id) : ast_id_(ast_id) {
2450 SetFlag(kChangesOsrEntries); 2652 SetFlag(kChangesOsrEntries);
2451 } 2653 }
2452 2654
2453 int ast_id() const { return ast_id_; } 2655 int ast_id() const { return ast_id_; }
(...skipping 15 matching lines...) Expand all
2469 2671
2470 virtual void PrintDataTo(StringStream* stream) const; 2672 virtual void PrintDataTo(StringStream* stream) const;
2471 2673
2472 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter") 2674 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
2473 2675
2474 private: 2676 private:
2475 unsigned index_; 2677 unsigned index_;
2476 }; 2678 };
2477 2679
2478 2680
2479 class HCallStub: public HInstruction { 2681 class HCallStub: public HUnaryCall {
2480 public: 2682 public:
2481 HCallStub(CodeStub::Major major_key, int argument_count) 2683 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count)
2482 : major_key_(major_key), 2684 : HUnaryCall(context, argument_count),
2483 argument_count_(argument_count), 2685 major_key_(major_key),
2484 transcendental_type_(TranscendentalCache::kNumberOfCaches) { 2686 transcendental_type_(TranscendentalCache::kNumberOfCaches) {
2485 set_representation(Representation::Tagged());
2486 SetFlagMask(AllSideEffects());
2487 } 2687 }
2488 2688
2489 CodeStub::Major major_key() { return major_key_; } 2689 CodeStub::Major major_key() { return major_key_; }
2490 int argument_count() { return argument_count_; } 2690
2691 HValue* context() const { return value(); }
2491 2692
2492 void set_transcendental_type(TranscendentalCache::Type transcendental_type) { 2693 void set_transcendental_type(TranscendentalCache::Type transcendental_type) {
2493 transcendental_type_ = transcendental_type; 2694 transcendental_type_ = transcendental_type;
2494 } 2695 }
2495 TranscendentalCache::Type transcendental_type() { 2696 TranscendentalCache::Type transcendental_type() {
2496 return transcendental_type_; 2697 return transcendental_type_;
2497 } 2698 }
2699
2498 virtual void PrintDataTo(StringStream* stream) const; 2700 virtual void PrintDataTo(StringStream* stream) const;
2499 2701
2500 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call_stub") 2702 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call_stub")
2501 2703
2502 private: 2704 private:
2503 CodeStub::Major major_key_; 2705 CodeStub::Major major_key_;
2504 int argument_count_;
2505 TranscendentalCache::Type transcendental_type_; 2706 TranscendentalCache::Type transcendental_type_;
2506 }; 2707 };
2507 2708
2508 2709
2509 class HUnknownOSRValue: public HInstruction { 2710 class HUnknownOSRValue: public HInstruction {
2510 public: 2711 public:
2511 HUnknownOSRValue() { set_representation(Representation::Tagged()); } 2712 HUnknownOSRValue() { set_representation(Representation::Tagged()); }
2512 2713
2513 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown_osr_value") 2714 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown_osr_value")
2514 }; 2715 };
(...skipping 30 matching lines...) Expand all
2545 } 2746 }
2546 2747
2547 private: 2748 private:
2548 Handle<JSGlobalPropertyCell> cell_; 2749 Handle<JSGlobalPropertyCell> cell_;
2549 bool check_hole_value_; 2750 bool check_hole_value_;
2550 }; 2751 };
2551 2752
2552 2753
2553 class HStoreGlobal: public HUnaryOperation { 2754 class HStoreGlobal: public HUnaryOperation {
2554 public: 2755 public:
2555 HStoreGlobal(HValue* value, Handle<JSGlobalPropertyCell> cell) 2756 HStoreGlobal(HValue* value,
2556 : HUnaryOperation(value), cell_(cell) { 2757 Handle<JSGlobalPropertyCell> cell,
2758 bool check_hole_value)
2759 : HUnaryOperation(value),
2760 cell_(cell),
2761 check_hole_value_(check_hole_value) {
2557 SetFlag(kChangesGlobalVars); 2762 SetFlag(kChangesGlobalVars);
2558 } 2763 }
2559 2764
2560 Handle<JSGlobalPropertyCell> cell() const { return cell_; } 2765 Handle<JSGlobalPropertyCell> cell() const { return cell_; }
2766 bool check_hole_value() const { return check_hole_value_; }
2561 2767
2562 virtual Representation RequiredInputRepresentation(int index) const { 2768 virtual Representation RequiredInputRepresentation(int index) const {
2563 return Representation::Tagged(); 2769 return Representation::Tagged();
2564 } 2770 }
2565 virtual void PrintDataTo(StringStream* stream) const; 2771 virtual void PrintDataTo(StringStream* stream) const;
2566 2772
2567 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global") 2773 DECLARE_CONCRETE_INSTRUCTION(StoreGlobal, "store_global")
2568 2774
2775 private:
2776 Handle<JSGlobalPropertyCell> cell_;
2777 bool check_hole_value_;
2778 };
2779
2780
2781 class HLoadContextSlot: public HUnaryOperation {
2782 public:
2783 HLoadContextSlot(HValue* context , int slot_index)
2784 : HUnaryOperation(context), slot_index_(slot_index) {
2785 set_representation(Representation::Tagged());
2786 SetFlag(kUseGVN);
2787 SetFlag(kDependsOnContextSlots);
2788 }
2789
2790 int slot_index() const { return slot_index_; }
2791
2792 virtual Representation RequiredInputRepresentation(int index) const {
2793 return Representation::Tagged();
2794 }
2795
2796 virtual void PrintDataTo(StringStream* stream) const;
2797
2798 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load_context_slot")
2799
2569 protected: 2800 protected:
2570 virtual bool DataEquals(HValue* other) const { 2801 virtual bool DataEquals(HValue* other) const {
2571 HStoreGlobal* b = HStoreGlobal::cast(other); 2802 HLoadContextSlot* b = HLoadContextSlot::cast(other);
2572 return cell_.is_identical_to(b->cell()); 2803 return (slot_index() == b->slot_index());
2573 } 2804 }
2574 2805
2575 private: 2806 private:
2576 Handle<JSGlobalPropertyCell> cell_; 2807 int slot_index_;
2808 };
2809
2810
2811 static inline bool StoringValueNeedsWriteBarrier(HValue* value) {
2812 return !value->type().IsSmi() &&
2813 !(value->IsConstant() && HConstant::cast(value)->InOldSpace());
2814 }
2815
2816
2817 class HStoreContextSlot: public HBinaryOperation {
2818 public:
2819 HStoreContextSlot(HValue* context, int slot_index, HValue* value)
2820 : HBinaryOperation(context, value), slot_index_(slot_index) {
2821 SetFlag(kChangesContextSlots);
2822 }
2823
2824 HValue* context() const { return OperandAt(0); }
2825 HValue* value() const { return OperandAt(1); }
2826 int slot_index() const { return slot_index_; }
2827
2828 bool NeedsWriteBarrier() const {
2829 return StoringValueNeedsWriteBarrier(value());
2830 }
2831
2832 virtual Representation RequiredInputRepresentation(int index) const {
2833 return Representation::Tagged();
2834 }
2835
2836 virtual void PrintDataTo(StringStream* stream) const;
2837
2838 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store_context_slot")
2839
2840 private:
2841 int slot_index_;
2577 }; 2842 };
2578 2843
2579 2844
2580 class HLoadNamedField: public HUnaryOperation { 2845 class HLoadNamedField: public HUnaryOperation {
2581 public: 2846 public:
2582 HLoadNamedField(HValue* object, bool is_in_object, int offset) 2847 HLoadNamedField(HValue* object, bool is_in_object, int offset)
2583 : HUnaryOperation(object), 2848 : HUnaryOperation(object),
2584 is_in_object_(is_in_object), 2849 is_in_object_(is_in_object),
2585 offset_(offset) { 2850 offset_(offset) {
2586 set_representation(Representation::Tagged()); 2851 set_representation(Representation::Tagged());
(...skipping 21 matching lines...) Expand all
2608 HLoadNamedField* b = HLoadNamedField::cast(other); 2873 HLoadNamedField* b = HLoadNamedField::cast(other);
2609 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; 2874 return is_in_object_ == b->is_in_object_ && offset_ == b->offset_;
2610 } 2875 }
2611 2876
2612 private: 2877 private:
2613 bool is_in_object_; 2878 bool is_in_object_;
2614 int offset_; 2879 int offset_;
2615 }; 2880 };
2616 2881
2617 2882
2618 class HLoadNamedGeneric: public HUnaryOperation { 2883 class HLoadNamedGeneric: public HBinaryOperation {
2619 public: 2884 public:
2620 HLoadNamedGeneric(HValue* object, Handle<Object> name) 2885 HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name)
2621 : HUnaryOperation(object), name_(name) { 2886 : HBinaryOperation(context, object), name_(name) {
2622 set_representation(Representation::Tagged()); 2887 set_representation(Representation::Tagged());
2623 SetFlagMask(AllSideEffects()); 2888 SetAllSideEffects();
2624 } 2889 }
2625 2890
2626 HValue* object() const { return OperandAt(0); } 2891 HValue* context() const { return OperandAt(0); }
2892 HValue* object() const { return OperandAt(1); }
2627 Handle<Object> name() const { return name_; } 2893 Handle<Object> name() const { return name_; }
2628 2894
2629 virtual Representation RequiredInputRepresentation(int index) const { 2895 virtual Representation RequiredInputRepresentation(int index) const {
2630 return Representation::Tagged(); 2896 return Representation::Tagged();
2631 } 2897 }
2632 2898
2633 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load_named_generic") 2899 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load_named_generic")
2634 2900
2635 protected:
2636 virtual bool DataEquals(HValue* other) const {
2637 HLoadNamedGeneric* b = HLoadNamedGeneric::cast(other);
2638 return name_.is_identical_to(b->name_);
2639 }
2640
2641 private: 2901 private:
2642 Handle<Object> name_; 2902 Handle<Object> name_;
2643 }; 2903 };
2644 2904
2645 2905
2646 class HLoadFunctionPrototype: public HUnaryOperation { 2906 class HLoadFunctionPrototype: public HUnaryOperation {
2647 public: 2907 public:
2648 explicit HLoadFunctionPrototype(HValue* function) 2908 explicit HLoadFunctionPrototype(HValue* function)
2649 : HUnaryOperation(function) { 2909 : HUnaryOperation(function) {
2650 set_representation(Representation::Tagged()); 2910 set_representation(Representation::Tagged());
2651 SetFlagMask(kDependsOnFunctionPrototypes); 2911 SetFlag(kUseGVN);
2912 SetFlag(kDependsOnCalls);
2652 } 2913 }
2653 2914
2654 HValue* function() const { return OperandAt(0); } 2915 HValue* function() const { return OperandAt(0); }
2655 2916
2656 virtual Representation RequiredInputRepresentation(int index) const { 2917 virtual Representation RequiredInputRepresentation(int index) const {
2657 return Representation::Tagged(); 2918 return Representation::Tagged();
2658 } 2919 }
2659 2920
2660 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load_function_prototype") 2921 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load_function_prototype")
2661 2922
(...skipping 28 matching lines...) Expand all
2690 } 2951 }
2691 2952
2692 virtual Representation RequiredInputRepresentation(int index) const { 2953 virtual Representation RequiredInputRepresentation(int index) const {
2693 // The key is supposed to be Integer32. 2954 // The key is supposed to be Integer32.
2694 return (index == 1) ? Representation::Integer32() 2955 return (index == 1) ? Representation::Integer32()
2695 : Representation::Tagged(); 2956 : Representation::Tagged();
2696 } 2957 }
2697 2958
2698 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, 2959 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement,
2699 "load_keyed_fast_element") 2960 "load_keyed_fast_element")
2961
2962 protected:
2963 virtual bool DataEquals(HValue* other) const { return true; }
2964 };
2965
2966
2967 class HLoadPixelArrayElement: public HBinaryOperation {
2968 public:
2969 HLoadPixelArrayElement(HValue* external_elements, HValue* key)
2970 : HBinaryOperation(external_elements, key) {
2971 set_representation(Representation::Integer32());
2972 SetFlag(kDependsOnPixelArrayElements);
2973 // Native code could change the pixel array.
2974 SetFlag(kDependsOnCalls);
2975 SetFlag(kUseGVN);
2976 }
2977
2978 virtual void PrintDataTo(StringStream* stream) const;
2979
2980 virtual Representation RequiredInputRepresentation(int index) const {
2981 // The key is supposed to be Integer32, but the base pointer
2982 // for the element load is a naked pointer.
2983 return (index == 1) ? Representation::Integer32()
2984 : Representation::External();
2985 }
2986
2987 HValue* external_pointer() const { return OperandAt(0); }
2988 HValue* key() const { return OperandAt(1); }
2989
2990 DECLARE_CONCRETE_INSTRUCTION(LoadPixelArrayElement,
2991 "load_pixel_array_element")
2992
2993 protected:
2994 virtual bool DataEquals(HValue* other) const { return true; }
2700 }; 2995 };
2701 2996
2702 2997
2703 class HLoadKeyedGeneric: public HLoadKeyed { 2998 class HLoadKeyedGeneric: public HLoadKeyed {
2704 public: 2999 public:
2705 HLoadKeyedGeneric(HValue* obj, HValue* key) : HLoadKeyed(obj, key) { 3000 HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key)
2706 SetFlagMask(AllSideEffects()); 3001 : HLoadKeyed(obj, key), context_(NULL) {
3002 SetOperandAt(2, context);
3003 SetAllSideEffects();
3004 }
3005
3006 HValue* context() const { return context_; }
3007 HValue* object() const { return operands_[0]; }
3008 HValue* key() const { return operands_[1]; }
3009
3010 virtual int OperandCount() const { return 3; }
3011 virtual HValue* OperandAt(int index) const {
3012 return (index < 2) ? operands_[index] : context_;
2707 } 3013 }
2708 3014
2709 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic") 3015 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load_keyed_generic")
3016
3017 protected:
3018 virtual void InternalSetOperandAt(int index, HValue* value);
3019
3020 private:
3021 HValue* context_;
2710 }; 3022 };
2711 3023
2712 3024
2713 static inline bool StoringValueNeedsWriteBarrier(HValue* value) {
2714 return !value->type().IsSmi() &&
2715 !(value->IsConstant() && HConstant::cast(value)->InOldSpace());
2716 }
2717
2718
2719 class HStoreNamed: public HBinaryOperation { 3025 class HStoreNamed: public HBinaryOperation {
2720 public: 3026 public:
2721 HStoreNamed(HValue* obj, Handle<Object> name, HValue* val) 3027 HStoreNamed(HValue* obj, Handle<String> name, HValue* val)
2722 : HBinaryOperation(obj, val), name_(name) { 3028 : HBinaryOperation(obj, val), name_(name) {
2723 } 3029 }
2724 3030
2725 virtual Representation RequiredInputRepresentation(int index) const { 3031 virtual Representation RequiredInputRepresentation(int index) const {
2726 return Representation::Tagged(); 3032 return Representation::Tagged();
2727 } 3033 }
2728 3034
2729 virtual void PrintDataTo(StringStream* stream) const; 3035 virtual void PrintDataTo(StringStream* stream) const;
2730 3036
2731 HValue* object() const { return OperandAt(0); } 3037 HValue* object() const { return OperandAt(0); }
2732 Handle<Object> name() const { return name_; } 3038 Handle<String> name() const { return name_; }
2733 HValue* value() const { return OperandAt(1); } 3039 HValue* value() const { return OperandAt(1); }
2734 void set_value(HValue* value) { SetOperandAt(1, value); } 3040 void set_value(HValue* value) { SetOperandAt(1, value); }
2735 3041
2736 bool NeedsWriteBarrier() const {
2737 return StoringValueNeedsWriteBarrier(value());
2738 }
2739
2740 DECLARE_INSTRUCTION(StoreNamed) 3042 DECLARE_INSTRUCTION(StoreNamed)
2741 3043
2742 protected:
2743 virtual bool DataEquals(HValue* other) const {
2744 HStoreNamed* b = HStoreNamed::cast(other);
2745 return name_.is_identical_to(b->name_);
2746 }
2747
2748 private: 3044 private:
2749 Handle<Object> name_; 3045 Handle<String> name_;
2750 }; 3046 };
2751 3047
2752 3048
2753 class HStoreNamedField: public HStoreNamed { 3049 class HStoreNamedField: public HStoreNamed {
2754 public: 3050 public:
2755 HStoreNamedField(HValue* obj, 3051 HStoreNamedField(HValue* obj,
2756 Handle<Object> name, 3052 Handle<String> name,
2757 HValue* val, 3053 HValue* val,
2758 bool in_object, 3054 bool in_object,
2759 int offset) 3055 int offset)
2760 : HStoreNamed(obj, name, val), 3056 : HStoreNamed(obj, name, val),
2761 is_in_object_(in_object), 3057 is_in_object_(in_object),
2762 offset_(offset) { 3058 offset_(offset) {
2763 if (is_in_object_) { 3059 if (is_in_object_) {
2764 SetFlag(kChangesInobjectFields); 3060 SetFlag(kChangesInobjectFields);
2765 } else { 3061 } else {
2766 SetFlag(kChangesBackingStoreFields); 3062 SetFlag(kChangesBackingStoreFields);
2767 } 3063 }
2768 } 3064 }
2769 3065
2770 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field") 3066 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store_named_field")
2771 3067
2772 virtual Representation RequiredInputRepresentation(int index) const { 3068 virtual Representation RequiredInputRepresentation(int index) const {
2773 return Representation::Tagged(); 3069 return Representation::Tagged();
2774 } 3070 }
2775 virtual void PrintDataTo(StringStream* stream) const; 3071 virtual void PrintDataTo(StringStream* stream) const;
2776 3072
2777 bool is_in_object() const { return is_in_object_; } 3073 bool is_in_object() const { return is_in_object_; }
2778 int offset() const { return offset_; } 3074 int offset() const { return offset_; }
2779 Handle<Map> transition() const { return transition_; } 3075 Handle<Map> transition() const { return transition_; }
2780 void set_transition(Handle<Map> map) { transition_ = map; } 3076 void set_transition(Handle<Map> map) { transition_ = map; }
2781 3077
3078 bool NeedsWriteBarrier() const {
3079 return StoringValueNeedsWriteBarrier(value());
3080 }
3081
2782 private: 3082 private:
2783 bool is_in_object_; 3083 bool is_in_object_;
2784 int offset_; 3084 int offset_;
2785 Handle<Map> transition_; 3085 Handle<Map> transition_;
2786 }; 3086 };
2787 3087
2788 3088
2789 class HStoreNamedGeneric: public HStoreNamed { 3089 class HStoreNamedGeneric: public HStoreNamed {
2790 public: 3090 public:
2791 HStoreNamedGeneric(HValue* obj, Handle<Object> name, HValue* val) 3091 HStoreNamedGeneric(HValue* context,
2792 : HStoreNamed(obj, name, val) { 3092 HValue* object,
2793 SetFlagMask(AllSideEffects()); 3093 Handle<String> name,
3094 HValue* value)
3095 : HStoreNamed(object, name, value), context_(NULL) {
3096 SetOperandAt(2, context);
3097 SetAllSideEffects();
3098 }
3099
3100 HValue* context() const { return context_; }
3101 HValue* object() const { return operands_[0]; }
3102 HValue* value() const { return operands_[1]; }
3103
3104 virtual int OperandCount() const { return 3; }
3105
3106 virtual HValue* OperandAt(int index) const {
3107 return (index < 2) ? operands_[index] : context_;
2794 } 3108 }
2795 3109
2796 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store_named_generic") 3110 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store_named_generic")
3111
3112 protected:
3113 virtual void InternalSetOperandAt(int index, HValue* value);
3114
3115 private:
3116 HValue* context_;
2797 }; 3117 };
2798 3118
2799 3119
2800 class HStoreKeyed: public HInstruction { 3120 class HStoreKeyed: public HInstruction {
2801 public: 3121 public:
2802 HStoreKeyed(HValue* obj, HValue* key, HValue* val) { 3122 HStoreKeyed(HValue* obj, HValue* key, HValue* val) {
2803 SetOperandAt(0, obj); 3123 SetOperandAt(0, obj);
2804 SetOperandAt(1, key); 3124 SetOperandAt(1, key);
2805 SetOperandAt(2, val); 3125 SetOperandAt(2, val);
2806 } 3126 }
(...skipping 14 matching lines...) Expand all
2821 return StoringValueNeedsWriteBarrier(value()); 3141 return StoringValueNeedsWriteBarrier(value());
2822 } 3142 }
2823 3143
2824 DECLARE_INSTRUCTION(StoreKeyed) 3144 DECLARE_INSTRUCTION(StoreKeyed)
2825 3145
2826 protected: 3146 protected:
2827 virtual void InternalSetOperandAt(int index, HValue* value) { 3147 virtual void InternalSetOperandAt(int index, HValue* value) {
2828 operands_[index] = value; 3148 operands_[index] = value;
2829 } 3149 }
2830 3150
2831 private:
2832 HOperandVector<3> operands_; 3151 HOperandVector<3> operands_;
2833 }; 3152 };
2834 3153
2835 3154
2836 class HStoreKeyedFastElement: public HStoreKeyed { 3155 class HStoreKeyedFastElement: public HStoreKeyed {
2837 public: 3156 public:
2838 HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val) 3157 HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val)
2839 : HStoreKeyed(obj, key, val) { 3158 : HStoreKeyed(obj, key, val) {
2840 SetFlag(kChangesArrayElements); 3159 SetFlag(kChangesArrayElements);
2841 } 3160 }
2842 3161
2843 virtual Representation RequiredInputRepresentation(int index) const { 3162 virtual Representation RequiredInputRepresentation(int index) const {
2844 // The key is supposed to be Integer32. 3163 // The key is supposed to be Integer32.
2845 return (index == 1) ? Representation::Integer32() 3164 return (index == 1) ? Representation::Integer32()
2846 : Representation::Tagged(); 3165 : Representation::Tagged();
2847 } 3166 }
2848 3167
2849 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement, 3168 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
2850 "store_keyed_fast_element") 3169 "store_keyed_fast_element")
2851 }; 3170 };
2852 3171
2853 3172
2854 class HStoreKeyedGeneric: public HStoreKeyed { 3173 class HStoreKeyedGeneric: public HStoreKeyed {
2855 public: 3174 public:
2856 HStoreKeyedGeneric(HValue* obj, HValue* key, HValue* val) 3175 HStoreKeyedGeneric(HValue* context,
2857 : HStoreKeyed(obj, key, val) { 3176 HValue* object,
2858 SetFlagMask(AllSideEffects()); 3177 HValue* key,
3178 HValue* value)
3179 : HStoreKeyed(object, key, value), context_(NULL) {
3180 SetOperandAt(3, context);
3181 SetAllSideEffects();
3182 }
3183
3184 HValue* context() const { return context_; }
3185 HValue* object() const { return operands_[0]; }
3186 HValue* key() const { return operands_[1]; }
3187 HValue* value() const { return operands_[2]; }
3188
3189 virtual int OperandCount() const { return 4; }
3190
3191 virtual HValue* OperandAt(int index) const {
3192 return (index < 3) ? operands_[index] : context_;
2859 } 3193 }
2860 3194
2861 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store_keyed_generic") 3195 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store_keyed_generic")
3196
3197 protected:
3198 virtual void InternalSetOperandAt(int index, HValue* value);
3199
3200 private:
3201 HValue* context_;
3202 };
3203
3204
3205 class HStringCharCodeAt: public HBinaryOperation {
3206 public:
3207 HStringCharCodeAt(HValue* string, HValue* index)
3208 : HBinaryOperation(string, index) {
3209 set_representation(Representation::Integer32());
3210 SetFlag(kUseGVN);
3211 }
3212
3213 virtual Representation RequiredInputRepresentation(int index) const {
3214 // The index is supposed to be Integer32.
3215 return (index == 1) ? Representation::Integer32()
3216 : Representation::Tagged();
3217 }
3218
3219 HValue* string() const { return OperandAt(0); }
3220 HValue* index() const { return OperandAt(1); }
3221
3222 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string_char_code_at")
3223
3224 protected:
3225 virtual bool DataEquals(HValue* other) const { return true; }
3226
3227 virtual Range* InferRange() {
3228 return new Range(0, String::kMaxUC16CharCode);
3229 }
3230 };
3231
3232
3233 class HStringLength: public HUnaryOperation {
3234 public:
3235 explicit HStringLength(HValue* string) : HUnaryOperation(string) {
3236 set_representation(Representation::Tagged());
3237 SetFlag(kUseGVN);
3238 }
3239
3240 virtual Representation RequiredInputRepresentation(int index) const {
3241 return Representation::Tagged();
3242 }
3243
3244 virtual HType CalculateInferredType() const {
3245 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3246 return HType::Smi();
3247 }
3248
3249 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string_length")
3250
3251 protected:
3252 virtual bool DataEquals(HValue* other) const { return true; }
3253
3254 virtual Range* InferRange() {
3255 return new Range(0, String::kMaxLength);
3256 }
2862 }; 3257 };
2863 3258
2864 3259
2865 class HMaterializedLiteral: public HInstruction { 3260 class HMaterializedLiteral: public HInstruction {
2866 public: 3261 public:
2867 HMaterializedLiteral(int index, int depth) 3262 HMaterializedLiteral(int index, int depth)
2868 : literal_index_(index), depth_(depth) { 3263 : literal_index_(index), depth_(depth) {
2869 set_representation(Representation::Tagged()); 3264 set_representation(Representation::Tagged());
2870 } 3265 }
2871 3266
(...skipping 26 matching lines...) Expand all
2898 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array_literal") 3293 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array_literal")
2899 3294
2900 private: 3295 private:
2901 int length_; 3296 int length_;
2902 Handle<FixedArray> constant_elements_; 3297 Handle<FixedArray> constant_elements_;
2903 }; 3298 };
2904 3299
2905 3300
2906 class HObjectLiteral: public HMaterializedLiteral { 3301 class HObjectLiteral: public HMaterializedLiteral {
2907 public: 3302 public:
2908 HObjectLiteral(Handle<FixedArray> constant_properties, 3303 HObjectLiteral(HValue* context,
3304 Handle<FixedArray> constant_properties,
2909 bool fast_elements, 3305 bool fast_elements,
2910 int literal_index, 3306 int literal_index,
2911 int depth) 3307 int depth)
2912 : HMaterializedLiteral(literal_index, depth), 3308 : HMaterializedLiteral(literal_index, depth),
3309 context_(NULL),
2913 constant_properties_(constant_properties), 3310 constant_properties_(constant_properties),
2914 fast_elements_(fast_elements) {} 3311 fast_elements_(fast_elements) {
3312 SetOperandAt(0, context);
3313 }
2915 3314
3315 HValue* context() const { return context_; }
2916 Handle<FixedArray> constant_properties() const { 3316 Handle<FixedArray> constant_properties() const {
2917 return constant_properties_; 3317 return constant_properties_;
2918 } 3318 }
2919 bool fast_elements() const { return fast_elements_; } 3319 bool fast_elements() const { return fast_elements_; }
2920 3320
3321 virtual int OperandCount() const { return 1; }
3322 virtual HValue* OperandAt(int index) const { return context_; }
3323
2921 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object_literal") 3324 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object_literal")
2922 3325
3326 protected:
3327 virtual void InternalSetOperandAt(int index, HValue* value) {
3328 context_ = value;
3329 }
3330
2923 private: 3331 private:
3332 HValue* context_;
2924 Handle<FixedArray> constant_properties_; 3333 Handle<FixedArray> constant_properties_;
2925 bool fast_elements_; 3334 bool fast_elements_;
2926 }; 3335 };
2927 3336
2928 3337
2929 class HRegExpLiteral: public HMaterializedLiteral { 3338 class HRegExpLiteral: public HMaterializedLiteral {
2930 public: 3339 public:
2931 HRegExpLiteral(Handle<String> pattern, 3340 HRegExpLiteral(Handle<String> pattern,
2932 Handle<String> flags, 3341 Handle<String> flags,
2933 int literal_index) 3342 int literal_index)
(...skipping 29 matching lines...) Expand all
2963 bool pretenure_; 3372 bool pretenure_;
2964 }; 3373 };
2965 3374
2966 3375
2967 class HTypeof: public HUnaryOperation { 3376 class HTypeof: public HUnaryOperation {
2968 public: 3377 public:
2969 explicit HTypeof(HValue* value) : HUnaryOperation(value) { 3378 explicit HTypeof(HValue* value) : HUnaryOperation(value) {
2970 set_representation(Representation::Tagged()); 3379 set_representation(Representation::Tagged());
2971 } 3380 }
2972 3381
3382 virtual Representation RequiredInputRepresentation(int index) const {
3383 return Representation::Tagged();
3384 }
3385
2973 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof") 3386 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2974 }; 3387 };
2975 3388
2976 3389
2977 class HValueOf: public HUnaryOperation { 3390 class HValueOf: public HUnaryOperation {
2978 public: 3391 public:
2979 explicit HValueOf(HValue* value) : HUnaryOperation(value) { 3392 explicit HValueOf(HValue* value) : HUnaryOperation(value) {
2980 set_representation(Representation::Tagged()); 3393 set_representation(Representation::Tagged());
2981 } 3394 }
2982 3395
2983 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value_of") 3396 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value_of")
2984 }; 3397 };
2985 3398
2986 3399
2987 class HDeleteProperty: public HBinaryOperation { 3400 class HDeleteProperty: public HBinaryOperation {
2988 public: 3401 public:
2989 HDeleteProperty(HValue* obj, HValue* key) 3402 HDeleteProperty(HValue* obj, HValue* key)
2990 : HBinaryOperation(obj, key) { 3403 : HBinaryOperation(obj, key) {
2991 set_representation(Representation::Tagged()); 3404 set_representation(Representation::Tagged());
2992 SetFlagMask(AllSideEffects()); 3405 SetAllSideEffects();
2993 } 3406 }
2994 3407
2995 virtual Representation RequiredInputRepresentation(int index) const { 3408 virtual Representation RequiredInputRepresentation(int index) const {
2996 return Representation::Tagged(); 3409 return Representation::Tagged();
2997 } 3410 }
2998 3411
2999 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete_property") 3412 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete_property")
3000 3413
3001 HValue* object() const { return left(); } 3414 HValue* object() const { return left(); }
3002 HValue* key() const { return right(); } 3415 HValue* key() const { return right(); }
3003 }; 3416 };
3004 3417
3005 #undef DECLARE_INSTRUCTION 3418 #undef DECLARE_INSTRUCTION
3006 #undef DECLARE_CONCRETE_INSTRUCTION 3419 #undef DECLARE_CONCRETE_INSTRUCTION
3007 3420
3008 } } // namespace v8::internal 3421 } } // namespace v8::internal
3009 3422
3010 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 3423 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698