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_X87_LITHIUM_X87_H_
6 #define V8_X87_LITHIUM_X87_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) \
48 V(ClampTToUint8NoSSE2) \
49 V(ClassOfTestAndBranch) \
51 V(CompareMinusZeroAndBranch) \
52 V(CompareNumericAndBranch) \
53 V(CmpObjectEqAndBranch) \
77 V(FlooringDivByConstI) \
78 V(FlooringDivByPowerOf2I) \
83 V(GetCachedArrayIndex) \
85 V(HasCachedArrayIndexAndBranch) \
86 V(HasInstanceTypeAndBranch) \
87 V(InnerAllocatedObject) \
89 V(InstanceOfKnownGlobal) \
91 V(Integer32ToDouble) \
93 V(IsConstructCallAndBranch) \
94 V(IsObjectAndBranch) \
95 V(IsStringAndBranch) \
97 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
167 return LInstruction::k##type; \
169 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
170 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
173 static L##type* cast(LInstruction* instr) { \
174 ASSERT(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 void set_environment(LEnvironment* env) { environment_ = env; }
224 LEnvironment* environment() const { return environment_; }
225 bool HasEnvironment() const { return environment_ != NULL; }
227 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
228 LPointerMap* pointer_map() const { return pointer_map_.get(); }
229 bool HasPointerMap() const { return pointer_map_.is_set(); }
231 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
232 HValue* hydrogen_value() const { return hydrogen_value_; }
234 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
236 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
237 bool IsCall() const { return IsCallBits::decode(bit_field_); }
239 // Interface to the register allocator and iterators.
240 bool ClobbersTemps() const { return IsCall(); }
241 bool ClobbersRegisters() const { return IsCall(); }
242 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
244 // We only have rudimentary X87Stack tracking, thus in general
245 // cannot handle phi-nodes.
249 virtual bool HasResult() const = 0;
250 virtual LOperand* result() const = 0;
252 bool HasDoubleRegisterResult();
253 bool HasDoubleRegisterInput();
254 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
259 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
267 friend class InputIterator;
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
271 friend class TempIterator;
272 virtual int TempCount() = 0;
273 virtual LOperand* TempAt(int i) = 0;
275 class IsCallBits: public BitField<bool, 0, 1> {};
277 LEnvironment* environment_;
278 SetOncePointer<LPointerMap> pointer_map_;
279 HValue* hydrogen_value_;
284 // R = number of result operands (0 or 1).
286 class LTemplateResultInstruction : public LInstruction {
288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
291 return R != 0 && result() != NULL;
293 void set_result(LOperand* operand) { results_[0] = operand; }
294 LOperand* result() const { return results_[0]; }
297 EmbeddedContainer<LOperand*, R> results_;
301 // R = number of result operands (0 or 1).
302 // I = number of input operands.
303 // T = number of temporary operands.
304 template<int R, int I, int T>
305 class LTemplateInstruction : public LTemplateResultInstruction<R> {
307 EmbeddedContainer<LOperand*, I> inputs_;
308 EmbeddedContainer<LOperand*, T> temps_;
312 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
313 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
315 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
316 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
320 class LGap : public LTemplateInstruction<0, 0, 0> {
322 explicit LGap(HBasicBlock* block) : block_(block) {
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
331 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
332 static LGap* cast(LInstruction* instr) {
333 ASSERT(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
351 if (parallel_moves_[pos] == NULL) {
352 parallel_moves_[pos] = new(zone) LParallelMove(zone);
354 return parallel_moves_[pos];
357 LParallelMove* GetParallelMove(InnerPosition pos) {
358 return parallel_moves_[pos];
362 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 class LInstructionGap V8_FINAL : public LGap {
369 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
371 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
372 return !IsRedundant();
375 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
379 class LClobberDoubles V8_FINAL : public LTemplateInstruction<0, 0, 0> {
381 explicit LClobberDoubles(Isolate* isolate) { }
383 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
387 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
391 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
398 virtual bool IsControl() const V8_OVERRIDE { return true; }
400 int block_id() const { return block_->block_id(); }
401 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
405 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
412 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
420 explicit LDummy() { }
421 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
425 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
427 explicit LDummyUse(LOperand* value) {
430 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
434 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
436 virtual bool IsControl() const V8_OVERRIDE { return true; }
437 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
438 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
442 class LLabel V8_FINAL : public LGap {
444 explicit LLabel(HBasicBlock* block)
445 : LGap(block), replacement_(NULL) { }
447 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
450 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
452 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
454 int block_id() const { return block()->block_id(); }
455 bool is_loop_header() const { return block()->IsLoopHeader(); }
456 bool is_osr_entry() const { return block()->is_osr_entry(); }
457 Label* label() { return &label_; }
458 LLabel* replacement() const { return replacement_; }
459 void set_replacement(LLabel* label) { replacement_ = label; }
460 bool HasReplacement() const { return replacement_ != NULL; }
464 LLabel* replacement_;
468 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
470 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
473 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
477 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
479 explicit LCallStub(LOperand* context) {
480 inputs_[0] = context;
483 LOperand* context() { return inputs_[0]; }
485 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
486 DECLARE_HYDROGEN_ACCESSOR(CallStub)
490 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
492 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
495 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
499 template<int I, int T>
500 class LControlInstruction: public LTemplateInstruction<0, I, T> {
502 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
504 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
506 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
507 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
509 int TrueDestination(LChunk* chunk) {
510 return chunk->LookupDestination(true_block_id());
512 int FalseDestination(LChunk* chunk) {
513 return chunk->LookupDestination(false_block_id());
516 Label* TrueLabel(LChunk* chunk) {
517 if (true_label_ == NULL) {
518 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
522 Label* FalseLabel(LChunk* chunk) {
523 if (false_label_ == NULL) {
524 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
530 int true_block_id() { return SuccessorAt(0)->block_id(); }
531 int false_block_id() { return SuccessorAt(1)->block_id(); }
534 HControlInstruction* hydrogen() {
535 return HControlInstruction::cast(this->hydrogen_value());
543 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 1> {
545 LWrapReceiver(LOperand* receiver,
548 inputs_[0] = receiver;
549 inputs_[1] = function;
553 LOperand* receiver() { return inputs_[0]; }
554 LOperand* function() { return inputs_[1]; }
555 LOperand* temp() { return temps_[0]; }
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
558 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
562 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
564 LApplyArguments(LOperand* function,
567 LOperand* elements) {
568 inputs_[0] = function;
569 inputs_[1] = receiver;
571 inputs_[3] = elements;
574 LOperand* function() { return inputs_[0]; }
575 LOperand* receiver() { return inputs_[1]; }
576 LOperand* length() { return inputs_[2]; }
577 LOperand* elements() { return inputs_[3]; }
579 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
583 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
585 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
586 inputs_[0] = arguments;
591 LOperand* arguments() { return inputs_[0]; }
592 LOperand* length() { return inputs_[1]; }
593 LOperand* index() { return inputs_[2]; }
595 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
597 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
601 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
603 explicit LArgumentsLength(LOperand* elements) {
604 inputs_[0] = elements;
607 LOperand* elements() { return inputs_[0]; }
609 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
613 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
616 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
620 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
622 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
626 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
628 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
629 inputs_[0] = dividend;
633 LOperand* dividend() { return inputs_[0]; }
634 int32_t divisor() const { return divisor_; }
636 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
637 DECLARE_HYDROGEN_ACCESSOR(Mod)
644 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
646 LModByConstI(LOperand* dividend,
650 inputs_[0] = dividend;
656 LOperand* dividend() { return inputs_[0]; }
657 int32_t divisor() const { return divisor_; }
658 LOperand* temp1() { return temps_[0]; }
659 LOperand* temp2() { return temps_[1]; }
661 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
662 DECLARE_HYDROGEN_ACCESSOR(Mod)
669 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
671 LModI(LOperand* left, LOperand* right, LOperand* temp) {
677 LOperand* left() { return inputs_[0]; }
678 LOperand* right() { return inputs_[1]; }
679 LOperand* temp() { return temps_[0]; }
681 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
682 DECLARE_HYDROGEN_ACCESSOR(Mod)
686 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
688 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
689 inputs_[0] = dividend;
693 LOperand* dividend() { return inputs_[0]; }
694 int32_t divisor() const { return divisor_; }
696 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
697 DECLARE_HYDROGEN_ACCESSOR(Div)
704 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
706 LDivByConstI(LOperand* dividend,
710 inputs_[0] = dividend;
716 LOperand* dividend() { return inputs_[0]; }
717 int32_t divisor() const { return divisor_; }
718 LOperand* temp1() { return temps_[0]; }
719 LOperand* temp2() { return temps_[1]; }
721 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
722 DECLARE_HYDROGEN_ACCESSOR(Div)
729 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
731 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
732 inputs_[0] = dividend;
733 inputs_[1] = divisor;
737 LOperand* dividend() { return inputs_[0]; }
738 LOperand* divisor() { return inputs_[1]; }
739 LOperand* temp() { return temps_[0]; }
741 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
742 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
746 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
748 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
749 inputs_[0] = dividend;
753 LOperand* dividend() { return inputs_[0]; }
754 int32_t divisor() const { return divisor_; }
756 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
757 "flooring-div-by-power-of-2-i")
758 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
765 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
767 LFlooringDivByConstI(LOperand* dividend,
772 inputs_[0] = dividend;
779 LOperand* dividend() { return inputs_[0]; }
780 int32_t divisor() const { return divisor_; }
781 LOperand* temp1() { return temps_[0]; }
782 LOperand* temp2() { return temps_[1]; }
783 LOperand* temp3() { return temps_[2]; }
785 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
786 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
793 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
795 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
796 inputs_[0] = dividend;
797 inputs_[1] = divisor;
801 LOperand* dividend() { return inputs_[0]; }
802 LOperand* divisor() { return inputs_[1]; }
803 LOperand* temp() { return temps_[0]; }
805 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
806 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
810 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
812 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
818 LOperand* left() { return inputs_[0]; }
819 LOperand* right() { return inputs_[1]; }
820 LOperand* temp() { return temps_[0]; }
822 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
823 DECLARE_HYDROGEN_ACCESSOR(Mul)
827 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
829 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
834 LOperand* left() { return inputs_[0]; }
835 LOperand* right() { return inputs_[1]; }
837 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
838 "compare-numeric-and-branch")
839 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
841 Token::Value op() const { return hydrogen()->token(); }
842 bool is_double() const {
843 return hydrogen()->representation().IsDouble();
846 virtual void PrintDataTo(StringStream* stream);
850 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
852 explicit LMathFloor(LOperand* value) {
856 LOperand* value() { return inputs_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
865 explicit LMathRound(LOperand* value) {
869 LOperand* value() { return inputs_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
872 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
876 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
878 LMathAbs(LOperand* context, LOperand* value) {
879 inputs_[1] = context;
883 LOperand* context() { return inputs_[1]; }
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
887 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
891 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
893 explicit LMathLog(LOperand* value) {
897 LOperand* value() { return inputs_[0]; }
899 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
903 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
905 explicit LMathClz32(LOperand* value) {
909 LOperand* value() { return inputs_[0]; }
911 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
915 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
917 LMathExp(LOperand* value,
923 ExternalReference::InitializeMathExpData();
926 LOperand* value() { return inputs_[0]; }
927 LOperand* temp1() { return temps_[0]; }
928 LOperand* temp2() { return temps_[1]; }
930 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
934 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
936 explicit LMathSqrt(LOperand* value) {
940 LOperand* value() { return inputs_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
946 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
948 LMathPowHalf(LOperand* value, LOperand* temp) {
953 LOperand* value() { return inputs_[0]; }
954 LOperand* temp() { return temps_[0]; }
956 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
960 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
962 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
967 LOperand* left() { return inputs_[0]; }
968 LOperand* right() { return inputs_[1]; }
970 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
974 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
976 explicit LCmpHoleAndBranch(LOperand* object) {
980 LOperand* object() { return inputs_[0]; }
982 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
983 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
987 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
989 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
994 LOperand* value() { return inputs_[0]; }
995 LOperand* temp() { return temps_[0]; }
997 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
998 "cmp-minus-zero-and-branch")
999 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1003 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1005 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1010 LOperand* value() { return inputs_[0]; }
1011 LOperand* temp() { return temps_[0]; }
1013 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1015 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1019 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1021 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1026 LOperand* value() { return inputs_[0]; }
1027 LOperand* temp() { return temps_[0]; }
1029 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1030 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1032 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1036 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1038 explicit LIsSmiAndBranch(LOperand* value) {
1042 LOperand* value() { return inputs_[0]; }
1044 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1045 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1047 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1051 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1053 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1058 LOperand* value() { return inputs_[0]; }
1059 LOperand* temp() { return temps_[0]; }
1061 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1062 "is-undetectable-and-branch")
1063 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1065 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1069 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1071 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1072 inputs_[0] = context;
1077 LOperand* context() { return inputs_[1]; }
1078 LOperand* left() { return inputs_[1]; }
1079 LOperand* right() { return inputs_[2]; }
1081 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1082 "string-compare-and-branch")
1083 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1085 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1087 Token::Value op() const { return hydrogen()->token(); }
1091 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1093 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1098 LOperand* value() { return inputs_[0]; }
1099 LOperand* temp() { return temps_[0]; }
1101 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1102 "has-instance-type-and-branch")
1103 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1105 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1109 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1111 explicit LGetCachedArrayIndex(LOperand* value) {
1115 LOperand* value() { return inputs_[0]; }
1117 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1118 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1122 class LHasCachedArrayIndexAndBranch V8_FINAL
1123 : public LControlInstruction<1, 0> {
1125 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1129 LOperand* value() { return inputs_[0]; }
1131 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1132 "has-cached-array-index-and-branch")
1134 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1138 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1140 explicit LIsConstructCallAndBranch(LOperand* temp) {
1144 LOperand* temp() { return temps_[0]; }
1146 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1147 "is-construct-call-and-branch")
1151 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1153 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1159 LOperand* value() { return inputs_[0]; }
1160 LOperand* temp() { return temps_[0]; }
1161 LOperand* temp2() { return temps_[1]; }
1163 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1164 "class-of-test-and-branch")
1165 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1167 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1171 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1173 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1174 inputs_[0] = context;
1179 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1180 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1182 LOperand* context() { return inputs_[0]; }
1183 Token::Value op() const { return hydrogen()->token(); }
1187 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1189 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1190 inputs_[0] = context;
1195 LOperand* context() { return inputs_[0]; }
1197 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1201 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1203 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1204 inputs_[0] = context;
1209 LOperand* context() { return inputs_[0]; }
1210 LOperand* value() { return inputs_[1]; }
1211 LOperand* temp() { return temps_[0]; }
1213 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1214 "instance-of-known-global")
1215 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1217 Handle<JSFunction> function() const { return hydrogen()->function(); }
1218 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1219 return lazy_deopt_env_;
1221 virtual void SetDeferredLazyDeoptimizationEnvironment(
1222 LEnvironment* env) V8_OVERRIDE {
1223 lazy_deopt_env_ = env;
1227 LEnvironment* lazy_deopt_env_;
1231 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1233 LBoundsCheck(LOperand* index, LOperand* length) {
1235 inputs_[1] = length;
1238 LOperand* index() { return inputs_[0]; }
1239 LOperand* length() { return inputs_[1]; }
1241 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1242 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1246 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1248 LBitI(LOperand* left, LOperand* right) {
1253 LOperand* left() { return inputs_[0]; }
1254 LOperand* right() { return inputs_[1]; }
1256 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1257 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1259 Token::Value op() const { return hydrogen()->op(); }
1263 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1265 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1266 : op_(op), can_deopt_(can_deopt) {
1271 LOperand* left() { return inputs_[0]; }
1272 LOperand* right() { return inputs_[1]; }
1274 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1276 Token::Value op() const { return op_; }
1277 bool can_deopt() const { return can_deopt_; }
1285 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1287 LSubI(LOperand* left, LOperand* right) {
1292 LOperand* left() { return inputs_[0]; }
1293 LOperand* right() { return inputs_[1]; }
1295 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1296 DECLARE_HYDROGEN_ACCESSOR(Sub)
1300 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 int32_t value() const { return hydrogen()->Integer32Value(); }
1309 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1318 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1320 explicit LConstantD(LOperand* temp) {
1324 LOperand* temp() { return temps_[0]; }
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 double value() const { return hydrogen()->DoubleValue(); }
1333 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1335 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1336 DECLARE_HYDROGEN_ACCESSOR(Constant)
1338 ExternalReference value() const {
1339 return hydrogen()->ExternalReferenceValue();
1344 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1346 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1347 DECLARE_HYDROGEN_ACCESSOR(Constant)
1349 Handle<Object> value(Isolate* isolate) const {
1350 return hydrogen()->handle(isolate);
1355 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1357 LBranch(LOperand* value, LOperand* temp) {
1362 LOperand* value() { return inputs_[0]; }
1363 LOperand* temp() { return temps_[0]; }
1365 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1366 DECLARE_HYDROGEN_ACCESSOR(Branch)
1368 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1372 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1374 explicit LCmpMapAndBranch(LOperand* value) {
1378 LOperand* value() { return inputs_[0]; }
1380 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1381 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1383 Handle<Map> map() const { return hydrogen()->map().handle(); }
1387 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1389 explicit LMapEnumLength(LOperand* value) {
1393 LOperand* value() { return inputs_[0]; }
1395 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1399 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1401 LDateField(LOperand* date, LOperand* temp, Smi* index)
1407 LOperand* date() { return inputs_[0]; }
1408 LOperand* temp() { return temps_[0]; }
1410 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1411 DECLARE_HYDROGEN_ACCESSOR(DateField)
1413 Smi* index() const { return index_; }
1420 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1422 LSeqStringGetChar(LOperand* string, LOperand* index) {
1423 inputs_[0] = string;
1427 LOperand* string() const { return inputs_[0]; }
1428 LOperand* index() const { return inputs_[1]; }
1430 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1431 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1435 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1437 LSeqStringSetChar(LOperand* context,
1441 inputs_[0] = context;
1442 inputs_[1] = string;
1447 LOperand* string() { return inputs_[1]; }
1448 LOperand* index() { return inputs_[2]; }
1449 LOperand* value() { return inputs_[3]; }
1451 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1452 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1456 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1458 LAddI(LOperand* left, LOperand* right) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 static bool UseLea(HAdd* add) {
1467 return !add->CheckFlag(HValue::kCanOverflow) &&
1468 add->BetterLeftOperand()->UseCount() > 1;
1471 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1472 DECLARE_HYDROGEN_ACCESSOR(Add)
1476 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1478 LMathMinMax(LOperand* left, LOperand* right) {
1483 LOperand* left() { return inputs_[0]; }
1484 LOperand* right() { return inputs_[1]; }
1486 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1487 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1491 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1493 LPower(LOperand* left, LOperand* right) {
1498 LOperand* left() { return inputs_[0]; }
1499 LOperand* right() { return inputs_[1]; }
1501 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1502 DECLARE_HYDROGEN_ACCESSOR(Power)
1506 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1508 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1514 LOperand* left() { return inputs_[0]; }
1515 LOperand* right() { return inputs_[1]; }
1517 Token::Value op() const { return op_; }
1519 virtual Opcode opcode() const V8_OVERRIDE {
1520 return LInstruction::kArithmeticD;
1522 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1523 virtual const char* Mnemonic() const V8_OVERRIDE;
1530 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1532 LArithmeticT(Token::Value op,
1537 inputs_[0] = context;
1542 LOperand* context() { return inputs_[0]; }
1543 LOperand* left() { return inputs_[1]; }
1544 LOperand* right() { return inputs_[2]; }
1546 virtual Opcode opcode() const V8_OVERRIDE {
1547 return LInstruction::kArithmeticT;
1549 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1550 virtual const char* Mnemonic() const V8_OVERRIDE;
1552 Token::Value op() const { return op_; }
1559 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1561 explicit LReturn(LOperand* value,
1563 LOperand* parameter_count) {
1565 inputs_[1] = context;
1566 inputs_[2] = parameter_count;
1569 bool has_constant_parameter_count() {
1570 return parameter_count()->IsConstantOperand();
1572 LConstantOperand* constant_parameter_count() {
1573 ASSERT(has_constant_parameter_count());
1574 return LConstantOperand::cast(parameter_count());
1576 LOperand* parameter_count() { return inputs_[2]; }
1578 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1579 DECLARE_HYDROGEN_ACCESSOR(Return)
1583 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1585 explicit LLoadNamedField(LOperand* object) {
1586 inputs_[0] = object;
1589 LOperand* object() { return inputs_[0]; }
1591 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1592 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1596 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1598 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1599 inputs_[0] = context;
1600 inputs_[1] = object;
1603 LOperand* context() { return inputs_[0]; }
1604 LOperand* object() { return inputs_[1]; }
1606 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1609 Handle<Object> name() const { return hydrogen()->name(); }
1613 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1615 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1616 inputs_[0] = function;
1620 LOperand* function() { return inputs_[0]; }
1621 LOperand* temp() { return temps_[0]; }
1623 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1624 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1628 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1630 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1631 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1633 Heap::RootListIndex index() const { return hydrogen()->index(); }
1637 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1639 LLoadKeyed(LOperand* elements, LOperand* key) {
1640 inputs_[0] = elements;
1643 LOperand* elements() { return inputs_[0]; }
1644 LOperand* key() { return inputs_[1]; }
1645 ElementsKind elements_kind() const {
1646 return hydrogen()->elements_kind();
1648 bool is_external() const {
1649 return hydrogen()->is_external();
1651 bool is_fixed_typed_array() const {
1652 return hydrogen()->is_fixed_typed_array();
1654 bool is_typed_elements() const {
1655 return is_external() || is_fixed_typed_array();
1658 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1661 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1662 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1664 return hydrogen()->key()->representation().IsTagged();
1669 inline static bool ExternalArrayOpRequiresTemp(
1670 Representation key_representation,
1671 ElementsKind elements_kind) {
1672 // Operations that require the key to be divided by two to be converted into
1673 // an index cannot fold the scale operation into a load and need an extra
1674 // temp register to do the work.
1675 return key_representation.IsSmi() &&
1676 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1677 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1678 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1679 elements_kind == UINT8_ELEMENTS ||
1680 elements_kind == INT8_ELEMENTS ||
1681 elements_kind == UINT8_CLAMPED_ELEMENTS);
1685 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1687 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1688 inputs_[0] = context;
1693 LOperand* context() { return inputs_[0]; }
1694 LOperand* object() { return inputs_[1]; }
1695 LOperand* key() { return inputs_[2]; }
1697 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1701 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1703 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1704 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1708 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1710 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1711 inputs_[0] = context;
1712 inputs_[1] = global_object;
1715 LOperand* context() { return inputs_[0]; }
1716 LOperand* global_object() { return inputs_[1]; }
1718 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1719 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1721 Handle<Object> name() const { return hydrogen()->name(); }
1722 bool for_typeof() const { return hydrogen()->for_typeof(); }
1726 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1728 explicit LStoreGlobalCell(LOperand* value) {
1732 LOperand* value() { return inputs_[0]; }
1734 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1735 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1739 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1741 explicit LLoadContextSlot(LOperand* context) {
1742 inputs_[0] = context;
1745 LOperand* context() { return inputs_[0]; }
1747 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1748 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1750 int slot_index() { return hydrogen()->slot_index(); }
1752 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1756 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1758 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1759 inputs_[0] = context;
1764 LOperand* context() { return inputs_[0]; }
1765 LOperand* value() { return inputs_[1]; }
1766 LOperand* temp() { return temps_[0]; }
1768 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1769 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1771 int slot_index() { return hydrogen()->slot_index(); }
1773 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1777 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1779 explicit LPushArgument(LOperand* value) {
1783 LOperand* value() { return inputs_[0]; }
1785 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1789 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1791 explicit LDrop(int count) : count_(count) { }
1793 int count() const { return count_; }
1795 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1802 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1804 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1805 inputs_[0] = function;
1806 inputs_[1] = code_object;
1809 LOperand* function() { return inputs_[0]; }
1810 LOperand* code_object() { return inputs_[1]; }
1812 virtual void PrintDataTo(StringStream* stream);
1814 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1815 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1819 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1821 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1822 inputs_[0] = base_object;
1823 inputs_[1] = offset;
1826 LOperand* base_object() const { return inputs_[0]; }
1827 LOperand* offset() const { return inputs_[1]; }
1829 virtual void PrintDataTo(StringStream* stream);
1831 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1835 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1837 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1838 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1842 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1844 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1845 DECLARE_HYDROGEN_ACCESSOR(Context)
1849 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1851 explicit LDeclareGlobals(LOperand* context) {
1852 inputs_[0] = context;
1855 LOperand* context() { return inputs_[0]; }
1857 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1858 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1862 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1864 explicit LCallJSFunction(LOperand* function) {
1865 inputs_[0] = function;
1868 LOperand* function() { return inputs_[0]; }
1870 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1871 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1873 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1875 int arity() const { return hydrogen()->argument_count() - 1; }
1879 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1881 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1882 const ZoneList<LOperand*>& operands,
1884 : inputs_(descriptor->environment_length() + 1, zone) {
1885 ASSERT(descriptor->environment_length() + 1 == operands.length());
1886 inputs_.AddAll(operands, zone);
1889 LOperand* target() const { return inputs_[0]; }
1892 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1893 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1895 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1897 int arity() const { return hydrogen()->argument_count() - 1; }
1899 ZoneList<LOperand*> inputs_;
1901 // Iterator support.
1902 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1903 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1905 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1906 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1910 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1912 LInvokeFunction(LOperand* context, LOperand* function) {
1913 inputs_[0] = context;
1914 inputs_[1] = function;
1917 LOperand* context() { return inputs_[0]; }
1918 LOperand* function() { return inputs_[1]; }
1920 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1921 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1923 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1931 explicit LCallFunction(LOperand* context, LOperand* function) {
1932 inputs_[0] = context;
1933 inputs_[1] = function;
1936 LOperand* context() { return inputs_[0]; }
1937 LOperand* function() { return inputs_[1]; }
1939 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1940 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1948 LCallNew(LOperand* context, LOperand* constructor) {
1949 inputs_[0] = context;
1950 inputs_[1] = constructor;
1953 LOperand* context() { return inputs_[0]; }
1954 LOperand* constructor() { return inputs_[1]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1959 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1967 LCallNewArray(LOperand* context, LOperand* constructor) {
1968 inputs_[0] = context;
1969 inputs_[1] = constructor;
1972 LOperand* context() { return inputs_[0]; }
1973 LOperand* constructor() { return inputs_[1]; }
1975 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1976 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1978 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1980 int arity() const { return hydrogen()->argument_count() - 1; }
1984 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1986 explicit LCallRuntime(LOperand* context) {
1987 inputs_[0] = context;
1990 LOperand* context() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1993 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1995 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1999 const Runtime::Function* function() const { return hydrogen()->function(); }
2000 int arity() const { return hydrogen()->argument_count(); }
2004 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2006 explicit LInteger32ToDouble(LOperand* value) {
2010 LOperand* value() { return inputs_[0]; }
2012 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2016 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2018 explicit LUint32ToDouble(LOperand* value) {
2022 LOperand* value() { return inputs_[0]; }
2024 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2028 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2030 LNumberTagI(LOperand* value, LOperand* temp) {
2035 LOperand* value() { return inputs_[0]; }
2036 LOperand* temp() { return temps_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2042 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2044 LNumberTagU(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2056 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2058 LNumberTagD(LOperand* value, LOperand* temp) {
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2067 DECLARE_HYDROGEN_ACCESSOR(Change)
2071 // Sometimes truncating conversion from a tagged value to an int32.
2072 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2074 explicit LDoubleToI(LOperand* value) {
2078 LOperand* value() { return inputs_[0]; }
2080 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2081 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2083 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2087 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2089 explicit LDoubleToSmi(LOperand* value) {
2093 LOperand* value() { return inputs_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2096 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2100 // Truncating conversion from a tagged value to an int32.
2101 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2103 explicit LTaggedToI(LOperand* value) {
2107 LOperand* value() { return inputs_[0]; }
2109 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2110 DECLARE_HYDROGEN_ACCESSOR(Change)
2112 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2116 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2118 explicit LSmiTag(LOperand* value) {
2122 LOperand* value() { return inputs_[0]; }
2124 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2125 DECLARE_HYDROGEN_ACCESSOR(Change)
2129 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2131 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2136 LOperand* value() { return inputs_[0]; }
2137 LOperand* temp() { return temps_[0]; }
2139 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2140 DECLARE_HYDROGEN_ACCESSOR(Change);
2144 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2146 LSmiUntag(LOperand* value, bool needs_check)
2147 : needs_check_(needs_check) {
2151 LOperand* value() { return inputs_[0]; }
2153 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2155 bool needs_check() const { return needs_check_; }
2162 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2164 LStoreNamedField(LOperand* obj,
2167 LOperand* temp_map) {
2171 temps_[1] = temp_map;
2174 LOperand* object() { return inputs_[0]; }
2175 LOperand* value() { return inputs_[1]; }
2176 LOperand* temp() { return temps_[0]; }
2177 LOperand* temp_map() { return temps_[1]; }
2179 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2180 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2182 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2186 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2188 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2189 inputs_[0] = context;
2190 inputs_[1] = object;
2194 LOperand* context() { return inputs_[0]; }
2195 LOperand* object() { return inputs_[1]; }
2196 LOperand* value() { return inputs_[2]; }
2198 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2199 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2201 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2202 Handle<Object> name() const { return hydrogen()->name(); }
2203 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2207 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2209 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2215 bool is_external() const { return hydrogen()->is_external(); }
2216 bool is_fixed_typed_array() const {
2217 return hydrogen()->is_fixed_typed_array();
2219 bool is_typed_elements() const {
2220 return is_external() || is_fixed_typed_array();
2222 LOperand* elements() { return inputs_[0]; }
2223 LOperand* key() { return inputs_[1]; }
2224 LOperand* value() { return inputs_[2]; }
2225 ElementsKind elements_kind() const {
2226 return hydrogen()->elements_kind();
2229 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2230 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2232 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2233 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2234 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2238 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2240 LStoreKeyedGeneric(LOperand* context,
2244 inputs_[0] = context;
2245 inputs_[1] = object;
2250 LOperand* context() { return inputs_[0]; }
2251 LOperand* object() { return inputs_[1]; }
2252 LOperand* key() { return inputs_[2]; }
2253 LOperand* value() { return inputs_[3]; }
2255 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2256 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2258 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2260 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2264 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2266 LTransitionElementsKind(LOperand* object,
2268 LOperand* new_map_temp,
2270 inputs_[0] = object;
2271 inputs_[1] = context;
2272 temps_[0] = new_map_temp;
2276 LOperand* context() { return inputs_[1]; }
2277 LOperand* object() { return inputs_[0]; }
2278 LOperand* new_map_temp() { return temps_[0]; }
2279 LOperand* temp() { return temps_[1]; }
2281 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2282 "transition-elements-kind")
2283 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2285 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2287 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2288 Handle<Map> transitioned_map() {
2289 return hydrogen()->transitioned_map().handle();
2291 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2292 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2296 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2298 LTrapAllocationMemento(LOperand* object,
2300 inputs_[0] = object;
2304 LOperand* object() { return inputs_[0]; }
2305 LOperand* temp() { return temps_[0]; }
2307 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2308 "trap-allocation-memento")
2312 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2314 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2315 inputs_[0] = context;
2320 LOperand* context() { return inputs_[0]; }
2321 LOperand* left() { return inputs_[1]; }
2322 LOperand* right() { return inputs_[2]; }
2324 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2325 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2329 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2331 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2332 inputs_[0] = context;
2333 inputs_[1] = string;
2337 LOperand* context() { return inputs_[0]; }
2338 LOperand* string() { return inputs_[1]; }
2339 LOperand* index() { return inputs_[2]; }
2341 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2342 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2346 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2348 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2349 inputs_[0] = context;
2350 inputs_[1] = char_code;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* char_code() { return inputs_[1]; }
2356 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2357 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2361 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2363 explicit LCheckValue(LOperand* value) {
2367 LOperand* value() { return inputs_[0]; }
2369 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2370 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2374 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2376 LCheckInstanceType(LOperand* value, LOperand* temp) {
2381 LOperand* value() { return inputs_[0]; }
2382 LOperand* temp() { return temps_[0]; }
2384 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2385 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2389 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2391 explicit LCheckMaps(LOperand* value = NULL) {
2395 LOperand* value() { return inputs_[0]; }
2397 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2398 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2402 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2404 explicit LCheckSmi(LOperand* value) {
2408 LOperand* value() { return inputs_[0]; }
2410 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2414 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2416 explicit LClampDToUint8(LOperand* value) {
2420 LOperand* unclamped() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2426 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2428 explicit LClampIToUint8(LOperand* value) {
2432 LOperand* unclamped() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2438 // Truncating conversion from a tagged value to an int32.
2439 class LClampTToUint8NoSSE2 V8_FINAL : public LTemplateInstruction<1, 1, 3> {
2441 LClampTToUint8NoSSE2(LOperand* unclamped,
2445 inputs_[0] = unclamped;
2451 LOperand* unclamped() { return inputs_[0]; }
2452 LOperand* scratch() { return temps_[0]; }
2453 LOperand* scratch2() { return temps_[1]; }
2454 LOperand* scratch3() { return temps_[2]; }
2456 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2457 "clamp-t-to-uint8-nosse2")
2458 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2462 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2464 explicit LCheckNonSmi(LOperand* value) {
2468 LOperand* value() { return inputs_[0]; }
2470 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2471 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2475 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2477 explicit LDoubleBits(LOperand* value) {
2481 LOperand* value() { return inputs_[0]; }
2483 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2484 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2488 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2490 LConstructDouble(LOperand* hi, LOperand* lo) {
2495 LOperand* hi() { return inputs_[0]; }
2496 LOperand* lo() { return inputs_[1]; }
2498 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2502 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2504 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2505 inputs_[0] = context;
2510 LOperand* context() { return inputs_[0]; }
2511 LOperand* size() { return inputs_[1]; }
2512 LOperand* temp() { return temps_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2515 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2519 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2521 explicit LRegExpLiteral(LOperand* context) {
2522 inputs_[0] = context;
2525 LOperand* context() { return inputs_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2528 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2532 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2534 explicit LFunctionLiteral(LOperand* context) {
2535 inputs_[0] = context;
2538 LOperand* context() { return inputs_[0]; }
2540 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2541 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2545 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2547 explicit LToFastProperties(LOperand* value) {
2551 LOperand* value() { return inputs_[0]; }
2553 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2554 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2558 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2560 LTypeof(LOperand* context, LOperand* value) {
2561 inputs_[0] = context;
2565 LOperand* context() { return inputs_[0]; }
2566 LOperand* value() { return inputs_[1]; }
2568 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2572 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2574 explicit LTypeofIsAndBranch(LOperand* value) {
2578 LOperand* value() { return inputs_[0]; }
2580 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2581 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2583 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2585 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2589 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2591 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2594 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2598 class LStackCheck V8_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 V8_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 V8_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 V8_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 V8_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 V8_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 V8_FINAL : public LChunkBuilderBase {
2722 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2723 : LChunkBuilderBase(graph->zone()),
2728 current_instruction_(NULL),
2729 current_block_(NULL),
2731 allocator_(allocator) { }
2733 Isolate* isolate() const { return graph_->isolate(); }
2735 // Build the sequence for the graph.
2736 LPlatformChunk* Build();
2738 // Declare methods that deal with the individual node types.
2739 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2740 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2743 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2744 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2745 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2746 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2747 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2748 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2749 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2750 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2751 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2752 LInstruction* DoDivByConstI(HDiv* instr);
2753 LInstruction* DoDivI(HDiv* instr);
2754 LInstruction* DoModByPowerOf2I(HMod* instr);
2755 LInstruction* DoModByConstI(HMod* instr);
2756 LInstruction* DoModI(HMod* instr);
2757 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2758 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2759 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2769 LPlatformChunk* chunk() const { return chunk_; }
2770 CompilationInfo* info() const { return info_; }
2771 HGraph* graph() const { return graph_; }
2773 bool is_unused() const { return status_ == UNUSED; }
2774 bool is_building() const { return status_ == BUILDING; }
2775 bool is_done() const { return status_ == DONE; }
2776 bool is_aborted() const { return status_ == ABORTED; }
2778 void Abort(BailoutReason reason);
2780 // Methods for getting operands for Use / Define / Temp.
2781 LUnallocated* ToUnallocated(Register reg);
2782 LUnallocated* ToUnallocated(X87Register reg);
2784 // Methods for setting up define-use relationships.
2785 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2786 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2788 // A value that is guaranteed to be allocated to a register.
2789 // Operand created by UseRegister is guaranteed to be live until the end of
2790 // instruction. This means that register allocator will not reuse it's
2791 // register for any other operand inside instruction.
2792 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2793 // instruction start. Register allocator is free to assign the same register
2794 // to some other operand used inside instruction (i.e. temporary or
2796 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2797 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2799 // An input operand in a register that may be trashed.
2800 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2802 // An input operand in a register or stack slot.
2803 MUST_USE_RESULT LOperand* Use(HValue* value);
2804 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2806 // An input operand in a register, stack slot or a constant operand.
2807 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2808 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2810 // An input operand in a fixed register or a constant operand.
2811 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2812 Register fixed_register);
2814 // An input operand in a register or a constant operand.
2815 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2816 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2818 // An input operand in a constant operand.
2819 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2821 // An input operand in register, stack slot or a constant operand.
2822 // Will not be moved to a register even if one is freely available.
2823 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2825 // Temporary operand that must be in a register.
2826 MUST_USE_RESULT LUnallocated* TempRegister();
2827 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2829 // Methods for setting up define-use relationships.
2830 // Return the same instruction that they are passed.
2831 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2832 LUnallocated* result);
2833 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2834 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2836 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2837 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2839 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2840 // Assigns an environment to an instruction. An instruction which can
2841 // deoptimize must have an environment.
2842 LInstruction* AssignEnvironment(LInstruction* instr);
2843 // Assigns a pointer map to an instruction. An instruction which can
2844 // trigger a GC or a lazy deoptimization must have a pointer map.
2845 LInstruction* AssignPointerMap(LInstruction* instr);
2847 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2849 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2851 // Marks a call for the register allocator. Assigns a pointer map to
2852 // support GC and lazy deoptimization. Assigns an environment to support
2853 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2854 LInstruction* MarkAsCall(
2855 LInstruction* instr,
2856 HInstruction* hinstr,
2857 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2859 void VisitInstruction(HInstruction* current);
2860 void AddInstruction(LInstruction* instr, HInstruction* current);
2862 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2863 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2864 LInstruction* DoArithmeticD(Token::Value op,
2865 HArithmeticBinaryOperation* instr);
2866 LInstruction* DoArithmeticT(Token::Value op,
2867 HBinaryOperation* instr);
2869 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2871 LPlatformChunk* chunk_;
2872 CompilationInfo* info_;
2873 HGraph* const graph_;
2875 HInstruction* current_instruction_;
2876 HBasicBlock* current_block_;
2877 HBasicBlock* next_block_;
2878 LAllocator* allocator_;
2880 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2883 #undef DECLARE_HYDROGEN_ACCESSOR
2884 #undef DECLARE_CONCRETE_INSTRUCTION
2886 } } // namespace v8::internal
2888 #endif // V8_X87_LITHIUM_X87_H_