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) \
133 V(SeqStringGetChar) \
134 V(SeqStringSetChar) \
140 V(StoreContextSlot) \
141 V(StoreFrameContext) \
144 V(StoreKeyedGeneric) \
146 V(StoreNamedGeneric) \
148 V(StringCharCodeAt) \
149 V(StringCharFromCode) \
150 V(StringCompareAndBranch) \
154 V(ToFastProperties) \
155 V(TransitionElementsKind) \
156 V(TrapAllocationMemento) \
158 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
166 return LInstruction::k##type; \
168 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
169 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
172 static L##type* cast(LInstruction* instr) { \
173 ASSERT(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 // Interface to the register allocator and iterators.
246 bool IsMarkedAsCall() const { return IsCall(); }
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() const = 0;
251 LOperand* FirstInput() { return InputAt(0); }
252 LOperand* Output() { return HasResult() ? result() : NULL; }
254 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
256 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
266 friend class InputIterator;
267 virtual int InputCount() = 0;
268 virtual LOperand* InputAt(int i) = 0;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
290 return R != 0 && result() != NULL;
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const { return results_[0]; }
295 virtual bool MustSignExtendResult(
296 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
315 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
317 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
318 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block)
326 parallel_moves_[BEFORE] = NULL;
327 parallel_moves_[START] = NULL;
328 parallel_moves_[END] = NULL;
329 parallel_moves_[AFTER] = NULL;
332 // Can't use the DECLARE-macro here because of sub-classes.
333 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
334 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
335 static LGap* cast(LInstruction* instr) {
336 ASSERT(instr->IsGap());
337 return reinterpret_cast<LGap*>(instr);
340 bool IsRedundant() const;
342 HBasicBlock* block() const { return block_; }
349 FIRST_INNER_POSITION = BEFORE,
350 LAST_INNER_POSITION = AFTER
353 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap V8_FINAL : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
385 explicit LGoto(HBasicBlock* block) : block_(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
388 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
389 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
390 virtual bool IsControl() const V8_OVERRIDE { return true; }
392 int block_id() const { return block_->block_id(); }
399 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 LLazyBailout() : gap_instructions_size_(0) { }
403 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
405 void set_gap_instructions_size(int gap_instructions_size) {
406 gap_instructions_size_ = gap_instructions_size;
408 int gap_instructions_size() { return gap_instructions_size_; }
411 int gap_instructions_size_;
415 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
417 explicit LDummy() { }
418 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
422 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
424 explicit LDummyUse(LOperand* value) {
427 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
431 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
433 virtual bool IsControl() const V8_OVERRIDE { return true; }
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
435 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
439 class LLabel V8_FINAL : public LGap {
441 explicit LLabel(HBasicBlock* block)
442 : LGap(block), replacement_(NULL) { }
444 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
447 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
449 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
451 int block_id() const { return block()->block_id(); }
452 bool is_loop_header() const { return block()->IsLoopHeader(); }
453 bool is_osr_entry() const { return block()->is_osr_entry(); }
454 Label* label() { return &label_; }
455 LLabel* replacement() const { return replacement_; }
456 void set_replacement(LLabel* label) { replacement_ = label; }
457 bool HasReplacement() const { return replacement_ != NULL; }
461 LLabel* replacement_;
465 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
467 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
489 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
492 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
496 template<int I, int T>
497 class LControlInstruction : public LTemplateInstruction<0, I, T> {
499 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
501 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
503 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
504 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
506 int TrueDestination(LChunk* chunk) {
507 return chunk->LookupDestination(true_block_id());
509 int FalseDestination(LChunk* chunk) {
510 return chunk->LookupDestination(false_block_id());
513 Label* TrueLabel(LChunk* chunk) {
514 if (true_label_ == NULL) {
515 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
519 Label* FalseLabel(LChunk* chunk) {
520 if (false_label_ == NULL) {
521 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
527 int true_block_id() { return SuccessorAt(0)->block_id(); }
528 int false_block_id() { return SuccessorAt(1)->block_id(); }
531 HControlInstruction* hydrogen() {
532 return HControlInstruction::cast(this->hydrogen_value());
540 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
542 LWrapReceiver(LOperand* receiver, LOperand* function) {
543 inputs_[0] = receiver;
544 inputs_[1] = function;
547 LOperand* receiver() { return inputs_[0]; }
548 LOperand* function() { return inputs_[1]; }
550 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
551 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
555 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
557 LApplyArguments(LOperand* function,
560 LOperand* elements) {
561 inputs_[0] = function;
562 inputs_[1] = receiver;
564 inputs_[3] = elements;
567 LOperand* function() { return inputs_[0]; }
568 LOperand* receiver() { return inputs_[1]; }
569 LOperand* length() { return inputs_[2]; }
570 LOperand* elements() { return inputs_[3]; }
572 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
576 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
578 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
579 inputs_[0] = arguments;
584 LOperand* arguments() { return inputs_[0]; }
585 LOperand* length() { return inputs_[1]; }
586 LOperand* index() { return inputs_[2]; }
588 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
590 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
594 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
596 explicit LArgumentsLength(LOperand* elements) {
597 inputs_[0] = elements;
600 LOperand* elements() { return inputs_[0]; }
602 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
606 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
608 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
609 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
613 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
615 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
616 inputs_[0] = dividend;
620 LOperand* dividend() { return inputs_[0]; }
621 int32_t divisor() const { return divisor_; }
623 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
624 DECLARE_HYDROGEN_ACCESSOR(Mod)
631 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
633 LModByConstI(LOperand* dividend,
637 inputs_[0] = dividend;
643 LOperand* dividend() { return inputs_[0]; }
644 int32_t divisor() const { return divisor_; }
645 LOperand* temp1() { return temps_[0]; }
646 LOperand* temp2() { return temps_[1]; }
648 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
649 DECLARE_HYDROGEN_ACCESSOR(Mod)
656 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
658 LModI(LOperand* left, LOperand* right, LOperand* temp) {
664 LOperand* left() { return inputs_[0]; }
665 LOperand* right() { return inputs_[1]; }
666 LOperand* temp() { return temps_[0]; }
668 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
673 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
675 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
676 inputs_[0] = dividend;
680 LOperand* dividend() { return inputs_[0]; }
681 int32_t divisor() const { return divisor_; }
683 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
684 DECLARE_HYDROGEN_ACCESSOR(Div)
691 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
693 LDivByConstI(LOperand* dividend,
697 inputs_[0] = dividend;
703 LOperand* dividend() { return inputs_[0]; }
704 int32_t divisor() const { return divisor_; }
705 LOperand* temp1() { return temps_[0]; }
706 LOperand* temp2() { return temps_[1]; }
708 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
709 DECLARE_HYDROGEN_ACCESSOR(Div)
716 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
718 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
719 inputs_[0] = dividend;
720 inputs_[1] = divisor;
724 LOperand* dividend() { return inputs_[0]; }
725 LOperand* divisor() { return inputs_[1]; }
726 LOperand* temp() { return temps_[0]; }
728 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
729 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
733 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
735 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
736 inputs_[0] = dividend;
740 LOperand* dividend() { return inputs_[0]; }
741 int32_t divisor() const { return divisor_; }
743 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
744 "flooring-div-by-power-of-2-i")
745 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
752 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
754 LFlooringDivByConstI(LOperand* dividend,
759 inputs_[0] = dividend;
766 LOperand* dividend() { return inputs_[0]; }
767 int32_t divisor() const { return divisor_; }
768 LOperand* temp1() { return temps_[0]; }
769 LOperand* temp2() { return temps_[1]; }
770 LOperand* temp3() { return temps_[2]; }
772 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
773 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
780 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
782 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
783 inputs_[0] = dividend;
784 inputs_[1] = divisor;
788 LOperand* dividend() { return inputs_[0]; }
789 LOperand* divisor() { return inputs_[1]; }
790 LOperand* temp() { return temps_[0]; }
792 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
793 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
797 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
799 LMulI(LOperand* left, LOperand* right) {
804 LOperand* left() { return inputs_[0]; }
805 LOperand* right() { return inputs_[1]; }
807 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
808 DECLARE_HYDROGEN_ACCESSOR(Mul)
812 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
814 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
819 LOperand* left() { return inputs_[0]; }
820 LOperand* right() { return inputs_[1]; }
822 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
823 "compare-numeric-and-branch")
824 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
826 Token::Value op() const { return hydrogen()->token(); }
827 bool is_double() const {
828 return hydrogen()->representation().IsDouble();
831 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
835 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
837 explicit LMathFloor(LOperand* value) {
841 LOperand* value() { return inputs_[0]; }
843 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
844 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
848 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
850 explicit LMathRound(LOperand* value, LOperand* temp) {
855 LOperand* value() { return inputs_[0]; }
856 LOperand* temp() { return temps_[0]; }
858 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
859 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
863 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
865 explicit LMathAbs(LOperand* context, LOperand* value) {
866 inputs_[1] = context;
870 LOperand* context() { return inputs_[1]; }
871 LOperand* value() { return inputs_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
874 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
878 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
880 explicit LMathLog(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
890 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
892 explicit LMathClz32(LOperand* value) {
896 LOperand* value() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
902 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
904 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
908 ExternalReference::InitializeMathExpData();
911 LOperand* value() { return inputs_[0]; }
912 LOperand* temp1() { return temps_[0]; }
913 LOperand* temp2() { return temps_[1]; }
915 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
919 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
921 explicit LMathSqrt(LOperand* value) {
925 LOperand* value() { return inputs_[0]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
931 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
933 explicit LMathPowHalf(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
943 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
945 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
950 LOperand* left() { return inputs_[0]; }
951 LOperand* right() { return inputs_[1]; }
953 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
957 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
959 explicit LCmpHoleAndBranch(LOperand* object) {
963 LOperand* object() { return inputs_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
966 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
970 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
972 explicit LCompareMinusZeroAndBranch(LOperand* value) {
976 LOperand* value() { return inputs_[0]; }
978 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
979 "cmp-minus-zero-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
985 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
987 explicit LIsObjectAndBranch(LOperand* value) {
991 LOperand* value() { return inputs_[0]; }
993 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
996 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1000 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1002 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1007 LOperand* value() { return inputs_[0]; }
1008 LOperand* temp() { return temps_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1011 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1013 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1017 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1019 explicit LIsSmiAndBranch(LOperand* value) {
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1034 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1043 "is-undetectable-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1052 explicit LStringCompareAndBranch(LOperand* context,
1055 inputs_[0] = context;
1060 LOperand* context() { return inputs_[0]; }
1061 LOperand* left() { return inputs_[1]; }
1062 LOperand* right() { return inputs_[2]; }
1064 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1065 "string-compare-and-branch")
1066 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1068 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1070 Token::Value op() const { return hydrogen()->token(); }
1074 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1076 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1080 LOperand* value() { return inputs_[0]; }
1082 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1083 "has-instance-type-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1090 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1092 explicit LGetCachedArrayIndex(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1099 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1103 class LHasCachedArrayIndexAndBranch V8_FINAL
1104 : public LControlInstruction<1, 0> {
1106 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1110 LOperand* value() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1113 "has-cached-array-index-and-branch")
1114 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1116 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1120 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1122 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1130 LOperand* temp2() { return temps_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1133 "class-of-test-and-branch")
1134 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1140 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1142 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1143 inputs_[0] = context;
1148 LOperand* context() { return inputs_[0]; }
1149 LOperand* left() { return inputs_[1]; }
1150 LOperand* right() { return inputs_[2]; }
1152 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1153 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1155 Token::Value op() const { return hydrogen()->token(); }
1159 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1161 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1162 inputs_[0] = context;
1167 LOperand* context() { return inputs_[0]; }
1168 LOperand* left() { return inputs_[1]; }
1169 LOperand* right() { return inputs_[2]; }
1171 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1175 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1177 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1178 inputs_[0] = context;
1183 LOperand* context() { return inputs_[0]; }
1184 LOperand* value() { return inputs_[1]; }
1185 LOperand* temp() { return temps_[0]; }
1187 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1188 "instance-of-known-global")
1189 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1191 Handle<JSFunction> function() const { return hydrogen()->function(); }
1192 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1193 return lazy_deopt_env_;
1195 virtual void SetDeferredLazyDeoptimizationEnvironment(
1196 LEnvironment* env) V8_OVERRIDE {
1197 lazy_deopt_env_ = env;
1201 LEnvironment* lazy_deopt_env_;
1205 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1207 LBoundsCheck(LOperand* index, LOperand* length) {
1209 inputs_[1] = length;
1212 LOperand* index() { return inputs_[0]; }
1213 LOperand* length() { return inputs_[1]; }
1215 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1216 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1220 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1222 LBitI(LOperand* left, LOperand* right) {
1227 LOperand* left() { return inputs_[0]; }
1228 LOperand* right() { return inputs_[1]; }
1230 Token::Value op() const { return hydrogen()->op(); }
1231 bool IsInteger32() const {
1232 return hydrogen()->representation().IsInteger32();
1235 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1236 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1240 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1242 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1243 : op_(op), can_deopt_(can_deopt) {
1248 Token::Value op() const { return op_; }
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1251 bool can_deopt() const { return can_deopt_; }
1253 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1263 LSubI(LOperand* left, LOperand* right) {
1268 LOperand* left() { return inputs_[0]; }
1269 LOperand* right() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1272 DECLARE_HYDROGEN_ACCESSOR(Sub)
1276 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1278 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1279 DECLARE_HYDROGEN_ACCESSOR(Constant)
1281 int32_t value() const { return hydrogen()->Integer32Value(); }
1285 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1287 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1288 DECLARE_HYDROGEN_ACCESSOR(Constant)
1290 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1294 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1296 explicit LConstantD(LOperand* temp) {
1300 LOperand* temp() { return temps_[0]; }
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 double value() const { return hydrogen()->DoubleValue(); }
1309 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 ExternalReference value() const {
1315 return hydrogen()->ExternalReferenceValue();
1320 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1322 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1323 DECLARE_HYDROGEN_ACCESSOR(Constant)
1325 Handle<Object> value(Isolate* isolate) const {
1326 return hydrogen()->handle(isolate);
1331 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1333 explicit LBranch(LOperand* value) {
1337 LOperand* value() { return inputs_[0]; }
1339 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1340 DECLARE_HYDROGEN_ACCESSOR(Branch)
1342 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1346 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1348 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1352 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1354 explicit LCmpMapAndBranch(LOperand* value) {
1358 LOperand* value() { return inputs_[0]; }
1360 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1361 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1363 Handle<Map> map() const { return hydrogen()->map().handle(); }
1367 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1369 explicit LMapEnumLength(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1379 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1381 LDateField(LOperand* date, Smi* index) : index_(index) {
1385 LOperand* date() { return inputs_[0]; }
1386 Smi* index() const { return index_; }
1388 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1389 DECLARE_HYDROGEN_ACCESSOR(DateField)
1396 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1398 LSeqStringGetChar(LOperand* string, LOperand* index) {
1399 inputs_[0] = string;
1403 LOperand* string() const { return inputs_[0]; }
1404 LOperand* index() const { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1407 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1411 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1413 LSeqStringSetChar(LOperand* context,
1417 inputs_[0] = context;
1418 inputs_[1] = string;
1423 LOperand* string() { return inputs_[1]; }
1424 LOperand* index() { return inputs_[2]; }
1425 LOperand* value() { return inputs_[3]; }
1427 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1428 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1432 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1434 LAddI(LOperand* left, LOperand* right) {
1439 LOperand* left() { return inputs_[0]; }
1440 LOperand* right() { return inputs_[1]; }
1442 static bool UseLea(HAdd* add) {
1443 return !add->CheckFlag(HValue::kCanOverflow) &&
1444 add->BetterLeftOperand()->UseCount() > 1;
1447 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1448 DECLARE_HYDROGEN_ACCESSOR(Add)
1452 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LMathMinMax(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1463 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1467 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LPower(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1478 DECLARE_HYDROGEN_ACCESSOR(Power)
1482 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1490 Token::Value op() const { return op_; }
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 virtual Opcode opcode() const V8_OVERRIDE {
1495 return LInstruction::kArithmeticD;
1497 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1498 virtual const char* Mnemonic() const V8_OVERRIDE;
1505 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1507 LArithmeticT(Token::Value op,
1512 inputs_[0] = context;
1517 Token::Value op() const { return op_; }
1518 LOperand* context() { return inputs_[0]; }
1519 LOperand* left() { return inputs_[1]; }
1520 LOperand* right() { return inputs_[2]; }
1522 virtual Opcode opcode() const V8_OVERRIDE {
1523 return LInstruction::kArithmeticT;
1525 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1526 virtual const char* Mnemonic() const V8_OVERRIDE;
1533 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1535 explicit LReturn(LOperand* value,
1537 LOperand* parameter_count) {
1539 inputs_[1] = context;
1540 inputs_[2] = parameter_count;
1543 LOperand* value() { return inputs_[0]; }
1544 LOperand* context() { return inputs_[1]; }
1546 bool has_constant_parameter_count() {
1547 return parameter_count()->IsConstantOperand();
1549 LConstantOperand* constant_parameter_count() {
1550 ASSERT(has_constant_parameter_count());
1551 return LConstantOperand::cast(parameter_count());
1553 LOperand* parameter_count() { return inputs_[2]; }
1555 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1556 DECLARE_HYDROGEN_ACCESSOR(Return)
1560 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1562 explicit LLoadNamedField(LOperand* object) {
1563 inputs_[0] = object;
1566 LOperand* object() { return inputs_[0]; }
1568 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1569 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1573 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1575 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1577 inputs_[0] = context;
1578 inputs_[1] = object;
1582 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1585 LOperand* context() { return inputs_[0]; }
1586 LOperand* object() { return inputs_[1]; }
1587 LOperand* temp_vector() { return temps_[0]; }
1589 Handle<Object> name() const { return hydrogen()->name(); }
1593 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1595 explicit LLoadFunctionPrototype(LOperand* function) {
1596 inputs_[0] = function;
1599 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1600 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1602 LOperand* function() { return inputs_[0]; }
1606 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1608 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1609 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1611 Heap::RootListIndex index() const { return hydrogen()->index(); }
1615 inline static bool ExternalArrayOpRequiresTemp(
1616 Representation key_representation,
1617 ElementsKind elements_kind) {
1618 // Operations that require the key to be divided by two to be converted into
1619 // an index cannot fold the scale operation into a load and need an extra
1620 // temp register to do the work.
1621 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1622 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1623 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1624 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1625 elements_kind == UINT8_ELEMENTS ||
1626 elements_kind == INT8_ELEMENTS ||
1627 elements_kind == UINT8_CLAMPED_ELEMENTS);
1631 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1633 LLoadKeyed(LOperand* elements, LOperand* key) {
1634 inputs_[0] = elements;
1638 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1639 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1641 bool is_external() const {
1642 return hydrogen()->is_external();
1644 bool is_fixed_typed_array() const {
1645 return hydrogen()->is_fixed_typed_array();
1647 bool is_typed_elements() const {
1648 return is_external() || is_fixed_typed_array();
1650 LOperand* elements() { return inputs_[0]; }
1651 LOperand* key() { return inputs_[1]; }
1652 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1653 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1654 ElementsKind elements_kind() const {
1655 return hydrogen()->elements_kind();
1660 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1662 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1664 inputs_[0] = context;
1670 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1671 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1673 LOperand* context() { return inputs_[0]; }
1674 LOperand* object() { return inputs_[1]; }
1675 LOperand* key() { return inputs_[2]; }
1676 LOperand* temp_vector() { return temps_[0]; }
1680 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1682 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1683 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1687 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1689 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1691 inputs_[0] = context;
1692 inputs_[1] = global_object;
1696 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1699 LOperand* context() { return inputs_[0]; }
1700 LOperand* global_object() { return inputs_[1]; }
1701 LOperand* temp_vector() { return temps_[0]; }
1703 Handle<Object> name() const { return hydrogen()->name(); }
1704 bool for_typeof() const { return hydrogen()->for_typeof(); }
1708 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1710 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1715 LOperand* value() { return inputs_[0]; }
1716 LOperand* temp() { return temps_[0]; }
1718 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1719 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1723 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1725 explicit LLoadContextSlot(LOperand* context) {
1726 inputs_[0] = context;
1729 LOperand* context() { return inputs_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1732 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1734 int slot_index() { return hydrogen()->slot_index(); }
1736 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1740 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1742 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1743 inputs_[0] = context;
1748 LOperand* context() { return inputs_[0]; }
1749 LOperand* value() { return inputs_[1]; }
1750 LOperand* temp() { return temps_[0]; }
1752 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1753 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1755 int slot_index() { return hydrogen()->slot_index(); }
1757 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1761 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1763 explicit LPushArgument(LOperand* value) {
1767 LOperand* value() { return inputs_[0]; }
1769 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1773 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1775 explicit LDrop(int count) : count_(count) { }
1777 int count() const { return count_; }
1779 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1786 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1788 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1789 inputs_[0] = function;
1790 inputs_[1] = code_object;
1793 LOperand* function() { return inputs_[0]; }
1794 LOperand* code_object() { return inputs_[1]; }
1796 virtual void PrintDataTo(StringStream* stream);
1798 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1799 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1803 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1805 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1806 inputs_[0] = base_object;
1807 inputs_[1] = offset;
1810 LOperand* base_object() const { return inputs_[0]; }
1811 LOperand* offset() const { return inputs_[1]; }
1813 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1815 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1819 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1821 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1822 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1826 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1828 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1829 DECLARE_HYDROGEN_ACCESSOR(Context)
1833 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1835 explicit LDeclareGlobals(LOperand* context) {
1836 inputs_[0] = context;
1839 LOperand* context() { return inputs_[0]; }
1841 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1842 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1846 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1848 explicit LCallJSFunction(LOperand* function) {
1849 inputs_[0] = function;
1852 LOperand* function() { return inputs_[0]; }
1854 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1855 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1857 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1859 int arity() const { return hydrogen()->argument_count() - 1; }
1863 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1865 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1866 const ZoneList<LOperand*>& operands,
1868 : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1869 ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1870 inputs_.AddAll(operands, zone);
1873 LOperand* target() const { return inputs_[0]; }
1876 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1877 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1879 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1881 int arity() const { return hydrogen()->argument_count() - 1; }
1883 ZoneList<LOperand*> inputs_;
1885 // Iterator support.
1886 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1887 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1889 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1890 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1894 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1896 LInvokeFunction(LOperand* context, LOperand* function) {
1897 inputs_[0] = context;
1898 inputs_[1] = function;
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* function() { return inputs_[1]; }
1904 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1905 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1907 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1913 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1915 LCallFunction(LOperand* context, LOperand* function) {
1916 inputs_[0] = context;
1917 inputs_[1] = function;
1920 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1921 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1923 LOperand* context() { return inputs_[0]; }
1924 LOperand* function() { return inputs_[1]; }
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1931 LCallNew(LOperand* context, LOperand* constructor) {
1932 inputs_[0] = context;
1933 inputs_[1] = constructor;
1936 LOperand* context() { return inputs_[0]; }
1937 LOperand* constructor() { return inputs_[1]; }
1939 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1940 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1942 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1944 int arity() const { return hydrogen()->argument_count() - 1; }
1948 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1950 LCallNewArray(LOperand* context, LOperand* constructor) {
1951 inputs_[0] = context;
1952 inputs_[1] = constructor;
1955 LOperand* context() { return inputs_[0]; }
1956 LOperand* constructor() { return inputs_[1]; }
1958 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1959 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1961 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1963 int arity() const { return hydrogen()->argument_count() - 1; }
1967 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1969 explicit LCallRuntime(LOperand* context) {
1970 inputs_[0] = context;
1973 LOperand* context() { return inputs_[0]; }
1975 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1976 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1978 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1979 return save_doubles() == kDontSaveFPRegs;
1982 const Runtime::Function* function() const { return hydrogen()->function(); }
1983 int arity() const { return hydrogen()->argument_count(); }
1984 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1988 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1990 explicit LInteger32ToDouble(LOperand* value) {
1994 LOperand* value() { return inputs_[0]; }
1996 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2000 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2002 explicit LUint32ToDouble(LOperand* value) {
2006 LOperand* value() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2012 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2014 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2020 LOperand* value() { return inputs_[0]; }
2021 LOperand* temp1() { return temps_[0]; }
2022 LOperand* temp2() { return temps_[1]; }
2024 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2028 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2030 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2036 LOperand* value() { return inputs_[0]; }
2037 LOperand* temp1() { return temps_[0]; }
2038 LOperand* temp2() { return temps_[1]; }
2040 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2044 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2046 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2055 DECLARE_HYDROGEN_ACCESSOR(Change)
2059 // Sometimes truncating conversion from a tagged value to an int32.
2060 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2062 explicit LDoubleToI(LOperand* value) {
2066 LOperand* value() { return inputs_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2069 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2071 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2075 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2077 explicit LDoubleToSmi(LOperand* value) {
2081 LOperand* value() { return inputs_[0]; }
2083 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2084 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2088 // Truncating conversion from a tagged value to an int32.
2089 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2091 LTaggedToI(LOperand* value, LOperand* temp) {
2096 LOperand* value() { return inputs_[0]; }
2097 LOperand* temp() { return temps_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2100 DECLARE_HYDROGEN_ACCESSOR(Change)
2102 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2106 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2108 explicit LSmiTag(LOperand* value) {
2112 LOperand* value() { return inputs_[0]; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2115 DECLARE_HYDROGEN_ACCESSOR(Change)
2119 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2121 explicit LNumberUntagD(LOperand* value) {
2125 LOperand* value() { return inputs_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2128 DECLARE_HYDROGEN_ACCESSOR(Change);
2132 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2134 LSmiUntag(LOperand* value, bool needs_check)
2135 : needs_check_(needs_check) {
2139 LOperand* value() { return inputs_[0]; }
2140 bool needs_check() const { return needs_check_; }
2142 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2149 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2151 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2152 inputs_[0] = object;
2157 LOperand* object() { return inputs_[0]; }
2158 LOperand* value() { return inputs_[1]; }
2159 LOperand* temp() { return temps_[0]; }
2161 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2162 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2164 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2166 Representation representation() const {
2167 return hydrogen()->field_representation();
2172 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2174 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2175 inputs_[0] = context;
2176 inputs_[1] = object;
2180 LOperand* context() { return inputs_[0]; }
2181 LOperand* object() { return inputs_[1]; }
2182 LOperand* value() { return inputs_[2]; }
2184 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2185 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2187 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2189 Handle<Object> name() const { return hydrogen()->name(); }
2190 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2194 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2196 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2197 inputs_[0] = object;
2202 bool is_external() const { return hydrogen()->is_external(); }
2203 bool is_fixed_typed_array() const {
2204 return hydrogen()->is_fixed_typed_array();
2206 bool is_typed_elements() const {
2207 return is_external() || is_fixed_typed_array();
2209 LOperand* elements() { return inputs_[0]; }
2210 LOperand* key() { return inputs_[1]; }
2211 LOperand* value() { return inputs_[2]; }
2212 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2214 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2215 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2217 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2218 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2219 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2223 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2225 LStoreKeyedGeneric(LOperand* context,
2229 inputs_[0] = context;
2230 inputs_[1] = object;
2235 LOperand* context() { return inputs_[0]; }
2236 LOperand* object() { return inputs_[1]; }
2237 LOperand* key() { return inputs_[2]; }
2238 LOperand* value() { return inputs_[3]; }
2240 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2241 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2243 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2245 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2249 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2251 LTransitionElementsKind(LOperand* object,
2253 LOperand* new_map_temp,
2255 inputs_[0] = object;
2256 inputs_[1] = context;
2257 temps_[0] = new_map_temp;
2261 LOperand* object() { return inputs_[0]; }
2262 LOperand* context() { return inputs_[1]; }
2263 LOperand* new_map_temp() { return temps_[0]; }
2264 LOperand* temp() { return temps_[1]; }
2266 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2267 "transition-elements-kind")
2268 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2270 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2272 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2273 Handle<Map> transitioned_map() {
2274 return hydrogen()->transitioned_map().handle();
2276 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2277 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2281 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2283 LTrapAllocationMemento(LOperand* object,
2285 inputs_[0] = object;
2289 LOperand* object() { return inputs_[0]; }
2290 LOperand* temp() { return temps_[0]; }
2292 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2293 "trap-allocation-memento")
2297 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2299 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2300 inputs_[0] = context;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* left() { return inputs_[1]; }
2307 LOperand* right() { return inputs_[2]; }
2309 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2310 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2314 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2316 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2317 inputs_[0] = context;
2318 inputs_[1] = string;
2322 LOperand* context() { return inputs_[0]; }
2323 LOperand* string() { return inputs_[1]; }
2324 LOperand* index() { return inputs_[2]; }
2326 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2327 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2331 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2333 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2334 inputs_[0] = context;
2335 inputs_[1] = char_code;
2338 LOperand* context() { return inputs_[0]; }
2339 LOperand* char_code() { return inputs_[1]; }
2341 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2342 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2346 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2348 explicit LCheckValue(LOperand* value) {
2352 LOperand* value() { return inputs_[0]; }
2354 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2355 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2359 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2361 explicit LCheckInstanceType(LOperand* value) {
2365 LOperand* value() { return inputs_[0]; }
2367 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2368 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2372 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2374 explicit LCheckMaps(LOperand* value = NULL) {
2378 LOperand* value() { return inputs_[0]; }
2380 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2381 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2385 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2387 explicit LCheckSmi(LOperand* value) {
2391 LOperand* value() { return inputs_[0]; }
2393 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2397 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2399 explicit LClampDToUint8(LOperand* unclamped) {
2400 inputs_[0] = unclamped;
2403 LOperand* unclamped() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2409 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2411 explicit LClampIToUint8(LOperand* unclamped) {
2412 inputs_[0] = unclamped;
2415 LOperand* unclamped() { return inputs_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2421 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2423 LClampTToUint8(LOperand* unclamped,
2424 LOperand* temp_xmm) {
2425 inputs_[0] = unclamped;
2426 temps_[0] = temp_xmm;
2429 LOperand* unclamped() { return inputs_[0]; }
2430 LOperand* temp_xmm() { return temps_[0]; }
2432 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2436 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2438 explicit LCheckNonSmi(LOperand* value) {
2442 LOperand* value() { return inputs_[0]; }
2444 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2445 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2449 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2451 explicit LDoubleBits(LOperand* value) {
2455 LOperand* value() { return inputs_[0]; }
2457 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2458 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2462 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2464 LConstructDouble(LOperand* hi, LOperand* lo) {
2469 LOperand* hi() { return inputs_[0]; }
2470 LOperand* lo() { return inputs_[1]; }
2472 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2476 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2478 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2479 inputs_[0] = context;
2484 LOperand* context() { return inputs_[0]; }
2485 LOperand* size() { return inputs_[1]; }
2486 LOperand* temp() { return temps_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2489 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2493 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2495 explicit LRegExpLiteral(LOperand* context) {
2496 inputs_[0] = context;
2499 LOperand* context() { return inputs_[0]; }
2501 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2502 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2506 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2508 explicit LFunctionLiteral(LOperand* context) {
2509 inputs_[0] = context;
2512 LOperand* context() { return inputs_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2515 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2519 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2521 explicit LToFastProperties(LOperand* value) {
2525 LOperand* value() { return inputs_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2528 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2532 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2534 LTypeof(LOperand* context, LOperand* value) {
2535 inputs_[0] = context;
2539 LOperand* context() { return inputs_[0]; }
2540 LOperand* value() { return inputs_[1]; }
2542 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2546 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2548 explicit LTypeofIsAndBranch(LOperand* value) {
2552 LOperand* value() { return inputs_[0]; }
2554 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2555 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2557 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2559 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2563 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2565 explicit LIsConstructCallAndBranch(LOperand* temp) {
2569 LOperand* temp() { return temps_[0]; }
2571 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2572 "is-construct-call-and-branch")
2573 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2577 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2581 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2584 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2588 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2590 explicit LStackCheck(LOperand* context) {
2591 inputs_[0] = context;
2594 LOperand* context() { return inputs_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2597 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2599 Label* done_label() { return &done_label_; }
2606 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2608 LForInPrepareMap(LOperand* context, LOperand* object) {
2609 inputs_[0] = context;
2610 inputs_[1] = object;
2613 LOperand* context() { return inputs_[0]; }
2614 LOperand* object() { return inputs_[1]; }
2616 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2620 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2622 explicit LForInCacheArray(LOperand* map) {
2626 LOperand* map() { return inputs_[0]; }
2628 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2631 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2636 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2638 LCheckMapValue(LOperand* value, LOperand* map) {
2643 LOperand* value() { return inputs_[0]; }
2644 LOperand* map() { return inputs_[1]; }
2646 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2650 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2652 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2653 inputs_[0] = object;
2657 LOperand* object() { return inputs_[0]; }
2658 LOperand* index() { return inputs_[1]; }
2660 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2664 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2666 explicit LStoreFrameContext(LOperand* context) {
2667 inputs_[0] = context;
2670 LOperand* context() { return inputs_[0]; }
2672 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2676 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2678 LAllocateBlockContext(LOperand* context, LOperand* function) {
2679 inputs_[0] = context;
2680 inputs_[1] = function;
2683 LOperand* context() { return inputs_[0]; }
2684 LOperand* function() { return inputs_[1]; }
2686 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2688 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2689 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2693 class LChunkBuilder;
2694 class LPlatformChunk V8_FINAL : public LChunk {
2696 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2697 : LChunk(info, graph),
2698 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2700 int GetNextSpillIndex(RegisterKind kind);
2701 LOperand* GetNextSpillSlot(RegisterKind kind);
2702 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2703 bool IsDehoistedKey(HValue* value) {
2704 return dehoisted_key_ids_.Contains(value->id());
2708 BitVector dehoisted_key_ids_;
2712 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2714 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2715 : LChunkBuilderBase(graph->zone()),
2720 current_instruction_(NULL),
2721 current_block_(NULL),
2723 allocator_(allocator) { }
2725 Isolate* isolate() const { return graph_->isolate(); }
2727 // Build the sequence for the graph.
2728 LPlatformChunk* Build();
2730 // Declare methods that deal with the individual node types.
2731 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2732 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2735 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2736 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2737 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2738 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2739 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2740 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2741 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2742 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2743 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2744 LInstruction* DoDivByConstI(HDiv* instr);
2745 LInstruction* DoDivI(HDiv* instr);
2746 LInstruction* DoModByPowerOf2I(HMod* instr);
2747 LInstruction* DoModByConstI(HMod* instr);
2748 LInstruction* DoModI(HMod* instr);
2749 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2750 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2751 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2761 LPlatformChunk* chunk() const { return chunk_; }
2762 CompilationInfo* info() const { return info_; }
2763 HGraph* graph() const { return graph_; }
2765 bool is_unused() const { return status_ == UNUSED; }
2766 bool is_building() const { return status_ == BUILDING; }
2767 bool is_done() const { return status_ == DONE; }
2768 bool is_aborted() const { return status_ == ABORTED; }
2770 void Abort(BailoutReason reason);
2772 // Methods for getting operands for Use / Define / Temp.
2773 LUnallocated* ToUnallocated(Register reg);
2774 LUnallocated* ToUnallocated(XMMRegister reg);
2776 // Methods for setting up define-use relationships.
2777 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2778 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2779 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2780 XMMRegister fixed_register);
2782 // A value that is guaranteed to be allocated to a register.
2783 // Operand created by UseRegister is guaranteed to be live until the end of
2784 // instruction. This means that register allocator will not reuse it's
2785 // register for any other operand inside instruction.
2786 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2787 // instruction start. Register allocator is free to assign the same register
2788 // to some other operand used inside instruction (i.e. temporary or
2790 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2791 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2793 // An input operand in a register that may be trashed.
2794 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2796 // An input operand in a register that may be trashed or a constant operand.
2797 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2799 // An input operand in a register or stack slot.
2800 MUST_USE_RESULT LOperand* Use(HValue* value);
2801 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2803 // An input operand in a register, stack slot or a constant operand.
2804 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2805 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2807 // An input operand in a register or a constant operand.
2808 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2809 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2811 // An input operand in a constant operand.
2812 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2814 // An input operand in register, stack slot or a constant operand.
2815 // Will not be moved to a register even if one is freely available.
2816 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2818 // Temporary operand that must be in a register.
2819 MUST_USE_RESULT LUnallocated* TempRegister();
2820 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2821 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2823 // Methods for setting up define-use relationships.
2824 // Return the same instruction that they are passed.
2825 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2826 LUnallocated* result);
2827 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2828 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2830 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2831 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2833 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2835 // Assigns an environment to an instruction. An instruction which can
2836 // deoptimize must have an environment.
2837 LInstruction* AssignEnvironment(LInstruction* instr);
2838 // Assigns a pointer map to an instruction. An instruction which can
2839 // trigger a GC or a lazy deoptimization must have a pointer map.
2840 LInstruction* AssignPointerMap(LInstruction* instr);
2842 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2844 // Marks a call for the register allocator. Assigns a pointer map to
2845 // support GC and lazy deoptimization. Assigns an environment to support
2846 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2847 LInstruction* MarkAsCall(
2848 LInstruction* instr,
2849 HInstruction* hinstr,
2850 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2852 void VisitInstruction(HInstruction* current);
2853 void AddInstruction(LInstruction* instr, HInstruction* current);
2855 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2856 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2857 LInstruction* DoArithmeticD(Token::Value op,
2858 HArithmeticBinaryOperation* instr);
2859 LInstruction* DoArithmeticT(Token::Value op,
2860 HBinaryOperation* instr);
2861 void FindDehoistedKeyDefinitions(HValue* candidate);
2863 LPlatformChunk* chunk_;
2864 CompilationInfo* info_;
2865 HGraph* const graph_;
2867 HInstruction* current_instruction_;
2868 HBasicBlock* current_block_;
2869 HBasicBlock* next_block_;
2870 LAllocator* allocator_;
2872 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2875 #undef DECLARE_HYDROGEN_ACCESSOR
2876 #undef DECLARE_CONCRETE_INSTRUCTION
2878 } } // namespace v8::int
2880 #endif // V8_X64_LITHIUM_X64_H_