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) \
122 V(NullarySIMDOperation) \
123 V(UnarySIMDOperation) \
124 V(BinarySIMDOperation) \
125 V(TernarySIMDOperation) \
126 V(QuarternarySIMDOperation) \
141 V(SeqStringGetChar) \
142 V(SeqStringSetChar) \
148 V(StoreContextSlot) \
149 V(StoreFrameContext) \
152 V(StoreKeyedGeneric) \
154 V(StoreNamedGeneric) \
156 V(StringCharCodeAt) \
157 V(StringCharFromCode) \
158 V(StringCompareAndBranch) \
161 V(TailCallThroughMegamorphicCache) \
163 V(ToFastProperties) \
164 V(TransitionElementsKind) \
165 V(TrapAllocationMemento) \
167 V(TypeofIsAndBranch) \
172 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
173 virtual Opcode opcode() const FINAL OVERRIDE { \
174 return LInstruction::k##type; \
176 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
177 virtual const char* Mnemonic() const FINAL OVERRIDE { \
180 static L##type* cast(LInstruction* instr) { \
181 DCHECK(instr->Is##type()); \
182 return reinterpret_cast<L##type*>(instr); \
186 #define DECLARE_HYDROGEN_ACCESSOR(type) \
187 H##type* hydrogen() const { \
188 return H##type::cast(hydrogen_value()); \
192 class LInstruction : public ZoneObject {
195 : environment_(NULL),
196 hydrogen_value_(NULL),
197 bit_field_(IsCallBits::encode(false)) {
200 virtual ~LInstruction() {}
202 virtual void CompileToNative(LCodeGen* generator) = 0;
203 virtual const char* Mnemonic() const = 0;
204 virtual void PrintTo(StringStream* stream);
205 virtual void PrintDataTo(StringStream* stream);
206 virtual void PrintOutputOperandTo(StringStream* stream);
209 // Declare a unique enum value for each instruction.
210 #define DECLARE_OPCODE(type) k##type,
211 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
212 kNumberOfInstructions
213 #undef DECLARE_OPCODE
216 virtual Opcode opcode() const = 0;
218 // Declare non-virtual type testers for all leaf IR classes.
219 #define DECLARE_PREDICATE(type) \
220 bool Is##type() const { return opcode() == k##type; }
221 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
222 #undef DECLARE_PREDICATE
224 // Declare virtual predicates for instructions that don't have
226 virtual bool IsGap() const { return false; }
228 virtual bool IsControl() const { return false; }
230 // Try deleting this instruction if possible.
231 virtual bool TryDelete() { return false; }
233 void set_environment(LEnvironment* env) { environment_ = env; }
234 LEnvironment* environment() const { return environment_; }
235 bool HasEnvironment() const { return environment_ != NULL; }
237 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
238 LPointerMap* pointer_map() const { return pointer_map_.get(); }
239 bool HasPointerMap() const { return pointer_map_.is_set(); }
241 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
242 HValue* hydrogen_value() const { return hydrogen_value_; }
244 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
245 bool IsCall() const { return IsCallBits::decode(bit_field_); }
247 // Interface to the register allocator and iterators.
248 bool ClobbersTemps() const { return IsCall(); }
249 bool ClobbersRegisters() const { return IsCall(); }
250 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
254 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
256 // Interface to the register allocator and iterators.
257 bool IsMarkedAsCall() const { return IsCall(); }
259 virtual bool HasResult() const = 0;
260 virtual LOperand* result() const = 0;
262 LOperand* FirstInput() { return InputAt(0); }
263 LOperand* Output() { return HasResult() ? result() : NULL; }
265 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
267 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
275 virtual int InputCount() = 0;
276 virtual LOperand* InputAt(int i) = 0;
280 friend class InputIterator;
282 friend class TempIterator;
283 virtual int TempCount() = 0;
284 virtual LOperand* TempAt(int i) = 0;
286 class IsCallBits: public BitField<bool, 0, 1> {};
288 LEnvironment* environment_;
289 SetOncePointer<LPointerMap> pointer_map_;
290 HValue* hydrogen_value_;
295 // R = number of result operands (0 or 1).
297 class LTemplateResultInstruction : public LInstruction {
299 // Allow 0 or 1 output operands.
300 STATIC_ASSERT(R == 0 || R == 1);
301 virtual bool HasResult() const FINAL OVERRIDE {
302 return R != 0 && result() != NULL;
304 void set_result(LOperand* operand) { results_[0] = operand; }
305 LOperand* result() const { return results_[0]; }
307 virtual bool MustSignExtendResult(
308 LPlatformChunk* chunk) const FINAL OVERRIDE;
311 EmbeddedContainer<LOperand*, R> results_;
315 // R = number of result operands (0 or 1).
316 // I = number of input operands.
317 // T = number of temporary operands.
318 template<int R, int I, int T>
319 class LTemplateInstruction : public LTemplateResultInstruction<R> {
321 EmbeddedContainer<LOperand*, I> inputs_;
322 EmbeddedContainer<LOperand*, T> temps_;
326 virtual int InputCount() FINAL OVERRIDE { return I; }
327 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
329 virtual int TempCount() FINAL OVERRIDE { return T; }
330 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
334 class LGap : public LTemplateInstruction<0, 0, 0> {
336 explicit LGap(HBasicBlock* block)
338 parallel_moves_[BEFORE] = NULL;
339 parallel_moves_[START] = NULL;
340 parallel_moves_[END] = NULL;
341 parallel_moves_[AFTER] = NULL;
344 // Can't use the DECLARE-macro here because of sub-classes.
345 virtual bool IsGap() const FINAL OVERRIDE { return true; }
346 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
347 static LGap* cast(LInstruction* instr) {
348 DCHECK(instr->IsGap());
349 return reinterpret_cast<LGap*>(instr);
352 bool IsRedundant() const;
354 HBasicBlock* block() const { return block_; }
361 FIRST_INNER_POSITION = BEFORE,
362 LAST_INNER_POSITION = AFTER
365 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
367 if (parallel_moves_[pos] == NULL) {
368 parallel_moves_[pos] = new(zone) LParallelMove(zone);
370 return parallel_moves_[pos];
373 LParallelMove* GetParallelMove(InnerPosition pos) {
374 return parallel_moves_[pos];
378 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
383 class LInstructionGap FINAL : public LGap {
385 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
388 return !IsRedundant();
391 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
395 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
397 explicit LGoto(HBasicBlock* block) : block_(block) { }
399 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
400 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
401 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
402 virtual bool IsControl() const OVERRIDE { return true; }
404 int block_id() const { return block_->block_id(); }
411 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
413 LLazyBailout() : gap_instructions_size_(0) { }
415 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
417 void set_gap_instructions_size(int gap_instructions_size) {
418 gap_instructions_size_ = gap_instructions_size;
420 int gap_instructions_size() { return gap_instructions_size_; }
423 int gap_instructions_size_;
427 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
430 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
434 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
436 explicit LDummyUse(LOperand* value) {
439 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
443 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
445 virtual bool IsControl() const OVERRIDE { return true; }
446 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
447 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
451 class LLabel FINAL : public LGap {
453 explicit LLabel(HBasicBlock* block)
454 : LGap(block), replacement_(NULL) { }
456 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
459 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
461 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
463 int block_id() const { return block()->block_id(); }
464 bool is_loop_header() const { return block()->IsLoopHeader(); }
465 bool is_osr_entry() const { return block()->is_osr_entry(); }
466 Label* label() { return &label_; }
467 LLabel* replacement() const { return replacement_; }
468 void set_replacement(LLabel* label) { replacement_ = label; }
469 bool HasReplacement() const { return replacement_ != NULL; }
473 LLabel* replacement_;
477 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
479 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
482 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
486 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
488 explicit LCallStub(LOperand* context) {
489 inputs_[0] = context;
492 LOperand* context() { return inputs_[0]; }
494 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
495 DECLARE_HYDROGEN_ACCESSOR(CallStub)
499 class LTailCallThroughMegamorphicCache FINAL
500 : public LTemplateInstruction<0, 3, 0> {
502 explicit LTailCallThroughMegamorphicCache(LOperand* context,
505 inputs_[0] = context;
506 inputs_[1] = receiver;
510 LOperand* context() { return inputs_[0]; }
511 LOperand* receiver() { return inputs_[1]; }
512 LOperand* name() { return inputs_[2]; }
514 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
515 "tail-call-through-megamorphic-cache")
516 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
520 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
522 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
525 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
529 template<int I, int T>
530 class LControlInstruction : public LTemplateInstruction<0, I, T> {
532 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
534 virtual bool IsControl() const FINAL OVERRIDE { return true; }
536 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
537 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
539 int TrueDestination(LChunk* chunk) {
540 return chunk->LookupDestination(true_block_id());
542 int FalseDestination(LChunk* chunk) {
543 return chunk->LookupDestination(false_block_id());
546 Label* TrueLabel(LChunk* chunk) {
547 if (true_label_ == NULL) {
548 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
552 Label* FalseLabel(LChunk* chunk) {
553 if (false_label_ == NULL) {
554 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
560 int true_block_id() { return SuccessorAt(0)->block_id(); }
561 int false_block_id() { return SuccessorAt(1)->block_id(); }
564 HControlInstruction* hydrogen() {
565 return HControlInstruction::cast(this->hydrogen_value());
573 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
575 LWrapReceiver(LOperand* receiver, LOperand* function) {
576 inputs_[0] = receiver;
577 inputs_[1] = function;
580 LOperand* receiver() { return inputs_[0]; }
581 LOperand* function() { return inputs_[1]; }
583 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
584 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
588 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
590 LApplyArguments(LOperand* function,
593 LOperand* elements) {
594 inputs_[0] = function;
595 inputs_[1] = receiver;
597 inputs_[3] = elements;
600 LOperand* function() { return inputs_[0]; }
601 LOperand* receiver() { return inputs_[1]; }
602 LOperand* length() { return inputs_[2]; }
603 LOperand* elements() { return inputs_[3]; }
605 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
609 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
611 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
612 inputs_[0] = arguments;
617 LOperand* arguments() { return inputs_[0]; }
618 LOperand* length() { return inputs_[1]; }
619 LOperand* index() { return inputs_[2]; }
621 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
623 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
627 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
629 explicit LArgumentsLength(LOperand* elements) {
630 inputs_[0] = elements;
633 LOperand* elements() { return inputs_[0]; }
635 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
639 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
641 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
642 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
646 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
648 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
649 inputs_[0] = dividend;
653 LOperand* dividend() { return inputs_[0]; }
654 int32_t divisor() const { return divisor_; }
656 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
657 DECLARE_HYDROGEN_ACCESSOR(Mod)
664 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
666 LModByConstI(LOperand* dividend,
670 inputs_[0] = dividend;
676 LOperand* dividend() { return inputs_[0]; }
677 int32_t divisor() const { return divisor_; }
678 LOperand* temp1() { return temps_[0]; }
679 LOperand* temp2() { return temps_[1]; }
681 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
682 DECLARE_HYDROGEN_ACCESSOR(Mod)
689 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
691 LModI(LOperand* left, LOperand* right, LOperand* temp) {
697 LOperand* left() { return inputs_[0]; }
698 LOperand* right() { return inputs_[1]; }
699 LOperand* temp() { return temps_[0]; }
701 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
702 DECLARE_HYDROGEN_ACCESSOR(Mod)
706 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
708 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
709 inputs_[0] = dividend;
713 LOperand* dividend() { return inputs_[0]; }
714 int32_t divisor() const { return divisor_; }
716 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
717 DECLARE_HYDROGEN_ACCESSOR(Div)
724 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
726 LDivByConstI(LOperand* dividend,
730 inputs_[0] = dividend;
736 LOperand* dividend() { return inputs_[0]; }
737 int32_t divisor() const { return divisor_; }
738 LOperand* temp1() { return temps_[0]; }
739 LOperand* temp2() { return temps_[1]; }
741 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
742 DECLARE_HYDROGEN_ACCESSOR(Div)
749 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
751 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
752 inputs_[0] = dividend;
753 inputs_[1] = divisor;
757 LOperand* dividend() { return inputs_[0]; }
758 LOperand* divisor() { return inputs_[1]; }
759 LOperand* temp() { return temps_[0]; }
761 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
762 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
766 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
768 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
769 inputs_[0] = dividend;
773 LOperand* dividend() { return inputs_[0]; }
774 int32_t divisor() const { return divisor_; }
776 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
777 "flooring-div-by-power-of-2-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
785 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
787 LFlooringDivByConstI(LOperand* dividend,
792 inputs_[0] = dividend;
799 LOperand* dividend() { return inputs_[0]; }
800 int32_t divisor() const { return divisor_; }
801 LOperand* temp1() { return temps_[0]; }
802 LOperand* temp2() { return temps_[1]; }
803 LOperand* temp3() { return temps_[2]; }
805 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
806 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
813 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
815 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
816 inputs_[0] = dividend;
817 inputs_[1] = divisor;
821 LOperand* dividend() { return inputs_[0]; }
822 LOperand* divisor() { return inputs_[1]; }
823 LOperand* temp() { return temps_[0]; }
825 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
826 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
830 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
832 LMulI(LOperand* left, LOperand* right) {
837 LOperand* left() { return inputs_[0]; }
838 LOperand* right() { return inputs_[1]; }
840 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
841 DECLARE_HYDROGEN_ACCESSOR(Mul)
845 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
847 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
852 LOperand* left() { return inputs_[0]; }
853 LOperand* right() { return inputs_[1]; }
855 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
856 "compare-numeric-and-branch")
857 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
859 Token::Value op() const { return hydrogen()->token(); }
860 bool is_double() const {
861 return hydrogen()->representation().IsDouble();
864 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
868 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
870 explicit LMathFloor(LOperand* value) {
874 LOperand* value() { return inputs_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
877 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
881 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
883 LMathRound(LOperand* value, LOperand* temp) {
888 LOperand* value() { return inputs_[0]; }
889 LOperand* temp() { return temps_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
892 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
896 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
898 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
906 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
908 explicit LMathAbs(LOperand* context, LOperand* value) {
909 inputs_[1] = context;
913 LOperand* context() { return inputs_[1]; }
914 LOperand* value() { return inputs_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
917 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
921 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathLog(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
933 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
935 explicit LMathClz32(LOperand* value) {
939 LOperand* value() { return inputs_[0]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
945 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
947 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
951 ExternalReference::InitializeMathExpData();
954 LOperand* value() { return inputs_[0]; }
955 LOperand* temp1() { return temps_[0]; }
956 LOperand* temp2() { return temps_[1]; }
958 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
962 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
964 explicit LMathSqrt(LOperand* value) {
968 LOperand* value() { return inputs_[0]; }
970 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
974 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
976 explicit LMathPowHalf(LOperand* value) {
980 LOperand* value() { return inputs_[0]; }
982 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
986 class LNullarySIMDOperation FINAL : public LTemplateInstruction<1, 0, 0> {
988 explicit LNullarySIMDOperation(BuiltinFunctionId op)
992 BuiltinFunctionId op() const { return op_; }
994 virtual Opcode opcode() const OVERRIDE {
995 return LInstruction::kNullarySIMDOperation;
997 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
998 virtual const char* Mnemonic() const OVERRIDE;
999 static LNullarySIMDOperation* cast(LInstruction* instr) {
1000 DCHECK(instr->IsNullarySIMDOperation());
1001 return reinterpret_cast<LNullarySIMDOperation*>(instr);
1004 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
1007 BuiltinFunctionId op_;
1011 class LUnarySIMDOperation FINAL : public LTemplateInstruction<1, 1, 0> {
1013 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
1018 LOperand* value() { return inputs_[0]; }
1019 BuiltinFunctionId op() const { return op_; }
1021 virtual Opcode opcode() const OVERRIDE {
1022 return LInstruction::kUnarySIMDOperation;
1024 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1025 virtual const char* Mnemonic() const OVERRIDE;
1026 static LUnarySIMDOperation* cast(LInstruction* instr) {
1027 DCHECK(instr->IsUnarySIMDOperation());
1028 return reinterpret_cast<LUnarySIMDOperation*>(instr);
1031 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
1034 BuiltinFunctionId op_;
1038 class LBinarySIMDOperation FINAL : public LTemplateInstruction<1, 2, 0> {
1040 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1046 LOperand* left() { return inputs_[0]; }
1047 LOperand* right() { return inputs_[1]; }
1048 BuiltinFunctionId op() const { return op_; }
1050 virtual Opcode opcode() const OVERRIDE {
1051 return LInstruction::kBinarySIMDOperation;
1053 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1054 virtual const char* Mnemonic() const OVERRIDE;
1055 static LBinarySIMDOperation* cast(LInstruction* instr) {
1056 DCHECK(instr->IsBinarySIMDOperation());
1057 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1060 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1063 BuiltinFunctionId op_;
1067 class LTernarySIMDOperation FINAL : public LTemplateInstruction<1, 3, 0> {
1069 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1070 BuiltinFunctionId op)
1073 inputs_[1] = second;
1077 LOperand* first() { return inputs_[0]; }
1078 LOperand* second() { return inputs_[1]; }
1079 LOperand* third() { return inputs_[2]; }
1080 BuiltinFunctionId op() const { return op_; }
1082 virtual Opcode opcode() const OVERRIDE {
1083 return LInstruction::kTernarySIMDOperation;
1085 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1086 virtual const char* Mnemonic() const OVERRIDE;
1087 static LTernarySIMDOperation* cast(LInstruction* instr) {
1088 DCHECK(instr->IsTernarySIMDOperation());
1089 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1092 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1095 BuiltinFunctionId op_;
1099 class LQuarternarySIMDOperation FINAL
1100 : public LTemplateInstruction<1, 4, 0> {
1102 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1103 LOperand* w, BuiltinFunctionId op)
1111 LOperand* x() { return inputs_[0]; }
1112 LOperand* y() { return inputs_[1]; }
1113 LOperand* z() { return inputs_[2]; }
1114 LOperand* w() { return inputs_[3]; }
1115 BuiltinFunctionId op() const { return op_; }
1117 virtual Opcode opcode() const OVERRIDE {
1118 return LInstruction::kQuarternarySIMDOperation;
1120 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1121 virtual const char* Mnemonic() const OVERRIDE;
1122 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1123 DCHECK(instr->IsQuarternarySIMDOperation());
1124 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1127 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1130 BuiltinFunctionId op_;
1134 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
1136 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1141 LOperand* left() { return inputs_[0]; }
1142 LOperand* right() { return inputs_[1]; }
1144 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1148 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1150 explicit LCmpHoleAndBranch(LOperand* object) {
1151 inputs_[0] = object;
1154 LOperand* object() { return inputs_[0]; }
1156 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1157 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1161 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1163 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1167 LOperand* value() { return inputs_[0]; }
1169 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1170 "cmp-minus-zero-and-branch")
1171 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1176 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 0> {
1178 explicit LIsObjectAndBranch(LOperand* value) {
1182 LOperand* value() { return inputs_[0]; }
1184 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1185 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1187 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1191 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1193 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1198 LOperand* value() { return inputs_[0]; }
1199 LOperand* temp() { return temps_[0]; }
1201 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1202 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1204 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1208 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1210 explicit LIsSmiAndBranch(LOperand* value) {
1214 LOperand* value() { return inputs_[0]; }
1216 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1217 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1219 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1223 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1225 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1230 LOperand* value() { return inputs_[0]; }
1231 LOperand* temp() { return temps_[0]; }
1233 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1234 "is-undetectable-and-branch")
1235 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1237 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1241 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1243 explicit LStringCompareAndBranch(LOperand* context,
1246 inputs_[0] = context;
1251 LOperand* context() { return inputs_[0]; }
1252 LOperand* left() { return inputs_[1]; }
1253 LOperand* right() { return inputs_[2]; }
1255 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1256 "string-compare-and-branch")
1257 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1259 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1261 Token::Value op() const { return hydrogen()->token(); }
1265 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1267 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1271 LOperand* value() { return inputs_[0]; }
1273 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1274 "has-instance-type-and-branch")
1275 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1277 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1281 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1283 explicit LGetCachedArrayIndex(LOperand* value) {
1287 LOperand* value() { return inputs_[0]; }
1289 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1290 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1294 class LHasCachedArrayIndexAndBranch FINAL
1295 : public LControlInstruction<1, 0> {
1297 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1301 LOperand* value() { return inputs_[0]; }
1303 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1304 "has-cached-array-index-and-branch")
1305 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1307 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1311 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1313 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1319 LOperand* value() { return inputs_[0]; }
1320 LOperand* temp() { return temps_[0]; }
1321 LOperand* temp2() { return temps_[1]; }
1323 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1324 "class-of-test-and-branch")
1325 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1327 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1331 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1333 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1334 inputs_[0] = context;
1339 LOperand* context() { return inputs_[0]; }
1340 LOperand* left() { return inputs_[1]; }
1341 LOperand* right() { return inputs_[2]; }
1343 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1344 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1346 Token::Value op() const { return hydrogen()->token(); }
1350 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1352 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1353 inputs_[0] = context;
1358 LOperand* context() { return inputs_[0]; }
1359 LOperand* left() { return inputs_[1]; }
1360 LOperand* right() { return inputs_[2]; }
1362 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1366 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1368 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1369 inputs_[0] = context;
1374 LOperand* context() { return inputs_[0]; }
1375 LOperand* value() { return inputs_[1]; }
1376 LOperand* temp() { return temps_[0]; }
1378 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1379 "instance-of-known-global")
1380 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1382 Handle<JSFunction> function() const { return hydrogen()->function(); }
1383 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1384 return lazy_deopt_env_;
1386 virtual void SetDeferredLazyDeoptimizationEnvironment(
1387 LEnvironment* env) OVERRIDE {
1388 lazy_deopt_env_ = env;
1392 LEnvironment* lazy_deopt_env_;
1396 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1398 LBoundsCheck(LOperand* index, LOperand* length) {
1400 inputs_[1] = length;
1403 LOperand* index() { return inputs_[0]; }
1404 LOperand* length() { return inputs_[1]; }
1406 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1407 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1411 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1413 LBitI(LOperand* left, LOperand* right) {
1418 LOperand* left() { return inputs_[0]; }
1419 LOperand* right() { return inputs_[1]; }
1421 Token::Value op() const { return hydrogen()->op(); }
1422 bool IsInteger32() const {
1423 return hydrogen()->representation().IsInteger32();
1426 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1427 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1431 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1433 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1434 : op_(op), can_deopt_(can_deopt) {
1439 Token::Value op() const { return op_; }
1440 LOperand* left() { return inputs_[0]; }
1441 LOperand* right() { return inputs_[1]; }
1442 bool can_deopt() const { return can_deopt_; }
1444 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1452 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1454 LSubI(LOperand* left, LOperand* right) {
1459 LOperand* left() { return inputs_[0]; }
1460 LOperand* right() { return inputs_[1]; }
1462 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1463 DECLARE_HYDROGEN_ACCESSOR(Sub)
1467 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1469 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1470 DECLARE_HYDROGEN_ACCESSOR(Constant)
1472 int32_t value() const { return hydrogen()->Integer32Value(); }
1476 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1478 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1479 DECLARE_HYDROGEN_ACCESSOR(Constant)
1481 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1485 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1487 explicit LConstantD(LOperand* temp) {
1491 LOperand* temp() { return temps_[0]; }
1493 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1494 DECLARE_HYDROGEN_ACCESSOR(Constant)
1496 double value() const { return hydrogen()->DoubleValue(); }
1500 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1502 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1503 DECLARE_HYDROGEN_ACCESSOR(Constant)
1505 ExternalReference value() const {
1506 return hydrogen()->ExternalReferenceValue();
1511 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1513 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1514 DECLARE_HYDROGEN_ACCESSOR(Constant)
1516 Handle<Object> value(Isolate* isolate) const {
1517 return hydrogen()->handle(isolate);
1522 class LBranch FINAL : public LControlInstruction<1, 0> {
1524 explicit LBranch(LOperand* value) {
1528 LOperand* value() { return inputs_[0]; }
1530 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1531 DECLARE_HYDROGEN_ACCESSOR(Branch)
1533 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1537 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
1539 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1543 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1545 explicit LCmpMapAndBranch(LOperand* value) {
1549 LOperand* value() { return inputs_[0]; }
1551 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1552 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1554 Handle<Map> map() const { return hydrogen()->map().handle(); }
1558 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1560 explicit LMapEnumLength(LOperand* value) {
1564 LOperand* value() { return inputs_[0]; }
1566 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1570 class LDateField FINAL : public LTemplateInstruction<1, 1, 0> {
1572 LDateField(LOperand* date, Smi* index) : index_(index) {
1576 LOperand* date() { return inputs_[0]; }
1577 Smi* index() const { return index_; }
1579 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1580 DECLARE_HYDROGEN_ACCESSOR(DateField)
1587 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1589 LSeqStringGetChar(LOperand* string, LOperand* index) {
1590 inputs_[0] = string;
1594 LOperand* string() const { return inputs_[0]; }
1595 LOperand* index() const { return inputs_[1]; }
1597 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1598 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1602 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1604 LSeqStringSetChar(LOperand* context,
1608 inputs_[0] = context;
1609 inputs_[1] = string;
1614 LOperand* string() { return inputs_[1]; }
1615 LOperand* index() { return inputs_[2]; }
1616 LOperand* value() { return inputs_[3]; }
1618 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1619 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1623 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1625 LAddI(LOperand* left, LOperand* right) {
1630 LOperand* left() { return inputs_[0]; }
1631 LOperand* right() { return inputs_[1]; }
1633 static bool UseLea(HAdd* add) {
1634 return !add->CheckFlag(HValue::kCanOverflow) &&
1635 add->BetterLeftOperand()->UseCount() > 1;
1638 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1639 DECLARE_HYDROGEN_ACCESSOR(Add)
1643 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1645 LMathMinMax(LOperand* left, LOperand* right) {
1650 LOperand* left() { return inputs_[0]; }
1651 LOperand* right() { return inputs_[1]; }
1653 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1654 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1658 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1660 LPower(LOperand* left, LOperand* right) {
1665 LOperand* left() { return inputs_[0]; }
1666 LOperand* right() { return inputs_[1]; }
1668 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1669 DECLARE_HYDROGEN_ACCESSOR(Power)
1673 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1675 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1681 Token::Value op() const { return op_; }
1682 LOperand* left() { return inputs_[0]; }
1683 LOperand* right() { return inputs_[1]; }
1685 virtual Opcode opcode() const OVERRIDE {
1686 return LInstruction::kArithmeticD;
1688 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1689 virtual const char* Mnemonic() const OVERRIDE;
1696 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1698 LArithmeticT(Token::Value op,
1703 inputs_[0] = context;
1708 Token::Value op() const { return op_; }
1709 LOperand* context() { return inputs_[0]; }
1710 LOperand* left() { return inputs_[1]; }
1711 LOperand* right() { return inputs_[2]; }
1713 virtual Opcode opcode() const OVERRIDE {
1714 return LInstruction::kArithmeticT;
1716 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1717 virtual const char* Mnemonic() const OVERRIDE;
1724 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1726 explicit LReturn(LOperand* value,
1728 LOperand* parameter_count) {
1730 inputs_[1] = context;
1731 inputs_[2] = parameter_count;
1734 LOperand* value() { return inputs_[0]; }
1735 LOperand* context() { return inputs_[1]; }
1737 bool has_constant_parameter_count() {
1738 return parameter_count()->IsConstantOperand();
1740 LConstantOperand* constant_parameter_count() {
1741 DCHECK(has_constant_parameter_count());
1742 return LConstantOperand::cast(parameter_count());
1744 LOperand* parameter_count() { return inputs_[2]; }
1746 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1747 DECLARE_HYDROGEN_ACCESSOR(Return)
1751 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1753 explicit LLoadNamedField(LOperand* object) {
1754 inputs_[0] = object;
1757 LOperand* object() { return inputs_[0]; }
1759 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1760 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1764 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1766 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1768 inputs_[0] = context;
1769 inputs_[1] = object;
1773 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1774 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1776 LOperand* context() { return inputs_[0]; }
1777 LOperand* object() { return inputs_[1]; }
1778 LOperand* temp_vector() { return temps_[0]; }
1780 Handle<Object> name() const { return hydrogen()->name(); }
1784 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1786 explicit LLoadFunctionPrototype(LOperand* function) {
1787 inputs_[0] = function;
1790 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1791 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1793 LOperand* function() { return inputs_[0]; }
1797 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1799 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1800 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1802 Heap::RootListIndex index() const { return hydrogen()->index(); }
1806 inline static bool ExternalArrayOpRequiresPreScale(
1807 Representation key_representation,
1808 ElementsKind kind) {
1809 int shift_size = ElementsKindToShiftSize(kind);
1810 return SmiValuesAre31Bits() && key_representation.IsSmi()
1811 ? shift_size > static_cast<int>(maximal_scale_factor) + kSmiTagSize
1812 : shift_size > static_cast<int>(maximal_scale_factor);
1816 inline static bool ExternalArrayOpRequiresTemp(
1817 Representation key_representation,
1818 ElementsKind elements_kind) {
1819 // Operations that require the key to be divided by two to be converted into
1820 // an index cannot fold the scale operation into a load and need an extra
1821 // temp register to do the work.
1822 return ExternalArrayOpRequiresPreScale(key_representation, elements_kind) ||
1823 (SmiValuesAre31Bits() && key_representation.IsSmi() &&
1824 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1825 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1826 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1827 elements_kind == UINT8_ELEMENTS ||
1828 elements_kind == INT8_ELEMENTS ||
1829 elements_kind == UINT8_CLAMPED_ELEMENTS));
1833 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1835 LLoadKeyed(LOperand* elements, LOperand* key) {
1836 inputs_[0] = elements;
1840 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1841 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1843 bool is_external() const {
1844 return hydrogen()->is_external();
1846 bool is_fixed_typed_array() const {
1847 return hydrogen()->is_fixed_typed_array();
1849 bool is_typed_elements() const {
1850 return is_external() || is_fixed_typed_array();
1852 LOperand* elements() { return inputs_[0]; }
1853 LOperand* key() { return inputs_[1]; }
1854 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1855 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1856 ElementsKind elements_kind() const {
1857 return hydrogen()->elements_kind();
1862 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1864 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1866 inputs_[0] = context;
1872 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1873 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1875 LOperand* context() { return inputs_[0]; }
1876 LOperand* object() { return inputs_[1]; }
1877 LOperand* key() { return inputs_[2]; }
1878 LOperand* temp_vector() { return temps_[0]; }
1882 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1884 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1885 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1889 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1891 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1893 inputs_[0] = context;
1894 inputs_[1] = global_object;
1898 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1899 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1901 LOperand* context() { return inputs_[0]; }
1902 LOperand* global_object() { return inputs_[1]; }
1903 LOperand* temp_vector() { return temps_[0]; }
1905 Handle<Object> name() const { return hydrogen()->name(); }
1906 bool for_typeof() const { return hydrogen()->for_typeof(); }
1910 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1912 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1917 LOperand* value() { return inputs_[0]; }
1918 LOperand* temp() { return temps_[0]; }
1920 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1921 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1925 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1927 explicit LLoadContextSlot(LOperand* context) {
1928 inputs_[0] = context;
1931 LOperand* context() { return inputs_[0]; }
1933 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1934 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1936 int slot_index() { return hydrogen()->slot_index(); }
1938 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1942 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1944 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1945 inputs_[0] = context;
1950 LOperand* context() { return inputs_[0]; }
1951 LOperand* value() { return inputs_[1]; }
1952 LOperand* temp() { return temps_[0]; }
1954 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1955 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1957 int slot_index() { return hydrogen()->slot_index(); }
1959 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1963 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1965 explicit LPushArgument(LOperand* value) {
1969 LOperand* value() { return inputs_[0]; }
1971 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1975 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1977 explicit LDrop(int count) : count_(count) { }
1979 int count() const { return count_; }
1981 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1988 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1990 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1991 inputs_[0] = function;
1992 inputs_[1] = code_object;
1995 LOperand* function() { return inputs_[0]; }
1996 LOperand* code_object() { return inputs_[1]; }
1998 virtual void PrintDataTo(StringStream* stream);
2000 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
2001 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
2005 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
2007 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
2008 inputs_[0] = base_object;
2009 inputs_[1] = offset;
2012 LOperand* base_object() const { return inputs_[0]; }
2013 LOperand* offset() const { return inputs_[1]; }
2015 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2017 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
2021 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
2023 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
2024 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
2028 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
2030 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
2031 DECLARE_HYDROGEN_ACCESSOR(Context)
2035 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
2037 explicit LDeclareGlobals(LOperand* context) {
2038 inputs_[0] = context;
2041 LOperand* context() { return inputs_[0]; }
2043 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
2044 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
2048 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
2050 explicit LCallJSFunction(LOperand* function) {
2051 inputs_[0] = function;
2054 LOperand* function() { return inputs_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
2057 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
2059 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2061 int arity() const { return hydrogen()->argument_count() - 1; }
2065 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
2067 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
2068 const ZoneList<LOperand*>& operands, Zone* zone)
2069 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
2070 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
2071 inputs_.AddAll(operands, zone);
2074 LOperand* target() const { return inputs_[0]; }
2076 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2079 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2081 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2083 int arity() const { return hydrogen()->argument_count() - 1; }
2085 ZoneList<LOperand*> inputs_;
2087 // Iterator support.
2088 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
2089 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
2091 virtual int TempCount() FINAL OVERRIDE { return 0; }
2092 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
2096 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
2098 LInvokeFunction(LOperand* context, LOperand* function) {
2099 inputs_[0] = context;
2100 inputs_[1] = function;
2103 LOperand* context() { return inputs_[0]; }
2104 LOperand* function() { return inputs_[1]; }
2106 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2107 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2109 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2111 int arity() const { return hydrogen()->argument_count() - 1; }
2115 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
2117 LCallFunction(LOperand* context, LOperand* function) {
2118 inputs_[0] = context;
2119 inputs_[1] = function;
2122 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2123 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2125 LOperand* context() { return inputs_[0]; }
2126 LOperand* function() { return inputs_[1]; }
2127 int arity() const { return hydrogen()->argument_count() - 1; }
2131 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
2133 LCallNew(LOperand* context, LOperand* constructor) {
2134 inputs_[0] = context;
2135 inputs_[1] = constructor;
2138 LOperand* context() { return inputs_[0]; }
2139 LOperand* constructor() { return inputs_[1]; }
2141 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2142 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2144 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2146 int arity() const { return hydrogen()->argument_count() - 1; }
2150 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2152 LCallNewArray(LOperand* context, LOperand* constructor) {
2153 inputs_[0] = context;
2154 inputs_[1] = constructor;
2157 LOperand* context() { return inputs_[0]; }
2158 LOperand* constructor() { return inputs_[1]; }
2160 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2161 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2163 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2165 int arity() const { return hydrogen()->argument_count() - 1; }
2169 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2171 explicit LCallRuntime(LOperand* context) {
2172 inputs_[0] = context;
2175 LOperand* context() { return inputs_[0]; }
2177 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2178 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2180 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2181 return save_doubles() == kDontSaveFPRegs;
2184 const Runtime::Function* function() const { return hydrogen()->function(); }
2185 int arity() const { return hydrogen()->argument_count(); }
2186 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2190 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2192 explicit LInteger32ToDouble(LOperand* value) {
2196 LOperand* value() { return inputs_[0]; }
2198 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2202 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2204 explicit LUint32ToDouble(LOperand* value) {
2208 LOperand* value() { return inputs_[0]; }
2210 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2214 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
2216 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
2222 LOperand* value() { return inputs_[0]; }
2223 LOperand* temp1() { return temps_[0]; }
2224 LOperand* temp2() { return temps_[1]; }
2226 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2230 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2232 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2238 LOperand* value() { return inputs_[0]; }
2239 LOperand* temp1() { return temps_[0]; }
2240 LOperand* temp2() { return temps_[1]; }
2242 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2246 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2248 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2253 LOperand* value() { return inputs_[0]; }
2254 LOperand* temp() { return temps_[0]; }
2256 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2257 DECLARE_HYDROGEN_ACCESSOR(Change)
2261 class LSIMD128ToTagged FINAL : public LTemplateInstruction<1, 1, 3> {
2263 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp,
2264 LOperand* temp2, LOperand* temp3) {
2271 LOperand* value() { return inputs_[0]; }
2272 LOperand* temp() { return temps_[0]; }
2273 LOperand* temp2() { return temps_[1]; }
2274 LOperand* temp3() { return temps_[2]; }
2276 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2277 DECLARE_HYDROGEN_ACCESSOR(Change)
2281 // Sometimes truncating conversion from a tagged value to an int32.
2282 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2284 explicit LDoubleToI(LOperand* value) {
2288 LOperand* value() { return inputs_[0]; }
2290 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2291 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2293 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2297 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2299 explicit LDoubleToSmi(LOperand* value) {
2303 LOperand* value() { return inputs_[0]; }
2305 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2306 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2310 // Truncating conversion from a tagged value to an int32.
2311 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 1> {
2313 LTaggedToI(LOperand* value, LOperand* temp) {
2318 LOperand* value() { return inputs_[0]; }
2319 LOperand* temp() { return temps_[0]; }
2321 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2322 DECLARE_HYDROGEN_ACCESSOR(Change)
2324 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2328 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2330 explicit LSmiTag(LOperand* value) {
2334 LOperand* value() { return inputs_[0]; }
2336 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2337 DECLARE_HYDROGEN_ACCESSOR(Change)
2341 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2343 explicit LNumberUntagD(LOperand* value) {
2347 LOperand* value() { return inputs_[0]; }
2349 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2350 DECLARE_HYDROGEN_ACCESSOR(Change);
2354 class LTaggedToSIMD128 FINAL : public LTemplateInstruction<1, 1, 1> {
2356 explicit LTaggedToSIMD128(LOperand* value, LOperand* temp,
2357 Representation representation)
2358 : representation_(representation) {
2363 LOperand* value() { return inputs_[0]; }
2364 LOperand* temp() { return temps_[0]; }
2365 Representation representation() const { return representation_; }
2367 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2368 DECLARE_HYDROGEN_ACCESSOR(Change);
2370 Representation representation_;
2374 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2376 LSmiUntag(LOperand* value, bool needs_check)
2377 : needs_check_(needs_check) {
2381 LOperand* value() { return inputs_[0]; }
2382 bool needs_check() const { return needs_check_; }
2384 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2391 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2393 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2394 inputs_[0] = object;
2399 LOperand* object() { return inputs_[0]; }
2400 LOperand* value() { return inputs_[1]; }
2401 LOperand* temp() { return temps_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2404 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2406 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2408 Representation representation() const {
2409 return hydrogen()->field_representation();
2414 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2416 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2417 inputs_[0] = context;
2418 inputs_[1] = object;
2422 LOperand* context() { return inputs_[0]; }
2423 LOperand* object() { return inputs_[1]; }
2424 LOperand* value() { return inputs_[2]; }
2426 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2427 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2429 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2431 Handle<Object> name() const { return hydrogen()->name(); }
2432 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2436 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2438 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2439 inputs_[0] = object;
2444 bool is_external() const { return hydrogen()->is_external(); }
2445 bool is_fixed_typed_array() const {
2446 return hydrogen()->is_fixed_typed_array();
2448 bool is_typed_elements() const {
2449 return is_external() || is_fixed_typed_array();
2451 LOperand* elements() { return inputs_[0]; }
2452 LOperand* key() { return inputs_[1]; }
2453 LOperand* value() { return inputs_[2]; }
2454 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2456 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2457 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2459 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2460 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2461 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2465 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2467 LStoreKeyedGeneric(LOperand* context,
2471 inputs_[0] = context;
2472 inputs_[1] = object;
2477 LOperand* context() { return inputs_[0]; }
2478 LOperand* object() { return inputs_[1]; }
2479 LOperand* key() { return inputs_[2]; }
2480 LOperand* value() { return inputs_[3]; }
2482 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2483 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2485 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2487 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2491 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2493 LTransitionElementsKind(LOperand* object,
2495 LOperand* new_map_temp,
2497 inputs_[0] = object;
2498 inputs_[1] = context;
2499 temps_[0] = new_map_temp;
2503 LOperand* object() { return inputs_[0]; }
2504 LOperand* context() { return inputs_[1]; }
2505 LOperand* new_map_temp() { return temps_[0]; }
2506 LOperand* temp() { return temps_[1]; }
2508 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2509 "transition-elements-kind")
2510 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2512 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2514 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2515 Handle<Map> transitioned_map() {
2516 return hydrogen()->transitioned_map().handle();
2518 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2519 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2523 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2525 LTrapAllocationMemento(LOperand* object,
2527 inputs_[0] = object;
2531 LOperand* object() { return inputs_[0]; }
2532 LOperand* temp() { return temps_[0]; }
2534 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2535 "trap-allocation-memento")
2539 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2541 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2542 inputs_[0] = context;
2547 LOperand* context() { return inputs_[0]; }
2548 LOperand* left() { return inputs_[1]; }
2549 LOperand* right() { return inputs_[2]; }
2551 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2552 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2556 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2558 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2559 inputs_[0] = context;
2560 inputs_[1] = string;
2564 LOperand* context() { return inputs_[0]; }
2565 LOperand* string() { return inputs_[1]; }
2566 LOperand* index() { return inputs_[2]; }
2568 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2569 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2573 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2575 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2576 inputs_[0] = context;
2577 inputs_[1] = char_code;
2580 LOperand* context() { return inputs_[0]; }
2581 LOperand* char_code() { return inputs_[1]; }
2583 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2584 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2588 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2590 explicit LCheckValue(LOperand* value) {
2594 LOperand* value() { return inputs_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2597 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2601 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2603 explicit LCheckInstanceType(LOperand* value) {
2607 LOperand* value() { return inputs_[0]; }
2609 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2610 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2614 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2616 explicit LCheckMaps(LOperand* value = NULL) {
2620 LOperand* value() { return inputs_[0]; }
2622 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2623 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2627 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2629 explicit LCheckSmi(LOperand* value) {
2633 LOperand* value() { return inputs_[0]; }
2635 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2639 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2641 explicit LClampDToUint8(LOperand* unclamped) {
2642 inputs_[0] = unclamped;
2645 LOperand* unclamped() { return inputs_[0]; }
2647 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2651 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2653 explicit LClampIToUint8(LOperand* unclamped) {
2654 inputs_[0] = unclamped;
2657 LOperand* unclamped() { return inputs_[0]; }
2659 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2663 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2665 LClampTToUint8(LOperand* unclamped,
2666 LOperand* temp_xmm) {
2667 inputs_[0] = unclamped;
2668 temps_[0] = temp_xmm;
2671 LOperand* unclamped() { return inputs_[0]; }
2672 LOperand* temp_xmm() { return temps_[0]; }
2674 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2678 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2680 explicit LCheckNonSmi(LOperand* value) {
2684 LOperand* value() { return inputs_[0]; }
2686 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2687 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2691 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2693 explicit LDoubleBits(LOperand* value) {
2697 LOperand* value() { return inputs_[0]; }
2699 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2700 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2704 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2706 LConstructDouble(LOperand* hi, LOperand* lo) {
2711 LOperand* hi() { return inputs_[0]; }
2712 LOperand* lo() { return inputs_[1]; }
2714 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2718 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2720 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2721 inputs_[0] = context;
2726 LOperand* context() { return inputs_[0]; }
2727 LOperand* size() { return inputs_[1]; }
2728 LOperand* temp() { return temps_[0]; }
2730 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2731 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2735 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2737 explicit LRegExpLiteral(LOperand* context) {
2738 inputs_[0] = context;
2741 LOperand* context() { return inputs_[0]; }
2743 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2744 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2748 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2750 explicit LFunctionLiteral(LOperand* context) {
2751 inputs_[0] = context;
2754 LOperand* context() { return inputs_[0]; }
2756 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2757 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2761 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2763 explicit LToFastProperties(LOperand* value) {
2767 LOperand* value() { return inputs_[0]; }
2769 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2770 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2774 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2776 LTypeof(LOperand* context, LOperand* value) {
2777 inputs_[0] = context;
2781 LOperand* context() { return inputs_[0]; }
2782 LOperand* value() { return inputs_[1]; }
2784 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2788 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2790 explicit LTypeofIsAndBranch(LOperand* value) {
2794 LOperand* value() { return inputs_[0]; }
2796 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2797 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2799 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2801 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2805 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2807 explicit LIsConstructCallAndBranch(LOperand* temp) {
2811 LOperand* temp() { return temps_[0]; }
2813 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2814 "is-construct-call-and-branch")
2815 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2819 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2823 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2826 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2830 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2832 explicit LStackCheck(LOperand* context) {
2833 inputs_[0] = context;
2836 LOperand* context() { return inputs_[0]; }
2838 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2839 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2841 Label* done_label() { return &done_label_; }
2848 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2850 LForInPrepareMap(LOperand* context, LOperand* object) {
2851 inputs_[0] = context;
2852 inputs_[1] = object;
2855 LOperand* context() { return inputs_[0]; }
2856 LOperand* object() { return inputs_[1]; }
2858 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2862 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2864 explicit LForInCacheArray(LOperand* map) {
2868 LOperand* map() { return inputs_[0]; }
2870 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2873 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2878 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2880 LCheckMapValue(LOperand* value, LOperand* map) {
2885 LOperand* value() { return inputs_[0]; }
2886 LOperand* map() { return inputs_[1]; }
2888 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2892 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2894 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2895 inputs_[0] = object;
2899 LOperand* object() { return inputs_[0]; }
2900 LOperand* index() { return inputs_[1]; }
2902 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2906 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2908 explicit LStoreFrameContext(LOperand* context) {
2909 inputs_[0] = context;
2912 LOperand* context() { return inputs_[0]; }
2914 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2918 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2920 LAllocateBlockContext(LOperand* context, LOperand* function) {
2921 inputs_[0] = context;
2922 inputs_[1] = function;
2925 LOperand* context() { return inputs_[0]; }
2926 LOperand* function() { return inputs_[1]; }
2928 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2930 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2931 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2935 class LChunkBuilder;
2936 class LPlatformChunk FINAL : public LChunk {
2938 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2939 : LChunk(info, graph),
2940 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2942 int GetNextSpillIndex(RegisterKind kind);
2943 LOperand* GetNextSpillSlot(RegisterKind kind);
2944 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2945 bool IsDehoistedKey(HValue* value) {
2946 return dehoisted_key_ids_.Contains(value->id());
2950 BitVector dehoisted_key_ids_;
2954 class LChunkBuilder FINAL : public LChunkBuilderBase {
2956 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2957 : LChunkBuilderBase(info, graph),
2958 current_instruction_(NULL),
2959 current_block_(NULL),
2961 allocator_(allocator) {}
2963 // Build the sequence for the graph.
2964 LPlatformChunk* Build();
2966 // Declare methods that deal with the individual node types.
2967 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2968 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2971 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2972 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2973 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2974 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2975 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2976 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2977 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2978 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2979 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2980 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2981 LInstruction* DoDivByConstI(HDiv* instr);
2982 LInstruction* DoDivI(HDiv* instr);
2983 LInstruction* DoModByPowerOf2I(HMod* instr);
2984 LInstruction* DoModByConstI(HMod* instr);
2985 LInstruction* DoModI(HMod* instr);
2986 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2987 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2988 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2991 // Methods for getting operands for Use / Define / Temp.
2992 LUnallocated* ToUnallocated(Register reg);
2993 LUnallocated* ToUnallocated(XMMRegister reg);
2995 // Methods for setting up define-use relationships.
2996 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2997 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2998 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2999 XMMRegister fixed_register);
3001 // A value that is guaranteed to be allocated to a register.
3002 // Operand created by UseRegister is guaranteed to be live until the end of
3003 // instruction. This means that register allocator will not reuse it's
3004 // register for any other operand inside instruction.
3005 // Operand created by UseRegisterAtStart is guaranteed to be live only at
3006 // instruction start. Register allocator is free to assign the same register
3007 // to some other operand used inside instruction (i.e. temporary or
3009 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
3010 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
3012 // An input operand in a register that may be trashed.
3013 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
3015 // An input operand in a register that may be trashed or a constant operand.
3016 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
3018 // An input operand in a register or stack slot.
3019 MUST_USE_RESULT LOperand* Use(HValue* value);
3020 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
3022 // An input operand in a register, stack slot or a constant operand.
3023 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
3024 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
3026 // An input operand in a register or a constant operand.
3027 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
3028 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
3030 // An input operand in a constant operand.
3031 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
3033 // An input operand in register, stack slot or a constant operand.
3034 // Will not be moved to a register even if one is freely available.
3035 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
3037 // Temporary operand that must be in a register.
3038 MUST_USE_RESULT LUnallocated* TempRegister();
3039 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
3040 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
3042 // Methods for setting up define-use relationships.
3043 // Return the same instruction that they are passed.
3044 LInstruction* Define(LTemplateResultInstruction<1>* instr,
3045 LUnallocated* result);
3046 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
3047 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
3049 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
3050 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
3052 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
3054 // Assigns an environment to an instruction. An instruction which can
3055 // deoptimize must have an environment.
3056 LInstruction* AssignEnvironment(LInstruction* instr);
3057 // Assigns a pointer map to an instruction. An instruction which can
3058 // trigger a GC or a lazy deoptimization must have a pointer map.
3059 LInstruction* AssignPointerMap(LInstruction* instr);
3061 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
3063 // Marks a call for the register allocator. Assigns a pointer map to
3064 // support GC and lazy deoptimization. Assigns an environment to support
3065 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
3066 LInstruction* MarkAsCall(
3067 LInstruction* instr,
3068 HInstruction* hinstr,
3069 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
3071 void VisitInstruction(HInstruction* current);
3072 void AddInstruction(LInstruction* instr, HInstruction* current);
3074 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
3075 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
3076 LInstruction* DoArithmeticD(Token::Value op,
3077 HArithmeticBinaryOperation* instr);
3078 LInstruction* DoArithmeticT(Token::Value op,
3079 HBinaryOperation* instr);
3080 void FindDehoistedKeyDefinitions(HValue* candidate);
3082 HInstruction* current_instruction_;
3083 HBasicBlock* current_block_;
3084 HBasicBlock* next_block_;
3085 LAllocator* allocator_;
3087 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3090 #undef DECLARE_HYDROGEN_ACCESSOR
3091 #undef DECLARE_CONCRETE_INSTRUCTION
3093 } } // namespace v8::int
3095 #endif // V8_X64_LITHIUM_X64_H_