1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_IA32_LITHIUM_IA32_H_
6 #define V8_IA32_LITHIUM_IA32_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckInstanceType) \
53 V(ClassOfTestAndBranch) \
54 V(CompareMinusZeroAndBranch) \
55 V(CompareNumericAndBranch) \
56 V(CmpObjectEqAndBranch) \
80 V(FlooringDivByConstI) \
81 V(FlooringDivByPowerOf2I) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInstanceTypeAndBranch) \
90 V(InnerAllocatedObject) \
92 V(InstanceOfKnownGlobal) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsObjectAndBranch) \
98 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
158 V(TailCallThroughMegamorphicCache) \
160 V(ToFastProperties) \
161 V(TransitionElementsKind) \
162 V(TrapAllocationMemento) \
164 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 Opcode opcode() const FINAL { return LInstruction::k##type; } \
172 void CompileToNative(LCodeGen* generator) FINAL; \
173 const char* Mnemonic() const FINAL { return mnemonic; } \
174 static L##type* cast(LInstruction* instr) { \
175 DCHECK(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
180 #define DECLARE_HYDROGEN_ACCESSOR(type) \
181 H##type* hydrogen() const { \
182 return H##type::cast(hydrogen_value()); \
186 class LInstruction : public ZoneObject {
189 : environment_(NULL),
190 hydrogen_value_(NULL),
191 bit_field_(IsCallBits::encode(false)) {
194 virtual ~LInstruction() {}
196 virtual void CompileToNative(LCodeGen* generator) = 0;
197 virtual const char* Mnemonic() const = 0;
198 virtual void PrintTo(StringStream* stream);
199 virtual void PrintDataTo(StringStream* stream);
200 virtual void PrintOutputOperandTo(StringStream* stream);
203 // Declare a unique enum value for each instruction.
204 #define DECLARE_OPCODE(type) k##type,
205 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
206 kNumberOfInstructions
207 #undef DECLARE_OPCODE
210 virtual Opcode opcode() const = 0;
212 // Declare non-virtual type testers for all leaf IR classes.
213 #define DECLARE_PREDICATE(type) \
214 bool Is##type() const { return opcode() == k##type; }
215 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
216 #undef DECLARE_PREDICATE
218 // Declare virtual predicates for instructions that don't have
220 virtual bool IsGap() const { return false; }
222 virtual bool IsControl() const { return false; }
224 // Try deleting this instruction if possible.
225 virtual bool TryDelete() { return false; }
227 void set_environment(LEnvironment* env) { environment_ = env; }
228 LEnvironment* environment() const { return environment_; }
229 bool HasEnvironment() const { return environment_ != NULL; }
231 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
232 LPointerMap* pointer_map() const { return pointer_map_.get(); }
233 bool HasPointerMap() const { return pointer_map_.is_set(); }
235 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
236 HValue* hydrogen_value() const { return hydrogen_value_; }
238 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
240 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
241 bool IsCall() const { return IsCallBits::decode(bit_field_); }
243 // Interface to the register allocator and iterators.
244 bool ClobbersTemps() const { return IsCall(); }
245 bool ClobbersRegisters() const { return IsCall(); }
246 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
250 virtual bool HasResult() const = 0;
251 virtual LOperand* result() const = 0;
253 bool HasDoubleRegisterResult();
254 bool HasDoubleRegisterInput();
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
259 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
265 virtual int InputCount() = 0;
266 virtual LOperand* InputAt(int i) = 0;
270 friend class InputIterator;
272 friend class TempIterator;
273 virtual int TempCount() = 0;
274 virtual LOperand* TempAt(int i) = 0;
276 class IsCallBits: public BitField<bool, 0, 1> {};
278 LEnvironment* environment_;
279 SetOncePointer<LPointerMap> pointer_map_;
280 HValue* hydrogen_value_;
285 // R = number of result operands (0 or 1).
287 class LTemplateResultInstruction : public LInstruction {
289 // Allow 0 or 1 output operands.
290 STATIC_ASSERT(R == 0 || R == 1);
291 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const OVERRIDE { return results_[0]; }
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 int InputCount() FINAL { return I; }
312 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
314 int TempCount() FINAL { return T; }
315 LOperand* TempAt(int i) FINAL { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block) : block_(block) {
322 parallel_moves_[BEFORE] = NULL;
323 parallel_moves_[START] = NULL;
324 parallel_moves_[END] = NULL;
325 parallel_moves_[AFTER] = NULL;
328 // Can't use the DECLARE-macro here because of sub-classes.
329 bool IsGap() const FINAL { return true; }
330 void PrintDataTo(StringStream* stream) OVERRIDE;
331 static LGap* cast(LInstruction* instr) {
332 DCHECK(instr->IsGap());
333 return reinterpret_cast<LGap*>(instr);
336 bool IsRedundant() const;
338 HBasicBlock* block() const { return block_; }
345 FIRST_INNER_POSITION = BEFORE,
346 LAST_INNER_POSITION = AFTER
349 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
350 if (parallel_moves_[pos] == NULL) {
351 parallel_moves_[pos] = new(zone) LParallelMove(zone);
353 return parallel_moves_[pos];
356 LParallelMove* GetParallelMove(InnerPosition pos) {
357 return parallel_moves_[pos];
361 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
366 class LInstructionGap FINAL : public LGap {
368 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
370 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
371 return !IsRedundant();
374 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
378 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
380 explicit LGoto(HBasicBlock* block) : block_(block) { }
382 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
383 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
384 void PrintDataTo(StringStream* stream) OVERRIDE;
385 bool IsControl() const OVERRIDE { return true; }
387 int block_id() const { return block_->block_id(); }
388 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
392 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
399 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
401 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
408 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
412 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
414 explicit LDummyUse(LOperand* value) {
417 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
421 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
423 bool IsControl() const OVERRIDE { return true; }
424 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
425 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
429 class LLabel FINAL : public LGap {
431 explicit LLabel(HBasicBlock* block)
432 : LGap(block), replacement_(NULL) { }
434 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
435 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
437 void PrintDataTo(StringStream* stream) OVERRIDE;
439 int block_id() const { return block()->block_id(); }
440 bool is_loop_header() const { return block()->IsLoopHeader(); }
441 bool is_osr_entry() const { return block()->is_osr_entry(); }
442 Label* label() { return &label_; }
443 LLabel* replacement() const { return replacement_; }
444 void set_replacement(LLabel* label) { replacement_ = label; }
445 bool HasReplacement() const { return replacement_ != NULL; }
449 LLabel* replacement_;
453 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
455 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
456 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
460 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
462 explicit LCallStub(LOperand* context) {
463 inputs_[0] = context;
466 LOperand* context() { return inputs_[0]; }
468 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
469 DECLARE_HYDROGEN_ACCESSOR(CallStub)
473 class LTailCallThroughMegamorphicCache FINAL
474 : public LTemplateInstruction<0, 5, 0> {
476 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
477 LOperand* name, LOperand* slot,
479 inputs_[0] = context;
480 inputs_[1] = receiver;
486 LOperand* context() { return inputs_[0]; }
487 LOperand* receiver() { return inputs_[1]; }
488 LOperand* name() { return inputs_[2]; }
489 LOperand* slot() { return inputs_[3]; }
490 LOperand* vector() { return inputs_[4]; }
492 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
493 "tail-call-through-megamorphic-cache")
494 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
498 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
500 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
501 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
505 template<int I, int T>
506 class LControlInstruction: public LTemplateInstruction<0, I, T> {
508 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
510 bool IsControl() const FINAL { return true; }
512 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
513 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
515 int TrueDestination(LChunk* chunk) {
516 return chunk->LookupDestination(true_block_id());
518 int FalseDestination(LChunk* chunk) {
519 return chunk->LookupDestination(false_block_id());
522 Label* TrueLabel(LChunk* chunk) {
523 if (true_label_ == NULL) {
524 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
528 Label* FalseLabel(LChunk* chunk) {
529 if (false_label_ == NULL) {
530 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
536 int true_block_id() { return SuccessorAt(0)->block_id(); }
537 int false_block_id() { return SuccessorAt(1)->block_id(); }
540 HControlInstruction* hydrogen() {
541 return HControlInstruction::cast(this->hydrogen_value());
549 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
551 LWrapReceiver(LOperand* receiver,
554 inputs_[0] = receiver;
555 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
561 LOperand* temp() { return temps_[0]; }
563 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
564 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
568 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
570 LApplyArguments(LOperand* function,
573 LOperand* elements) {
574 inputs_[0] = function;
575 inputs_[1] = receiver;
577 inputs_[3] = elements;
580 LOperand* function() { return inputs_[0]; }
581 LOperand* receiver() { return inputs_[1]; }
582 LOperand* length() { return inputs_[2]; }
583 LOperand* elements() { return inputs_[3]; }
585 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
589 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
591 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
592 inputs_[0] = arguments;
597 LOperand* arguments() { return inputs_[0]; }
598 LOperand* length() { return inputs_[1]; }
599 LOperand* index() { return inputs_[2]; }
601 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
603 void PrintDataTo(StringStream* stream) OVERRIDE;
607 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
609 explicit LArgumentsLength(LOperand* elements) {
610 inputs_[0] = elements;
613 LOperand* elements() { return inputs_[0]; }
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
619 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
621 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
622 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
626 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
628 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
632 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
634 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
635 inputs_[0] = dividend;
639 LOperand* dividend() { return inputs_[0]; }
640 int32_t divisor() const { return divisor_; }
642 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
643 DECLARE_HYDROGEN_ACCESSOR(Mod)
650 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
652 LModByConstI(LOperand* dividend,
656 inputs_[0] = dividend;
662 LOperand* dividend() { return inputs_[0]; }
663 int32_t divisor() const { return divisor_; }
664 LOperand* temp1() { return temps_[0]; }
665 LOperand* temp2() { return temps_[1]; }
667 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
668 DECLARE_HYDROGEN_ACCESSOR(Mod)
675 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
677 LModI(LOperand* left, LOperand* right, LOperand* temp) {
683 LOperand* left() { return inputs_[0]; }
684 LOperand* right() { return inputs_[1]; }
685 LOperand* temp() { return temps_[0]; }
687 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
688 DECLARE_HYDROGEN_ACCESSOR(Mod)
692 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
694 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
695 inputs_[0] = dividend;
699 LOperand* dividend() { return inputs_[0]; }
700 int32_t divisor() const { return divisor_; }
702 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
703 DECLARE_HYDROGEN_ACCESSOR(Div)
710 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
712 LDivByConstI(LOperand* dividend,
716 inputs_[0] = dividend;
722 LOperand* dividend() { return inputs_[0]; }
723 int32_t divisor() const { return divisor_; }
724 LOperand* temp1() { return temps_[0]; }
725 LOperand* temp2() { return temps_[1]; }
727 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
728 DECLARE_HYDROGEN_ACCESSOR(Div)
735 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
737 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
738 inputs_[0] = dividend;
739 inputs_[1] = divisor;
743 LOperand* dividend() { return inputs_[0]; }
744 LOperand* divisor() { return inputs_[1]; }
745 LOperand* temp() { return temps_[0]; }
747 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
748 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
752 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
754 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
755 inputs_[0] = dividend;
759 LOperand* dividend() { return inputs_[0]; }
760 int32_t divisor() const { return divisor_; }
762 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
763 "flooring-div-by-power-of-2-i")
764 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
771 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
773 LFlooringDivByConstI(LOperand* dividend,
778 inputs_[0] = dividend;
785 LOperand* dividend() { return inputs_[0]; }
786 int32_t divisor() const { return divisor_; }
787 LOperand* temp1() { return temps_[0]; }
788 LOperand* temp2() { return temps_[1]; }
789 LOperand* temp3() { return temps_[2]; }
791 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
792 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
799 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
801 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
802 inputs_[0] = dividend;
803 inputs_[1] = divisor;
807 LOperand* dividend() { return inputs_[0]; }
808 LOperand* divisor() { return inputs_[1]; }
809 LOperand* temp() { return temps_[0]; }
811 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
812 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
816 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
818 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
824 LOperand* left() { return inputs_[0]; }
825 LOperand* right() { return inputs_[1]; }
826 LOperand* temp() { return temps_[0]; }
828 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
829 DECLARE_HYDROGEN_ACCESSOR(Mul)
833 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
835 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
840 LOperand* left() { return inputs_[0]; }
841 LOperand* right() { return inputs_[1]; }
843 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
844 "compare-numeric-and-branch")
845 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
847 Token::Value op() const { return hydrogen()->token(); }
848 bool is_double() const {
849 return hydrogen()->representation().IsDouble();
852 void PrintDataTo(StringStream* stream) OVERRIDE;
856 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
858 explicit LMathFloor(LOperand* value) {
862 LOperand* value() { return inputs_[0]; }
864 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
865 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
869 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
871 LMathRound(LOperand* value, LOperand* temp) {
876 LOperand* temp() { return temps_[0]; }
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
880 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
884 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
886 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
894 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
896 LMathAbs(LOperand* context, LOperand* value) {
897 inputs_[1] = context;
901 LOperand* context() { return inputs_[1]; }
902 LOperand* value() { return inputs_[0]; }
904 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
905 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
909 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
911 explicit LMathLog(LOperand* value) {
915 LOperand* value() { return inputs_[0]; }
917 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
921 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathClz32(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
933 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
935 LMathExp(LOperand* value,
941 ExternalReference::InitializeMathExpData();
944 LOperand* value() { return inputs_[0]; }
945 LOperand* temp1() { return temps_[0]; }
946 LOperand* temp2() { return temps_[1]; }
948 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
952 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
954 explicit LMathSqrt(LOperand* value) {
958 LOperand* value() { return inputs_[0]; }
960 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
964 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
966 LMathPowHalf(LOperand* value, LOperand* temp) {
971 LOperand* value() { return inputs_[0]; }
972 LOperand* temp() { return temps_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
978 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
980 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
985 LOperand* left() { return inputs_[0]; }
986 LOperand* right() { return inputs_[1]; }
988 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
992 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
994 explicit LCmpHoleAndBranch(LOperand* object) {
998 LOperand* object() { return inputs_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1005 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1007 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1012 LOperand* value() { return inputs_[0]; }
1013 LOperand* temp() { return temps_[0]; }
1015 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1016 "cmp-minus-zero-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1021 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1023 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1028 LOperand* value() { return inputs_[0]; }
1029 LOperand* temp() { return temps_[0]; }
1031 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1033 void PrintDataTo(StringStream* stream) OVERRIDE;
1037 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1039 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1044 LOperand* value() { return inputs_[0]; }
1045 LOperand* temp() { return temps_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1048 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1050 void PrintDataTo(StringStream* stream) OVERRIDE;
1054 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1056 explicit LIsSmiAndBranch(LOperand* value) {
1060 LOperand* value() { return inputs_[0]; }
1062 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1063 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1065 void PrintDataTo(StringStream* stream) OVERRIDE;
1069 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1071 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1076 LOperand* value() { return inputs_[0]; }
1077 LOperand* temp() { return temps_[0]; }
1079 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1080 "is-undetectable-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1083 void PrintDataTo(StringStream* stream) OVERRIDE;
1087 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1089 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1090 inputs_[0] = context;
1095 LOperand* context() { return inputs_[1]; }
1096 LOperand* left() { return inputs_[1]; }
1097 LOperand* right() { return inputs_[2]; }
1099 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1100 "string-compare-and-branch")
1101 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1103 void PrintDataTo(StringStream* stream) OVERRIDE;
1105 Token::Value op() const { return hydrogen()->token(); }
1109 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1111 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1116 LOperand* value() { return inputs_[0]; }
1117 LOperand* temp() { return temps_[0]; }
1119 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1120 "has-instance-type-and-branch")
1121 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1123 void PrintDataTo(StringStream* stream) OVERRIDE;
1127 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1129 explicit LGetCachedArrayIndex(LOperand* value) {
1133 LOperand* value() { return inputs_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1136 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1140 class LHasCachedArrayIndexAndBranch FINAL
1141 : public LControlInstruction<1, 0> {
1143 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1147 LOperand* value() { return inputs_[0]; }
1149 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1150 "has-cached-array-index-and-branch")
1152 void PrintDataTo(StringStream* stream) OVERRIDE;
1156 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1158 explicit LIsConstructCallAndBranch(LOperand* temp) {
1162 LOperand* temp() { return temps_[0]; }
1164 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1165 "is-construct-call-and-branch")
1169 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1171 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1177 LOperand* value() { return inputs_[0]; }
1178 LOperand* temp() { return temps_[0]; }
1179 LOperand* temp2() { return temps_[1]; }
1181 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1182 "class-of-test-and-branch")
1183 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1185 void PrintDataTo(StringStream* stream) OVERRIDE;
1189 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1191 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1192 inputs_[0] = context;
1197 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1198 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1200 LOperand* context() { return inputs_[0]; }
1201 Token::Value op() const { return hydrogen()->token(); }
1205 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1207 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1208 inputs_[0] = context;
1213 LOperand* context() { return inputs_[0]; }
1215 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1219 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1221 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1222 inputs_[0] = context;
1227 LOperand* context() { return inputs_[0]; }
1228 LOperand* value() { return inputs_[1]; }
1229 LOperand* temp() { return temps_[0]; }
1231 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1232 "instance-of-known-global")
1233 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1235 Handle<JSFunction> function() const { return hydrogen()->function(); }
1236 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1237 return lazy_deopt_env_;
1239 virtual void SetDeferredLazyDeoptimizationEnvironment(
1240 LEnvironment* env) OVERRIDE {
1241 lazy_deopt_env_ = env;
1245 LEnvironment* lazy_deopt_env_;
1249 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1251 LBoundsCheck(LOperand* index, LOperand* length) {
1253 inputs_[1] = length;
1256 LOperand* index() { return inputs_[0]; }
1257 LOperand* length() { return inputs_[1]; }
1259 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1260 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1264 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1266 LBitI(LOperand* left, LOperand* right) {
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1274 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1275 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1277 Token::Value op() const { return hydrogen()->op(); }
1281 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1283 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1284 : op_(op), can_deopt_(can_deopt) {
1289 LOperand* left() { return inputs_[0]; }
1290 LOperand* right() { return inputs_[1]; }
1292 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1294 Token::Value op() const { return op_; }
1295 bool can_deopt() const { return can_deopt_; }
1303 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1305 LSubI(LOperand* left, LOperand* right) {
1310 LOperand* left() { return inputs_[0]; }
1311 LOperand* right() { return inputs_[1]; }
1313 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1314 DECLARE_HYDROGEN_ACCESSOR(Sub)
1318 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 int32_t value() const { return hydrogen()->Integer32Value(); }
1327 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1329 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1330 DECLARE_HYDROGEN_ACCESSOR(Constant)
1332 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1336 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1338 explicit LConstantD(LOperand* temp) {
1342 LOperand* temp() { return temps_[0]; }
1344 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1345 DECLARE_HYDROGEN_ACCESSOR(Constant)
1347 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1351 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1353 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1354 DECLARE_HYDROGEN_ACCESSOR(Constant)
1356 ExternalReference value() const {
1357 return hydrogen()->ExternalReferenceValue();
1362 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1364 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1365 DECLARE_HYDROGEN_ACCESSOR(Constant)
1367 Handle<Object> value(Isolate* isolate) const {
1368 return hydrogen()->handle(isolate);
1373 class LBranch FINAL : public LControlInstruction<1, 1> {
1375 LBranch(LOperand* value, LOperand* temp) {
1380 LOperand* value() { return inputs_[0]; }
1381 LOperand* temp() { return temps_[0]; }
1383 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1384 DECLARE_HYDROGEN_ACCESSOR(Branch)
1386 void PrintDataTo(StringStream* stream) OVERRIDE;
1390 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1392 explicit LCmpMapAndBranch(LOperand* value) {
1396 LOperand* value() { return inputs_[0]; }
1398 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1399 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1401 Handle<Map> map() const { return hydrogen()->map().handle(); }
1405 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1407 explicit LMapEnumLength(LOperand* value) {
1411 LOperand* value() { return inputs_[0]; }
1413 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1417 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1419 LDateField(LOperand* date, LOperand* temp, Smi* index)
1425 LOperand* date() { return inputs_[0]; }
1426 LOperand* temp() { return temps_[0]; }
1428 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1429 DECLARE_HYDROGEN_ACCESSOR(DateField)
1431 Smi* index() const { return index_; }
1438 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1440 LSeqStringGetChar(LOperand* string, LOperand* index) {
1441 inputs_[0] = string;
1445 LOperand* string() const { return inputs_[0]; }
1446 LOperand* index() const { return inputs_[1]; }
1448 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1449 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1453 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1455 LSeqStringSetChar(LOperand* context,
1459 inputs_[0] = context;
1460 inputs_[1] = string;
1465 LOperand* string() { return inputs_[1]; }
1466 LOperand* index() { return inputs_[2]; }
1467 LOperand* value() { return inputs_[3]; }
1469 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1470 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1474 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1476 LAddI(LOperand* left, LOperand* right) {
1481 LOperand* left() { return inputs_[0]; }
1482 LOperand* right() { return inputs_[1]; }
1484 static bool UseLea(HAdd* add) {
1485 return !add->CheckFlag(HValue::kCanOverflow) &&
1486 add->BetterLeftOperand()->UseCount() > 1;
1489 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1490 DECLARE_HYDROGEN_ACCESSOR(Add)
1494 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1496 LMathMinMax(LOperand* left, LOperand* right) {
1501 LOperand* left() { return inputs_[0]; }
1502 LOperand* right() { return inputs_[1]; }
1504 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1505 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1509 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1511 LPower(LOperand* left, LOperand* right) {
1516 LOperand* left() { return inputs_[0]; }
1517 LOperand* right() { return inputs_[1]; }
1519 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1520 DECLARE_HYDROGEN_ACCESSOR(Power)
1524 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1526 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1532 LOperand* left() { return inputs_[0]; }
1533 LOperand* right() { return inputs_[1]; }
1535 Token::Value op() const { return op_; }
1537 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1538 void CompileToNative(LCodeGen* generator) OVERRIDE;
1539 const char* Mnemonic() const OVERRIDE;
1546 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1548 LArithmeticT(Token::Value op,
1553 inputs_[0] = context;
1558 LOperand* context() { return inputs_[0]; }
1559 LOperand* left() { return inputs_[1]; }
1560 LOperand* right() { return inputs_[2]; }
1562 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1563 void CompileToNative(LCodeGen* generator) OVERRIDE;
1564 const char* Mnemonic() const OVERRIDE;
1566 Token::Value op() const { return op_; }
1573 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1575 explicit LReturn(LOperand* value,
1577 LOperand* parameter_count) {
1579 inputs_[1] = context;
1580 inputs_[2] = parameter_count;
1583 bool has_constant_parameter_count() {
1584 return parameter_count()->IsConstantOperand();
1586 LConstantOperand* constant_parameter_count() {
1587 DCHECK(has_constant_parameter_count());
1588 return LConstantOperand::cast(parameter_count());
1590 LOperand* parameter_count() { return inputs_[2]; }
1592 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1593 DECLARE_HYDROGEN_ACCESSOR(Return)
1597 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1599 explicit LLoadNamedField(LOperand* object) {
1600 inputs_[0] = object;
1603 LOperand* object() { return inputs_[0]; }
1605 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1606 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1610 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1612 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1613 inputs_[0] = context;
1614 inputs_[1] = object;
1618 LOperand* context() { return inputs_[0]; }
1619 LOperand* object() { return inputs_[1]; }
1620 LOperand* temp_vector() { return temps_[0]; }
1622 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1623 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1625 Handle<Object> name() const { return hydrogen()->name(); }
1629 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1631 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1632 inputs_[0] = function;
1636 LOperand* function() { return inputs_[0]; }
1637 LOperand* temp() { return temps_[0]; }
1639 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1640 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1644 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1646 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1647 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1649 Heap::RootListIndex index() const { return hydrogen()->index(); }
1653 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1655 LLoadKeyed(LOperand* elements, LOperand* key) {
1656 inputs_[0] = elements;
1659 LOperand* elements() { return inputs_[0]; }
1660 LOperand* key() { return inputs_[1]; }
1661 ElementsKind elements_kind() const {
1662 return hydrogen()->elements_kind();
1664 bool is_external() const {
1665 return hydrogen()->is_external();
1667 bool is_fixed_typed_array() const {
1668 return hydrogen()->is_fixed_typed_array();
1670 bool is_typed_elements() const {
1671 return is_external() || is_fixed_typed_array();
1674 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1675 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1677 void PrintDataTo(StringStream* stream) OVERRIDE;
1678 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1680 return hydrogen()->key()->representation().IsTagged();
1685 inline static bool ExternalArrayOpRequiresTemp(
1686 Representation key_representation,
1687 ElementsKind elements_kind) {
1688 // Operations that require the key to be divided by two to be converted into
1689 // an index cannot fold the scale operation into a load and need an extra
1690 // temp register to do the work.
1691 return key_representation.IsSmi() &&
1692 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1693 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1694 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1695 elements_kind == UINT8_ELEMENTS ||
1696 elements_kind == INT8_ELEMENTS ||
1697 elements_kind == UINT8_CLAMPED_ELEMENTS);
1701 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1703 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1705 inputs_[0] = context;
1711 LOperand* context() { return inputs_[0]; }
1712 LOperand* object() { return inputs_[1]; }
1713 LOperand* key() { return inputs_[2]; }
1714 LOperand* temp_vector() { return temps_[0]; }
1716 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1717 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1721 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1723 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1724 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1728 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1730 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1732 inputs_[0] = context;
1733 inputs_[1] = global_object;
1737 LOperand* context() { return inputs_[0]; }
1738 LOperand* global_object() { return inputs_[1]; }
1739 LOperand* temp_vector() { return temps_[0]; }
1741 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1742 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1744 Handle<Object> name() const { return hydrogen()->name(); }
1745 bool for_typeof() const { return hydrogen()->for_typeof(); }
1749 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1751 explicit LStoreGlobalCell(LOperand* value) {
1755 LOperand* value() { return inputs_[0]; }
1757 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1758 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1762 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1764 explicit LLoadContextSlot(LOperand* context) {
1765 inputs_[0] = context;
1768 LOperand* context() { return inputs_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1771 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1773 int slot_index() { return hydrogen()->slot_index(); }
1775 void PrintDataTo(StringStream* stream) OVERRIDE;
1779 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1781 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1782 inputs_[0] = context;
1787 LOperand* context() { return inputs_[0]; }
1788 LOperand* value() { return inputs_[1]; }
1789 LOperand* temp() { return temps_[0]; }
1791 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1792 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1794 int slot_index() { return hydrogen()->slot_index(); }
1796 void PrintDataTo(StringStream* stream) OVERRIDE;
1800 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1802 explicit LPushArgument(LOperand* value) {
1806 LOperand* value() { return inputs_[0]; }
1808 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1812 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1814 explicit LDrop(int count) : count_(count) { }
1816 int count() const { return count_; }
1818 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1825 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1827 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1828 inputs_[0] = function;
1829 inputs_[1] = code_object;
1832 LOperand* function() { return inputs_[0]; }
1833 LOperand* code_object() { return inputs_[1]; }
1835 void PrintDataTo(StringStream* stream) OVERRIDE;
1837 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1838 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1842 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1844 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1845 inputs_[0] = base_object;
1846 inputs_[1] = offset;
1849 LOperand* base_object() const { return inputs_[0]; }
1850 LOperand* offset() const { return inputs_[1]; }
1852 void PrintDataTo(StringStream* stream) OVERRIDE;
1854 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1858 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1860 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1861 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1865 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1867 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1868 DECLARE_HYDROGEN_ACCESSOR(Context)
1872 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1874 explicit LDeclareGlobals(LOperand* context) {
1875 inputs_[0] = context;
1878 LOperand* context() { return inputs_[0]; }
1880 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1881 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1885 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1887 explicit LCallJSFunction(LOperand* function) {
1888 inputs_[0] = function;
1891 LOperand* function() { return inputs_[0]; }
1893 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1894 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1896 void PrintDataTo(StringStream* stream) OVERRIDE;
1898 int arity() const { return hydrogen()->argument_count() - 1; }
1902 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1904 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1905 const ZoneList<LOperand*>& operands, Zone* zone)
1906 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1907 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1908 inputs_.AddAll(operands, zone);
1911 LOperand* target() const { return inputs_[0]; }
1913 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1916 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1918 void PrintDataTo(StringStream* stream) OVERRIDE;
1920 int arity() const { return hydrogen()->argument_count() - 1; }
1922 ZoneList<LOperand*> inputs_;
1924 // Iterator support.
1925 int InputCount() FINAL { return inputs_.length(); }
1926 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1928 int TempCount() FINAL { return 0; }
1929 LOperand* TempAt(int i) FINAL { return NULL; }
1933 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1935 LInvokeFunction(LOperand* context, LOperand* function) {
1936 inputs_[0] = context;
1937 inputs_[1] = function;
1940 LOperand* context() { return inputs_[0]; }
1941 LOperand* function() { return inputs_[1]; }
1943 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1944 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1946 void PrintDataTo(StringStream* stream) OVERRIDE;
1948 int arity() const { return hydrogen()->argument_count() - 1; }
1952 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1954 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1956 inputs_[0] = context;
1957 inputs_[1] = function;
1962 LOperand* context() { return inputs_[0]; }
1963 LOperand* function() { return inputs_[1]; }
1964 LOperand* temp_slot() { return temps_[0]; }
1965 LOperand* temp_vector() { return temps_[1]; }
1967 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1968 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1970 void PrintDataTo(StringStream* stream) OVERRIDE;
1971 int arity() const { return hydrogen()->argument_count() - 1; }
1975 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1977 LCallNew(LOperand* context, LOperand* constructor) {
1978 inputs_[0] = context;
1979 inputs_[1] = constructor;
1982 LOperand* context() { return inputs_[0]; }
1983 LOperand* constructor() { return inputs_[1]; }
1985 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1986 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1988 void PrintDataTo(StringStream* stream) OVERRIDE;
1990 int arity() const { return hydrogen()->argument_count() - 1; }
1994 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1996 LCallNewArray(LOperand* context, LOperand* constructor) {
1997 inputs_[0] = context;
1998 inputs_[1] = constructor;
2001 LOperand* context() { return inputs_[0]; }
2002 LOperand* constructor() { return inputs_[1]; }
2004 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2005 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2007 void PrintDataTo(StringStream* stream) OVERRIDE;
2009 int arity() const { return hydrogen()->argument_count() - 1; }
2013 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2015 explicit LCallRuntime(LOperand* context) {
2016 inputs_[0] = context;
2019 LOperand* context() { return inputs_[0]; }
2021 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2022 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2024 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2025 return save_doubles() == kDontSaveFPRegs;
2028 const Runtime::Function* function() const { return hydrogen()->function(); }
2029 int arity() const { return hydrogen()->argument_count(); }
2030 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2034 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2036 explicit LInteger32ToDouble(LOperand* value) {
2040 LOperand* value() { return inputs_[0]; }
2042 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2046 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2048 explicit LUint32ToDouble(LOperand* value) {
2052 LOperand* value() { return inputs_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2058 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2060 LNumberTagI(LOperand* value, LOperand* temp) {
2065 LOperand* value() { return inputs_[0]; }
2066 LOperand* temp() { return temps_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2072 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2074 LNumberTagU(LOperand* value, LOperand* temp) {
2079 LOperand* value() { return inputs_[0]; }
2080 LOperand* temp() { return temps_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2086 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2088 LNumberTagD(LOperand* value, LOperand* temp) {
2093 LOperand* value() { return inputs_[0]; }
2094 LOperand* temp() { return temps_[0]; }
2096 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2097 DECLARE_HYDROGEN_ACCESSOR(Change)
2101 // Sometimes truncating conversion from a tagged value to an int32.
2102 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 1> {
2104 LDoubleToI(LOperand* value, LOperand* temp) {
2109 LOperand* value() { return inputs_[0]; }
2110 LOperand* temp() { return temps_[0]; }
2112 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2113 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2115 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2119 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2121 explicit LDoubleToSmi(LOperand* value) {
2125 LOperand* value() { return inputs_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2128 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2132 // Truncating conversion from a tagged value to an int32.
2133 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2135 LTaggedToI(LOperand* value, LOperand* temp) {
2140 LOperand* value() { return inputs_[0]; }
2141 LOperand* temp() { return temps_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2144 DECLARE_HYDROGEN_ACCESSOR(Change)
2146 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2150 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2152 explicit LSmiTag(LOperand* value) {
2156 LOperand* value() { return inputs_[0]; }
2158 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2159 DECLARE_HYDROGEN_ACCESSOR(Change)
2163 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2165 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2170 LOperand* value() { return inputs_[0]; }
2171 LOperand* temp() { return temps_[0]; }
2173 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2174 DECLARE_HYDROGEN_ACCESSOR(Change);
2178 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2180 LSmiUntag(LOperand* value, bool needs_check)
2181 : needs_check_(needs_check) {
2185 LOperand* value() { return inputs_[0]; }
2187 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2189 bool needs_check() const { return needs_check_; }
2196 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2198 LStoreNamedField(LOperand* obj,
2201 LOperand* temp_map) {
2205 temps_[1] = temp_map;
2208 LOperand* object() { return inputs_[0]; }
2209 LOperand* value() { return inputs_[1]; }
2210 LOperand* temp() { return temps_[0]; }
2211 LOperand* temp_map() { return temps_[1]; }
2213 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2214 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2216 void PrintDataTo(StringStream* stream) OVERRIDE;
2220 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2222 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2223 inputs_[0] = context;
2224 inputs_[1] = object;
2228 LOperand* context() { return inputs_[0]; }
2229 LOperand* object() { return inputs_[1]; }
2230 LOperand* value() { return inputs_[2]; }
2232 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2233 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2235 void PrintDataTo(StringStream* stream) OVERRIDE;
2236 Handle<Object> name() const { return hydrogen()->name(); }
2237 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2241 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2243 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2249 bool is_external() const { return hydrogen()->is_external(); }
2250 bool is_fixed_typed_array() const {
2251 return hydrogen()->is_fixed_typed_array();
2253 bool is_typed_elements() const {
2254 return is_external() || is_fixed_typed_array();
2256 LOperand* elements() { return inputs_[0]; }
2257 LOperand* key() { return inputs_[1]; }
2258 LOperand* value() { return inputs_[2]; }
2259 ElementsKind elements_kind() const {
2260 return hydrogen()->elements_kind();
2263 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2264 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2266 void PrintDataTo(StringStream* stream) OVERRIDE;
2267 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2268 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2272 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2274 LStoreKeyedGeneric(LOperand* context,
2278 inputs_[0] = context;
2279 inputs_[1] = object;
2284 LOperand* context() { return inputs_[0]; }
2285 LOperand* object() { return inputs_[1]; }
2286 LOperand* key() { return inputs_[2]; }
2287 LOperand* value() { return inputs_[3]; }
2289 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2290 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2292 void PrintDataTo(StringStream* stream) OVERRIDE;
2294 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2298 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2300 LTransitionElementsKind(LOperand* object,
2302 LOperand* new_map_temp,
2304 inputs_[0] = object;
2305 inputs_[1] = context;
2306 temps_[0] = new_map_temp;
2310 LOperand* context() { return inputs_[1]; }
2311 LOperand* object() { return inputs_[0]; }
2312 LOperand* new_map_temp() { return temps_[0]; }
2313 LOperand* temp() { return temps_[1]; }
2315 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2316 "transition-elements-kind")
2317 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2319 void PrintDataTo(StringStream* stream) OVERRIDE;
2321 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2322 Handle<Map> transitioned_map() {
2323 return hydrogen()->transitioned_map().handle();
2325 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2326 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2330 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2332 LTrapAllocationMemento(LOperand* object,
2334 inputs_[0] = object;
2338 LOperand* object() { return inputs_[0]; }
2339 LOperand* temp() { return temps_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2342 "trap-allocation-memento")
2346 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2348 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2349 inputs_[0] = context;
2354 LOperand* context() { return inputs_[0]; }
2355 LOperand* left() { return inputs_[1]; }
2356 LOperand* right() { return inputs_[2]; }
2358 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2359 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2363 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2365 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2366 inputs_[0] = context;
2367 inputs_[1] = string;
2371 LOperand* context() { return inputs_[0]; }
2372 LOperand* string() { return inputs_[1]; }
2373 LOperand* index() { return inputs_[2]; }
2375 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2376 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2380 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2382 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2383 inputs_[0] = context;
2384 inputs_[1] = char_code;
2387 LOperand* context() { return inputs_[0]; }
2388 LOperand* char_code() { return inputs_[1]; }
2390 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2391 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2395 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2397 explicit LCheckValue(LOperand* value) {
2401 LOperand* value() { return inputs_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2404 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2408 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2410 LCheckInstanceType(LOperand* value, LOperand* temp) {
2415 LOperand* value() { return inputs_[0]; }
2416 LOperand* temp() { return temps_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2419 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2423 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2425 explicit LCheckMaps(LOperand* value = NULL) {
2429 LOperand* value() { return inputs_[0]; }
2431 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2432 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2436 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2438 explicit LCheckSmi(LOperand* value) {
2442 LOperand* value() { return inputs_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2448 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2450 explicit LClampDToUint8(LOperand* value) {
2454 LOperand* unclamped() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2460 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2462 explicit LClampIToUint8(LOperand* value) {
2466 LOperand* unclamped() { return inputs_[0]; }
2468 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2472 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2474 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2476 temps_[0] = temp_xmm;
2479 LOperand* unclamped() { return inputs_[0]; }
2480 LOperand* temp_xmm() { return temps_[0]; }
2482 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2486 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2488 explicit LCheckNonSmi(LOperand* value) {
2492 LOperand* value() { return inputs_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2495 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2499 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2501 explicit LDoubleBits(LOperand* value) {
2505 LOperand* value() { return inputs_[0]; }
2507 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2508 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2512 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2514 LConstructDouble(LOperand* hi, LOperand* lo) {
2519 LOperand* hi() { return inputs_[0]; }
2520 LOperand* lo() { return inputs_[1]; }
2522 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2526 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2528 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2529 inputs_[0] = context;
2534 LOperand* context() { return inputs_[0]; }
2535 LOperand* size() { return inputs_[1]; }
2536 LOperand* temp() { return temps_[0]; }
2538 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2539 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2543 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2545 explicit LRegExpLiteral(LOperand* context) {
2546 inputs_[0] = context;
2549 LOperand* context() { return inputs_[0]; }
2551 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2552 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2556 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2558 explicit LFunctionLiteral(LOperand* context) {
2559 inputs_[0] = context;
2562 LOperand* context() { return inputs_[0]; }
2564 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2565 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2569 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2571 explicit LToFastProperties(LOperand* value) {
2575 LOperand* value() { return inputs_[0]; }
2577 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2578 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2582 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2584 LTypeof(LOperand* context, LOperand* value) {
2585 inputs_[0] = context;
2589 LOperand* context() { return inputs_[0]; }
2590 LOperand* value() { return inputs_[1]; }
2592 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2596 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2598 explicit LTypeofIsAndBranch(LOperand* value) {
2602 LOperand* value() { return inputs_[0]; }
2604 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2605 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2607 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2609 void PrintDataTo(StringStream* stream) OVERRIDE;
2613 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2615 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2616 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2620 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2622 explicit LStackCheck(LOperand* context) {
2623 inputs_[0] = context;
2626 LOperand* context() { return inputs_[0]; }
2628 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2629 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2631 Label* done_label() { return &done_label_; }
2638 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2640 LForInPrepareMap(LOperand* context, LOperand* object) {
2641 inputs_[0] = context;
2642 inputs_[1] = object;
2645 LOperand* context() { return inputs_[0]; }
2646 LOperand* object() { return inputs_[1]; }
2648 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2652 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2654 explicit LForInCacheArray(LOperand* map) {
2658 LOperand* map() { return inputs_[0]; }
2660 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2663 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2668 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2670 LCheckMapValue(LOperand* value, LOperand* map) {
2675 LOperand* value() { return inputs_[0]; }
2676 LOperand* map() { return inputs_[1]; }
2678 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2682 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2684 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2685 inputs_[0] = object;
2689 LOperand* object() { return inputs_[0]; }
2690 LOperand* index() { return inputs_[1]; }
2692 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2696 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2698 explicit LStoreFrameContext(LOperand* context) {
2699 inputs_[0] = context;
2702 LOperand* context() { return inputs_[0]; }
2704 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2708 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2710 LAllocateBlockContext(LOperand* context, LOperand* function) {
2711 inputs_[0] = context;
2712 inputs_[1] = function;
2715 LOperand* context() { return inputs_[0]; }
2716 LOperand* function() { return inputs_[1]; }
2718 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2720 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2721 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2725 class LChunkBuilder;
2726 class LPlatformChunk FINAL : public LChunk {
2728 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2729 : LChunk(info, graph),
2730 num_double_slots_(0) { }
2732 int GetNextSpillIndex(RegisterKind kind);
2733 LOperand* GetNextSpillSlot(RegisterKind kind);
2735 int num_double_slots() const { return num_double_slots_; }
2738 int num_double_slots_;
2742 class LChunkBuilder FINAL : public LChunkBuilderBase {
2744 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2745 : LChunkBuilderBase(info, graph),
2746 current_instruction_(NULL),
2747 current_block_(NULL),
2749 allocator_(allocator) {}
2751 // Build the sequence for the graph.
2752 LPlatformChunk* Build();
2754 // Declare methods that deal with the individual node types.
2755 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2756 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2759 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2760 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2761 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2762 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2763 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2764 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2765 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2766 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2767 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2768 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2769 LInstruction* DoDivByConstI(HDiv* instr);
2770 LInstruction* DoDivI(HDiv* instr);
2771 LInstruction* DoModByPowerOf2I(HMod* instr);
2772 LInstruction* DoModByConstI(HMod* instr);
2773 LInstruction* DoModI(HMod* instr);
2774 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2775 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2776 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2779 // Methods for getting operands for Use / Define / Temp.
2780 LUnallocated* ToUnallocated(Register reg);
2781 LUnallocated* ToUnallocated(XMMRegister reg);
2783 // Methods for setting up define-use relationships.
2784 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2785 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2786 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2787 XMMRegister fixed_register);
2789 // A value that is guaranteed to be allocated to a register.
2790 // Operand created by UseRegister is guaranteed to be live until the end of
2791 // instruction. This means that register allocator will not reuse it's
2792 // register for any other operand inside instruction.
2793 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2794 // instruction start. Register allocator is free to assign the same register
2795 // to some other operand used inside instruction (i.e. temporary or
2797 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2798 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2800 // An input operand in a register that may be trashed.
2801 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2803 // An input operand in a register or stack slot.
2804 MUST_USE_RESULT LOperand* Use(HValue* value);
2805 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2807 // An input operand in a register, stack slot or a constant operand.
2808 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2809 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2811 // An input operand in a fixed register or a constant operand.
2812 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2813 Register fixed_register);
2815 // An input operand in a register or a constant operand.
2816 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2817 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2819 // An input operand in a constant operand.
2820 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2822 // An input operand in register, stack slot or a constant operand.
2823 // Will not be moved to a register even if one is freely available.
2824 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2826 // Temporary operand that must be in a register.
2827 MUST_USE_RESULT LUnallocated* TempRegister();
2828 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2829 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2831 // Methods for setting up define-use relationships.
2832 // Return the same instruction that they are passed.
2833 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2834 LUnallocated* result);
2835 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2836 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2838 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2839 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2841 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2843 // Assigns an environment to an instruction. An instruction which can
2844 // deoptimize must have an environment.
2845 LInstruction* AssignEnvironment(LInstruction* instr);
2846 // Assigns a pointer map to an instruction. An instruction which can
2847 // trigger a GC or a lazy deoptimization must have a pointer map.
2848 LInstruction* AssignPointerMap(LInstruction* instr);
2850 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2852 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2854 // Marks a call for the register allocator. Assigns a pointer map to
2855 // support GC and lazy deoptimization. Assigns an environment to support
2856 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2857 LInstruction* MarkAsCall(
2858 LInstruction* instr,
2859 HInstruction* hinstr,
2860 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2862 void VisitInstruction(HInstruction* current);
2863 void AddInstruction(LInstruction* instr, HInstruction* current);
2865 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2866 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2867 LInstruction* DoArithmeticD(Token::Value op,
2868 HArithmeticBinaryOperation* instr);
2869 LInstruction* DoArithmeticT(Token::Value op,
2870 HBinaryOperation* instr);
2872 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2874 HInstruction* current_instruction_;
2875 HBasicBlock* current_block_;
2876 HBasicBlock* next_block_;
2877 LAllocator* allocator_;
2879 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2882 #undef DECLARE_HYDROGEN_ACCESSOR
2883 #undef DECLARE_CONCRETE_INSTRUCTION
2885 } } // namespace v8::internal
2887 #endif // V8_IA32_LITHIUM_IA32_H_