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_X64_LITHIUM_X64_H_
6 #define V8_X64_LITHIUM_X64_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 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) \
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 DCHECK(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 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
238 bool IsCall() const { return IsCallBits::decode(bit_field_); }
240 // Interface to the register allocator and iterators.
241 bool ClobbersTemps() const { return IsCall(); }
242 bool ClobbersRegisters() const { return IsCall(); }
243 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
249 // Interface to the register allocator and iterators.
250 bool IsMarkedAsCall() const { return IsCall(); }
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 LOperand* FirstInput() { return InputAt(0); }
256 LOperand* Output() { return HasResult() ? result() : NULL; }
258 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
260 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
295 return R != 0 && result() != NULL;
297 void set_result(LOperand* operand) { results_[0] = operand; }
298 LOperand* result() const { return results_[0]; }
300 virtual bool MustSignExtendResult(
301 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
304 EmbeddedContainer<LOperand*, R> results_;
308 // R = number of result operands (0 or 1).
309 // I = number of input operands.
310 // T = number of temporary operands.
311 template<int R, int I, int T>
312 class LTemplateInstruction : public LTemplateResultInstruction<R> {
314 EmbeddedContainer<LOperand*, I> inputs_;
315 EmbeddedContainer<LOperand*, T> temps_;
319 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
320 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
322 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
323 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
327 class LGap : public LTemplateInstruction<0, 0, 0> {
329 explicit LGap(HBasicBlock* block)
331 parallel_moves_[BEFORE] = NULL;
332 parallel_moves_[START] = NULL;
333 parallel_moves_[END] = NULL;
334 parallel_moves_[AFTER] = NULL;
337 // Can't use the DECLARE-macro here because of sub-classes.
338 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
339 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
340 static LGap* cast(LInstruction* instr) {
341 DCHECK(instr->IsGap());
342 return reinterpret_cast<LGap*>(instr);
345 bool IsRedundant() const;
347 HBasicBlock* block() const { return block_; }
354 FIRST_INNER_POSITION = BEFORE,
355 LAST_INNER_POSITION = AFTER
358 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
360 if (parallel_moves_[pos] == NULL) {
361 parallel_moves_[pos] = new(zone) LParallelMove(zone);
363 return parallel_moves_[pos];
366 LParallelMove* GetParallelMove(InnerPosition pos) {
367 return parallel_moves_[pos];
371 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
376 class LInstructionGap V8_FINAL : public LGap {
378 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
380 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
381 return !IsRedundant();
384 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
388 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
390 explicit LGoto(HBasicBlock* block) : block_(block) { }
392 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
393 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
394 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
395 virtual bool IsControl() const V8_OVERRIDE { return true; }
397 int block_id() const { return block_->block_id(); }
404 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
406 LLazyBailout() : gap_instructions_size_(0) { }
408 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
410 void set_gap_instructions_size(int gap_instructions_size) {
411 gap_instructions_size_ = gap_instructions_size;
413 int gap_instructions_size() { return gap_instructions_size_; }
416 int gap_instructions_size_;
420 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
423 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
427 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
429 explicit LDummyUse(LOperand* value) {
432 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
436 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
438 virtual bool IsControl() const V8_OVERRIDE { return true; }
439 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
440 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
444 class LLabel V8_FINAL : public LGap {
446 explicit LLabel(HBasicBlock* block)
447 : LGap(block), replacement_(NULL) { }
449 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
452 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
454 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
456 int block_id() const { return block()->block_id(); }
457 bool is_loop_header() const { return block()->IsLoopHeader(); }
458 bool is_osr_entry() const { return block()->is_osr_entry(); }
459 Label* label() { return &label_; }
460 LLabel* replacement() const { return replacement_; }
461 void set_replacement(LLabel* label) { replacement_ = label; }
462 bool HasReplacement() const { return replacement_ != NULL; }
466 LLabel* replacement_;
470 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
472 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
475 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
479 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
481 explicit LCallStub(LOperand* context) {
482 inputs_[0] = context;
485 LOperand* context() { return inputs_[0]; }
487 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
488 DECLARE_HYDROGEN_ACCESSOR(CallStub)
492 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
494 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
497 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
501 template<int I, int T>
502 class LControlInstruction : public LTemplateInstruction<0, I, T> {
504 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
506 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
508 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
509 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
511 int TrueDestination(LChunk* chunk) {
512 return chunk->LookupDestination(true_block_id());
514 int FalseDestination(LChunk* chunk) {
515 return chunk->LookupDestination(false_block_id());
518 Label* TrueLabel(LChunk* chunk) {
519 if (true_label_ == NULL) {
520 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
524 Label* FalseLabel(LChunk* chunk) {
525 if (false_label_ == NULL) {
526 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
532 int true_block_id() { return SuccessorAt(0)->block_id(); }
533 int false_block_id() { return SuccessorAt(1)->block_id(); }
536 HControlInstruction* hydrogen() {
537 return HControlInstruction::cast(this->hydrogen_value());
545 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
547 LWrapReceiver(LOperand* receiver, LOperand* function) {
548 inputs_[0] = receiver;
549 inputs_[1] = function;
552 LOperand* receiver() { return inputs_[0]; }
553 LOperand* function() { return inputs_[1]; }
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
556 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
562 LApplyArguments(LOperand* function,
565 LOperand* elements) {
566 inputs_[0] = function;
567 inputs_[1] = receiver;
569 inputs_[3] = elements;
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
583 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
584 inputs_[0] = arguments;
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
599 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
601 explicit LArgumentsLength(LOperand* elements) {
602 inputs_[0] = elements;
605 LOperand* elements() { return inputs_[0]; }
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
611 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
614 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
618 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
620 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
621 inputs_[0] = dividend;
625 LOperand* dividend() { return inputs_[0]; }
626 int32_t divisor() const { return divisor_; }
628 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
629 DECLARE_HYDROGEN_ACCESSOR(Mod)
636 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
638 LModByConstI(LOperand* dividend,
642 inputs_[0] = dividend;
648 LOperand* dividend() { return inputs_[0]; }
649 int32_t divisor() const { return divisor_; }
650 LOperand* temp1() { return temps_[0]; }
651 LOperand* temp2() { return temps_[1]; }
653 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
654 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
663 LModI(LOperand* left, LOperand* right, LOperand* temp) {
669 LOperand* left() { return inputs_[0]; }
670 LOperand* right() { return inputs_[1]; }
671 LOperand* temp() { return temps_[0]; }
673 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
674 DECLARE_HYDROGEN_ACCESSOR(Mod)
678 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
680 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
681 inputs_[0] = dividend;
685 LOperand* dividend() { return inputs_[0]; }
686 int32_t divisor() const { return divisor_; }
688 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
689 DECLARE_HYDROGEN_ACCESSOR(Div)
696 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
698 LDivByConstI(LOperand* dividend,
702 inputs_[0] = dividend;
708 LOperand* dividend() { return inputs_[0]; }
709 int32_t divisor() const { return divisor_; }
710 LOperand* temp1() { return temps_[0]; }
711 LOperand* temp2() { return temps_[1]; }
713 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
714 DECLARE_HYDROGEN_ACCESSOR(Div)
721 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
723 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
724 inputs_[0] = dividend;
725 inputs_[1] = divisor;
729 LOperand* dividend() { return inputs_[0]; }
730 LOperand* divisor() { return inputs_[1]; }
731 LOperand* temp() { return temps_[0]; }
733 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
734 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
738 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
740 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
741 inputs_[0] = dividend;
745 LOperand* dividend() { return inputs_[0]; }
746 int32_t divisor() const { return divisor_; }
748 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
749 "flooring-div-by-power-of-2-i")
750 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
757 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
759 LFlooringDivByConstI(LOperand* dividend,
764 inputs_[0] = dividend;
771 LOperand* dividend() { return inputs_[0]; }
772 int32_t divisor() const { return divisor_; }
773 LOperand* temp1() { return temps_[0]; }
774 LOperand* temp2() { return temps_[1]; }
775 LOperand* temp3() { return temps_[2]; }
777 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
785 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
787 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
788 inputs_[0] = dividend;
789 inputs_[1] = divisor;
793 LOperand* dividend() { return inputs_[0]; }
794 LOperand* divisor() { return inputs_[1]; }
795 LOperand* temp() { return temps_[0]; }
797 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
798 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
802 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
804 LMulI(LOperand* left, LOperand* right) {
809 LOperand* left() { return inputs_[0]; }
810 LOperand* right() { return inputs_[1]; }
812 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
813 DECLARE_HYDROGEN_ACCESSOR(Mul)
817 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
819 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
824 LOperand* left() { return inputs_[0]; }
825 LOperand* right() { return inputs_[1]; }
827 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
828 "compare-numeric-and-branch")
829 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
831 Token::Value op() const { return hydrogen()->token(); }
832 bool is_double() const {
833 return hydrogen()->representation().IsDouble();
836 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
840 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
842 explicit LMathFloor(LOperand* value) {
846 LOperand* value() { return inputs_[0]; }
848 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
849 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
853 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
855 LMathRound(LOperand* value, LOperand* temp) {
860 LOperand* value() { return inputs_[0]; }
861 LOperand* temp() { return temps_[0]; }
863 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
864 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
868 class LMathFround V8_FINAL : public LTemplateInstruction<1, 1, 0> {
870 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
872 LOperand* value() { return inputs_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
878 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
880 explicit LMathAbs(LOperand* context, LOperand* value) {
881 inputs_[1] = context;
885 LOperand* context() { return inputs_[1]; }
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
889 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
893 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
895 explicit LMathLog(LOperand* value) {
899 LOperand* value() { return inputs_[0]; }
901 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
905 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
907 explicit LMathClz32(LOperand* value) {
911 LOperand* value() { return inputs_[0]; }
913 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
917 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
919 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
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, 0> {
948 explicit LMathPowHalf(LOperand* value) {
952 LOperand* value() { return inputs_[0]; }
954 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
958 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
960 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
965 LOperand* left() { return inputs_[0]; }
966 LOperand* right() { return inputs_[1]; }
968 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
972 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
974 explicit LCmpHoleAndBranch(LOperand* object) {
978 LOperand* object() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
985 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
987 explicit LCompareMinusZeroAndBranch(LOperand* value) {
991 LOperand* value() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
994 "cmp-minus-zero-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1000 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1002 explicit LIsObjectAndBranch(LOperand* value) {
1006 LOperand* value() { return inputs_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1011 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1015 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1017 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1022 LOperand* value() { return inputs_[0]; }
1023 LOperand* temp() { return temps_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1034 explicit LIsSmiAndBranch(LOperand* value) {
1038 LOperand* value() { return inputs_[0]; }
1040 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1041 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1043 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1047 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1049 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1054 LOperand* value() { return inputs_[0]; }
1055 LOperand* temp() { return temps_[0]; }
1057 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1058 "is-undetectable-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1061 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1065 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1067 explicit LStringCompareAndBranch(LOperand* context,
1070 inputs_[0] = context;
1075 LOperand* context() { return inputs_[0]; }
1076 LOperand* left() { return inputs_[1]; }
1077 LOperand* right() { return inputs_[2]; }
1079 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1080 "string-compare-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1083 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1085 Token::Value op() const { return hydrogen()->token(); }
1089 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1091 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1095 LOperand* value() { return inputs_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1098 "has-instance-type-and-branch")
1099 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1101 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1105 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1107 explicit LGetCachedArrayIndex(LOperand* value) {
1111 LOperand* value() { return inputs_[0]; }
1113 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1114 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1118 class LHasCachedArrayIndexAndBranch V8_FINAL
1119 : public LControlInstruction<1, 0> {
1121 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1125 LOperand* value() { return inputs_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1128 "has-cached-array-index-and-branch")
1129 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1131 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1135 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1137 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1143 LOperand* value() { return inputs_[0]; }
1144 LOperand* temp() { return temps_[0]; }
1145 LOperand* temp2() { return temps_[1]; }
1147 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1148 "class-of-test-and-branch")
1149 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1151 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1155 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1157 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1158 inputs_[0] = context;
1163 LOperand* context() { return inputs_[0]; }
1164 LOperand* left() { return inputs_[1]; }
1165 LOperand* right() { return inputs_[2]; }
1167 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1168 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1170 Token::Value op() const { return hydrogen()->token(); }
1174 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1176 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1177 inputs_[0] = context;
1182 LOperand* context() { return inputs_[0]; }
1183 LOperand* left() { return inputs_[1]; }
1184 LOperand* right() { return inputs_[2]; }
1186 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1190 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1192 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1193 inputs_[0] = context;
1198 LOperand* context() { return inputs_[0]; }
1199 LOperand* value() { return inputs_[1]; }
1200 LOperand* temp() { return temps_[0]; }
1202 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1203 "instance-of-known-global")
1204 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1206 Handle<JSFunction> function() const { return hydrogen()->function(); }
1207 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1208 return lazy_deopt_env_;
1210 virtual void SetDeferredLazyDeoptimizationEnvironment(
1211 LEnvironment* env) V8_OVERRIDE {
1212 lazy_deopt_env_ = env;
1216 LEnvironment* lazy_deopt_env_;
1220 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1222 LBoundsCheck(LOperand* index, LOperand* length) {
1224 inputs_[1] = length;
1227 LOperand* index() { return inputs_[0]; }
1228 LOperand* length() { return inputs_[1]; }
1230 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1231 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1235 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1237 LBitI(LOperand* left, LOperand* right) {
1242 LOperand* left() { return inputs_[0]; }
1243 LOperand* right() { return inputs_[1]; }
1245 Token::Value op() const { return hydrogen()->op(); }
1246 bool IsInteger32() const {
1247 return hydrogen()->representation().IsInteger32();
1250 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1251 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1255 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1257 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1258 : op_(op), can_deopt_(can_deopt) {
1263 Token::Value op() const { return op_; }
1264 LOperand* left() { return inputs_[0]; }
1265 LOperand* right() { return inputs_[1]; }
1266 bool can_deopt() const { return can_deopt_; }
1268 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1276 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LSubI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Sub)
1291 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1293 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Constant)
1296 int32_t value() const { return hydrogen()->Integer32Value(); }
1300 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1309 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1311 explicit LConstantD(LOperand* temp) {
1315 LOperand* temp() { return temps_[0]; }
1317 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1318 DECLARE_HYDROGEN_ACCESSOR(Constant)
1320 double value() const { return hydrogen()->DoubleValue(); }
1324 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 ExternalReference value() const {
1330 return hydrogen()->ExternalReferenceValue();
1335 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 Handle<Object> value(Isolate* isolate) const {
1341 return hydrogen()->handle(isolate);
1346 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1348 explicit LBranch(LOperand* value) {
1352 LOperand* value() { return inputs_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1355 DECLARE_HYDROGEN_ACCESSOR(Branch)
1357 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1361 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1367 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1369 explicit LCmpMapAndBranch(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1396 LDateField(LOperand* date, Smi* index) : index_(index) {
1400 LOperand* date() { return inputs_[0]; }
1401 Smi* index() const { return index_; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1411 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1413 LSeqStringGetChar(LOperand* string, LOperand* index) {
1414 inputs_[0] = string;
1418 LOperand* string() const { return inputs_[0]; }
1419 LOperand* index() const { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1428 LSeqStringSetChar(LOperand* context,
1432 inputs_[0] = context;
1433 inputs_[1] = string;
1438 LOperand* string() { return inputs_[1]; }
1439 LOperand* index() { return inputs_[2]; }
1440 LOperand* value() { return inputs_[3]; }
1442 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1443 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 static bool UseLea(HAdd* add) {
1458 return !add->CheckFlag(HValue::kCanOverflow) &&
1459 add->BetterLeftOperand()->UseCount() > 1;
1462 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1463 DECLARE_HYDROGEN_ACCESSOR(Add)
1467 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LMathMinMax(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1478 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1482 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LPower(LOperand* left, LOperand* right) {
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1493 DECLARE_HYDROGEN_ACCESSOR(Power)
1497 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1499 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1505 Token::Value op() const { return op_; }
1506 LOperand* left() { return inputs_[0]; }
1507 LOperand* right() { return inputs_[1]; }
1509 virtual Opcode opcode() const V8_OVERRIDE {
1510 return LInstruction::kArithmeticD;
1512 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1513 virtual const char* Mnemonic() const V8_OVERRIDE;
1520 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1522 LArithmeticT(Token::Value op,
1527 inputs_[0] = context;
1532 Token::Value op() const { return op_; }
1533 LOperand* context() { return inputs_[0]; }
1534 LOperand* left() { return inputs_[1]; }
1535 LOperand* right() { return inputs_[2]; }
1537 virtual Opcode opcode() const V8_OVERRIDE {
1538 return LInstruction::kArithmeticT;
1540 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1541 virtual const char* Mnemonic() const V8_OVERRIDE;
1548 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1550 explicit LReturn(LOperand* value,
1552 LOperand* parameter_count) {
1554 inputs_[1] = context;
1555 inputs_[2] = parameter_count;
1558 LOperand* value() { return inputs_[0]; }
1559 LOperand* context() { return inputs_[1]; }
1561 bool has_constant_parameter_count() {
1562 return parameter_count()->IsConstantOperand();
1564 LConstantOperand* constant_parameter_count() {
1565 DCHECK(has_constant_parameter_count());
1566 return LConstantOperand::cast(parameter_count());
1568 LOperand* parameter_count() { return inputs_[2]; }
1570 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1571 DECLARE_HYDROGEN_ACCESSOR(Return)
1575 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1577 explicit LLoadNamedField(LOperand* object) {
1578 inputs_[0] = object;
1581 LOperand* object() { return inputs_[0]; }
1583 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1590 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1592 inputs_[0] = context;
1593 inputs_[1] = object;
1597 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1598 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1600 LOperand* context() { return inputs_[0]; }
1601 LOperand* object() { return inputs_[1]; }
1602 LOperand* temp_vector() { return temps_[0]; }
1604 Handle<Object> name() const { return hydrogen()->name(); }
1608 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1610 explicit LLoadFunctionPrototype(LOperand* function) {
1611 inputs_[0] = function;
1614 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1615 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1617 LOperand* function() { return inputs_[0]; }
1621 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1623 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1624 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1626 Heap::RootListIndex index() const { return hydrogen()->index(); }
1630 inline static bool ExternalArrayOpRequiresTemp(
1631 Representation key_representation,
1632 ElementsKind elements_kind) {
1633 // Operations that require the key to be divided by two to be converted into
1634 // an index cannot fold the scale operation into a load and need an extra
1635 // temp register to do the work.
1636 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1637 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1638 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1639 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1640 elements_kind == UINT8_ELEMENTS ||
1641 elements_kind == INT8_ELEMENTS ||
1642 elements_kind == UINT8_CLAMPED_ELEMENTS);
1646 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1648 LLoadKeyed(LOperand* elements, LOperand* key) {
1649 inputs_[0] = elements;
1653 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1654 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1656 bool is_external() const {
1657 return hydrogen()->is_external();
1659 bool is_fixed_typed_array() const {
1660 return hydrogen()->is_fixed_typed_array();
1662 bool is_typed_elements() const {
1663 return is_external() || is_fixed_typed_array();
1665 LOperand* elements() { return inputs_[0]; }
1666 LOperand* key() { return inputs_[1]; }
1667 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1668 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1669 ElementsKind elements_kind() const {
1670 return hydrogen()->elements_kind();
1675 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1677 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1679 inputs_[0] = context;
1685 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1686 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1688 LOperand* context() { return inputs_[0]; }
1689 LOperand* object() { return inputs_[1]; }
1690 LOperand* key() { return inputs_[2]; }
1691 LOperand* temp_vector() { return temps_[0]; }
1695 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1697 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1698 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1702 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1704 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1706 inputs_[0] = context;
1707 inputs_[1] = global_object;
1711 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1712 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1714 LOperand* context() { return inputs_[0]; }
1715 LOperand* global_object() { return inputs_[1]; }
1716 LOperand* temp_vector() { return temps_[0]; }
1718 Handle<Object> name() const { return hydrogen()->name(); }
1719 bool for_typeof() const { return hydrogen()->for_typeof(); }
1723 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1725 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1730 LOperand* value() { return inputs_[0]; }
1731 LOperand* temp() { return temps_[0]; }
1733 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1734 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1738 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1740 explicit LLoadContextSlot(LOperand* context) {
1741 inputs_[0] = context;
1744 LOperand* context() { return inputs_[0]; }
1746 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1747 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1749 int slot_index() { return hydrogen()->slot_index(); }
1751 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1755 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1757 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1758 inputs_[0] = context;
1763 LOperand* context() { return inputs_[0]; }
1764 LOperand* value() { return inputs_[1]; }
1765 LOperand* temp() { return temps_[0]; }
1767 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1768 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1770 int slot_index() { return hydrogen()->slot_index(); }
1772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1776 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1778 explicit LPushArgument(LOperand* value) {
1782 LOperand* value() { return inputs_[0]; }
1784 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1788 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1790 explicit LDrop(int count) : count_(count) { }
1792 int count() const { return count_; }
1794 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1801 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1803 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1804 inputs_[0] = function;
1805 inputs_[1] = code_object;
1808 LOperand* function() { return inputs_[0]; }
1809 LOperand* code_object() { return inputs_[1]; }
1811 virtual void PrintDataTo(StringStream* stream);
1813 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1814 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1818 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1820 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1821 inputs_[0] = base_object;
1822 inputs_[1] = offset;
1825 LOperand* base_object() const { return inputs_[0]; }
1826 LOperand* offset() const { return inputs_[1]; }
1828 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1830 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1834 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1836 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1837 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1841 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1843 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1844 DECLARE_HYDROGEN_ACCESSOR(Context)
1848 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1850 explicit LDeclareGlobals(LOperand* context) {
1851 inputs_[0] = context;
1854 LOperand* context() { return inputs_[0]; }
1856 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1857 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1861 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1863 explicit LCallJSFunction(LOperand* function) {
1864 inputs_[0] = function;
1867 LOperand* function() { return inputs_[0]; }
1869 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1870 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1872 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1874 int arity() const { return hydrogen()->argument_count() - 1; }
1878 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1880 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1881 const ZoneList<LOperand*>& operands,
1883 : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1884 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1885 inputs_.AddAll(operands, zone);
1888 LOperand* target() const { return inputs_[0]; }
1891 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1892 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1894 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1896 int arity() const { return hydrogen()->argument_count() - 1; }
1898 ZoneList<LOperand*> inputs_;
1900 // Iterator support.
1901 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1902 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1904 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1905 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1909 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1911 LInvokeFunction(LOperand* context, LOperand* function) {
1912 inputs_[0] = context;
1913 inputs_[1] = function;
1916 LOperand* context() { return inputs_[0]; }
1917 LOperand* function() { return inputs_[1]; }
1919 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1920 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1922 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1924 int arity() const { return hydrogen()->argument_count() - 1; }
1928 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1930 LCallFunction(LOperand* context, LOperand* function) {
1931 inputs_[0] = context;
1932 inputs_[1] = function;
1935 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1936 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1938 LOperand* context() { return inputs_[0]; }
1939 LOperand* function() { return inputs_[1]; }
1940 int arity() const { return hydrogen()->argument_count() - 1; }
1944 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1946 LCallNew(LOperand* context, LOperand* constructor) {
1947 inputs_[0] = context;
1948 inputs_[1] = constructor;
1951 LOperand* context() { return inputs_[0]; }
1952 LOperand* constructor() { return inputs_[1]; }
1954 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1955 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1957 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1959 int arity() const { return hydrogen()->argument_count() - 1; }
1963 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1965 LCallNewArray(LOperand* context, LOperand* constructor) {
1966 inputs_[0] = context;
1967 inputs_[1] = constructor;
1970 LOperand* context() { return inputs_[0]; }
1971 LOperand* constructor() { return inputs_[1]; }
1973 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1974 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1976 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1978 int arity() const { return hydrogen()->argument_count() - 1; }
1982 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1984 explicit LCallRuntime(LOperand* context) {
1985 inputs_[0] = context;
1988 LOperand* context() { return inputs_[0]; }
1990 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1991 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1993 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1994 return save_doubles() == kDontSaveFPRegs;
1997 const Runtime::Function* function() const { return hydrogen()->function(); }
1998 int arity() const { return hydrogen()->argument_count(); }
1999 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2003 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2005 explicit LInteger32ToDouble(LOperand* value) {
2009 LOperand* value() { return inputs_[0]; }
2011 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2015 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2017 explicit LUint32ToDouble(LOperand* value) {
2021 LOperand* value() { return inputs_[0]; }
2023 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2027 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2029 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2035 LOperand* value() { return inputs_[0]; }
2036 LOperand* temp1() { return temps_[0]; }
2037 LOperand* temp2() { return temps_[1]; }
2039 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2043 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2045 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp1() { return temps_[0]; }
2053 LOperand* temp2() { return temps_[1]; }
2055 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2059 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2061 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2066 LOperand* value() { return inputs_[0]; }
2067 LOperand* temp() { return temps_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2070 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 // Sometimes truncating conversion from a tagged value to an int32.
2075 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2077 explicit LDoubleToI(LOperand* value) {
2081 LOperand* value() { return inputs_[0]; }
2083 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2084 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2086 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2090 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2092 explicit LDoubleToSmi(LOperand* value) {
2096 LOperand* value() { return inputs_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2099 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2103 // Truncating conversion from a tagged value to an int32.
2104 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2106 LTaggedToI(LOperand* value, LOperand* temp) {
2111 LOperand* value() { return inputs_[0]; }
2112 LOperand* temp() { return temps_[0]; }
2114 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2115 DECLARE_HYDROGEN_ACCESSOR(Change)
2117 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2121 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2123 explicit LSmiTag(LOperand* value) {
2127 LOperand* value() { return inputs_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2130 DECLARE_HYDROGEN_ACCESSOR(Change)
2134 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2136 explicit LNumberUntagD(LOperand* value) {
2140 LOperand* value() { return inputs_[0]; }
2142 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2143 DECLARE_HYDROGEN_ACCESSOR(Change);
2147 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2149 LSmiUntag(LOperand* value, bool needs_check)
2150 : needs_check_(needs_check) {
2154 LOperand* value() { return inputs_[0]; }
2155 bool needs_check() const { return needs_check_; }
2157 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2164 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2166 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2167 inputs_[0] = object;
2172 LOperand* object() { return inputs_[0]; }
2173 LOperand* value() { return inputs_[1]; }
2174 LOperand* temp() { return temps_[0]; }
2176 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2177 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2179 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2181 Representation representation() const {
2182 return hydrogen()->field_representation();
2187 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2189 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2190 inputs_[0] = context;
2191 inputs_[1] = object;
2195 LOperand* context() { return inputs_[0]; }
2196 LOperand* object() { return inputs_[1]; }
2197 LOperand* value() { return inputs_[2]; }
2199 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2200 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2202 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2204 Handle<Object> name() const { return hydrogen()->name(); }
2205 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2209 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2211 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2212 inputs_[0] = object;
2217 bool is_external() const { return hydrogen()->is_external(); }
2218 bool is_fixed_typed_array() const {
2219 return hydrogen()->is_fixed_typed_array();
2221 bool is_typed_elements() const {
2222 return is_external() || is_fixed_typed_array();
2224 LOperand* elements() { return inputs_[0]; }
2225 LOperand* key() { return inputs_[1]; }
2226 LOperand* value() { return inputs_[2]; }
2227 ElementsKind elements_kind() const { 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 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2234 uint32_t base_offset() const { return hydrogen()->base_offset(); }
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* object() { return inputs_[0]; }
2277 LOperand* context() { return inputs_[1]; }
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 explicit 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, 0> {
2376 explicit LCheckInstanceType(LOperand* value) {
2380 LOperand* value() { return inputs_[0]; }
2382 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2383 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2387 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2389 explicit LCheckMaps(LOperand* value = NULL) {
2393 LOperand* value() { return inputs_[0]; }
2395 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2396 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2400 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2402 explicit LCheckSmi(LOperand* value) {
2406 LOperand* value() { return inputs_[0]; }
2408 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2412 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2414 explicit LClampDToUint8(LOperand* unclamped) {
2415 inputs_[0] = unclamped;
2418 LOperand* unclamped() { return inputs_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2424 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2426 explicit LClampIToUint8(LOperand* unclamped) {
2427 inputs_[0] = unclamped;
2430 LOperand* unclamped() { return inputs_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2436 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2438 LClampTToUint8(LOperand* unclamped,
2439 LOperand* temp_xmm) {
2440 inputs_[0] = unclamped;
2441 temps_[0] = temp_xmm;
2444 LOperand* unclamped() { return inputs_[0]; }
2445 LOperand* temp_xmm() { return temps_[0]; }
2447 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2451 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2453 explicit LCheckNonSmi(LOperand* value) {
2457 LOperand* value() { return inputs_[0]; }
2459 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2460 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2464 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2466 explicit LDoubleBits(LOperand* value) {
2470 LOperand* value() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2473 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2477 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2479 LConstructDouble(LOperand* hi, LOperand* lo) {
2484 LOperand* hi() { return inputs_[0]; }
2485 LOperand* lo() { return inputs_[1]; }
2487 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2491 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2493 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2494 inputs_[0] = context;
2499 LOperand* context() { return inputs_[0]; }
2500 LOperand* size() { return inputs_[1]; }
2501 LOperand* temp() { return temps_[0]; }
2503 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2504 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2508 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2510 explicit LRegExpLiteral(LOperand* context) {
2511 inputs_[0] = context;
2514 LOperand* context() { return inputs_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2517 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2521 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2523 explicit LFunctionLiteral(LOperand* context) {
2524 inputs_[0] = context;
2527 LOperand* context() { return inputs_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2530 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2534 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2536 explicit LToFastProperties(LOperand* value) {
2540 LOperand* value() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2543 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2547 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2549 LTypeof(LOperand* context, LOperand* value) {
2550 inputs_[0] = context;
2554 LOperand* context() { return inputs_[0]; }
2555 LOperand* value() { return inputs_[1]; }
2557 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2561 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2563 explicit LTypeofIsAndBranch(LOperand* value) {
2567 LOperand* value() { return inputs_[0]; }
2569 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2570 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2572 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2574 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2578 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2580 explicit LIsConstructCallAndBranch(LOperand* temp) {
2584 LOperand* temp() { return temps_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2587 "is-construct-call-and-branch")
2588 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2592 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2596 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2599 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2603 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2605 explicit LStackCheck(LOperand* context) {
2606 inputs_[0] = context;
2609 LOperand* context() { return inputs_[0]; }
2611 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2612 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2614 Label* done_label() { return &done_label_; }
2621 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2623 LForInPrepareMap(LOperand* context, LOperand* object) {
2624 inputs_[0] = context;
2625 inputs_[1] = object;
2628 LOperand* context() { return inputs_[0]; }
2629 LOperand* object() { return inputs_[1]; }
2631 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2635 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2637 explicit LForInCacheArray(LOperand* map) {
2641 LOperand* map() { return inputs_[0]; }
2643 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2646 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2651 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2653 LCheckMapValue(LOperand* value, LOperand* map) {
2658 LOperand* value() { return inputs_[0]; }
2659 LOperand* map() { return inputs_[1]; }
2661 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2665 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2667 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2668 inputs_[0] = object;
2672 LOperand* object() { return inputs_[0]; }
2673 LOperand* index() { return inputs_[1]; }
2675 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2679 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2681 explicit LStoreFrameContext(LOperand* context) {
2682 inputs_[0] = context;
2685 LOperand* context() { return inputs_[0]; }
2687 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2691 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2693 LAllocateBlockContext(LOperand* context, LOperand* function) {
2694 inputs_[0] = context;
2695 inputs_[1] = function;
2698 LOperand* context() { return inputs_[0]; }
2699 LOperand* function() { return inputs_[1]; }
2701 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2703 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2704 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2708 class LChunkBuilder;
2709 class LPlatformChunk V8_FINAL : public LChunk {
2711 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2712 : LChunk(info, graph),
2713 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2715 int GetNextSpillIndex(RegisterKind kind);
2716 LOperand* GetNextSpillSlot(RegisterKind kind);
2717 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2718 bool IsDehoistedKey(HValue* value) {
2719 return dehoisted_key_ids_.Contains(value->id());
2723 BitVector dehoisted_key_ids_;
2727 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2729 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2730 : LChunkBuilderBase(graph->zone()),
2735 current_instruction_(NULL),
2736 current_block_(NULL),
2738 allocator_(allocator) { }
2740 Isolate* isolate() const { return graph_->isolate(); }
2742 // Build the sequence for the graph.
2743 LPlatformChunk* Build();
2745 // Declare methods that deal with the individual node types.
2746 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2747 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2750 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2751 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2752 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2753 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2754 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2755 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2756 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2757 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2758 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2759 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2760 LInstruction* DoDivByConstI(HDiv* instr);
2761 LInstruction* DoDivI(HDiv* instr);
2762 LInstruction* DoModByPowerOf2I(HMod* instr);
2763 LInstruction* DoModByConstI(HMod* instr);
2764 LInstruction* DoModI(HMod* instr);
2765 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2766 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2767 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2777 LPlatformChunk* chunk() const { return chunk_; }
2778 CompilationInfo* info() const { return info_; }
2779 HGraph* graph() const { return graph_; }
2781 bool is_unused() const { return status_ == UNUSED; }
2782 bool is_building() const { return status_ == BUILDING; }
2783 bool is_done() const { return status_ == DONE; }
2784 bool is_aborted() const { return status_ == ABORTED; }
2786 void Abort(BailoutReason reason);
2788 // Methods for getting operands for Use / Define / Temp.
2789 LUnallocated* ToUnallocated(Register reg);
2790 LUnallocated* ToUnallocated(XMMRegister reg);
2792 // Methods for setting up define-use relationships.
2793 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2794 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2795 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2796 XMMRegister fixed_register);
2798 // A value that is guaranteed to be allocated to a register.
2799 // Operand created by UseRegister is guaranteed to be live until the end of
2800 // instruction. This means that register allocator will not reuse it's
2801 // register for any other operand inside instruction.
2802 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2803 // instruction start. Register allocator is free to assign the same register
2804 // to some other operand used inside instruction (i.e. temporary or
2806 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2807 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2809 // An input operand in a register that may be trashed.
2810 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2812 // An input operand in a register that may be trashed or a constant operand.
2813 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2815 // An input operand in a register or stack slot.
2816 MUST_USE_RESULT LOperand* Use(HValue* value);
2817 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2819 // An input operand in a register, stack slot or a constant operand.
2820 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2821 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2823 // An input operand in a register or a constant operand.
2824 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2825 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2827 // An input operand in a constant operand.
2828 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2830 // An input operand in register, stack slot or a constant operand.
2831 // Will not be moved to a register even if one is freely available.
2832 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2834 // Temporary operand that must be in a register.
2835 MUST_USE_RESULT LUnallocated* TempRegister();
2836 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2837 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2839 // Methods for setting up define-use relationships.
2840 // Return the same instruction that they are passed.
2841 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2842 LUnallocated* result);
2843 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2844 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2846 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2847 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2849 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2851 // Assigns an environment to an instruction. An instruction which can
2852 // deoptimize must have an environment.
2853 LInstruction* AssignEnvironment(LInstruction* instr);
2854 // Assigns a pointer map to an instruction. An instruction which can
2855 // trigger a GC or a lazy deoptimization must have a pointer map.
2856 LInstruction* AssignPointerMap(LInstruction* instr);
2858 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2860 // Marks a call for the register allocator. Assigns a pointer map to
2861 // support GC and lazy deoptimization. Assigns an environment to support
2862 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2863 LInstruction* MarkAsCall(
2864 LInstruction* instr,
2865 HInstruction* hinstr,
2866 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2868 void VisitInstruction(HInstruction* current);
2869 void AddInstruction(LInstruction* instr, HInstruction* current);
2871 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2872 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2873 LInstruction* DoArithmeticD(Token::Value op,
2874 HArithmeticBinaryOperation* instr);
2875 LInstruction* DoArithmeticT(Token::Value op,
2876 HBinaryOperation* instr);
2877 void FindDehoistedKeyDefinitions(HValue* candidate);
2879 LPlatformChunk* chunk_;
2880 CompilationInfo* info_;
2881 HGraph* const graph_;
2883 HInstruction* current_instruction_;
2884 HBasicBlock* current_block_;
2885 HBasicBlock* next_block_;
2886 LAllocator* allocator_;
2888 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2891 #undef DECLARE_HYDROGEN_ACCESSOR
2892 #undef DECLARE_CONCRETE_INSTRUCTION
2894 } } // namespace v8::int
2896 #endif // V8_X64_LITHIUM_X64_H_