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) \
106 V(LoadGlobalGeneric) \
108 V(LoadKeyedGeneric) \
110 V(LoadNamedGeneric) \
137 V(SeqStringGetChar) \
138 V(SeqStringSetChar) \
144 V(StoreContextSlot) \
145 V(StoreFrameContext) \
147 V(StoreKeyedGeneric) \
149 V(StoreNamedGeneric) \
151 V(StringCharCodeAt) \
152 V(StringCharFromCode) \
153 V(StringCompareAndBranch) \
156 V(TailCallThroughMegamorphicCache) \
158 V(ToFastProperties) \
159 V(TransitionElementsKind) \
160 V(TrapAllocationMemento) \
162 V(TypeofIsAndBranch) \
168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
169 Opcode opcode() const FINAL { return LInstruction::k##type; } \
170 void CompileToNative(LCodeGen* generator) FINAL; \
171 const char* Mnemonic() const FINAL { return mnemonic; } \
172 static L##type* cast(LInstruction* instr) { \
173 DCHECK(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 // Try deleting this instruction if possible.
223 virtual bool TryDelete() { return false; }
225 void set_environment(LEnvironment* env) { environment_ = env; }
226 LEnvironment* environment() const { return environment_; }
227 bool HasEnvironment() const { return environment_ != NULL; }
229 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
230 LPointerMap* pointer_map() const { return pointer_map_.get(); }
231 bool HasPointerMap() const { return pointer_map_.is_set(); }
233 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
234 HValue* hydrogen_value() const { return hydrogen_value_; }
236 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
238 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
239 bool IsCall() const { return IsCallBits::decode(bit_field_); }
241 // Interface to the register allocator and iterators.
242 bool ClobbersTemps() const { return IsCall(); }
243 bool ClobbersRegisters() const { return IsCall(); }
244 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 bool HasDoubleRegisterResult();
252 bool HasDoubleRegisterInput();
254 LOperand* FirstInput() { return InputAt(0); }
255 LOperand* Output() { return HasResult() ? result() : NULL; }
257 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
290 void set_result(LOperand* operand) { results_[0] = operand; }
291 LOperand* result() const OVERRIDE { return results_[0]; }
294 EmbeddedContainer<LOperand*, R> results_;
298 // R = number of result operands (0 or 1).
299 // I = number of input operands.
300 // T = number of temporary operands.
301 template<int R, int I, int T>
302 class LTemplateInstruction : public LTemplateResultInstruction<R> {
304 EmbeddedContainer<LOperand*, I> inputs_;
305 EmbeddedContainer<LOperand*, T> temps_;
309 int InputCount() FINAL { return I; }
310 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
312 int TempCount() FINAL { return T; }
313 LOperand* TempAt(int i) FINAL { return temps_[i]; }
317 class LGap : public LTemplateInstruction<0, 0, 0> {
319 explicit LGap(HBasicBlock* block) : block_(block) {
320 parallel_moves_[BEFORE] = NULL;
321 parallel_moves_[START] = NULL;
322 parallel_moves_[END] = NULL;
323 parallel_moves_[AFTER] = NULL;
326 // Can't use the DECLARE-macro here because of sub-classes.
327 bool IsGap() const FINAL { return true; }
328 void PrintDataTo(StringStream* stream) OVERRIDE;
329 static LGap* cast(LInstruction* instr) {
330 DCHECK(instr->IsGap());
331 return reinterpret_cast<LGap*>(instr);
334 bool IsRedundant() const;
336 HBasicBlock* block() const { return block_; }
343 FIRST_INNER_POSITION = BEFORE,
344 LAST_INNER_POSITION = AFTER
347 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
348 if (parallel_moves_[pos] == NULL) {
349 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap FINAL : public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
369 return !IsRedundant();
372 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
376 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
378 explicit LGoto(HBasicBlock* block) : block_(block) { }
380 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
381 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
382 void PrintDataTo(StringStream* stream) OVERRIDE;
383 bool IsControl() const OVERRIDE { return true; }
385 int block_id() const { return block_->block_id(); }
386 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
390 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
397 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
399 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
403 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
406 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
410 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
412 explicit LDummyUse(LOperand* value) {
415 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
419 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
421 bool IsControl() const OVERRIDE { return true; }
422 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
423 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
427 class LLabel FINAL : public LGap {
429 explicit LLabel(HBasicBlock* block)
430 : LGap(block), replacement_(NULL) { }
432 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
433 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
435 void PrintDataTo(StringStream* stream) OVERRIDE;
437 int block_id() const { return block()->block_id(); }
438 bool is_loop_header() const { return block()->IsLoopHeader(); }
439 bool is_osr_entry() const { return block()->is_osr_entry(); }
440 Label* label() { return &label_; }
441 LLabel* replacement() const { return replacement_; }
442 void set_replacement(LLabel* label) { replacement_ = label; }
443 bool HasReplacement() const { return replacement_ != NULL; }
447 LLabel* replacement_;
451 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
453 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
454 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
458 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
460 explicit LCallStub(LOperand* context) {
461 inputs_[0] = context;
464 LOperand* context() { return inputs_[0]; }
466 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
467 DECLARE_HYDROGEN_ACCESSOR(CallStub)
471 class LTailCallThroughMegamorphicCache FINAL
472 : public LTemplateInstruction<0, 5, 0> {
474 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
475 LOperand* name, LOperand* slot,
477 inputs_[0] = context;
478 inputs_[1] = receiver;
484 LOperand* context() { return inputs_[0]; }
485 LOperand* receiver() { return inputs_[1]; }
486 LOperand* name() { return inputs_[2]; }
487 LOperand* slot() { return inputs_[3]; }
488 LOperand* vector() { return inputs_[4]; }
490 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
491 "tail-call-through-megamorphic-cache")
492 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
496 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
498 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
499 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
503 template<int I, int T>
504 class LControlInstruction: public LTemplateInstruction<0, I, T> {
506 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
508 bool IsControl() const FINAL { return true; }
510 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
511 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
513 int TrueDestination(LChunk* chunk) {
514 return chunk->LookupDestination(true_block_id());
516 int FalseDestination(LChunk* chunk) {
517 return chunk->LookupDestination(false_block_id());
520 Label* TrueLabel(LChunk* chunk) {
521 if (true_label_ == NULL) {
522 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
526 Label* FalseLabel(LChunk* chunk) {
527 if (false_label_ == NULL) {
528 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
534 int true_block_id() { return SuccessorAt(0)->block_id(); }
535 int false_block_id() { return SuccessorAt(1)->block_id(); }
538 HControlInstruction* hydrogen() {
539 return HControlInstruction::cast(this->hydrogen_value());
547 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
549 LWrapReceiver(LOperand* receiver,
552 inputs_[0] = receiver;
553 inputs_[1] = function;
557 LOperand* receiver() { return inputs_[0]; }
558 LOperand* function() { return inputs_[1]; }
559 LOperand* temp() { return temps_[0]; }
561 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
562 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
566 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
568 LApplyArguments(LOperand* function,
571 LOperand* elements) {
572 inputs_[0] = function;
573 inputs_[1] = receiver;
575 inputs_[3] = elements;
578 LOperand* function() { return inputs_[0]; }
579 LOperand* receiver() { return inputs_[1]; }
580 LOperand* length() { return inputs_[2]; }
581 LOperand* elements() { return inputs_[3]; }
583 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
587 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
589 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
590 inputs_[0] = arguments;
595 LOperand* arguments() { return inputs_[0]; }
596 LOperand* length() { return inputs_[1]; }
597 LOperand* index() { return inputs_[2]; }
599 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
601 void PrintDataTo(StringStream* stream) OVERRIDE;
605 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
607 explicit LArgumentsLength(LOperand* elements) {
608 inputs_[0] = elements;
611 LOperand* elements() { return inputs_[0]; }
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
617 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
620 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
624 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
626 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
630 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
632 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
633 inputs_[0] = dividend;
637 LOperand* dividend() { return inputs_[0]; }
638 int32_t divisor() const { return divisor_; }
640 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
641 DECLARE_HYDROGEN_ACCESSOR(Mod)
648 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
650 LModByConstI(LOperand* dividend,
654 inputs_[0] = dividend;
660 LOperand* dividend() { return inputs_[0]; }
661 int32_t divisor() const { return divisor_; }
662 LOperand* temp1() { return temps_[0]; }
663 LOperand* temp2() { return temps_[1]; }
665 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
666 DECLARE_HYDROGEN_ACCESSOR(Mod)
673 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
675 LModI(LOperand* left, LOperand* right, LOperand* temp) {
681 LOperand* left() { return inputs_[0]; }
682 LOperand* right() { return inputs_[1]; }
683 LOperand* temp() { return temps_[0]; }
685 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
686 DECLARE_HYDROGEN_ACCESSOR(Mod)
690 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
692 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
693 inputs_[0] = dividend;
697 LOperand* dividend() { return inputs_[0]; }
698 int32_t divisor() const { return divisor_; }
700 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
701 DECLARE_HYDROGEN_ACCESSOR(Div)
708 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
710 LDivByConstI(LOperand* dividend,
714 inputs_[0] = dividend;
720 LOperand* dividend() { return inputs_[0]; }
721 int32_t divisor() const { return divisor_; }
722 LOperand* temp1() { return temps_[0]; }
723 LOperand* temp2() { return temps_[1]; }
725 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
726 DECLARE_HYDROGEN_ACCESSOR(Div)
733 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
735 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
736 inputs_[0] = dividend;
737 inputs_[1] = divisor;
741 LOperand* dividend() { return inputs_[0]; }
742 LOperand* divisor() { return inputs_[1]; }
743 LOperand* temp() { return temps_[0]; }
745 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
746 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
750 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
752 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
753 inputs_[0] = dividend;
757 LOperand* dividend() { return inputs_[0]; }
758 int32_t divisor() const { return divisor_; }
760 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
761 "flooring-div-by-power-of-2-i")
762 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
769 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
771 LFlooringDivByConstI(LOperand* dividend,
776 inputs_[0] = dividend;
783 LOperand* dividend() { return inputs_[0]; }
784 int32_t divisor() const { return divisor_; }
785 LOperand* temp1() { return temps_[0]; }
786 LOperand* temp2() { return temps_[1]; }
787 LOperand* temp3() { return temps_[2]; }
789 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
790 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
797 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
799 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
800 inputs_[0] = dividend;
801 inputs_[1] = divisor;
805 LOperand* dividend() { return inputs_[0]; }
806 LOperand* divisor() { return inputs_[1]; }
807 LOperand* temp() { return temps_[0]; }
809 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
810 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
814 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
816 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
822 LOperand* left() { return inputs_[0]; }
823 LOperand* right() { return inputs_[1]; }
824 LOperand* temp() { return temps_[0]; }
826 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
827 DECLARE_HYDROGEN_ACCESSOR(Mul)
831 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
833 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
838 LOperand* left() { return inputs_[0]; }
839 LOperand* right() { return inputs_[1]; }
841 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
842 "compare-numeric-and-branch")
843 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
845 Token::Value op() const { return hydrogen()->token(); }
846 bool is_double() const {
847 return hydrogen()->representation().IsDouble();
850 void PrintDataTo(StringStream* stream) OVERRIDE;
854 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
856 explicit LMathFloor(LOperand* value) {
860 LOperand* value() { return inputs_[0]; }
862 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
863 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
867 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
869 LMathRound(LOperand* value, LOperand* temp) {
874 LOperand* temp() { return temps_[0]; }
875 LOperand* value() { return inputs_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
878 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
882 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
884 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
892 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
894 LMathAbs(LOperand* context, LOperand* value) {
895 inputs_[1] = context;
899 LOperand* context() { return inputs_[1]; }
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
903 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
907 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
909 explicit LMathLog(LOperand* value) {
913 LOperand* value() { return inputs_[0]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
919 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathClz32(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
931 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
933 LMathExp(LOperand* value,
939 ExternalReference::InitializeMathExpData();
942 LOperand* value() { return inputs_[0]; }
943 LOperand* temp1() { return temps_[0]; }
944 LOperand* temp2() { return temps_[1]; }
946 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
950 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
952 explicit LMathSqrt(LOperand* value) {
956 LOperand* value() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
962 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
964 LMathPowHalf(LOperand* value, LOperand* temp) {
969 LOperand* value() { return inputs_[0]; }
970 LOperand* temp() { return temps_[0]; }
972 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
976 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
978 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
983 LOperand* left() { return inputs_[0]; }
984 LOperand* right() { return inputs_[1]; }
986 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
990 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
992 explicit LCmpHoleAndBranch(LOperand* object) {
996 LOperand* object() { return inputs_[0]; }
998 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
999 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1003 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1005 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1010 LOperand* value() { return inputs_[0]; }
1011 LOperand* temp() { return temps_[0]; }
1013 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1014 "cmp-minus-zero-and-branch")
1015 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1019 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1021 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1026 LOperand* value() { return inputs_[0]; }
1027 LOperand* temp() { return temps_[0]; }
1029 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1031 void PrintDataTo(StringStream* stream) OVERRIDE;
1035 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1037 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1042 LOperand* value() { return inputs_[0]; }
1043 LOperand* temp() { return temps_[0]; }
1045 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1046 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1048 void PrintDataTo(StringStream* stream) OVERRIDE;
1052 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1054 explicit LIsSmiAndBranch(LOperand* value) {
1058 LOperand* value() { return inputs_[0]; }
1060 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1061 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1063 void PrintDataTo(StringStream* stream) OVERRIDE;
1067 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1069 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1074 LOperand* value() { return inputs_[0]; }
1075 LOperand* temp() { return temps_[0]; }
1077 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1078 "is-undetectable-and-branch")
1079 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1081 void PrintDataTo(StringStream* stream) OVERRIDE;
1085 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1087 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1088 inputs_[0] = context;
1093 LOperand* context() { return inputs_[1]; }
1094 LOperand* left() { return inputs_[1]; }
1095 LOperand* right() { return inputs_[2]; }
1097 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1098 "string-compare-and-branch")
1099 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1101 void PrintDataTo(StringStream* stream) OVERRIDE;
1103 Token::Value op() const { return hydrogen()->token(); }
1107 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1109 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1114 LOperand* value() { return inputs_[0]; }
1115 LOperand* temp() { return temps_[0]; }
1117 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1118 "has-instance-type-and-branch")
1119 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1121 void PrintDataTo(StringStream* stream) OVERRIDE;
1125 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1127 explicit LGetCachedArrayIndex(LOperand* value) {
1131 LOperand* value() { return inputs_[0]; }
1133 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1134 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1138 class LHasCachedArrayIndexAndBranch FINAL
1139 : public LControlInstruction<1, 0> {
1141 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1145 LOperand* value() { return inputs_[0]; }
1147 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1148 "has-cached-array-index-and-branch")
1150 void PrintDataTo(StringStream* stream) OVERRIDE;
1154 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1156 explicit LIsConstructCallAndBranch(LOperand* temp) {
1160 LOperand* temp() { return temps_[0]; }
1162 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1163 "is-construct-call-and-branch")
1167 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1169 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1175 LOperand* value() { return inputs_[0]; }
1176 LOperand* temp() { return temps_[0]; }
1177 LOperand* temp2() { return temps_[1]; }
1179 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1180 "class-of-test-and-branch")
1181 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1183 void PrintDataTo(StringStream* stream) OVERRIDE;
1187 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1189 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1190 inputs_[0] = context;
1195 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1196 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1198 LOperand* context() { return inputs_[0]; }
1199 Token::Value op() const { return hydrogen()->token(); }
1203 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1205 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1206 inputs_[0] = context;
1211 LOperand* context() { return inputs_[0]; }
1213 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1217 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1219 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1220 inputs_[0] = context;
1225 LOperand* context() { return inputs_[0]; }
1226 LOperand* value() { return inputs_[1]; }
1227 LOperand* temp() { return temps_[0]; }
1229 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1230 "instance-of-known-global")
1231 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1233 Handle<JSFunction> function() const { return hydrogen()->function(); }
1234 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1235 return lazy_deopt_env_;
1237 virtual void SetDeferredLazyDeoptimizationEnvironment(
1238 LEnvironment* env) OVERRIDE {
1239 lazy_deopt_env_ = env;
1243 LEnvironment* lazy_deopt_env_;
1247 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1249 LBoundsCheck(LOperand* index, LOperand* length) {
1251 inputs_[1] = length;
1254 LOperand* index() { return inputs_[0]; }
1255 LOperand* length() { return inputs_[1]; }
1257 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1258 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1262 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1264 LBitI(LOperand* left, LOperand* right) {
1269 LOperand* left() { return inputs_[0]; }
1270 LOperand* right() { return inputs_[1]; }
1272 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1273 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1275 Token::Value op() const { return hydrogen()->op(); }
1279 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1281 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1282 : op_(op), can_deopt_(can_deopt) {
1287 LOperand* left() { return inputs_[0]; }
1288 LOperand* right() { return inputs_[1]; }
1290 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1292 Token::Value op() const { return op_; }
1293 bool can_deopt() const { return can_deopt_; }
1301 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1303 LSubI(LOperand* left, LOperand* right) {
1308 LOperand* left() { return inputs_[0]; }
1309 LOperand* right() { return inputs_[1]; }
1311 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1312 DECLARE_HYDROGEN_ACCESSOR(Sub)
1316 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1318 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1319 DECLARE_HYDROGEN_ACCESSOR(Constant)
1321 int32_t value() const { return hydrogen()->Integer32Value(); }
1325 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1334 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1336 explicit LConstantD(LOperand* temp) {
1340 LOperand* temp() { return temps_[0]; }
1342 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1343 DECLARE_HYDROGEN_ACCESSOR(Constant)
1345 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1349 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1351 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1352 DECLARE_HYDROGEN_ACCESSOR(Constant)
1354 ExternalReference value() const {
1355 return hydrogen()->ExternalReferenceValue();
1360 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1362 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1363 DECLARE_HYDROGEN_ACCESSOR(Constant)
1365 Handle<Object> value(Isolate* isolate) const {
1366 return hydrogen()->handle(isolate);
1371 class LBranch FINAL : public LControlInstruction<1, 1> {
1373 LBranch(LOperand* value, LOperand* temp) {
1378 LOperand* value() { return inputs_[0]; }
1379 LOperand* temp() { return temps_[0]; }
1381 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1382 DECLARE_HYDROGEN_ACCESSOR(Branch)
1384 void PrintDataTo(StringStream* stream) OVERRIDE;
1388 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1390 explicit LCmpMapAndBranch(LOperand* value) {
1394 LOperand* value() { return inputs_[0]; }
1396 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1397 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1399 Handle<Map> map() const { return hydrogen()->map().handle(); }
1403 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1405 explicit LMapEnumLength(LOperand* value) {
1409 LOperand* value() { return inputs_[0]; }
1411 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1415 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1417 LDateField(LOperand* date, LOperand* temp, Smi* index)
1423 LOperand* date() { return inputs_[0]; }
1424 LOperand* temp() { return temps_[0]; }
1426 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1427 DECLARE_HYDROGEN_ACCESSOR(DateField)
1429 Smi* index() const { return index_; }
1436 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1438 LSeqStringGetChar(LOperand* string, LOperand* index) {
1439 inputs_[0] = string;
1443 LOperand* string() const { return inputs_[0]; }
1444 LOperand* index() const { return inputs_[1]; }
1446 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1447 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1451 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1453 LSeqStringSetChar(LOperand* context,
1457 inputs_[0] = context;
1458 inputs_[1] = string;
1463 LOperand* string() { return inputs_[1]; }
1464 LOperand* index() { return inputs_[2]; }
1465 LOperand* value() { return inputs_[3]; }
1467 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1468 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1472 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1474 LAddI(LOperand* left, LOperand* right) {
1479 LOperand* left() { return inputs_[0]; }
1480 LOperand* right() { return inputs_[1]; }
1482 static bool UseLea(HAdd* add) {
1483 return !add->CheckFlag(HValue::kCanOverflow) &&
1484 add->BetterLeftOperand()->UseCount() > 1;
1487 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1488 DECLARE_HYDROGEN_ACCESSOR(Add)
1492 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1494 LMathMinMax(LOperand* left, LOperand* right) {
1499 LOperand* left() { return inputs_[0]; }
1500 LOperand* right() { return inputs_[1]; }
1502 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1503 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1507 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1509 LPower(LOperand* left, LOperand* right) {
1514 LOperand* left() { return inputs_[0]; }
1515 LOperand* right() { return inputs_[1]; }
1517 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1518 DECLARE_HYDROGEN_ACCESSOR(Power)
1522 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1524 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1530 LOperand* left() { return inputs_[0]; }
1531 LOperand* right() { return inputs_[1]; }
1533 Token::Value op() const { return op_; }
1535 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1536 void CompileToNative(LCodeGen* generator) OVERRIDE;
1537 const char* Mnemonic() const OVERRIDE;
1544 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1546 LArithmeticT(Token::Value op,
1551 inputs_[0] = context;
1556 LOperand* context() { return inputs_[0]; }
1557 LOperand* left() { return inputs_[1]; }
1558 LOperand* right() { return inputs_[2]; }
1560 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1561 void CompileToNative(LCodeGen* generator) OVERRIDE;
1562 const char* Mnemonic() const OVERRIDE;
1564 Token::Value op() const { return op_; }
1571 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1573 explicit LReturn(LOperand* value,
1575 LOperand* parameter_count) {
1577 inputs_[1] = context;
1578 inputs_[2] = parameter_count;
1581 bool has_constant_parameter_count() {
1582 return parameter_count()->IsConstantOperand();
1584 LConstantOperand* constant_parameter_count() {
1585 DCHECK(has_constant_parameter_count());
1586 return LConstantOperand::cast(parameter_count());
1588 LOperand* parameter_count() { return inputs_[2]; }
1590 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1591 DECLARE_HYDROGEN_ACCESSOR(Return)
1595 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1597 explicit LLoadNamedField(LOperand* object) {
1598 inputs_[0] = object;
1601 LOperand* object() { return inputs_[0]; }
1603 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1604 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1608 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1610 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1611 inputs_[0] = context;
1612 inputs_[1] = object;
1616 LOperand* context() { return inputs_[0]; }
1617 LOperand* object() { return inputs_[1]; }
1618 LOperand* temp_vector() { return temps_[0]; }
1620 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1621 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1623 Handle<Object> name() const { return hydrogen()->name(); }
1627 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1629 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1630 inputs_[0] = function;
1634 LOperand* function() { return inputs_[0]; }
1635 LOperand* temp() { return temps_[0]; }
1637 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1638 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1642 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1644 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1645 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1647 Heap::RootListIndex index() const { return hydrogen()->index(); }
1651 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1653 LLoadKeyed(LOperand* elements, LOperand* key) {
1654 inputs_[0] = elements;
1657 LOperand* elements() { return inputs_[0]; }
1658 LOperand* key() { return inputs_[1]; }
1659 ElementsKind elements_kind() const {
1660 return hydrogen()->elements_kind();
1662 bool is_external() const {
1663 return hydrogen()->is_external();
1665 bool is_fixed_typed_array() const {
1666 return hydrogen()->is_fixed_typed_array();
1668 bool is_typed_elements() const {
1669 return is_external() || is_fixed_typed_array();
1672 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1673 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1675 void PrintDataTo(StringStream* stream) OVERRIDE;
1676 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1678 return hydrogen()->key()->representation().IsTagged();
1683 inline static bool ExternalArrayOpRequiresTemp(
1684 Representation key_representation,
1685 ElementsKind elements_kind) {
1686 // Operations that require the key to be divided by two to be converted into
1687 // an index cannot fold the scale operation into a load and need an extra
1688 // temp register to do the work.
1689 return key_representation.IsSmi() &&
1690 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1691 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1692 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1693 elements_kind == UINT8_ELEMENTS ||
1694 elements_kind == INT8_ELEMENTS ||
1695 elements_kind == UINT8_CLAMPED_ELEMENTS);
1699 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1701 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1703 inputs_[0] = context;
1709 LOperand* context() { return inputs_[0]; }
1710 LOperand* object() { return inputs_[1]; }
1711 LOperand* key() { return inputs_[2]; }
1712 LOperand* temp_vector() { return temps_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1715 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1719 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1721 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1723 inputs_[0] = context;
1724 inputs_[1] = global_object;
1728 LOperand* context() { return inputs_[0]; }
1729 LOperand* global_object() { return inputs_[1]; }
1730 LOperand* temp_vector() { return temps_[0]; }
1732 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1733 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1735 Handle<Object> name() const { return hydrogen()->name(); }
1736 bool for_typeof() const { return hydrogen()->for_typeof(); }
1740 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1742 explicit LLoadContextSlot(LOperand* context) {
1743 inputs_[0] = context;
1746 LOperand* context() { return inputs_[0]; }
1748 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1749 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1751 int slot_index() { return hydrogen()->slot_index(); }
1753 void PrintDataTo(StringStream* stream) OVERRIDE;
1757 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1759 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1760 inputs_[0] = context;
1765 LOperand* context() { return inputs_[0]; }
1766 LOperand* value() { return inputs_[1]; }
1767 LOperand* temp() { return temps_[0]; }
1769 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1770 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1772 int slot_index() { return hydrogen()->slot_index(); }
1774 void PrintDataTo(StringStream* stream) OVERRIDE;
1778 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1780 explicit LPushArgument(LOperand* value) {
1784 LOperand* value() { return inputs_[0]; }
1786 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1790 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1792 explicit LDrop(int count) : count_(count) { }
1794 int count() const { return count_; }
1796 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1803 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1805 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1806 inputs_[0] = function;
1807 inputs_[1] = code_object;
1810 LOperand* function() { return inputs_[0]; }
1811 LOperand* code_object() { return inputs_[1]; }
1813 void PrintDataTo(StringStream* stream) OVERRIDE;
1815 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1816 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1820 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1822 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1823 inputs_[0] = base_object;
1824 inputs_[1] = offset;
1827 LOperand* base_object() const { return inputs_[0]; }
1828 LOperand* offset() const { return inputs_[1]; }
1830 void PrintDataTo(StringStream* stream) OVERRIDE;
1832 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1836 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1838 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1839 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1843 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1845 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1846 DECLARE_HYDROGEN_ACCESSOR(Context)
1850 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1852 explicit LDeclareGlobals(LOperand* context) {
1853 inputs_[0] = context;
1856 LOperand* context() { return inputs_[0]; }
1858 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1859 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1863 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1865 explicit LCallJSFunction(LOperand* function) {
1866 inputs_[0] = function;
1869 LOperand* function() { return inputs_[0]; }
1871 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1872 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1874 void PrintDataTo(StringStream* stream) OVERRIDE;
1876 int arity() const { return hydrogen()->argument_count() - 1; }
1880 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1882 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1883 const ZoneList<LOperand*>& operands, Zone* zone)
1884 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1885 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1886 inputs_.AddAll(operands, zone);
1889 LOperand* target() const { return inputs_[0]; }
1891 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1894 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1896 void PrintDataTo(StringStream* stream) OVERRIDE;
1898 int arity() const { return hydrogen()->argument_count() - 1; }
1900 ZoneList<LOperand*> inputs_;
1902 // Iterator support.
1903 int InputCount() FINAL { return inputs_.length(); }
1904 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1906 int TempCount() FINAL { return 0; }
1907 LOperand* TempAt(int i) FINAL { return NULL; }
1911 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1913 LInvokeFunction(LOperand* context, LOperand* function) {
1914 inputs_[0] = context;
1915 inputs_[1] = function;
1918 LOperand* context() { return inputs_[0]; }
1919 LOperand* function() { return inputs_[1]; }
1921 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1922 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1924 void PrintDataTo(StringStream* stream) OVERRIDE;
1926 int arity() const { return hydrogen()->argument_count() - 1; }
1930 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1932 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1934 inputs_[0] = context;
1935 inputs_[1] = function;
1940 LOperand* context() { return inputs_[0]; }
1941 LOperand* function() { return inputs_[1]; }
1942 LOperand* temp_slot() { return temps_[0]; }
1943 LOperand* temp_vector() { return temps_[1]; }
1945 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1946 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1948 void PrintDataTo(StringStream* stream) OVERRIDE;
1949 int arity() const { return hydrogen()->argument_count() - 1; }
1953 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1955 LCallNew(LOperand* context, LOperand* constructor) {
1956 inputs_[0] = context;
1957 inputs_[1] = constructor;
1960 LOperand* context() { return inputs_[0]; }
1961 LOperand* constructor() { return inputs_[1]; }
1963 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1964 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1966 void PrintDataTo(StringStream* stream) OVERRIDE;
1968 int arity() const { return hydrogen()->argument_count() - 1; }
1972 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1974 LCallNewArray(LOperand* context, LOperand* constructor) {
1975 inputs_[0] = context;
1976 inputs_[1] = constructor;
1979 LOperand* context() { return inputs_[0]; }
1980 LOperand* constructor() { return inputs_[1]; }
1982 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1983 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1985 void PrintDataTo(StringStream* stream) OVERRIDE;
1987 int arity() const { return hydrogen()->argument_count() - 1; }
1991 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1993 explicit LCallRuntime(LOperand* context) {
1994 inputs_[0] = context;
1997 LOperand* context() { return inputs_[0]; }
1999 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2000 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2002 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2003 return save_doubles() == kDontSaveFPRegs;
2006 const Runtime::Function* function() const { return hydrogen()->function(); }
2007 int arity() const { return hydrogen()->argument_count(); }
2008 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2012 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2014 explicit LInteger32ToDouble(LOperand* value) {
2018 LOperand* value() { return inputs_[0]; }
2020 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2024 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2026 explicit LUint32ToDouble(LOperand* value) {
2030 LOperand* value() { return inputs_[0]; }
2032 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2036 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2038 LNumberTagI(LOperand* value, LOperand* temp) {
2043 LOperand* value() { return inputs_[0]; }
2044 LOperand* temp() { return temps_[0]; }
2046 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2050 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2052 LNumberTagU(LOperand* value, LOperand* temp) {
2057 LOperand* value() { return inputs_[0]; }
2058 LOperand* temp() { return temps_[0]; }
2060 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2064 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2066 LNumberTagD(LOperand* value, LOperand* temp) {
2071 LOperand* value() { return inputs_[0]; }
2072 LOperand* temp() { return temps_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2075 DECLARE_HYDROGEN_ACCESSOR(Change)
2079 // Sometimes truncating conversion from a tagged value to an int32.
2080 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 1> {
2082 LDoubleToI(LOperand* value, LOperand* temp) {
2087 LOperand* value() { return inputs_[0]; }
2088 LOperand* temp() { return temps_[0]; }
2090 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2091 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2093 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2097 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2099 explicit LDoubleToSmi(LOperand* value) {
2103 LOperand* value() { return inputs_[0]; }
2105 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2106 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2110 // Truncating conversion from a tagged value to an int32.
2111 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2113 LTaggedToI(LOperand* value, LOperand* temp) {
2118 LOperand* value() { return inputs_[0]; }
2119 LOperand* temp() { return temps_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2122 DECLARE_HYDROGEN_ACCESSOR(Change)
2124 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2128 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2130 explicit LSmiTag(LOperand* value) {
2134 LOperand* value() { return inputs_[0]; }
2136 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2137 DECLARE_HYDROGEN_ACCESSOR(Change)
2141 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2143 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2148 LOperand* value() { return inputs_[0]; }
2149 LOperand* temp() { return temps_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2152 DECLARE_HYDROGEN_ACCESSOR(Change);
2156 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2158 LSmiUntag(LOperand* value, bool needs_check)
2159 : needs_check_(needs_check) {
2163 LOperand* value() { return inputs_[0]; }
2165 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2167 bool needs_check() const { return needs_check_; }
2174 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2176 LStoreNamedField(LOperand* obj,
2179 LOperand* temp_map) {
2183 temps_[1] = temp_map;
2186 LOperand* object() { return inputs_[0]; }
2187 LOperand* value() { return inputs_[1]; }
2188 LOperand* temp() { return temps_[0]; }
2189 LOperand* temp_map() { return temps_[1]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2192 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2194 void PrintDataTo(StringStream* stream) OVERRIDE;
2198 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2200 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2201 inputs_[0] = context;
2202 inputs_[1] = object;
2206 LOperand* context() { return inputs_[0]; }
2207 LOperand* object() { return inputs_[1]; }
2208 LOperand* value() { return inputs_[2]; }
2210 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2211 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2213 void PrintDataTo(StringStream* stream) OVERRIDE;
2214 Handle<Object> name() const { return hydrogen()->name(); }
2215 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2219 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2221 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2227 bool is_external() const { return hydrogen()->is_external(); }
2228 bool is_fixed_typed_array() const {
2229 return hydrogen()->is_fixed_typed_array();
2231 bool is_typed_elements() const {
2232 return is_external() || is_fixed_typed_array();
2234 LOperand* elements() { return inputs_[0]; }
2235 LOperand* key() { return inputs_[1]; }
2236 LOperand* value() { return inputs_[2]; }
2237 ElementsKind elements_kind() const {
2238 return hydrogen()->elements_kind();
2241 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2242 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2244 void PrintDataTo(StringStream* stream) OVERRIDE;
2245 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2246 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2250 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2252 LStoreKeyedGeneric(LOperand* context,
2256 inputs_[0] = context;
2257 inputs_[1] = object;
2262 LOperand* context() { return inputs_[0]; }
2263 LOperand* object() { return inputs_[1]; }
2264 LOperand* key() { return inputs_[2]; }
2265 LOperand* value() { return inputs_[3]; }
2267 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2268 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2270 void PrintDataTo(StringStream* stream) OVERRIDE;
2272 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2276 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2278 LTransitionElementsKind(LOperand* object,
2280 LOperand* new_map_temp,
2282 inputs_[0] = object;
2283 inputs_[1] = context;
2284 temps_[0] = new_map_temp;
2288 LOperand* context() { return inputs_[1]; }
2289 LOperand* object() { return inputs_[0]; }
2290 LOperand* new_map_temp() { return temps_[0]; }
2291 LOperand* temp() { return temps_[1]; }
2293 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2294 "transition-elements-kind")
2295 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2297 void PrintDataTo(StringStream* stream) OVERRIDE;
2299 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2300 Handle<Map> transitioned_map() {
2301 return hydrogen()->transitioned_map().handle();
2303 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2304 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2308 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2310 LTrapAllocationMemento(LOperand* object,
2312 inputs_[0] = object;
2316 LOperand* object() { return inputs_[0]; }
2317 LOperand* temp() { return temps_[0]; }
2319 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2320 "trap-allocation-memento")
2324 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2326 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2327 inputs_[0] = context;
2332 LOperand* context() { return inputs_[0]; }
2333 LOperand* left() { return inputs_[1]; }
2334 LOperand* right() { return inputs_[2]; }
2336 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2337 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2341 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2343 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2344 inputs_[0] = context;
2345 inputs_[1] = string;
2349 LOperand* context() { return inputs_[0]; }
2350 LOperand* string() { return inputs_[1]; }
2351 LOperand* index() { return inputs_[2]; }
2353 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2354 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2358 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2360 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2361 inputs_[0] = context;
2362 inputs_[1] = char_code;
2365 LOperand* context() { return inputs_[0]; }
2366 LOperand* char_code() { return inputs_[1]; }
2368 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2369 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2373 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2375 explicit LCheckValue(LOperand* value) {
2379 LOperand* value() { return inputs_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2382 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2386 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2388 LCheckInstanceType(LOperand* value, LOperand* temp) {
2393 LOperand* value() { return inputs_[0]; }
2394 LOperand* temp() { return temps_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2397 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2401 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2403 explicit LCheckMaps(LOperand* value = NULL) {
2407 LOperand* value() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2410 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2414 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2416 explicit LCheckSmi(LOperand* value) {
2420 LOperand* value() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2426 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2428 explicit LClampDToUint8(LOperand* value) {
2432 LOperand* unclamped() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2438 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2440 explicit LClampIToUint8(LOperand* value) {
2444 LOperand* unclamped() { return inputs_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2450 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2452 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2454 temps_[0] = temp_xmm;
2457 LOperand* unclamped() { return inputs_[0]; }
2458 LOperand* temp_xmm() { return temps_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2464 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2466 explicit LCheckNonSmi(LOperand* value) {
2470 LOperand* value() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2473 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2477 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2479 explicit LDoubleBits(LOperand* value) {
2483 LOperand* value() { return inputs_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2486 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2490 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2492 LConstructDouble(LOperand* hi, LOperand* lo) {
2497 LOperand* hi() { return inputs_[0]; }
2498 LOperand* lo() { return inputs_[1]; }
2500 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2504 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2506 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2507 inputs_[0] = context;
2512 LOperand* context() { return inputs_[0]; }
2513 LOperand* size() { return inputs_[1]; }
2514 LOperand* temp() { return temps_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2517 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2521 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2523 explicit LRegExpLiteral(LOperand* context) {
2524 inputs_[0] = context;
2527 LOperand* context() { return inputs_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2530 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2534 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2536 explicit LFunctionLiteral(LOperand* context) {
2537 inputs_[0] = context;
2540 LOperand* context() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2543 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2547 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2549 explicit LToFastProperties(LOperand* value) {
2553 LOperand* value() { return inputs_[0]; }
2555 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2556 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2560 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2562 LTypeof(LOperand* context, LOperand* value) {
2563 inputs_[0] = context;
2567 LOperand* context() { return inputs_[0]; }
2568 LOperand* value() { return inputs_[1]; }
2570 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2574 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2576 explicit LTypeofIsAndBranch(LOperand* value) {
2580 LOperand* value() { return inputs_[0]; }
2582 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2583 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2585 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2587 void PrintDataTo(StringStream* stream) OVERRIDE;
2591 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2593 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2594 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2598 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2600 explicit LStackCheck(LOperand* context) {
2601 inputs_[0] = context;
2604 LOperand* context() { return inputs_[0]; }
2606 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2607 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2609 Label* done_label() { return &done_label_; }
2616 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2618 LForInPrepareMap(LOperand* context, LOperand* object) {
2619 inputs_[0] = context;
2620 inputs_[1] = object;
2623 LOperand* context() { return inputs_[0]; }
2624 LOperand* object() { return inputs_[1]; }
2626 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2630 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2632 explicit LForInCacheArray(LOperand* map) {
2636 LOperand* map() { return inputs_[0]; }
2638 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2641 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2646 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2648 LCheckMapValue(LOperand* value, LOperand* map) {
2653 LOperand* value() { return inputs_[0]; }
2654 LOperand* map() { return inputs_[1]; }
2656 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2660 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2662 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2663 inputs_[0] = object;
2667 LOperand* object() { return inputs_[0]; }
2668 LOperand* index() { return inputs_[1]; }
2670 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2674 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2676 explicit LStoreFrameContext(LOperand* context) {
2677 inputs_[0] = context;
2680 LOperand* context() { return inputs_[0]; }
2682 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2686 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2688 LAllocateBlockContext(LOperand* context, LOperand* function) {
2689 inputs_[0] = context;
2690 inputs_[1] = function;
2693 LOperand* context() { return inputs_[0]; }
2694 LOperand* function() { return inputs_[1]; }
2696 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2698 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2699 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2703 class LChunkBuilder;
2704 class LPlatformChunk FINAL : public LChunk {
2706 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2707 : LChunk(info, graph),
2708 num_double_slots_(0) { }
2710 int GetNextSpillIndex(RegisterKind kind);
2711 LOperand* GetNextSpillSlot(RegisterKind kind);
2713 int num_double_slots() const { return num_double_slots_; }
2716 int num_double_slots_;
2720 class LChunkBuilder FINAL : public LChunkBuilderBase {
2722 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2723 : LChunkBuilderBase(info, graph),
2724 current_instruction_(NULL),
2725 current_block_(NULL),
2727 allocator_(allocator) {}
2729 // Build the sequence for the graph.
2730 LPlatformChunk* Build();
2732 // Declare methods that deal with the individual node types.
2733 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2734 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2737 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2738 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2739 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2740 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2741 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2742 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2743 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2744 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2745 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2746 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2747 LInstruction* DoDivByConstI(HDiv* instr);
2748 LInstruction* DoDivI(HDiv* instr);
2749 LInstruction* DoModByPowerOf2I(HMod* instr);
2750 LInstruction* DoModByConstI(HMod* instr);
2751 LInstruction* DoModI(HMod* instr);
2752 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2753 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2754 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2757 // Methods for getting operands for Use / Define / Temp.
2758 LUnallocated* ToUnallocated(Register reg);
2759 LUnallocated* ToUnallocated(XMMRegister reg);
2761 // Methods for setting up define-use relationships.
2762 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2763 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2764 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2765 XMMRegister fixed_register);
2767 // A value that is guaranteed to be allocated to a register.
2768 // Operand created by UseRegister is guaranteed to be live until the end of
2769 // instruction. This means that register allocator will not reuse it's
2770 // register for any other operand inside instruction.
2771 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2772 // instruction start. Register allocator is free to assign the same register
2773 // to some other operand used inside instruction (i.e. temporary or
2775 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2776 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2778 // An input operand in a register that may be trashed.
2779 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2781 // An input operand in a register or stack slot.
2782 MUST_USE_RESULT LOperand* Use(HValue* value);
2783 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2785 // An input operand in a register, stack slot or a constant operand.
2786 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2787 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2789 // An input operand in a fixed register or a constant operand.
2790 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2791 Register fixed_register);
2793 // An input operand in a register or a constant operand.
2794 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2795 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2797 // An input operand in a constant operand.
2798 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2800 // An input operand in register, stack slot or a constant operand.
2801 // Will not be moved to a register even if one is freely available.
2802 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2804 // Temporary operand that must be in a register.
2805 MUST_USE_RESULT LUnallocated* TempRegister();
2806 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2807 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2809 // Methods for setting up define-use relationships.
2810 // Return the same instruction that they are passed.
2811 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2812 LUnallocated* result);
2813 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2814 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2816 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2817 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2819 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2821 // Assigns an environment to an instruction. An instruction which can
2822 // deoptimize must have an environment.
2823 LInstruction* AssignEnvironment(LInstruction* instr);
2824 // Assigns a pointer map to an instruction. An instruction which can
2825 // trigger a GC or a lazy deoptimization must have a pointer map.
2826 LInstruction* AssignPointerMap(LInstruction* instr);
2828 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2830 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2832 // Marks a call for the register allocator. Assigns a pointer map to
2833 // support GC and lazy deoptimization. Assigns an environment to support
2834 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2835 LInstruction* MarkAsCall(
2836 LInstruction* instr,
2837 HInstruction* hinstr,
2838 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2840 void VisitInstruction(HInstruction* current);
2841 void AddInstruction(LInstruction* instr, HInstruction* current);
2843 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2844 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2845 LInstruction* DoArithmeticD(Token::Value op,
2846 HArithmeticBinaryOperation* instr);
2847 LInstruction* DoArithmeticT(Token::Value op,
2848 HBinaryOperation* instr);
2850 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2852 HInstruction* current_instruction_;
2853 HBasicBlock* current_block_;
2854 HBasicBlock* next_block_;
2855 LAllocator* allocator_;
2857 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2860 #undef DECLARE_HYDROGEN_ACCESSOR
2861 #undef DECLARE_CONCRETE_INSTRUCTION
2863 } } // namespace v8::internal
2865 #endif // V8_IA32_LITHIUM_IA32_H_