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_MIPS_LITHIUM_MIPS_H_
6 #define V8_MIPS_LITHIUM_MIPS_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
17 // Forward declarations.
20 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
21 V(AccessArgumentsAt) \
24 V(AllocateBlockContext) \
26 V(ArgumentsElements) \
34 V(CallWithDescriptor) \
40 V(CheckInstanceType) \
49 V(ClassOfTestAndBranch) \
50 V(CompareMinusZeroAndBranch) \
51 V(CompareNumericAndBranch) \
52 V(CmpObjectEqAndBranch) \
76 V(FlooringDivByConstI) \
77 V(FlooringDivByPowerOf2I) \
82 V(GetCachedArrayIndex) \
84 V(HasCachedArrayIndexAndBranch) \
85 V(HasInstanceTypeAndBranch) \
86 V(InnerAllocatedObject) \
88 V(InstanceOfKnownGlobal) \
90 V(Integer32ToDouble) \
92 V(IsConstructCallAndBranch) \
93 V(IsObjectAndBranch) \
94 V(IsStringAndBranch) \
96 V(IsUndetectableAndBranch) \
101 V(LoadFieldByIndex) \
102 V(LoadFunctionPrototype) \
104 V(LoadGlobalGeneric) \
106 V(LoadKeyedGeneric) \
108 V(LoadNamedGeneric) \
134 V(SeqStringGetChar) \
135 V(SeqStringSetChar) \
141 V(StoreContextSlot) \
142 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
154 V(TailCallThroughMegamorphicCache) \
156 V(ToFastProperties) \
157 V(TransitionElementsKind) \
158 V(TrapAllocationMemento) \
160 V(TypeofIsAndBranch) \
165 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
166 Opcode opcode() const FINAL { return LInstruction::k##type; } \
167 void CompileToNative(LCodeGen* generator) FINAL; \
168 const char* Mnemonic() const FINAL { return mnemonic; } \
169 static L##type* cast(LInstruction* instr) { \
170 DCHECK(instr->Is##type()); \
171 return reinterpret_cast<L##type*>(instr); \
175 #define DECLARE_HYDROGEN_ACCESSOR(type) \
176 H##type* hydrogen() const { \
177 return H##type::cast(hydrogen_value()); \
181 class LInstruction : public ZoneObject {
184 : environment_(NULL),
185 hydrogen_value_(NULL),
186 bit_field_(IsCallBits::encode(false)) {
189 virtual ~LInstruction() {}
191 virtual void CompileToNative(LCodeGen* generator) = 0;
192 virtual const char* Mnemonic() const = 0;
193 virtual void PrintTo(StringStream* stream);
194 virtual void PrintDataTo(StringStream* stream);
195 virtual void PrintOutputOperandTo(StringStream* stream);
198 // Declare a unique enum value for each instruction.
199 #define DECLARE_OPCODE(type) k##type,
200 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
201 kNumberOfInstructions
202 #undef DECLARE_OPCODE
205 virtual Opcode opcode() const = 0;
207 // Declare non-virtual type testers for all leaf IR classes.
208 #define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211 #undef DECLARE_PREDICATE
213 // Declare virtual predicates for instructions that don't have
215 virtual bool IsGap() const { return false; }
217 virtual bool IsControl() const { return false; }
219 // Try deleting this instruction if possible.
220 virtual bool TryDelete() { return false; }
222 void set_environment(LEnvironment* env) { environment_ = env; }
223 LEnvironment* environment() const { return environment_; }
224 bool HasEnvironment() const { return environment_ != NULL; }
226 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
227 LPointerMap* pointer_map() const { return pointer_map_.get(); }
228 bool HasPointerMap() const { return pointer_map_.is_set(); }
230 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
231 HValue* hydrogen_value() const { return hydrogen_value_; }
233 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
235 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
236 bool IsCall() const { return IsCallBits::decode(bit_field_); }
238 // Interface to the register allocator and iterators.
239 bool ClobbersTemps() const { return IsCall(); }
240 bool ClobbersRegisters() const { return IsCall(); }
241 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
245 // 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; }
260 virtual int InputCount() = 0;
261 virtual LOperand* InputAt(int i) = 0;
264 // Iterator interface.
265 friend class InputIterator;
267 friend class TempIterator;
268 virtual int TempCount() = 0;
269 virtual LOperand* TempAt(int i) = 0;
271 class IsCallBits: public BitField<bool, 0, 1> {};
273 LEnvironment* environment_;
274 SetOncePointer<LPointerMap> pointer_map_;
275 HValue* hydrogen_value_;
280 // R = number of result operands (0 or 1).
282 class LTemplateResultInstruction : public LInstruction {
284 // Allow 0 or 1 output operands.
285 STATIC_ASSERT(R == 0 || R == 1);
286 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
287 void set_result(LOperand* operand) { results_[0] = operand; }
288 LOperand* result() const OVERRIDE { return results_[0]; }
291 EmbeddedContainer<LOperand*, R> results_;
295 // R = number of result operands (0 or 1).
296 // I = number of input operands.
297 // T = number of temporary operands.
298 template<int R, int I, int T>
299 class LTemplateInstruction : public LTemplateResultInstruction<R> {
301 EmbeddedContainer<LOperand*, I> inputs_;
302 EmbeddedContainer<LOperand*, T> temps_;
306 int InputCount() FINAL { return I; }
307 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
309 int TempCount() FINAL { return T; }
310 LOperand* TempAt(int i) FINAL { return temps_[i]; }
314 class LGap : public LTemplateInstruction<0, 0, 0> {
316 explicit LGap(HBasicBlock* block)
318 parallel_moves_[BEFORE] = NULL;
319 parallel_moves_[START] = NULL;
320 parallel_moves_[END] = NULL;
321 parallel_moves_[AFTER] = NULL;
324 // Can't use the DECLARE-macro here because of sub-classes.
325 bool IsGap() const FINAL { return true; }
326 void PrintDataTo(StringStream* stream) OVERRIDE;
327 static LGap* cast(LInstruction* instr) {
328 DCHECK(instr->IsGap());
329 return reinterpret_cast<LGap*>(instr);
332 bool IsRedundant() const;
334 HBasicBlock* block() const { return block_; }
341 FIRST_INNER_POSITION = BEFORE,
342 LAST_INNER_POSITION = AFTER
345 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
346 if (parallel_moves_[pos] == NULL) {
347 parallel_moves_[pos] = new(zone) LParallelMove(zone);
349 return parallel_moves_[pos];
352 LParallelMove* GetParallelMove(InnerPosition pos) {
353 return parallel_moves_[pos];
357 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
362 class LInstructionGap FINAL : public LGap {
364 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
366 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
367 return !IsRedundant();
370 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
374 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
376 explicit LGoto(HBasicBlock* block) : block_(block) { }
378 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
379 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
380 void PrintDataTo(StringStream* stream) OVERRIDE;
381 bool IsControl() const OVERRIDE { return true; }
383 int block_id() const { return block_->block_id(); }
390 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
392 LLazyBailout() : gap_instructions_size_(0) { }
394 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
396 void set_gap_instructions_size(int gap_instructions_size) {
397 gap_instructions_size_ = gap_instructions_size;
399 int gap_instructions_size() { return gap_instructions_size_; }
402 int gap_instructions_size_;
406 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
409 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
413 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
415 explicit LDummyUse(LOperand* value) {
418 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
422 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
424 bool IsControl() const OVERRIDE { return true; }
425 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
426 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
430 class LLabel FINAL : public LGap {
432 explicit LLabel(HBasicBlock* block)
433 : LGap(block), replacement_(NULL) { }
435 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
436 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
438 void PrintDataTo(StringStream* stream) OVERRIDE;
440 int block_id() const { return block()->block_id(); }
441 bool is_loop_header() const { return block()->IsLoopHeader(); }
442 bool is_osr_entry() const { return block()->is_osr_entry(); }
443 Label* label() { return &label_; }
444 LLabel* replacement() const { return replacement_; }
445 void set_replacement(LLabel* label) { replacement_ = label; }
446 bool HasReplacement() const { return replacement_ != NULL; }
450 LLabel* replacement_;
454 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
456 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
457 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
463 explicit LCallStub(LOperand* context) {
464 inputs_[0] = context;
467 LOperand* context() { return inputs_[0]; }
469 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
470 DECLARE_HYDROGEN_ACCESSOR(CallStub)
474 class LTailCallThroughMegamorphicCache FINAL
475 : public LTemplateInstruction<0, 5, 0> {
477 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
478 LOperand* name, LOperand* slot,
480 inputs_[0] = context;
481 inputs_[1] = receiver;
487 LOperand* context() { return inputs_[0]; }
488 LOperand* receiver() { return inputs_[1]; }
489 LOperand* name() { return inputs_[2]; }
490 LOperand* slot() { return inputs_[3]; }
491 LOperand* vector() { return inputs_[4]; }
493 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
494 "tail-call-through-megamorphic-cache")
495 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
499 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
501 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
502 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
506 template<int I, int T>
507 class LControlInstruction : public LTemplateInstruction<0, I, T> {
509 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
511 bool IsControl() const FINAL { return true; }
513 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
514 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
516 int TrueDestination(LChunk* chunk) {
517 return chunk->LookupDestination(true_block_id());
519 int FalseDestination(LChunk* chunk) {
520 return chunk->LookupDestination(false_block_id());
523 Label* TrueLabel(LChunk* chunk) {
524 if (true_label_ == NULL) {
525 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
529 Label* FalseLabel(LChunk* chunk) {
530 if (false_label_ == NULL) {
531 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
537 int true_block_id() { return SuccessorAt(0)->block_id(); }
538 int false_block_id() { return SuccessorAt(1)->block_id(); }
541 HControlInstruction* hydrogen() {
542 return HControlInstruction::cast(this->hydrogen_value());
550 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
552 LWrapReceiver(LOperand* receiver, LOperand* function) {
553 inputs_[0] = receiver;
554 inputs_[1] = function;
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
558 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 LOperand* receiver() { return inputs_[0]; }
561 LOperand* function() { return inputs_[1]; }
565 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
586 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 void PrintDataTo(StringStream* stream) OVERRIDE;
604 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
625 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
626 inputs_[0] = dividend;
630 LOperand* dividend() { return inputs_[0]; }
631 int32_t divisor() const { return divisor_; }
633 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
634 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
643 LModByConstI(LOperand* dividend, int32_t divisor) {
644 inputs_[0] = dividend;
648 LOperand* dividend() { return inputs_[0]; }
649 int32_t divisor() const { return divisor_; }
651 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
652 DECLARE_HYDROGEN_ACCESSOR(Mod)
659 class LModI FINAL : public LTemplateInstruction<1, 2, 3> {
661 LModI(LOperand* left,
667 LOperand* left() { return inputs_[0]; }
668 LOperand* right() { return inputs_[1]; }
670 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
671 DECLARE_HYDROGEN_ACCESSOR(Mod)
675 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
677 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
678 inputs_[0] = dividend;
682 LOperand* dividend() { return inputs_[0]; }
683 int32_t divisor() const { return divisor_; }
685 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
686 DECLARE_HYDROGEN_ACCESSOR(Div)
693 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
695 LDivByConstI(LOperand* dividend, int32_t divisor) {
696 inputs_[0] = dividend;
700 LOperand* dividend() { return inputs_[0]; }
701 int32_t divisor() const { return divisor_; }
703 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
704 DECLARE_HYDROGEN_ACCESSOR(Div)
711 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
713 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
714 inputs_[0] = dividend;
715 inputs_[1] = divisor;
719 LOperand* dividend() { return inputs_[0]; }
720 LOperand* divisor() { return inputs_[1]; }
721 LOperand* temp() { return temps_[0]; }
723 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
724 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
728 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
730 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
731 inputs_[0] = dividend;
735 LOperand* dividend() { return inputs_[0]; }
736 int32_t divisor() { return divisor_; }
738 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
739 "flooring-div-by-power-of-2-i")
740 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
747 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
749 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
750 inputs_[0] = dividend;
755 LOperand* dividend() { return inputs_[0]; }
756 int32_t divisor() const { return divisor_; }
757 LOperand* temp() { return temps_[0]; }
759 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
760 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
767 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
769 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
770 inputs_[0] = dividend;
771 inputs_[1] = divisor;
774 LOperand* dividend() { return inputs_[0]; }
775 LOperand* divisor() { return inputs_[1]; }
777 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
782 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
784 LMulI(LOperand* left, LOperand* right) {
789 LOperand* left() { return inputs_[0]; }
790 LOperand* right() { return inputs_[1]; }
792 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
793 DECLARE_HYDROGEN_ACCESSOR(Mul)
797 // Instruction for computing multiplier * multiplicand + addend.
798 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
800 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
801 LOperand* multiplicand) {
803 inputs_[1] = multiplier;
804 inputs_[2] = multiplicand;
807 LOperand* addend() { return inputs_[0]; }
808 LOperand* multiplier() { return inputs_[1]; }
809 LOperand* multiplicand() { return inputs_[2]; }
811 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
815 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
817 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
821 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
823 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
828 LOperand* left() { return inputs_[0]; }
829 LOperand* right() { return inputs_[1]; }
831 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
832 "compare-numeric-and-branch")
833 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
835 Token::Value op() const { return hydrogen()->token(); }
836 bool is_double() const {
837 return hydrogen()->representation().IsDouble();
840 void PrintDataTo(StringStream* stream) OVERRIDE;
844 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 1> {
846 LMathFloor(LOperand* value, LOperand* temp) {
851 LOperand* value() { return inputs_[0]; }
852 LOperand* temp() { return temps_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
855 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
859 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
861 LMathRound(LOperand* value, LOperand* temp) {
866 LOperand* value() { return inputs_[0]; }
867 LOperand* temp() { return temps_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
870 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
874 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
876 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
884 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
886 LMathAbs(LOperand* context, LOperand* value) {
887 inputs_[1] = context;
891 LOperand* context() { return inputs_[1]; }
892 LOperand* value() { return inputs_[0]; }
894 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
895 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
899 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
901 explicit LMathLog(LOperand* value) {
905 LOperand* value() { return inputs_[0]; }
907 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
911 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
913 explicit LMathClz32(LOperand* value) {
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
923 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
925 LMathExp(LOperand* value,
926 LOperand* double_temp,
932 temps_[2] = double_temp;
933 ExternalReference::InitializeMathExpData();
936 LOperand* value() { return inputs_[0]; }
937 LOperand* temp1() { return temps_[0]; }
938 LOperand* temp2() { return temps_[1]; }
939 LOperand* double_temp() { return temps_[2]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
945 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
947 explicit LMathSqrt(LOperand* value) {
951 LOperand* value() { return inputs_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
957 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
959 LMathPowHalf(LOperand* value, LOperand* temp) {
964 LOperand* value() { return inputs_[0]; }
965 LOperand* temp() { return temps_[0]; }
967 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
971 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
973 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
978 LOperand* left() { return inputs_[0]; }
979 LOperand* right() { return inputs_[1]; }
981 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
982 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
986 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
988 explicit LCmpHoleAndBranch(LOperand* object) {
992 LOperand* object() { return inputs_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
999 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1001 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1006 LOperand* value() { return inputs_[0]; }
1007 LOperand* temp() { return temps_[0]; }
1009 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1010 "cmp-minus-zero-and-branch")
1011 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1015 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1017 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1022 LOperand* value() { return inputs_[0]; }
1023 LOperand* temp() { return temps_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1028 void PrintDataTo(StringStream* stream) OVERRIDE;
1032 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1034 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1043 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1045 void PrintDataTo(StringStream* stream) OVERRIDE;
1049 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1051 explicit LIsSmiAndBranch(LOperand* value) {
1055 LOperand* value() { return inputs_[0]; }
1057 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1058 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1060 void PrintDataTo(StringStream* stream) OVERRIDE;
1064 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1066 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1071 LOperand* value() { return inputs_[0]; }
1072 LOperand* temp() { return temps_[0]; }
1074 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1075 "is-undetectable-and-branch")
1076 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1078 void PrintDataTo(StringStream* stream) OVERRIDE;
1082 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1084 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1085 inputs_[0] = context;
1090 LOperand* context() { return inputs_[0]; }
1091 LOperand* left() { return inputs_[1]; }
1092 LOperand* right() { return inputs_[2]; }
1094 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1095 "string-compare-and-branch")
1096 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1098 Token::Value op() const { return hydrogen()->token(); }
1100 void PrintDataTo(StringStream* stream) OVERRIDE;
1104 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1106 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1110 LOperand* value() { return inputs_[0]; }
1112 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1113 "has-instance-type-and-branch")
1114 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1116 void PrintDataTo(StringStream* stream) OVERRIDE;
1120 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1122 explicit LGetCachedArrayIndex(LOperand* value) {
1126 LOperand* value() { return inputs_[0]; }
1128 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1129 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1133 class LHasCachedArrayIndexAndBranch FINAL
1134 : public LControlInstruction<1, 0> {
1136 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1140 LOperand* value() { return inputs_[0]; }
1142 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1143 "has-cached-array-index-and-branch")
1144 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1146 void PrintDataTo(StringStream* stream) OVERRIDE;
1150 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1152 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1157 LOperand* value() { return inputs_[0]; }
1158 LOperand* temp() { return temps_[0]; }
1160 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1161 "class-of-test-and-branch")
1162 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1164 void PrintDataTo(StringStream* stream) OVERRIDE;
1168 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1170 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1171 inputs_[0] = context;
1176 LOperand* context() { return inputs_[0]; }
1177 LOperand* left() { return inputs_[1]; }
1178 LOperand* right() { return inputs_[2]; }
1180 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1181 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1183 Token::Value op() const { return hydrogen()->token(); }
1187 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1189 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1190 inputs_[0] = context;
1195 LOperand* context() { return inputs_[0]; }
1196 LOperand* left() { return inputs_[1]; }
1197 LOperand* right() { return inputs_[2]; }
1199 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1203 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1205 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1206 inputs_[0] = context;
1211 LOperand* context() { return inputs_[0]; }
1212 LOperand* value() { return inputs_[1]; }
1213 LOperand* temp() { return temps_[0]; }
1215 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1216 "instance-of-known-global")
1217 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1219 Handle<JSFunction> function() const { return hydrogen()->function(); }
1220 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1221 return lazy_deopt_env_;
1223 virtual void SetDeferredLazyDeoptimizationEnvironment(
1224 LEnvironment* env) OVERRIDE {
1225 lazy_deopt_env_ = env;
1229 LEnvironment* lazy_deopt_env_;
1233 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1235 LBoundsCheck(LOperand* index, LOperand* length) {
1237 inputs_[1] = length;
1240 LOperand* index() { return inputs_[0]; }
1241 LOperand* length() { return inputs_[1]; }
1243 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1244 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1248 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1250 LBitI(LOperand* left, LOperand* right) {
1255 LOperand* left() { return inputs_[0]; }
1256 LOperand* right() { return inputs_[1]; }
1258 Token::Value op() const { return hydrogen()->op(); }
1260 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1261 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1265 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1267 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1268 : op_(op), can_deopt_(can_deopt) {
1273 Token::Value op() const { return op_; }
1274 LOperand* left() { return inputs_[0]; }
1275 LOperand* right() { return inputs_[1]; }
1276 bool can_deopt() const { return can_deopt_; }
1278 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1286 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1288 LSubI(LOperand* left, LOperand* right) {
1293 LOperand* left() { return inputs_[0]; }
1294 LOperand* right() { return inputs_[1]; }
1296 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1297 DECLARE_HYDROGEN_ACCESSOR(Sub)
1301 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1303 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1304 DECLARE_HYDROGEN_ACCESSOR(Constant)
1306 int32_t value() const { return hydrogen()->Integer32Value(); }
1310 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1312 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1313 DECLARE_HYDROGEN_ACCESSOR(Constant)
1315 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1319 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1321 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1322 DECLARE_HYDROGEN_ACCESSOR(Constant)
1324 double value() const { return hydrogen()->DoubleValue(); }
1328 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1330 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1331 DECLARE_HYDROGEN_ACCESSOR(Constant)
1333 ExternalReference value() const {
1334 return hydrogen()->ExternalReferenceValue();
1339 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 Handle<Object> value(Isolate* isolate) const {
1345 return hydrogen()->handle(isolate);
1350 class LBranch FINAL : public LControlInstruction<1, 0> {
1352 explicit LBranch(LOperand* value) {
1356 LOperand* value() { return inputs_[0]; }
1358 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1359 DECLARE_HYDROGEN_ACCESSOR(Branch)
1361 void PrintDataTo(StringStream* stream) OVERRIDE;
1365 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1367 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1372 LOperand* value() { return inputs_[0]; }
1373 LOperand* temp() { return temps_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1396 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1401 LOperand* date() { return inputs_[0]; }
1402 LOperand* temp() { return temps_[0]; }
1403 Smi* index() const { return index_; }
1405 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1406 DECLARE_HYDROGEN_ACCESSOR(DateField)
1413 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1415 LSeqStringGetChar(LOperand* string, LOperand* index) {
1416 inputs_[0] = string;
1420 LOperand* string() const { return inputs_[0]; }
1421 LOperand* index() const { return inputs_[1]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1424 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1428 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1430 LSeqStringSetChar(LOperand* context,
1434 inputs_[0] = context;
1435 inputs_[1] = string;
1440 LOperand* string() { return inputs_[1]; }
1441 LOperand* index() { return inputs_[2]; }
1442 LOperand* value() { return inputs_[3]; }
1444 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1445 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1449 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1451 LAddI(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1460 DECLARE_HYDROGEN_ACCESSOR(Add)
1464 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1466 LMathMinMax(LOperand* left, LOperand* right) {
1471 LOperand* left() { return inputs_[0]; }
1472 LOperand* right() { return inputs_[1]; }
1474 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1475 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1479 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1481 LPower(LOperand* left, LOperand* right) {
1486 LOperand* left() { return inputs_[0]; }
1487 LOperand* right() { return inputs_[1]; }
1489 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1490 DECLARE_HYDROGEN_ACCESSOR(Power)
1494 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1496 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1502 Token::Value op() const { return op_; }
1503 LOperand* left() { return inputs_[0]; }
1504 LOperand* right() { return inputs_[1]; }
1506 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1507 void CompileToNative(LCodeGen* generator) OVERRIDE;
1508 const char* Mnemonic() const OVERRIDE;
1515 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1517 LArithmeticT(Token::Value op,
1522 inputs_[0] = context;
1527 LOperand* context() { return inputs_[0]; }
1528 LOperand* left() { return inputs_[1]; }
1529 LOperand* right() { return inputs_[2]; }
1530 Token::Value op() const { return op_; }
1532 Opcode opcode() const FINAL { return LInstruction::kArithmeticT; }
1533 void CompileToNative(LCodeGen* generator) OVERRIDE;
1534 const char* Mnemonic() const OVERRIDE;
1541 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1543 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1545 inputs_[1] = context;
1546 inputs_[2] = parameter_count;
1549 LOperand* value() { return inputs_[0]; }
1551 bool has_constant_parameter_count() {
1552 return parameter_count()->IsConstantOperand();
1554 LConstantOperand* constant_parameter_count() {
1555 DCHECK(has_constant_parameter_count());
1556 return LConstantOperand::cast(parameter_count());
1558 LOperand* parameter_count() { return inputs_[2]; }
1560 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1564 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1566 explicit LLoadNamedField(LOperand* object) {
1567 inputs_[0] = object;
1570 LOperand* object() { return inputs_[0]; }
1572 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1573 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1577 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1579 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1580 inputs_[0] = context;
1581 inputs_[1] = object;
1585 LOperand* context() { return inputs_[0]; }
1586 LOperand* object() { return inputs_[1]; }
1587 LOperand* temp_vector() { return temps_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1592 Handle<Object> name() const { return hydrogen()->name(); }
1596 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1598 explicit LLoadFunctionPrototype(LOperand* function) {
1599 inputs_[0] = function;
1602 LOperand* function() { return inputs_[0]; }
1604 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1605 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1609 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1611 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1612 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1614 Heap::RootListIndex index() const { return hydrogen()->index(); }
1618 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1620 LLoadKeyed(LOperand* elements, LOperand* key) {
1621 inputs_[0] = elements;
1625 LOperand* elements() { return inputs_[0]; }
1626 LOperand* key() { return inputs_[1]; }
1627 ElementsKind elements_kind() const {
1628 return hydrogen()->elements_kind();
1630 bool is_external() const {
1631 return hydrogen()->is_external();
1633 bool is_fixed_typed_array() const {
1634 return hydrogen()->is_fixed_typed_array();
1636 bool is_typed_elements() const {
1637 return is_external() || is_fixed_typed_array();
1640 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1641 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1643 void PrintDataTo(StringStream* stream) OVERRIDE;
1644 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1648 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1650 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1652 inputs_[0] = context;
1653 inputs_[1] = object;
1658 LOperand* context() { return inputs_[0]; }
1659 LOperand* object() { return inputs_[1]; }
1660 LOperand* key() { return inputs_[2]; }
1661 LOperand* temp_vector() { return temps_[0]; }
1663 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1664 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1668 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1670 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1671 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1675 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1677 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1679 inputs_[0] = context;
1680 inputs_[1] = global_object;
1684 LOperand* context() { return inputs_[0]; }
1685 LOperand* global_object() { return inputs_[1]; }
1686 LOperand* temp_vector() { return temps_[0]; }
1688 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1691 Handle<Object> name() const { return hydrogen()->name(); }
1692 bool for_typeof() const { return hydrogen()->for_typeof(); }
1696 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 1> {
1698 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1703 LOperand* value() { return inputs_[0]; }
1704 LOperand* temp() { return temps_[0]; }
1706 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1707 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1711 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1713 explicit LLoadContextSlot(LOperand* context) {
1714 inputs_[0] = context;
1717 LOperand* context() { return inputs_[0]; }
1719 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1720 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1722 int slot_index() { return hydrogen()->slot_index(); }
1724 void PrintDataTo(StringStream* stream) OVERRIDE;
1728 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1730 LStoreContextSlot(LOperand* context, LOperand* value) {
1731 inputs_[0] = context;
1735 LOperand* context() { return inputs_[0]; }
1736 LOperand* value() { return inputs_[1]; }
1738 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1739 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1741 int slot_index() { return hydrogen()->slot_index(); }
1743 void PrintDataTo(StringStream* stream) OVERRIDE;
1747 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1749 explicit LPushArgument(LOperand* value) {
1753 LOperand* value() { return inputs_[0]; }
1755 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1759 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1761 explicit LDrop(int count) : count_(count) { }
1763 int count() const { return count_; }
1765 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1772 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1774 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1775 inputs_[0] = function;
1776 inputs_[1] = code_object;
1779 LOperand* function() { return inputs_[0]; }
1780 LOperand* code_object() { return inputs_[1]; }
1782 void PrintDataTo(StringStream* stream) OVERRIDE;
1784 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1785 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1789 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1791 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1792 inputs_[0] = base_object;
1793 inputs_[1] = offset;
1796 LOperand* base_object() const { return inputs_[0]; }
1797 LOperand* offset() const { return inputs_[1]; }
1799 void PrintDataTo(StringStream* stream) OVERRIDE;
1801 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1805 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1807 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1808 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1812 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1814 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1815 DECLARE_HYDROGEN_ACCESSOR(Context)
1819 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1821 explicit LDeclareGlobals(LOperand* context) {
1822 inputs_[0] = context;
1825 LOperand* context() { return inputs_[0]; }
1827 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1828 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1832 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1834 explicit LCallJSFunction(LOperand* function) {
1835 inputs_[0] = function;
1838 LOperand* function() { return inputs_[0]; }
1840 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1841 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1843 void PrintDataTo(StringStream* stream) OVERRIDE;
1845 int arity() const { return hydrogen()->argument_count() - 1; }
1849 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1851 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1852 const ZoneList<LOperand*>& operands, Zone* zone)
1853 : descriptor_(descriptor),
1854 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1855 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1856 inputs_.AddAll(operands, zone);
1859 LOperand* target() const { return inputs_[0]; }
1861 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1863 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1866 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1868 void PrintDataTo(StringStream* stream) OVERRIDE;
1870 int arity() const { return hydrogen()->argument_count() - 1; }
1872 CallInterfaceDescriptor descriptor_;
1873 ZoneList<LOperand*> inputs_;
1875 // Iterator support.
1876 int InputCount() FINAL { return inputs_.length(); }
1877 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1879 int TempCount() FINAL { return 0; }
1880 LOperand* TempAt(int i) FINAL { return NULL; }
1885 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1887 LInvokeFunction(LOperand* context, LOperand* function) {
1888 inputs_[0] = context;
1889 inputs_[1] = function;
1892 LOperand* context() { return inputs_[0]; }
1893 LOperand* function() { return inputs_[1]; }
1895 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1896 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1898 void PrintDataTo(StringStream* stream) OVERRIDE;
1900 int arity() const { return hydrogen()->argument_count() - 1; }
1904 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1906 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1908 inputs_[0] = context;
1909 inputs_[1] = function;
1914 LOperand* context() { return inputs_[0]; }
1915 LOperand* function() { return inputs_[1]; }
1916 LOperand* temp_slot() { return temps_[0]; }
1917 LOperand* temp_vector() { return temps_[1]; }
1919 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1920 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1922 int arity() const { return hydrogen()->argument_count() - 1; }
1923 void PrintDataTo(StringStream* stream) OVERRIDE;
1927 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1929 LCallNew(LOperand* context, LOperand* constructor) {
1930 inputs_[0] = context;
1931 inputs_[1] = constructor;
1934 LOperand* context() { return inputs_[0]; }
1935 LOperand* constructor() { return inputs_[1]; }
1937 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1938 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1940 void PrintDataTo(StringStream* stream) OVERRIDE;
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1946 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1948 LCallNewArray(LOperand* context, LOperand* constructor) {
1949 inputs_[0] = context;
1950 inputs_[1] = constructor;
1953 LOperand* context() { return inputs_[0]; }
1954 LOperand* constructor() { return inputs_[1]; }
1956 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1957 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1959 void PrintDataTo(StringStream* stream) OVERRIDE;
1961 int arity() const { return hydrogen()->argument_count() - 1; }
1965 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1967 explicit LCallRuntime(LOperand* context) {
1968 inputs_[0] = context;
1971 LOperand* context() { return inputs_[0]; }
1973 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1974 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1976 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1977 return save_doubles() == kDontSaveFPRegs;
1980 const Runtime::Function* function() const { return hydrogen()->function(); }
1981 int arity() const { return hydrogen()->argument_count(); }
1982 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1986 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LInteger32ToDouble(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1998 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2000 explicit LUint32ToDouble(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2010 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
2012 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2018 LOperand* value() { return inputs_[0]; }
2019 LOperand* temp1() { return temps_[0]; }
2020 LOperand* temp2() { return temps_[1]; }
2022 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2026 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
2028 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2034 LOperand* value() { return inputs_[0]; }
2035 LOperand* temp() { return temps_[0]; }
2036 LOperand* temp2() { return temps_[1]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2039 DECLARE_HYDROGEN_ACCESSOR(Change)
2043 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2045 explicit LDoubleToSmi(LOperand* value) {
2049 LOperand* value() { return inputs_[0]; }
2051 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2052 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2054 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2058 // Sometimes truncating conversion from a tagged value to an int32.
2059 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2061 explicit LDoubleToI(LOperand* value) {
2065 LOperand* value() { return inputs_[0]; }
2067 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2068 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2070 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2074 // Truncating conversion from a tagged value to an int32.
2075 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2077 LTaggedToI(LOperand* value,
2085 LOperand* value() { return inputs_[0]; }
2086 LOperand* temp() { return temps_[0]; }
2087 LOperand* temp2() { return temps_[1]; }
2089 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2090 DECLARE_HYDROGEN_ACCESSOR(Change)
2092 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2096 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2098 explicit LSmiTag(LOperand* value) {
2102 LOperand* value() { return inputs_[0]; }
2104 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2105 DECLARE_HYDROGEN_ACCESSOR(Change)
2109 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2111 explicit LNumberUntagD(LOperand* value) {
2115 LOperand* value() { return inputs_[0]; }
2117 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2118 DECLARE_HYDROGEN_ACCESSOR(Change)
2122 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2124 LSmiUntag(LOperand* value, bool needs_check)
2125 : needs_check_(needs_check) {
2129 LOperand* value() { return inputs_[0]; }
2130 bool needs_check() const { return needs_check_; }
2132 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2139 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2141 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2142 inputs_[0] = object;
2147 LOperand* object() { return inputs_[0]; }
2148 LOperand* value() { return inputs_[1]; }
2149 LOperand* temp() { return temps_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2152 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2154 void PrintDataTo(StringStream* stream) OVERRIDE;
2156 Representation representation() const {
2157 return hydrogen()->field_representation();
2162 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2164 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2165 inputs_[0] = context;
2166 inputs_[1] = object;
2170 LOperand* context() { return inputs_[0]; }
2171 LOperand* object() { return inputs_[1]; }
2172 LOperand* value() { return inputs_[2]; }
2174 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2175 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2177 void PrintDataTo(StringStream* stream) OVERRIDE;
2179 Handle<Object> name() const { return hydrogen()->name(); }
2180 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2184 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2186 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2187 inputs_[0] = object;
2192 bool is_external() const { return hydrogen()->is_external(); }
2193 bool is_fixed_typed_array() const {
2194 return hydrogen()->is_fixed_typed_array();
2196 bool is_typed_elements() const {
2197 return is_external() || is_fixed_typed_array();
2199 LOperand* elements() { return inputs_[0]; }
2200 LOperand* key() { return inputs_[1]; }
2201 LOperand* value() { return inputs_[2]; }
2202 ElementsKind elements_kind() const {
2203 return hydrogen()->elements_kind();
2206 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2207 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2209 void PrintDataTo(StringStream* stream) OVERRIDE;
2210 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2211 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2215 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2217 LStoreKeyedGeneric(LOperand* context,
2221 inputs_[0] = context;
2227 LOperand* context() { return inputs_[0]; }
2228 LOperand* object() { return inputs_[1]; }
2229 LOperand* key() { return inputs_[2]; }
2230 LOperand* value() { return inputs_[3]; }
2232 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2233 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2235 void PrintDataTo(StringStream* stream) OVERRIDE;
2237 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2241 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2243 LTransitionElementsKind(LOperand* object,
2245 LOperand* new_map_temp) {
2246 inputs_[0] = object;
2247 inputs_[1] = context;
2248 temps_[0] = new_map_temp;
2251 LOperand* context() { return inputs_[1]; }
2252 LOperand* object() { return inputs_[0]; }
2253 LOperand* new_map_temp() { return temps_[0]; }
2255 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2256 "transition-elements-kind")
2257 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2259 void PrintDataTo(StringStream* stream) OVERRIDE;
2261 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2262 Handle<Map> transitioned_map() {
2263 return hydrogen()->transitioned_map().handle();
2265 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2266 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2270 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2272 LTrapAllocationMemento(LOperand* object,
2274 inputs_[0] = object;
2278 LOperand* object() { return inputs_[0]; }
2279 LOperand* temp() { return temps_[0]; }
2281 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2282 "trap-allocation-memento")
2286 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2288 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2289 inputs_[0] = context;
2294 LOperand* context() { return inputs_[0]; }
2295 LOperand* left() { return inputs_[1]; }
2296 LOperand* right() { return inputs_[2]; }
2298 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2299 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2304 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2306 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2307 inputs_[0] = context;
2308 inputs_[1] = string;
2312 LOperand* context() { return inputs_[0]; }
2313 LOperand* string() { return inputs_[1]; }
2314 LOperand* index() { return inputs_[2]; }
2316 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2317 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2321 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2323 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2324 inputs_[0] = context;
2325 inputs_[1] = char_code;
2328 LOperand* context() { return inputs_[0]; }
2329 LOperand* char_code() { return inputs_[1]; }
2331 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2332 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2336 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2338 explicit LCheckValue(LOperand* value) {
2342 LOperand* value() { return inputs_[0]; }
2344 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2345 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2349 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2351 explicit LCheckInstanceType(LOperand* value) {
2355 LOperand* value() { return inputs_[0]; }
2357 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2358 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2362 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2364 explicit LCheckMaps(LOperand* value = NULL) {
2368 LOperand* value() { return inputs_[0]; }
2370 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2371 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2375 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2377 explicit LCheckSmi(LOperand* value) {
2381 LOperand* value() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2387 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2389 explicit LCheckNonSmi(LOperand* value) {
2393 LOperand* value() { return inputs_[0]; }
2395 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2396 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2400 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2402 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2403 inputs_[0] = unclamped;
2407 LOperand* unclamped() { return inputs_[0]; }
2408 LOperand* temp() { return temps_[0]; }
2410 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2414 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2416 explicit LClampIToUint8(LOperand* unclamped) {
2417 inputs_[0] = unclamped;
2420 LOperand* unclamped() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2426 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2428 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2429 inputs_[0] = unclamped;
2433 LOperand* unclamped() { return inputs_[0]; }
2434 LOperand* temp() { return temps_[0]; }
2436 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2440 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2442 explicit LDoubleBits(LOperand* value) {
2446 LOperand* value() { return inputs_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2449 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2453 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2455 LConstructDouble(LOperand* hi, LOperand* lo) {
2460 LOperand* hi() { return inputs_[0]; }
2461 LOperand* lo() { return inputs_[1]; }
2463 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2467 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2469 LAllocate(LOperand* context,
2473 inputs_[0] = context;
2479 LOperand* context() { return inputs_[0]; }
2480 LOperand* size() { return inputs_[1]; }
2481 LOperand* temp1() { return temps_[0]; }
2482 LOperand* temp2() { return temps_[1]; }
2484 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2485 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2489 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2491 explicit LRegExpLiteral(LOperand* context) {
2492 inputs_[0] = context;
2495 LOperand* context() { return inputs_[0]; }
2497 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2498 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2502 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2504 explicit LFunctionLiteral(LOperand* context) {
2505 inputs_[0] = context;
2508 LOperand* context() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2511 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2515 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2517 explicit LToFastProperties(LOperand* value) {
2521 LOperand* value() { return inputs_[0]; }
2523 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2524 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2528 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2530 LTypeof(LOperand* context, LOperand* value) {
2531 inputs_[0] = context;
2535 LOperand* context() { return inputs_[0]; }
2536 LOperand* value() { return inputs_[1]; }
2538 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2542 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2544 explicit LTypeofIsAndBranch(LOperand* value) {
2548 LOperand* value() { return inputs_[0]; }
2550 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2551 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2553 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2555 void PrintDataTo(StringStream* stream) OVERRIDE;
2559 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2561 explicit LIsConstructCallAndBranch(LOperand* temp) {
2565 LOperand* temp() { return temps_[0]; }
2567 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2568 "is-construct-call-and-branch")
2572 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2576 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2577 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2581 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2583 explicit LStackCheck(LOperand* context) {
2584 inputs_[0] = context;
2587 LOperand* context() { return inputs_[0]; }
2589 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2590 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2592 Label* done_label() { return &done_label_; }
2599 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2601 LForInPrepareMap(LOperand* context, LOperand* object) {
2602 inputs_[0] = context;
2603 inputs_[1] = object;
2606 LOperand* context() { return inputs_[0]; }
2607 LOperand* object() { return inputs_[1]; }
2609 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2613 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2615 explicit LForInCacheArray(LOperand* map) {
2619 LOperand* map() { return inputs_[0]; }
2621 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2624 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2629 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2631 LCheckMapValue(LOperand* value, LOperand* map) {
2636 LOperand* value() { return inputs_[0]; }
2637 LOperand* map() { return inputs_[1]; }
2639 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2643 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2645 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2646 inputs_[0] = object;
2650 LOperand* object() { return inputs_[0]; }
2651 LOperand* index() { return inputs_[1]; }
2653 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2657 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2659 explicit LStoreFrameContext(LOperand* context) {
2660 inputs_[0] = context;
2663 LOperand* context() { return inputs_[0]; }
2665 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2669 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2671 LAllocateBlockContext(LOperand* context, LOperand* function) {
2672 inputs_[0] = context;
2673 inputs_[1] = function;
2676 LOperand* context() { return inputs_[0]; }
2677 LOperand* function() { return inputs_[1]; }
2679 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2681 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2682 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2686 class LChunkBuilder;
2687 class LPlatformChunk FINAL : public LChunk {
2689 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2690 : LChunk(info, graph) { }
2692 int GetNextSpillIndex(RegisterKind kind);
2693 LOperand* GetNextSpillSlot(RegisterKind kind);
2697 class LChunkBuilder FINAL : public LChunkBuilderBase {
2699 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2700 : LChunkBuilderBase(info, graph),
2701 current_instruction_(NULL),
2702 current_block_(NULL),
2704 allocator_(allocator) {}
2706 // Build the sequence for the graph.
2707 LPlatformChunk* Build();
2709 // Declare methods that deal with the individual node types.
2710 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2711 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2714 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2716 static bool HasMagicNumberForDivisor(int32_t divisor);
2718 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2719 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2720 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2721 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2722 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2723 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2724 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2725 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2726 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2727 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2728 LInstruction* DoDivByConstI(HDiv* instr);
2729 LInstruction* DoDivI(HDiv* instr);
2730 LInstruction* DoModByPowerOf2I(HMod* instr);
2731 LInstruction* DoModByConstI(HMod* instr);
2732 LInstruction* DoModI(HMod* instr);
2733 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2734 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2735 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2738 // Methods for getting operands for Use / Define / Temp.
2739 LUnallocated* ToUnallocated(Register reg);
2740 LUnallocated* ToUnallocated(DoubleRegister reg);
2742 // Methods for setting up define-use relationships.
2743 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2744 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2745 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2746 DoubleRegister fixed_register);
2748 // A value that is guaranteed to be allocated to a register.
2749 // Operand created by UseRegister is guaranteed to be live until the end of
2750 // instruction. This means that register allocator will not reuse it's
2751 // register for any other operand inside instruction.
2752 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2753 // instruction start. Register allocator is free to assign the same register
2754 // to some other operand used inside instruction (i.e. temporary or
2756 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2757 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2759 // An input operand in a register that may be trashed.
2760 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2762 // An input operand in a register or stack slot.
2763 MUST_USE_RESULT LOperand* Use(HValue* value);
2764 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2766 // An input operand in a register, stack slot or a constant operand.
2767 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2768 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2770 // An input operand in a register or a constant operand.
2771 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2772 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2774 // An input operand in a constant operand.
2775 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2777 // An input operand in register, stack slot or a constant operand.
2778 // Will not be moved to a register even if one is freely available.
2779 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2781 // Temporary operand that must be in a register.
2782 MUST_USE_RESULT LUnallocated* TempRegister();
2783 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2784 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2785 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2787 // Methods for setting up define-use relationships.
2788 // Return the same instruction that they are passed.
2789 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2790 LUnallocated* result);
2791 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2792 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2794 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2795 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2797 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2798 DoubleRegister reg);
2799 LInstruction* AssignEnvironment(LInstruction* instr);
2800 LInstruction* AssignPointerMap(LInstruction* instr);
2802 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2804 // By default we assume that instruction sequences generated for calls
2805 // cannot deoptimize eagerly and we do not attach environment to this
2807 LInstruction* MarkAsCall(
2808 LInstruction* instr,
2809 HInstruction* hinstr,
2810 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2812 void VisitInstruction(HInstruction* current);
2813 void AddInstruction(LInstruction* instr, HInstruction* current);
2815 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2816 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2817 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2818 LInstruction* DoArithmeticD(Token::Value op,
2819 HArithmeticBinaryOperation* instr);
2820 LInstruction* DoArithmeticT(Token::Value op,
2821 HBinaryOperation* instr);
2823 HInstruction* current_instruction_;
2824 HBasicBlock* current_block_;
2825 HBasicBlock* next_block_;
2826 LAllocator* allocator_;
2828 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2831 #undef DECLARE_HYDROGEN_ACCESSOR
2832 #undef DECLARE_CONCRETE_INSTRUCTION
2834 } } // namespace v8::internal
2836 #endif // V8_MIPS_LITHIUM_MIPS_H_