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-allocator.h"
10 #include "src/lithium.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
23 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
100 V(LoadFieldByIndex) \
101 V(LoadFunctionPrototype) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
166 return LInstruction::k##type; \
168 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
169 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
172 static L##type* cast(LInstruction* instr) { \
173 ASSERT(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)
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 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
235 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
236 bool IsCall() const { return IsCallBits::decode(bit_field_); }
238 // Interface to the register allocator and iterators.
239 bool ClobbersTemps() const { return IsCall(); }
240 bool ClobbersRegisters() const { return IsCall(); }
241 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
245 virtual bool HasResult() const = 0;
246 virtual LOperand* result() const = 0;
248 bool HasDoubleRegisterResult();
249 bool HasDoubleRegisterInput();
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
262 friend class InputIterator;
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
266 friend class TempIterator;
267 virtual int TempCount() = 0;
268 virtual LOperand* TempAt(int i) = 0;
270 class IsCallBits: public BitField<bool, 0, 1> {};
272 LEnvironment* environment_;
273 SetOncePointer<LPointerMap> pointer_map_;
274 HValue* hydrogen_value_;
279 // R = number of result operands (0 or 1).
281 class LTemplateResultInstruction : public LInstruction {
283 // Allow 0 or 1 output operands.
284 STATIC_ASSERT(R == 0 || R == 1);
285 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
286 return R != 0 && result() != NULL;
288 void set_result(LOperand* operand) { results_[0] = operand; }
289 LOperand* result() const { return results_[0]; }
292 EmbeddedContainer<LOperand*, R> results_;
296 // R = number of result operands (0 or 1).
297 // I = number of input operands.
298 // T = number of temporary operands.
299 template<int R, int I, int T>
300 class LTemplateInstruction : public LTemplateResultInstruction<R> {
302 EmbeddedContainer<LOperand*, I> inputs_;
303 EmbeddedContainer<LOperand*, T> temps_;
307 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
308 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
310 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
311 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
315 class LGap : public LTemplateInstruction<0, 0, 0> {
317 explicit LGap(HBasicBlock* block) : block_(block) {
318 parallel_moves_[BEFORE] = NULL;
319 parallel_moves_[START] = NULL;
320 parallel_moves_[END] = NULL;
321 parallel_moves_[AFTER] = NULL;
324 // Can't use the DECLARE-macro here because of sub-classes.
325 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
326 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
327 static LGap* cast(LInstruction* instr) {
328 ASSERT(instr->IsGap());
329 return reinterpret_cast<LGap*>(instr);
332 bool IsRedundant() const;
334 HBasicBlock* block() const { return block_; }
341 FIRST_INNER_POSITION = BEFORE,
342 LAST_INNER_POSITION = AFTER
345 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
346 if (parallel_moves_[pos] == NULL) {
347 parallel_moves_[pos] = new(zone) LParallelMove(zone);
349 return parallel_moves_[pos];
352 LParallelMove* GetParallelMove(InnerPosition pos) {
353 return parallel_moves_[pos];
357 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
362 class LInstructionGap V8_FINAL : public LGap {
364 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
366 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
367 return !IsRedundant();
370 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
374 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
376 explicit LGoto(HBasicBlock* block) : block_(block) { }
378 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
379 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
380 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
381 virtual bool IsControl() const V8_OVERRIDE { return true; }
383 int block_id() const { return block_->block_id(); }
384 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
388 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
395 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
397 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
401 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
403 explicit LDummy() { }
404 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
408 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
410 explicit LDummyUse(LOperand* value) {
413 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
417 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
419 virtual bool IsControl() const V8_OVERRIDE { return true; }
420 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
421 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
425 class LLabel V8_FINAL : public LGap {
427 explicit LLabel(HBasicBlock* block)
428 : LGap(block), replacement_(NULL) { }
430 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
433 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
435 virtual void PrintDataTo(StringStream* stream) V8_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 V8_FINAL : public LTemplateInstruction<1, 0, 0> {
453 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
456 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
460 class LCallStub V8_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 LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
475 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
478 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
482 template<int I, int T>
483 class LControlInstruction: public LTemplateInstruction<0, I, T> {
485 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
487 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
489 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
490 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
492 int TrueDestination(LChunk* chunk) {
493 return chunk->LookupDestination(true_block_id());
495 int FalseDestination(LChunk* chunk) {
496 return chunk->LookupDestination(false_block_id());
499 Label* TrueLabel(LChunk* chunk) {
500 if (true_label_ == NULL) {
501 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
505 Label* FalseLabel(LChunk* chunk) {
506 if (false_label_ == NULL) {
507 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
513 int true_block_id() { return SuccessorAt(0)->block_id(); }
514 int false_block_id() { return SuccessorAt(1)->block_id(); }
517 HControlInstruction* hydrogen() {
518 return HControlInstruction::cast(this->hydrogen_value());
526 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 1> {
528 LWrapReceiver(LOperand* receiver,
531 inputs_[0] = receiver;
532 inputs_[1] = function;
536 LOperand* receiver() { return inputs_[0]; }
537 LOperand* function() { return inputs_[1]; }
538 LOperand* temp() { return temps_[0]; }
540 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
541 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
545 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
547 LApplyArguments(LOperand* function,
550 LOperand* elements) {
551 inputs_[0] = function;
552 inputs_[1] = receiver;
554 inputs_[3] = elements;
557 LOperand* function() { return inputs_[0]; }
558 LOperand* receiver() { return inputs_[1]; }
559 LOperand* length() { return inputs_[2]; }
560 LOperand* elements() { return inputs_[3]; }
562 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
566 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
568 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
569 inputs_[0] = arguments;
574 LOperand* arguments() { return inputs_[0]; }
575 LOperand* length() { return inputs_[1]; }
576 LOperand* index() { return inputs_[2]; }
578 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
580 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
584 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
586 explicit LArgumentsLength(LOperand* elements) {
587 inputs_[0] = elements;
590 LOperand* elements() { return inputs_[0]; }
592 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
596 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
598 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
599 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
603 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
605 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
609 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
611 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
612 inputs_[0] = dividend;
616 LOperand* dividend() { return inputs_[0]; }
617 int32_t divisor() const { return divisor_; }
619 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
620 DECLARE_HYDROGEN_ACCESSOR(Mod)
627 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
629 LModByConstI(LOperand* dividend,
633 inputs_[0] = dividend;
639 LOperand* dividend() { return inputs_[0]; }
640 int32_t divisor() const { return divisor_; }
641 LOperand* temp1() { return temps_[0]; }
642 LOperand* temp2() { return temps_[1]; }
644 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
645 DECLARE_HYDROGEN_ACCESSOR(Mod)
652 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
654 LModI(LOperand* left, LOperand* right, LOperand* temp) {
660 LOperand* left() { return inputs_[0]; }
661 LOperand* right() { return inputs_[1]; }
662 LOperand* temp() { return temps_[0]; }
664 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
665 DECLARE_HYDROGEN_ACCESSOR(Mod)
669 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
671 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
672 inputs_[0] = dividend;
676 LOperand* dividend() { return inputs_[0]; }
677 int32_t divisor() const { return divisor_; }
679 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
680 DECLARE_HYDROGEN_ACCESSOR(Div)
687 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
689 LDivByConstI(LOperand* dividend,
693 inputs_[0] = dividend;
699 LOperand* dividend() { return inputs_[0]; }
700 int32_t divisor() const { return divisor_; }
701 LOperand* temp1() { return temps_[0]; }
702 LOperand* temp2() { return temps_[1]; }
704 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
705 DECLARE_HYDROGEN_ACCESSOR(Div)
712 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
714 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
715 inputs_[0] = dividend;
716 inputs_[1] = divisor;
720 LOperand* dividend() { return inputs_[0]; }
721 LOperand* divisor() { return inputs_[1]; }
722 LOperand* temp() { return temps_[0]; }
724 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
725 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
729 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
731 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
732 inputs_[0] = dividend;
736 LOperand* dividend() { return inputs_[0]; }
737 int32_t divisor() const { return divisor_; }
739 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
740 "flooring-div-by-power-of-2-i")
741 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
748 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
750 LFlooringDivByConstI(LOperand* dividend,
755 inputs_[0] = dividend;
762 LOperand* dividend() { return inputs_[0]; }
763 int32_t divisor() const { return divisor_; }
764 LOperand* temp1() { return temps_[0]; }
765 LOperand* temp2() { return temps_[1]; }
766 LOperand* temp3() { return temps_[2]; }
768 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
769 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
776 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
778 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
779 inputs_[0] = dividend;
780 inputs_[1] = divisor;
784 LOperand* dividend() { return inputs_[0]; }
785 LOperand* divisor() { return inputs_[1]; }
786 LOperand* temp() { return temps_[0]; }
788 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
789 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
793 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
795 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
801 LOperand* left() { return inputs_[0]; }
802 LOperand* right() { return inputs_[1]; }
803 LOperand* temp() { return temps_[0]; }
805 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
806 DECLARE_HYDROGEN_ACCESSOR(Mul)
810 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
812 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
817 LOperand* left() { return inputs_[0]; }
818 LOperand* right() { return inputs_[1]; }
820 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
821 "compare-numeric-and-branch")
822 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
824 Token::Value op() const { return hydrogen()->token(); }
825 bool is_double() const {
826 return hydrogen()->representation().IsDouble();
829 virtual void PrintDataTo(StringStream* stream);
833 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
835 explicit LMathFloor(LOperand* value) {
839 LOperand* value() { return inputs_[0]; }
841 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
842 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
846 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
848 LMathRound(LOperand* value, LOperand* temp) {
853 LOperand* value() { return inputs_[0]; }
854 LOperand* temp() { return temps_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
857 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
861 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
863 LMathAbs(LOperand* context, LOperand* value) {
864 inputs_[1] = context;
868 LOperand* context() { return inputs_[1]; }
869 LOperand* value() { return inputs_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
872 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
876 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
878 explicit LMathLog(LOperand* value) {
882 LOperand* value() { return inputs_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
888 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
890 explicit LMathClz32(LOperand* value) {
894 LOperand* value() { return inputs_[0]; }
896 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
900 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
902 LMathExp(LOperand* value,
908 ExternalReference::InitializeMathExpData();
911 LOperand* value() { return inputs_[0]; }
912 LOperand* temp1() { return temps_[0]; }
913 LOperand* temp2() { return temps_[1]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
919 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathSqrt(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
931 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
933 LMathPowHalf(LOperand* value, LOperand* temp) {
938 LOperand* value() { return inputs_[0]; }
939 LOperand* temp() { return temps_[0]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
945 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
947 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
952 LOperand* left() { return inputs_[0]; }
953 LOperand* right() { return inputs_[1]; }
955 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
959 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
961 explicit LCmpHoleAndBranch(LOperand* object) {
965 LOperand* object() { return inputs_[0]; }
967 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
968 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
972 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
974 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
979 LOperand* value() { return inputs_[0]; }
980 LOperand* temp() { return temps_[0]; }
982 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
983 "cmp-minus-zero-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
988 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
990 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
995 LOperand* value() { return inputs_[0]; }
996 LOperand* temp() { return temps_[0]; }
998 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1000 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1004 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1006 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1011 LOperand* value() { return inputs_[0]; }
1012 LOperand* temp() { return temps_[0]; }
1014 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1015 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1017 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1021 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1023 explicit LIsSmiAndBranch(LOperand* value) {
1027 LOperand* value() { return inputs_[0]; }
1029 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1030 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1032 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1036 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1038 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1043 LOperand* value() { return inputs_[0]; }
1044 LOperand* temp() { return temps_[0]; }
1046 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1047 "is-undetectable-and-branch")
1048 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1050 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1054 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1056 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1057 inputs_[0] = context;
1062 LOperand* context() { return inputs_[1]; }
1063 LOperand* left() { return inputs_[1]; }
1064 LOperand* right() { return inputs_[2]; }
1066 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1067 "string-compare-and-branch")
1068 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1070 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1072 Token::Value op() const { return hydrogen()->token(); }
1076 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1078 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1083 LOperand* value() { return inputs_[0]; }
1084 LOperand* temp() { return temps_[0]; }
1086 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1087 "has-instance-type-and-branch")
1088 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1090 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1094 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1096 explicit LGetCachedArrayIndex(LOperand* value) {
1100 LOperand* value() { return inputs_[0]; }
1102 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1103 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1107 class LHasCachedArrayIndexAndBranch V8_FINAL
1108 : public LControlInstruction<1, 0> {
1110 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1114 LOperand* value() { return inputs_[0]; }
1116 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1117 "has-cached-array-index-and-branch")
1119 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1123 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1125 explicit LIsConstructCallAndBranch(LOperand* temp) {
1129 LOperand* temp() { return temps_[0]; }
1131 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1132 "is-construct-call-and-branch")
1136 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1138 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1144 LOperand* value() { return inputs_[0]; }
1145 LOperand* temp() { return temps_[0]; }
1146 LOperand* temp2() { return temps_[1]; }
1148 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1149 "class-of-test-and-branch")
1150 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1152 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1156 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1158 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1159 inputs_[0] = context;
1164 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1165 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1167 LOperand* context() { return inputs_[0]; }
1168 Token::Value op() const { return hydrogen()->token(); }
1172 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1174 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1175 inputs_[0] = context;
1180 LOperand* context() { return inputs_[0]; }
1182 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1186 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1188 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1189 inputs_[0] = context;
1194 LOperand* context() { return inputs_[0]; }
1195 LOperand* value() { return inputs_[1]; }
1196 LOperand* temp() { return temps_[0]; }
1198 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1199 "instance-of-known-global")
1200 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1202 Handle<JSFunction> function() const { return hydrogen()->function(); }
1203 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1204 return lazy_deopt_env_;
1206 virtual void SetDeferredLazyDeoptimizationEnvironment(
1207 LEnvironment* env) V8_OVERRIDE {
1208 lazy_deopt_env_ = env;
1212 LEnvironment* lazy_deopt_env_;
1216 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1218 LBoundsCheck(LOperand* index, LOperand* length) {
1220 inputs_[1] = length;
1223 LOperand* index() { return inputs_[0]; }
1224 LOperand* length() { return inputs_[1]; }
1226 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1227 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1231 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1233 LBitI(LOperand* left, LOperand* right) {
1238 LOperand* left() { return inputs_[0]; }
1239 LOperand* right() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1242 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1244 Token::Value op() const { return hydrogen()->op(); }
1248 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1250 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1251 : op_(op), can_deopt_(can_deopt) {
1256 LOperand* left() { return inputs_[0]; }
1257 LOperand* right() { return inputs_[1]; }
1259 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 Token::Value op() const { return op_; }
1262 bool can_deopt() const { return can_deopt_; }
1270 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1272 LSubI(LOperand* left, LOperand* right) {
1277 LOperand* left() { return inputs_[0]; }
1278 LOperand* right() { return inputs_[1]; }
1280 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1281 DECLARE_HYDROGEN_ACCESSOR(Sub)
1285 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 int32_t value() const { return hydrogen()->Integer32Value(); }
1294 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1296 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1297 DECLARE_HYDROGEN_ACCESSOR(Constant)
1299 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1303 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1305 explicit LConstantD(LOperand* temp) {
1309 LOperand* temp() { return temps_[0]; }
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 double value() const { return hydrogen()->DoubleValue(); }
1318 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1320 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1321 DECLARE_HYDROGEN_ACCESSOR(Constant)
1323 ExternalReference value() const {
1324 return hydrogen()->ExternalReferenceValue();
1329 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1331 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1332 DECLARE_HYDROGEN_ACCESSOR(Constant)
1334 Handle<Object> value(Isolate* isolate) const {
1335 return hydrogen()->handle(isolate);
1340 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1342 LBranch(LOperand* value, LOperand* temp) {
1347 LOperand* value() { return inputs_[0]; }
1348 LOperand* temp() { return temps_[0]; }
1350 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1351 DECLARE_HYDROGEN_ACCESSOR(Branch)
1353 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1357 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1359 explicit LCmpMapAndBranch(LOperand* value) {
1363 LOperand* value() { return inputs_[0]; }
1365 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1366 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1368 Handle<Map> map() const { return hydrogen()->map().handle(); }
1372 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1374 explicit LMapEnumLength(LOperand* value) {
1378 LOperand* value() { return inputs_[0]; }
1380 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1384 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1386 LDateField(LOperand* date, LOperand* temp, Smi* index)
1392 LOperand* date() { return inputs_[0]; }
1393 LOperand* temp() { return temps_[0]; }
1395 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1396 DECLARE_HYDROGEN_ACCESSOR(DateField)
1398 Smi* index() const { return index_; }
1405 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1407 LSeqStringGetChar(LOperand* string, LOperand* index) {
1408 inputs_[0] = string;
1412 LOperand* string() const { return inputs_[0]; }
1413 LOperand* index() const { return inputs_[1]; }
1415 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1416 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1420 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1422 LSeqStringSetChar(LOperand* context,
1426 inputs_[0] = context;
1427 inputs_[1] = string;
1432 LOperand* string() { return inputs_[1]; }
1433 LOperand* index() { return inputs_[2]; }
1434 LOperand* value() { return inputs_[3]; }
1436 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1437 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1441 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1443 LAddI(LOperand* left, LOperand* right) {
1448 LOperand* left() { return inputs_[0]; }
1449 LOperand* right() { return inputs_[1]; }
1451 static bool UseLea(HAdd* add) {
1452 return !add->CheckFlag(HValue::kCanOverflow) &&
1453 add->BetterLeftOperand()->UseCount() > 1;
1456 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1457 DECLARE_HYDROGEN_ACCESSOR(Add)
1461 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1463 LMathMinMax(LOperand* left, LOperand* right) {
1468 LOperand* left() { return inputs_[0]; }
1469 LOperand* right() { return inputs_[1]; }
1471 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1472 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1476 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1478 LPower(LOperand* left, LOperand* right) {
1483 LOperand* left() { return inputs_[0]; }
1484 LOperand* right() { return inputs_[1]; }
1486 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1487 DECLARE_HYDROGEN_ACCESSOR(Power)
1491 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1493 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1499 LOperand* left() { return inputs_[0]; }
1500 LOperand* right() { return inputs_[1]; }
1502 Token::Value op() const { return op_; }
1504 virtual Opcode opcode() const V8_OVERRIDE {
1505 return LInstruction::kArithmeticD;
1507 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1508 virtual const char* Mnemonic() const V8_OVERRIDE;
1515 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1517 LArithmeticT(Token::Value op,
1522 inputs_[0] = context;
1527 LOperand* context() { return inputs_[0]; }
1528 LOperand* left() { return inputs_[1]; }
1529 LOperand* right() { return inputs_[2]; }
1531 virtual Opcode opcode() const V8_OVERRIDE {
1532 return LInstruction::kArithmeticT;
1534 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1535 virtual const char* Mnemonic() const V8_OVERRIDE;
1537 Token::Value op() const { return op_; }
1544 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1546 explicit LReturn(LOperand* value,
1548 LOperand* parameter_count) {
1550 inputs_[1] = context;
1551 inputs_[2] = parameter_count;
1554 bool has_constant_parameter_count() {
1555 return parameter_count()->IsConstantOperand();
1557 LConstantOperand* constant_parameter_count() {
1558 ASSERT(has_constant_parameter_count());
1559 return LConstantOperand::cast(parameter_count());
1561 LOperand* parameter_count() { return inputs_[2]; }
1563 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1564 DECLARE_HYDROGEN_ACCESSOR(Return)
1568 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1570 explicit LLoadNamedField(LOperand* object) {
1571 inputs_[0] = object;
1574 LOperand* object() { return inputs_[0]; }
1576 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1577 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1581 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1583 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1584 inputs_[0] = context;
1585 inputs_[1] = object;
1588 LOperand* context() { return inputs_[0]; }
1589 LOperand* object() { return inputs_[1]; }
1591 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1592 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1594 Handle<Object> name() const { return hydrogen()->name(); }
1598 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1600 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1601 inputs_[0] = function;
1605 LOperand* function() { return inputs_[0]; }
1606 LOperand* temp() { return temps_[0]; }
1608 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1609 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1613 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1615 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1616 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1618 Heap::RootListIndex index() const { return hydrogen()->index(); }
1622 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1624 LLoadKeyed(LOperand* elements, LOperand* key) {
1625 inputs_[0] = elements;
1628 LOperand* elements() { return inputs_[0]; }
1629 LOperand* key() { return inputs_[1]; }
1630 ElementsKind elements_kind() const {
1631 return hydrogen()->elements_kind();
1633 bool is_external() const {
1634 return hydrogen()->is_external();
1636 bool is_fixed_typed_array() const {
1637 return hydrogen()->is_fixed_typed_array();
1639 bool is_typed_elements() const {
1640 return is_external() || is_fixed_typed_array();
1643 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1644 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1646 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1647 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1649 return hydrogen()->key()->representation().IsTagged();
1654 inline static bool ExternalArrayOpRequiresTemp(
1655 Representation key_representation,
1656 ElementsKind elements_kind) {
1657 // Operations that require the key to be divided by two to be converted into
1658 // an index cannot fold the scale operation into a load and need an extra
1659 // temp register to do the work.
1660 return key_representation.IsSmi() &&
1661 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1662 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1663 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1664 elements_kind == UINT8_ELEMENTS ||
1665 elements_kind == INT8_ELEMENTS ||
1666 elements_kind == UINT8_CLAMPED_ELEMENTS);
1670 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1672 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1673 inputs_[0] = context;
1678 LOperand* context() { return inputs_[0]; }
1679 LOperand* object() { return inputs_[1]; }
1680 LOperand* key() { return inputs_[2]; }
1682 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1686 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1688 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1693 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1695 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1696 inputs_[0] = context;
1697 inputs_[1] = global_object;
1700 LOperand* context() { return inputs_[0]; }
1701 LOperand* global_object() { return inputs_[1]; }
1703 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1704 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1706 Handle<Object> name() const { return hydrogen()->name(); }
1707 bool for_typeof() const { return hydrogen()->for_typeof(); }
1711 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1713 explicit LStoreGlobalCell(LOperand* value) {
1717 LOperand* value() { return inputs_[0]; }
1719 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1720 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1724 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1726 explicit LLoadContextSlot(LOperand* context) {
1727 inputs_[0] = context;
1730 LOperand* context() { return inputs_[0]; }
1732 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1733 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1735 int slot_index() { return hydrogen()->slot_index(); }
1737 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1741 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1743 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1744 inputs_[0] = context;
1749 LOperand* context() { return inputs_[0]; }
1750 LOperand* value() { return inputs_[1]; }
1751 LOperand* temp() { return temps_[0]; }
1753 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1754 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1756 int slot_index() { return hydrogen()->slot_index(); }
1758 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1762 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1764 explicit LPushArgument(LOperand* value) {
1768 LOperand* value() { return inputs_[0]; }
1770 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1774 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1776 explicit LDrop(int count) : count_(count) { }
1778 int count() const { return count_; }
1780 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1787 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1789 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1790 inputs_[0] = function;
1791 inputs_[1] = code_object;
1794 LOperand* function() { return inputs_[0]; }
1795 LOperand* code_object() { return inputs_[1]; }
1797 virtual void PrintDataTo(StringStream* stream);
1799 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1800 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1804 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1806 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1807 inputs_[0] = base_object;
1808 inputs_[1] = offset;
1811 LOperand* base_object() const { return inputs_[0]; }
1812 LOperand* offset() const { return inputs_[1]; }
1814 virtual void PrintDataTo(StringStream* stream);
1816 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1820 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1822 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1823 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1827 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1829 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1830 DECLARE_HYDROGEN_ACCESSOR(Context)
1834 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1836 explicit LDeclareGlobals(LOperand* context) {
1837 inputs_[0] = context;
1840 LOperand* context() { return inputs_[0]; }
1842 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1843 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1847 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1849 explicit LCallJSFunction(LOperand* function) {
1850 inputs_[0] = function;
1853 LOperand* function() { return inputs_[0]; }
1855 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1856 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1858 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1860 int arity() const { return hydrogen()->argument_count() - 1; }
1864 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1866 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1867 const ZoneList<LOperand*>& operands,
1869 : inputs_(descriptor->environment_length() + 1, zone) {
1870 ASSERT(descriptor->environment_length() + 1 == operands.length());
1871 inputs_.AddAll(operands, zone);
1874 LOperand* target() const { return inputs_[0]; }
1877 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1878 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1880 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1882 int arity() const { return hydrogen()->argument_count() - 1; }
1884 ZoneList<LOperand*> inputs_;
1886 // Iterator support.
1887 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1888 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1890 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1891 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1895 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1897 LInvokeFunction(LOperand* context, LOperand* function) {
1898 inputs_[0] = context;
1899 inputs_[1] = function;
1902 LOperand* context() { return inputs_[0]; }
1903 LOperand* function() { return inputs_[1]; }
1905 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1906 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1908 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1910 int arity() const { return hydrogen()->argument_count() - 1; }
1914 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1916 explicit LCallFunction(LOperand* context, LOperand* function) {
1917 inputs_[0] = context;
1918 inputs_[1] = function;
1921 LOperand* context() { return inputs_[0]; }
1922 LOperand* function() { return inputs_[1]; }
1924 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1925 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1927 int arity() const { return hydrogen()->argument_count() - 1; }
1931 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1933 LCallNew(LOperand* context, LOperand* constructor) {
1934 inputs_[0] = context;
1935 inputs_[1] = constructor;
1938 LOperand* context() { return inputs_[0]; }
1939 LOperand* constructor() { return inputs_[1]; }
1941 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1942 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1944 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1946 int arity() const { return hydrogen()->argument_count() - 1; }
1950 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1952 LCallNewArray(LOperand* context, LOperand* constructor) {
1953 inputs_[0] = context;
1954 inputs_[1] = constructor;
1957 LOperand* context() { return inputs_[0]; }
1958 LOperand* constructor() { return inputs_[1]; }
1960 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1961 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1963 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1965 int arity() const { return hydrogen()->argument_count() - 1; }
1969 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1971 explicit LCallRuntime(LOperand* context) {
1972 inputs_[0] = context;
1975 LOperand* context() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1978 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1980 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1981 return save_doubles() == kDontSaveFPRegs;
1984 const Runtime::Function* function() const { return hydrogen()->function(); }
1985 int arity() const { return hydrogen()->argument_count(); }
1986 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1990 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1992 explicit LInteger32ToDouble(LOperand* value) {
1996 LOperand* value() { return inputs_[0]; }
1998 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2002 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2004 explicit LUint32ToDouble(LOperand* value) {
2008 LOperand* value() { return inputs_[0]; }
2010 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2014 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2016 LNumberTagI(LOperand* value, LOperand* temp) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp() { return temps_[0]; }
2024 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2028 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2030 LNumberTagU(LOperand* value, LOperand* temp) {
2035 LOperand* value() { return inputs_[0]; }
2036 LOperand* temp() { return temps_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2042 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2044 LNumberTagD(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2053 DECLARE_HYDROGEN_ACCESSOR(Change)
2057 // Sometimes truncating conversion from a tagged value to an int32.
2058 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2060 LDoubleToI(LOperand* value, LOperand* temp) {
2065 LOperand* value() { return inputs_[0]; }
2066 LOperand* temp() { return temps_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2069 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2075 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2077 explicit LDoubleToSmi(LOperand* value) {
2081 LOperand* value() { return inputs_[0]; }
2083 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2084 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2088 // Truncating conversion from a tagged value to an int32.
2089 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2091 LTaggedToI(LOperand* value, LOperand* temp) {
2096 LOperand* value() { return inputs_[0]; }
2097 LOperand* temp() { return temps_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2100 DECLARE_HYDROGEN_ACCESSOR(Change)
2102 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2106 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2108 explicit LSmiTag(LOperand* value) {
2112 LOperand* value() { return inputs_[0]; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2115 DECLARE_HYDROGEN_ACCESSOR(Change)
2119 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2121 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2126 LOperand* value() { return inputs_[0]; }
2127 LOperand* temp() { return temps_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2130 DECLARE_HYDROGEN_ACCESSOR(Change);
2134 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2136 LSmiUntag(LOperand* value, bool needs_check)
2137 : needs_check_(needs_check) {
2141 LOperand* value() { return inputs_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2145 bool needs_check() const { return needs_check_; }
2152 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2154 LStoreNamedField(LOperand* obj,
2157 LOperand* temp_map) {
2161 temps_[1] = temp_map;
2164 LOperand* object() { return inputs_[0]; }
2165 LOperand* value() { return inputs_[1]; }
2166 LOperand* temp() { return temps_[0]; }
2167 LOperand* temp_map() { return temps_[1]; }
2169 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2170 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2172 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2176 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2178 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2179 inputs_[0] = context;
2180 inputs_[1] = object;
2184 LOperand* context() { return inputs_[0]; }
2185 LOperand* object() { return inputs_[1]; }
2186 LOperand* value() { return inputs_[2]; }
2188 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2189 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2191 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2192 Handle<Object> name() const { return hydrogen()->name(); }
2193 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2197 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2199 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2205 bool is_external() const { return hydrogen()->is_external(); }
2206 bool is_fixed_typed_array() const {
2207 return hydrogen()->is_fixed_typed_array();
2209 bool is_typed_elements() const {
2210 return is_external() || is_fixed_typed_array();
2212 LOperand* elements() { return inputs_[0]; }
2213 LOperand* key() { return inputs_[1]; }
2214 LOperand* value() { return inputs_[2]; }
2215 ElementsKind elements_kind() const {
2216 return hydrogen()->elements_kind();
2219 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2220 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2222 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2223 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2224 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2228 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2230 LStoreKeyedGeneric(LOperand* context,
2234 inputs_[0] = context;
2235 inputs_[1] = object;
2240 LOperand* context() { return inputs_[0]; }
2241 LOperand* object() { return inputs_[1]; }
2242 LOperand* key() { return inputs_[2]; }
2243 LOperand* value() { return inputs_[3]; }
2245 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2246 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2248 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2250 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2254 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2256 LTransitionElementsKind(LOperand* object,
2258 LOperand* new_map_temp,
2260 inputs_[0] = object;
2261 inputs_[1] = context;
2262 temps_[0] = new_map_temp;
2266 LOperand* context() { return inputs_[1]; }
2267 LOperand* object() { return inputs_[0]; }
2268 LOperand* new_map_temp() { return temps_[0]; }
2269 LOperand* temp() { return temps_[1]; }
2271 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2272 "transition-elements-kind")
2273 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2275 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2277 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2278 Handle<Map> transitioned_map() {
2279 return hydrogen()->transitioned_map().handle();
2281 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2282 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2286 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2288 LTrapAllocationMemento(LOperand* object,
2290 inputs_[0] = object;
2294 LOperand* object() { return inputs_[0]; }
2295 LOperand* temp() { return temps_[0]; }
2297 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2298 "trap-allocation-memento")
2302 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2304 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2305 inputs_[0] = context;
2310 LOperand* context() { return inputs_[0]; }
2311 LOperand* left() { return inputs_[1]; }
2312 LOperand* right() { return inputs_[2]; }
2314 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2315 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2319 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2321 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2322 inputs_[0] = context;
2323 inputs_[1] = string;
2327 LOperand* context() { return inputs_[0]; }
2328 LOperand* string() { return inputs_[1]; }
2329 LOperand* index() { return inputs_[2]; }
2331 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2332 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2336 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2338 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2339 inputs_[0] = context;
2340 inputs_[1] = char_code;
2343 LOperand* context() { return inputs_[0]; }
2344 LOperand* char_code() { return inputs_[1]; }
2346 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2347 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2351 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2353 explicit LCheckValue(LOperand* value) {
2357 LOperand* value() { return inputs_[0]; }
2359 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2360 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2364 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2366 LCheckInstanceType(LOperand* value, LOperand* temp) {
2371 LOperand* value() { return inputs_[0]; }
2372 LOperand* temp() { return temps_[0]; }
2374 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2375 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2379 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2381 explicit LCheckMaps(LOperand* value = NULL) {
2385 LOperand* value() { return inputs_[0]; }
2387 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2388 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2392 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2394 explicit LCheckSmi(LOperand* value) {
2398 LOperand* value() { return inputs_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2404 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2406 explicit LClampDToUint8(LOperand* value) {
2410 LOperand* unclamped() { return inputs_[0]; }
2412 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2416 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2418 explicit LClampIToUint8(LOperand* value) {
2422 LOperand* unclamped() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2428 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2430 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2432 temps_[0] = temp_xmm;
2435 LOperand* unclamped() { return inputs_[0]; }
2436 LOperand* temp_xmm() { return temps_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2442 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2444 explicit LCheckNonSmi(LOperand* value) {
2448 LOperand* value() { return inputs_[0]; }
2450 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2451 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2455 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2457 explicit LDoubleBits(LOperand* value) {
2461 LOperand* value() { return inputs_[0]; }
2463 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2464 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2468 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2470 LConstructDouble(LOperand* hi, LOperand* lo) {
2475 LOperand* hi() { return inputs_[0]; }
2476 LOperand* lo() { return inputs_[1]; }
2478 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2482 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2484 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2485 inputs_[0] = context;
2490 LOperand* context() { return inputs_[0]; }
2491 LOperand* size() { return inputs_[1]; }
2492 LOperand* temp() { return temps_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2495 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2499 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2501 explicit LRegExpLiteral(LOperand* context) {
2502 inputs_[0] = context;
2505 LOperand* context() { return inputs_[0]; }
2507 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2508 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2512 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2514 explicit LFunctionLiteral(LOperand* context) {
2515 inputs_[0] = context;
2518 LOperand* context() { return inputs_[0]; }
2520 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2521 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2525 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2527 explicit LToFastProperties(LOperand* value) {
2531 LOperand* value() { return inputs_[0]; }
2533 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2534 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2538 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2540 LTypeof(LOperand* context, LOperand* value) {
2541 inputs_[0] = context;
2545 LOperand* context() { return inputs_[0]; }
2546 LOperand* value() { return inputs_[1]; }
2548 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2552 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2554 explicit LTypeofIsAndBranch(LOperand* value) {
2558 LOperand* value() { return inputs_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2561 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2563 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2565 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2569 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2571 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2574 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2578 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2580 explicit LStackCheck(LOperand* context) {
2581 inputs_[0] = context;
2584 LOperand* context() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2587 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2589 Label* done_label() { return &done_label_; }
2596 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2598 LForInPrepareMap(LOperand* context, LOperand* object) {
2599 inputs_[0] = context;
2600 inputs_[1] = object;
2603 LOperand* context() { return inputs_[0]; }
2604 LOperand* object() { return inputs_[1]; }
2606 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2610 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2612 explicit LForInCacheArray(LOperand* map) {
2616 LOperand* map() { return inputs_[0]; }
2618 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2621 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2626 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2628 LCheckMapValue(LOperand* value, LOperand* map) {
2633 LOperand* value() { return inputs_[0]; }
2634 LOperand* map() { return inputs_[1]; }
2636 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2640 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2642 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2643 inputs_[0] = object;
2647 LOperand* object() { return inputs_[0]; }
2648 LOperand* index() { return inputs_[1]; }
2650 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2654 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2656 explicit LStoreFrameContext(LOperand* context) {
2657 inputs_[0] = context;
2660 LOperand* context() { return inputs_[0]; }
2662 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2666 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2668 LAllocateBlockContext(LOperand* context, LOperand* function) {
2669 inputs_[0] = context;
2670 inputs_[1] = function;
2673 LOperand* context() { return inputs_[0]; }
2674 LOperand* function() { return inputs_[1]; }
2676 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2678 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2679 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2683 class LChunkBuilder;
2684 class LPlatformChunk V8_FINAL : public LChunk {
2686 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2687 : LChunk(info, graph),
2688 num_double_slots_(0) { }
2690 int GetNextSpillIndex(RegisterKind kind);
2691 LOperand* GetNextSpillSlot(RegisterKind kind);
2693 int num_double_slots() const { return num_double_slots_; }
2696 int num_double_slots_;
2700 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2702 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2703 : LChunkBuilderBase(graph->zone()),
2708 current_instruction_(NULL),
2709 current_block_(NULL),
2711 allocator_(allocator) { }
2713 Isolate* isolate() const { return graph_->isolate(); }
2715 // Build the sequence for the graph.
2716 LPlatformChunk* Build();
2718 // Declare methods that deal with the individual node types.
2719 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2720 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2723 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2724 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2725 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2726 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2727 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2728 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2729 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2730 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2731 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2732 LInstruction* DoDivByConstI(HDiv* instr);
2733 LInstruction* DoDivI(HDiv* instr);
2734 LInstruction* DoModByPowerOf2I(HMod* instr);
2735 LInstruction* DoModByConstI(HMod* instr);
2736 LInstruction* DoModI(HMod* instr);
2737 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2738 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2739 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2749 LPlatformChunk* chunk() const { return chunk_; }
2750 CompilationInfo* info() const { return info_; }
2751 HGraph* graph() const { return graph_; }
2753 bool is_unused() const { return status_ == UNUSED; }
2754 bool is_building() const { return status_ == BUILDING; }
2755 bool is_done() const { return status_ == DONE; }
2756 bool is_aborted() const { return status_ == ABORTED; }
2758 void Abort(BailoutReason reason);
2760 // Methods for getting operands for Use / Define / Temp.
2761 LUnallocated* ToUnallocated(Register reg);
2762 LUnallocated* ToUnallocated(XMMRegister reg);
2764 // Methods for setting up define-use relationships.
2765 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2766 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2767 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2768 XMMRegister fixed_register);
2770 // A value that is guaranteed to be allocated to a register.
2771 // Operand created by UseRegister is guaranteed to be live until the end of
2772 // instruction. This means that register allocator will not reuse it's
2773 // register for any other operand inside instruction.
2774 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2775 // instruction start. Register allocator is free to assign the same register
2776 // to some other operand used inside instruction (i.e. temporary or
2778 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2779 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2781 // An input operand in a register that may be trashed.
2782 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2784 // An input operand in a register or stack slot.
2785 MUST_USE_RESULT LOperand* Use(HValue* value);
2786 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2788 // An input operand in a register, stack slot or a constant operand.
2789 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2790 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2792 // An input operand in a fixed register or a constant operand.
2793 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2794 Register fixed_register);
2796 // An input operand in a register or a constant operand.
2797 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2798 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2800 // An input operand in a constant operand.
2801 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2803 // An input operand in register, stack slot or a constant operand.
2804 // Will not be moved to a register even if one is freely available.
2805 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2807 // Temporary operand that must be in a register.
2808 MUST_USE_RESULT LUnallocated* TempRegister();
2809 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2810 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2812 // Methods for setting up define-use relationships.
2813 // Return the same instruction that they are passed.
2814 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2815 LUnallocated* result);
2816 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2817 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2819 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2820 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2822 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2824 // Assigns an environment to an instruction. An instruction which can
2825 // deoptimize must have an environment.
2826 LInstruction* AssignEnvironment(LInstruction* instr);
2827 // Assigns a pointer map to an instruction. An instruction which can
2828 // trigger a GC or a lazy deoptimization must have a pointer map.
2829 LInstruction* AssignPointerMap(LInstruction* instr);
2831 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2833 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2835 // Marks a call for the register allocator. Assigns a pointer map to
2836 // support GC and lazy deoptimization. Assigns an environment to support
2837 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2838 LInstruction* MarkAsCall(
2839 LInstruction* instr,
2840 HInstruction* hinstr,
2841 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2843 void VisitInstruction(HInstruction* current);
2844 void AddInstruction(LInstruction* instr, HInstruction* current);
2846 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2847 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2848 LInstruction* DoArithmeticD(Token::Value op,
2849 HArithmeticBinaryOperation* instr);
2850 LInstruction* DoArithmeticT(Token::Value op,
2851 HBinaryOperation* instr);
2853 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2855 LPlatformChunk* chunk_;
2856 CompilationInfo* info_;
2857 HGraph* const graph_;
2859 HInstruction* current_instruction_;
2860 HBasicBlock* current_block_;
2861 HBasicBlock* next_block_;
2862 LAllocator* allocator_;
2864 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2867 #undef DECLARE_HYDROGEN_ACCESSOR
2868 #undef DECLARE_CONCRETE_INSTRUCTION
2870 } } // namespace v8::internal
2872 #endif // V8_IA32_LITHIUM_IA32_H_