1 // Copyright 2014 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_PPC_LITHIUM_PPC_H_
6 #define V8_PPC_LITHIUM_PPC_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) \
103 V(LoadGlobalGeneric) \
105 V(LoadKeyedGeneric) \
107 V(LoadNamedGeneric) \
135 V(SeqStringGetChar) \
136 V(SeqStringSetChar) \
142 V(StoreContextSlot) \
143 V(StoreFrameContext) \
145 V(StoreKeyedGeneric) \
147 V(StoreNamedGeneric) \
149 V(StringCharCodeAt) \
150 V(StringCharFromCode) \
151 V(StringCompareAndBranch) \
155 V(TailCallThroughMegamorphicCache) \
157 V(ToFastProperties) \
158 V(TransitionElementsKind) \
159 V(TrapAllocationMemento) \
161 V(TypeofIsAndBranch) \
167 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
168 Opcode opcode() const FINAL { return LInstruction::k##type; } \
169 void CompileToNative(LCodeGen* generator) FINAL; \
170 const char* Mnemonic() const FINAL { return mnemonic; } \
171 static L##type* cast(LInstruction* instr) { \
172 DCHECK(instr->Is##type()); \
173 return reinterpret_cast<L##type*>(instr); \
177 #define DECLARE_HYDROGEN_ACCESSOR(type) \
178 H##type* hydrogen() const { return H##type::cast(hydrogen_value()); }
181 class LInstruction : public ZoneObject {
184 : environment_(NULL),
185 hydrogen_value_(NULL),
186 bit_field_(IsCallBits::encode(false)) {}
188 virtual ~LInstruction() {}
190 virtual void CompileToNative(LCodeGen* generator) = 0;
191 virtual const char* Mnemonic() const = 0;
192 virtual void PrintTo(StringStream* stream);
193 virtual void PrintDataTo(StringStream* stream);
194 virtual void PrintOutputOperandTo(StringStream* stream);
197 // Declare a unique enum value for each instruction.
198 #define DECLARE_OPCODE(type) k##type,
199 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kNumberOfInstructions
200 #undef DECLARE_OPCODE
203 virtual Opcode opcode() const = 0;
205 // Declare non-virtual type testers for all leaf IR classes.
206 #define DECLARE_PREDICATE(type) \
207 bool Is##type() const { return opcode() == k##type; }
208 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
209 #undef DECLARE_PREDICATE
211 // Declare virtual predicates for instructions that don't have
213 virtual bool IsGap() const { return false; }
215 virtual bool IsControl() const { return false; }
217 // Try deleting this instruction if possible.
218 virtual bool TryDelete() { return false; }
220 void set_environment(LEnvironment* env) { environment_ = env; }
221 LEnvironment* environment() const { return environment_; }
222 bool HasEnvironment() const { return environment_ != NULL; }
224 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
225 LPointerMap* pointer_map() const { return pointer_map_.get(); }
226 bool HasPointerMap() const { return pointer_map_.is_set(); }
228 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
229 HValue* hydrogen_value() const { return hydrogen_value_; }
231 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {}
233 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
234 bool IsCall() const { return IsCallBits::decode(bit_field_); }
236 // Interface to the register allocator and iterators.
237 bool ClobbersTemps() const { return IsCall(); }
238 bool ClobbersRegisters() const { return IsCall(); }
239 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
243 // Interface to the register allocator and iterators.
244 bool IsMarkedAsCall() const { return IsCall(); }
246 virtual bool HasResult() const = 0;
247 virtual LOperand* result() const = 0;
249 LOperand* FirstInput() { return InputAt(0); }
250 LOperand* Output() { return HasResult() ? result() : NULL; }
252 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
258 virtual int InputCount() = 0;
259 virtual LOperand* InputAt(int i) = 0;
263 friend class InputIterator;
265 friend class TempIterator;
266 virtual int TempCount() = 0;
267 virtual LOperand* TempAt(int i) = 0;
269 class IsCallBits : public BitField<bool, 0, 1> {};
271 LEnvironment* environment_;
272 SetOncePointer<LPointerMap> pointer_map_;
273 HValue* hydrogen_value_;
278 // R = number of result operands (0 or 1).
280 class LTemplateResultInstruction : public LInstruction {
282 // Allow 0 or 1 output operands.
283 STATIC_ASSERT(R == 0 || R == 1);
284 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
285 void set_result(LOperand* operand) { results_[0] = operand; }
286 LOperand* result() const OVERRIDE { return results_[0]; }
289 EmbeddedContainer<LOperand*, R> results_;
293 // R = number of result operands (0 or 1).
294 // I = number of input operands.
295 // T = number of temporary operands.
296 template <int R, int I, int T>
297 class LTemplateInstruction : public LTemplateResultInstruction<R> {
299 EmbeddedContainer<LOperand*, I> inputs_;
300 EmbeddedContainer<LOperand*, T> temps_;
304 int InputCount() FINAL { return I; }
305 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
307 int TempCount() FINAL { return T; }
308 LOperand* TempAt(int i) FINAL { return temps_[i]; }
312 class LGap : public LTemplateInstruction<0, 0, 0> {
314 explicit LGap(HBasicBlock* block) : block_(block) {
315 parallel_moves_[BEFORE] = NULL;
316 parallel_moves_[START] = NULL;
317 parallel_moves_[END] = NULL;
318 parallel_moves_[AFTER] = NULL;
321 // Can't use the DECLARE-macro here because of sub-classes.
322 bool IsGap() const OVERRIDE { return true; }
323 void PrintDataTo(StringStream* stream) OVERRIDE;
324 static LGap* cast(LInstruction* instr) {
325 DCHECK(instr->IsGap());
326 return reinterpret_cast<LGap*>(instr);
329 bool IsRedundant() const;
331 HBasicBlock* block() const { return block_; }
338 FIRST_INNER_POSITION = BEFORE,
339 LAST_INNER_POSITION = AFTER
342 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
343 if (parallel_moves_[pos] == NULL) {
344 parallel_moves_[pos] = new (zone) LParallelMove(zone);
346 return parallel_moves_[pos];
349 LParallelMove* GetParallelMove(InnerPosition pos) {
350 return parallel_moves_[pos];
354 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
359 class LInstructionGap FINAL : public LGap {
361 explicit LInstructionGap(HBasicBlock* block) : LGap(block) {}
363 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
364 return !IsRedundant();
367 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
371 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
373 explicit LGoto(HBasicBlock* block) : block_(block) {}
375 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
376 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
377 void PrintDataTo(StringStream* stream) OVERRIDE;
378 bool IsControl() const OVERRIDE { return true; }
380 int block_id() const { return block_->block_id(); }
387 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
389 LLazyBailout() : gap_instructions_size_(0) {}
391 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
393 void set_gap_instructions_size(int gap_instructions_size) {
394 gap_instructions_size_ = gap_instructions_size;
396 int gap_instructions_size() { return gap_instructions_size_; }
399 int gap_instructions_size_;
403 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
406 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
410 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
412 explicit LDummyUse(LOperand* value) { inputs_[0] = value; }
413 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
417 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
419 bool IsControl() const OVERRIDE { return true; }
420 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
421 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
425 class LLabel FINAL : public LGap {
427 explicit LLabel(HBasicBlock* block) : LGap(block), replacement_(NULL) {}
429 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
430 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
432 void PrintDataTo(StringStream* stream) OVERRIDE;
434 int block_id() const { return block()->block_id(); }
435 bool is_loop_header() const { return block()->IsLoopHeader(); }
436 bool is_osr_entry() const { return block()->is_osr_entry(); }
437 Label* label() { return &label_; }
438 LLabel* replacement() const { return replacement_; }
439 void set_replacement(LLabel* label) { replacement_ = label; }
440 bool HasReplacement() const { return replacement_ != NULL; }
444 LLabel* replacement_;
448 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
450 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
451 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
455 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
457 explicit LCallStub(LOperand* context) { inputs_[0] = context; }
459 LOperand* context() { return inputs_[0]; }
461 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
462 DECLARE_HYDROGEN_ACCESSOR(CallStub)
466 class LTailCallThroughMegamorphicCache FINAL
467 : public LTemplateInstruction<0, 5, 0> {
469 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
470 LOperand* name, LOperand* slot,
472 inputs_[0] = context;
473 inputs_[1] = receiver;
479 LOperand* context() { return inputs_[0]; }
480 LOperand* receiver() { return inputs_[1]; }
481 LOperand* name() { return inputs_[2]; }
482 LOperand* slot() { return inputs_[3]; }
483 LOperand* vector() { return inputs_[4]; }
485 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
486 "tail-call-through-megamorphic-cache")
487 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
491 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
493 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
494 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
498 template <int I, int T>
499 class LControlInstruction : public LTemplateInstruction<0, I, T> {
501 LControlInstruction() : false_label_(NULL), true_label_(NULL) {}
503 bool IsControl() const FINAL { return true; }
505 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
506 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
508 int TrueDestination(LChunk* chunk) {
509 return chunk->LookupDestination(true_block_id());
511 int FalseDestination(LChunk* chunk) {
512 return chunk->LookupDestination(false_block_id());
515 Label* TrueLabel(LChunk* chunk) {
516 if (true_label_ == NULL) {
517 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
521 Label* FalseLabel(LChunk* chunk) {
522 if (false_label_ == NULL) {
523 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
529 int true_block_id() { return SuccessorAt(0)->block_id(); }
530 int false_block_id() { return SuccessorAt(1)->block_id(); }
533 HControlInstruction* hydrogen() {
534 return HControlInstruction::cast(this->hydrogen_value());
542 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 0> {
544 LWrapReceiver(LOperand* receiver, LOperand* function) {
545 inputs_[0] = receiver;
546 inputs_[1] = function;
549 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
550 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
552 LOperand* receiver() { return inputs_[0]; }
553 LOperand* function() { return inputs_[1]; }
557 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
559 LApplyArguments(LOperand* function, LOperand* receiver, LOperand* length,
560 LOperand* elements) {
561 inputs_[0] = function;
562 inputs_[1] = receiver;
564 inputs_[3] = elements;
567 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
569 LOperand* function() { return inputs_[0]; }
570 LOperand* receiver() { return inputs_[1]; }
571 LOperand* length() { return inputs_[2]; }
572 LOperand* elements() { return inputs_[3]; }
576 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
578 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
579 inputs_[0] = arguments;
584 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
586 LOperand* arguments() { return inputs_[0]; }
587 LOperand* length() { return inputs_[1]; }
588 LOperand* index() { return inputs_[2]; }
590 void PrintDataTo(StringStream* stream) OVERRIDE;
594 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
596 explicit LArgumentsLength(LOperand* elements) { inputs_[0] = elements; }
598 LOperand* elements() { return inputs_[0]; }
600 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
604 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
607 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
611 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
613 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
614 inputs_[0] = dividend;
618 LOperand* dividend() { return inputs_[0]; }
619 int32_t divisor() const { return divisor_; }
621 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
622 DECLARE_HYDROGEN_ACCESSOR(Mod)
629 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
631 LModByConstI(LOperand* dividend, int32_t divisor) {
632 inputs_[0] = dividend;
636 LOperand* dividend() { return inputs_[0]; }
637 int32_t divisor() const { return divisor_; }
639 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
640 DECLARE_HYDROGEN_ACCESSOR(Mod)
647 class LModI FINAL : public LTemplateInstruction<1, 2, 0> {
649 LModI(LOperand* left, LOperand* right) {
654 LOperand* left() { return inputs_[0]; }
655 LOperand* right() { return inputs_[1]; }
657 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
658 DECLARE_HYDROGEN_ACCESSOR(Mod)
662 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
664 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
665 inputs_[0] = dividend;
669 LOperand* dividend() { return inputs_[0]; }
670 int32_t divisor() const { return divisor_; }
672 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
673 DECLARE_HYDROGEN_ACCESSOR(Div)
680 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 0> {
682 LDivByConstI(LOperand* dividend, int32_t divisor) {
683 inputs_[0] = dividend;
687 LOperand* dividend() { return inputs_[0]; }
688 int32_t divisor() const { return divisor_; }
690 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
691 DECLARE_HYDROGEN_ACCESSOR(Div)
698 class LDivI FINAL : public LTemplateInstruction<1, 2, 0> {
700 LDivI(LOperand* dividend, LOperand* divisor) {
701 inputs_[0] = dividend;
702 inputs_[1] = divisor;
705 LOperand* dividend() { return inputs_[0]; }
706 LOperand* divisor() { return inputs_[1]; }
708 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
709 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
713 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
715 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
716 inputs_[0] = dividend;
720 LOperand* dividend() { return inputs_[0]; }
721 int32_t divisor() { return divisor_; }
723 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
724 "flooring-div-by-power-of-2-i")
725 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
732 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 1> {
734 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
735 inputs_[0] = dividend;
740 LOperand* dividend() { return inputs_[0]; }
741 int32_t divisor() const { return divisor_; }
742 LOperand* temp() { return temps_[0]; }
744 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
745 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
752 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 0> {
754 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
755 inputs_[0] = dividend;
756 inputs_[1] = divisor;
759 LOperand* dividend() { return inputs_[0]; }
760 LOperand* divisor() { return inputs_[1]; }
762 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
763 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
767 class LMulI FINAL : public LTemplateInstruction<1, 2, 0> {
769 LMulI(LOperand* left, LOperand* right) {
774 LOperand* left() { return inputs_[0]; }
775 LOperand* right() { return inputs_[1]; }
777 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
778 DECLARE_HYDROGEN_ACCESSOR(Mul)
782 // Instruction for computing multiplier * multiplicand + addend.
783 class LMultiplyAddD FINAL : public LTemplateInstruction<1, 3, 0> {
785 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
786 LOperand* multiplicand) {
788 inputs_[1] = multiplier;
789 inputs_[2] = multiplicand;
792 LOperand* addend() { return inputs_[0]; }
793 LOperand* multiplier() { return inputs_[1]; }
794 LOperand* multiplicand() { return inputs_[2]; }
796 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
800 // Instruction for computing minuend - multiplier * multiplicand.
801 class LMultiplySubD FINAL : public LTemplateInstruction<1, 3, 0> {
803 LMultiplySubD(LOperand* minuend, LOperand* multiplier,
804 LOperand* multiplicand) {
805 inputs_[0] = minuend;
806 inputs_[1] = multiplier;
807 inputs_[2] = multiplicand;
810 LOperand* minuend() { return inputs_[0]; }
811 LOperand* multiplier() { return inputs_[1]; }
812 LOperand* multiplicand() { return inputs_[2]; }
814 DECLARE_CONCRETE_INSTRUCTION(MultiplySubD, "multiply-sub-d")
818 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
820 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
824 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
826 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
831 LOperand* left() { return inputs_[0]; }
832 LOperand* right() { return inputs_[1]; }
834 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
835 "compare-numeric-and-branch")
836 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
838 Token::Value op() const { return hydrogen()->token(); }
839 bool is_double() const { return hydrogen()->representation().IsDouble(); }
841 void PrintDataTo(StringStream* stream) OVERRIDE;
845 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
847 explicit LMathFloor(LOperand* value) { inputs_[0] = value; }
849 LOperand* value() { return inputs_[0]; }
851 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
852 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
856 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
858 LMathRound(LOperand* value, LOperand* temp) {
863 LOperand* value() { return inputs_[0]; }
864 LOperand* temp() { return temps_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
867 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
871 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
873 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
875 LOperand* value() { return inputs_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
881 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
883 LMathAbs(LOperand* context, LOperand* value) {
884 inputs_[1] = context;
888 LOperand* context() { return inputs_[1]; }
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
892 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
896 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
898 explicit LMathLog(LOperand* value) { inputs_[0] = value; }
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
906 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
908 explicit LMathClz32(LOperand* value) { inputs_[0] = value; }
910 LOperand* value() { return inputs_[0]; }
912 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
916 class LMathExp FINAL : public LTemplateInstruction<1, 1, 3> {
918 LMathExp(LOperand* value, LOperand* double_temp, LOperand* temp1,
923 temps_[2] = double_temp;
924 ExternalReference::InitializeMathExpData();
927 LOperand* value() { return inputs_[0]; }
928 LOperand* temp1() { return temps_[0]; }
929 LOperand* temp2() { return temps_[1]; }
930 LOperand* double_temp() { return temps_[2]; }
932 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
936 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
938 explicit LMathSqrt(LOperand* value) { inputs_[0] = value; }
940 LOperand* value() { return inputs_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
946 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
948 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
950 LOperand* value() { return inputs_[0]; }
952 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
956 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
958 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
963 LOperand* left() { return inputs_[0]; }
964 LOperand* right() { return inputs_[1]; }
966 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
967 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
971 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
973 explicit LCmpHoleAndBranch(LOperand* object) { inputs_[0] = object; }
975 LOperand* object() { return inputs_[0]; }
977 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
978 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
982 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
984 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
989 LOperand* value() { return inputs_[0]; }
990 LOperand* temp() { return temps_[0]; }
992 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
993 "cmp-minus-zero-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
998 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1000 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1005 LOperand* value() { return inputs_[0]; }
1006 LOperand* temp() { return temps_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1011 void PrintDataTo(StringStream* stream) OVERRIDE;
1015 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1017 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1022 LOperand* value() { return inputs_[0]; }
1023 LOperand* temp() { return temps_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1028 void PrintDataTo(StringStream* stream) OVERRIDE;
1032 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1034 explicit LIsSmiAndBranch(LOperand* value) { inputs_[0] = value; }
1036 LOperand* value() { return inputs_[0]; }
1038 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1041 void PrintDataTo(StringStream* stream) OVERRIDE;
1045 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1047 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1052 LOperand* value() { return inputs_[0]; }
1053 LOperand* temp() { return temps_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1056 "is-undetectable-and-branch")
1057 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1059 void PrintDataTo(StringStream* stream) OVERRIDE;
1063 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1065 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1066 inputs_[0] = context;
1071 LOperand* context() { return inputs_[0]; }
1072 LOperand* left() { return inputs_[1]; }
1073 LOperand* right() { return inputs_[2]; }
1075 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1076 "string-compare-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1079 Token::Value op() const { return hydrogen()->token(); }
1081 void PrintDataTo(StringStream* stream) OVERRIDE;
1085 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 0> {
1087 explicit LHasInstanceTypeAndBranch(LOperand* value) { inputs_[0] = value; }
1089 LOperand* value() { return inputs_[0]; }
1091 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1092 "has-instance-type-and-branch")
1093 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1095 void PrintDataTo(StringStream* stream) OVERRIDE;
1099 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1101 explicit LGetCachedArrayIndex(LOperand* value) { inputs_[0] = value; }
1103 LOperand* value() { return inputs_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1106 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1110 class LHasCachedArrayIndexAndBranch FINAL : public LControlInstruction<1, 0> {
1112 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1116 LOperand* value() { return inputs_[0]; }
1118 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1119 "has-cached-array-index-and-branch")
1120 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1122 void PrintDataTo(StringStream* stream) OVERRIDE;
1126 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 1> {
1128 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1133 LOperand* value() { return inputs_[0]; }
1134 LOperand* temp() { return temps_[0]; }
1136 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, "class-of-test-and-branch")
1137 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1139 void PrintDataTo(StringStream* stream) OVERRIDE;
1143 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1145 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1146 inputs_[0] = context;
1151 LOperand* context() { return inputs_[0]; }
1152 LOperand* left() { return inputs_[1]; }
1153 LOperand* right() { return inputs_[2]; }
1155 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1156 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1158 Token::Value op() const { return hydrogen()->token(); }
1162 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1164 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1165 inputs_[0] = context;
1170 LOperand* context() { return inputs_[0]; }
1171 LOperand* left() { return inputs_[1]; }
1172 LOperand* right() { return inputs_[2]; }
1174 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1178 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1180 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1181 inputs_[0] = context;
1186 LOperand* context() { return inputs_[0]; }
1187 LOperand* value() { return inputs_[1]; }
1188 LOperand* temp() { return temps_[0]; }
1190 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1191 "instance-of-known-global")
1192 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1194 Handle<JSFunction> function() const { return hydrogen()->function(); }
1195 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1196 return lazy_deopt_env_;
1198 virtual void SetDeferredLazyDeoptimizationEnvironment(
1199 LEnvironment* env) OVERRIDE {
1200 lazy_deopt_env_ = env;
1204 LEnvironment* lazy_deopt_env_;
1208 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1210 LBoundsCheck(LOperand* index, LOperand* length) {
1212 inputs_[1] = length;
1215 LOperand* index() { return inputs_[0]; }
1216 LOperand* length() { return inputs_[1]; }
1218 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1219 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1223 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1225 LBitI(LOperand* left, LOperand* right) {
1230 LOperand* left() { return inputs_[0]; }
1231 LOperand* right() { return inputs_[1]; }
1233 Token::Value op() const { return hydrogen()->op(); }
1235 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1236 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1240 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1242 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1243 : op_(op), can_deopt_(can_deopt) {
1248 Token::Value op() const { return op_; }
1249 LOperand* left() { return inputs_[0]; }
1250 LOperand* right() { return inputs_[1]; }
1251 bool can_deopt() const { return can_deopt_; }
1253 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1261 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1263 LSubI(LOperand* left, LOperand* right) {
1268 LOperand* left() { return inputs_[0]; }
1269 LOperand* right() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1272 DECLARE_HYDROGEN_ACCESSOR(Sub)
1276 class LRSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LRSubI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Sub)
1291 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1293 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Constant)
1296 int32_t value() const { return hydrogen()->Integer32Value(); }
1300 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1309 class LConstantD FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 double value() const { return hydrogen()->DoubleValue(); }
1315 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1319 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1321 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1322 DECLARE_HYDROGEN_ACCESSOR(Constant)
1324 ExternalReference value() const {
1325 return hydrogen()->ExternalReferenceValue();
1330 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1332 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1333 DECLARE_HYDROGEN_ACCESSOR(Constant)
1335 Handle<Object> value(Isolate* isolate) const {
1336 return hydrogen()->handle(isolate);
1341 class LBranch FINAL : public LControlInstruction<1, 0> {
1343 explicit LBranch(LOperand* value) { inputs_[0] = value; }
1345 LOperand* value() { return inputs_[0]; }
1347 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1348 DECLARE_HYDROGEN_ACCESSOR(Branch)
1350 void PrintDataTo(StringStream* stream) OVERRIDE;
1354 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 1> {
1356 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1361 LOperand* value() { return inputs_[0]; }
1362 LOperand* temp() { return temps_[0]; }
1364 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1365 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1367 Handle<Map> map() const { return hydrogen()->map().handle(); }
1371 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1373 explicit LMapEnumLength(LOperand* value) { inputs_[0] = value; }
1375 LOperand* value() { return inputs_[0]; }
1377 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1381 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1383 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1388 LOperand* date() { return inputs_[0]; }
1389 LOperand* temp() { return temps_[0]; }
1390 Smi* index() const { return index_; }
1392 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1393 DECLARE_HYDROGEN_ACCESSOR(DateField)
1400 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1402 LSeqStringGetChar(LOperand* string, LOperand* index) {
1403 inputs_[0] = string;
1407 LOperand* string() const { return inputs_[0]; }
1408 LOperand* index() const { return inputs_[1]; }
1410 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1411 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1415 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1417 LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1419 inputs_[0] = context;
1420 inputs_[1] = string;
1425 LOperand* string() { return inputs_[1]; }
1426 LOperand* index() { return inputs_[2]; }
1427 LOperand* value() { return inputs_[3]; }
1429 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1430 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1434 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1436 LAddI(LOperand* left, LOperand* right) {
1441 LOperand* left() { return inputs_[0]; }
1442 LOperand* right() { return inputs_[1]; }
1444 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1445 DECLARE_HYDROGEN_ACCESSOR(Add)
1449 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1451 LMathMinMax(LOperand* left, LOperand* right) {
1456 LOperand* left() { return inputs_[0]; }
1457 LOperand* right() { return inputs_[1]; }
1459 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1460 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1464 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1466 LPower(LOperand* left, LOperand* right) {
1471 LOperand* left() { return inputs_[0]; }
1472 LOperand* right() { return inputs_[1]; }
1474 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1475 DECLARE_HYDROGEN_ACCESSOR(Power)
1479 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1481 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1486 Token::Value op() const { return op_; }
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1491 void CompileToNative(LCodeGen* generator) OVERRIDE;
1492 const char* Mnemonic() const OVERRIDE;
1499 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1501 LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1504 inputs_[0] = context;
1509 LOperand* context() { return inputs_[0]; }
1510 LOperand* left() { return inputs_[1]; }
1511 LOperand* right() { return inputs_[2]; }
1512 Token::Value op() const { return op_; }
1514 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1515 void CompileToNative(LCodeGen* generator) OVERRIDE;
1516 const char* Mnemonic() const OVERRIDE;
1523 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1525 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1527 inputs_[1] = context;
1528 inputs_[2] = parameter_count;
1531 LOperand* value() { return inputs_[0]; }
1533 bool has_constant_parameter_count() {
1534 return parameter_count()->IsConstantOperand();
1536 LConstantOperand* constant_parameter_count() {
1537 DCHECK(has_constant_parameter_count());
1538 return LConstantOperand::cast(parameter_count());
1540 LOperand* parameter_count() { return inputs_[2]; }
1542 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1546 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1548 explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1550 LOperand* object() { return inputs_[0]; }
1552 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1553 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1557 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1559 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1560 inputs_[0] = context;
1561 inputs_[1] = object;
1565 LOperand* context() { return inputs_[0]; }
1566 LOperand* object() { return inputs_[1]; }
1567 LOperand* temp_vector() { return temps_[0]; }
1569 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1570 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1572 Handle<Object> name() const { return hydrogen()->name(); }
1576 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 0> {
1578 explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1580 LOperand* function() { return inputs_[0]; }
1582 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1583 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1587 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1589 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1592 Heap::RootListIndex index() const { return hydrogen()->index(); }
1596 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1598 LLoadKeyed(LOperand* elements, LOperand* key) {
1599 inputs_[0] = elements;
1603 LOperand* elements() { return inputs_[0]; }
1604 LOperand* key() { return inputs_[1]; }
1605 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1606 bool is_external() const { return hydrogen()->is_external(); }
1607 bool is_fixed_typed_array() const {
1608 return hydrogen()->is_fixed_typed_array();
1610 bool is_typed_elements() const {
1611 return is_external() || is_fixed_typed_array();
1614 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1615 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1617 void PrintDataTo(StringStream* stream) OVERRIDE;
1618 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1622 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1624 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1626 inputs_[0] = context;
1627 inputs_[1] = object;
1632 LOperand* context() { return inputs_[0]; }
1633 LOperand* object() { return inputs_[1]; }
1634 LOperand* key() { return inputs_[2]; }
1635 LOperand* temp_vector() { return temps_[0]; }
1637 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1638 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1642 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1644 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1646 inputs_[0] = context;
1647 inputs_[1] = global_object;
1651 LOperand* context() { return inputs_[0]; }
1652 LOperand* global_object() { return inputs_[1]; }
1653 LOperand* temp_vector() { return temps_[0]; }
1655 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1656 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1658 Handle<Object> name() const { return hydrogen()->name(); }
1659 bool for_typeof() const { return hydrogen()->for_typeof(); }
1663 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1665 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1667 LOperand* context() { return inputs_[0]; }
1669 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1670 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1672 int slot_index() { return hydrogen()->slot_index(); }
1674 void PrintDataTo(StringStream* stream) OVERRIDE;
1678 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 0> {
1680 LStoreContextSlot(LOperand* context, LOperand* value) {
1681 inputs_[0] = context;
1685 LOperand* context() { return inputs_[0]; }
1686 LOperand* value() { return inputs_[1]; }
1688 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1689 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1691 int slot_index() { return hydrogen()->slot_index(); }
1693 void PrintDataTo(StringStream* stream) OVERRIDE;
1697 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1699 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1701 LOperand* value() { return inputs_[0]; }
1703 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1707 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1709 explicit LDrop(int count) : count_(count) {}
1711 int count() const { return count_; }
1713 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1720 class LStoreCodeEntry FINAL : public LTemplateInstruction<0, 2, 0> {
1722 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1723 inputs_[0] = function;
1724 inputs_[1] = code_object;
1727 LOperand* function() { return inputs_[0]; }
1728 LOperand* code_object() { return inputs_[1]; }
1730 void PrintDataTo(StringStream* stream) OVERRIDE;
1732 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1733 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1737 class LInnerAllocatedObject FINAL : public LTemplateInstruction<1, 2, 0> {
1739 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1740 inputs_[0] = base_object;
1741 inputs_[1] = offset;
1744 LOperand* base_object() const { return inputs_[0]; }
1745 LOperand* offset() const { return inputs_[1]; }
1747 void PrintDataTo(StringStream* stream) OVERRIDE;
1749 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1753 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1755 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1756 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1760 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1762 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1763 DECLARE_HYDROGEN_ACCESSOR(Context)
1767 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1769 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1771 LOperand* context() { return inputs_[0]; }
1773 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1774 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1778 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1780 explicit LCallJSFunction(LOperand* function) { inputs_[0] = function; }
1782 LOperand* function() { return inputs_[0]; }
1784 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1785 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1787 void PrintDataTo(StringStream* stream) OVERRIDE;
1789 int arity() const { return hydrogen()->argument_count() - 1; }
1793 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1795 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1796 const ZoneList<LOperand*>& operands, Zone* zone)
1797 : descriptor_(descriptor),
1798 inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1799 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1800 inputs_.AddAll(operands, zone);
1803 LOperand* target() const { return inputs_[0]; }
1805 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1807 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1810 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1812 void PrintDataTo(StringStream* stream) OVERRIDE;
1814 int arity() const { return hydrogen()->argument_count() - 1; }
1816 CallInterfaceDescriptor descriptor_;
1817 ZoneList<LOperand*> inputs_;
1819 // Iterator support.
1820 int InputCount() FINAL { return inputs_.length(); }
1821 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1823 int TempCount() FINAL { return 0; }
1824 LOperand* TempAt(int i) FINAL { return NULL; }
1828 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1830 LInvokeFunction(LOperand* context, LOperand* function) {
1831 inputs_[0] = context;
1832 inputs_[1] = function;
1835 LOperand* context() { return inputs_[0]; }
1836 LOperand* function() { return inputs_[1]; }
1838 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1839 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1841 void PrintDataTo(StringStream* stream) OVERRIDE;
1843 int arity() const { return hydrogen()->argument_count() - 1; }
1847 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1849 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1851 inputs_[0] = context;
1852 inputs_[1] = function;
1857 LOperand* context() { return inputs_[0]; }
1858 LOperand* function() { return inputs_[1]; }
1859 LOperand* temp_slot() { return temps_[0]; }
1860 LOperand* temp_vector() { return temps_[1]; }
1862 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1863 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1865 int arity() const { return hydrogen()->argument_count() - 1; }
1866 void PrintDataTo(StringStream* stream) OVERRIDE;
1870 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1872 LCallNew(LOperand* context, LOperand* constructor) {
1873 inputs_[0] = context;
1874 inputs_[1] = constructor;
1877 LOperand* context() { return inputs_[0]; }
1878 LOperand* constructor() { return inputs_[1]; }
1880 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1881 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1883 void PrintDataTo(StringStream* stream) OVERRIDE;
1885 int arity() const { return hydrogen()->argument_count() - 1; }
1889 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1891 LCallNewArray(LOperand* context, LOperand* constructor) {
1892 inputs_[0] = context;
1893 inputs_[1] = constructor;
1896 LOperand* context() { return inputs_[0]; }
1897 LOperand* constructor() { return inputs_[1]; }
1899 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1900 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1902 void PrintDataTo(StringStream* stream) OVERRIDE;
1904 int arity() const { return hydrogen()->argument_count() - 1; }
1908 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
1910 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1912 LOperand* context() { return inputs_[0]; }
1914 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1915 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1917 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
1918 return save_doubles() == kDontSaveFPRegs;
1921 const Runtime::Function* function() const { return hydrogen()->function(); }
1922 int arity() const { return hydrogen()->argument_count(); }
1923 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1927 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1929 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1931 LOperand* value() { return inputs_[0]; }
1933 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1937 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
1939 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1941 LOperand* value() { return inputs_[0]; }
1943 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1947 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 2> {
1949 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1955 LOperand* value() { return inputs_[0]; }
1956 LOperand* temp1() { return temps_[0]; }
1957 LOperand* temp2() { return temps_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1963 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 2> {
1965 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1971 LOperand* value() { return inputs_[0]; }
1972 LOperand* temp1() { return temps_[0]; }
1973 LOperand* temp2() { return temps_[1]; }
1975 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1979 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 2> {
1981 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1987 LOperand* value() { return inputs_[0]; }
1988 LOperand* temp() { return temps_[0]; }
1989 LOperand* temp2() { return temps_[1]; }
1991 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1992 DECLARE_HYDROGEN_ACCESSOR(Change)
1996 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
1998 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
2000 LOperand* value() { return inputs_[0]; }
2002 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2003 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2005 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2009 // Sometimes truncating conversion from a tagged value to an int32.
2010 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2012 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
2014 LOperand* value() { return inputs_[0]; }
2016 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2017 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2019 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2023 // Truncating conversion from a tagged value to an int32.
2024 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 2> {
2026 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
2032 LOperand* value() { return inputs_[0]; }
2033 LOperand* temp() { return temps_[0]; }
2034 LOperand* temp2() { return temps_[1]; }
2036 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2037 DECLARE_HYDROGEN_ACCESSOR(Change)
2039 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2043 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2045 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2050 DECLARE_HYDROGEN_ACCESSOR(Change)
2054 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 0> {
2056 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
2058 LOperand* value() { return inputs_[0]; }
2060 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2061 DECLARE_HYDROGEN_ACCESSOR(Change)
2065 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2067 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
2071 LOperand* value() { return inputs_[0]; }
2072 bool needs_check() const { return needs_check_; }
2074 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2081 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 1> {
2083 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2084 inputs_[0] = object;
2089 LOperand* object() { return inputs_[0]; }
2090 LOperand* value() { return inputs_[1]; }
2091 LOperand* temp() { return temps_[0]; }
2093 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2094 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2096 void PrintDataTo(StringStream* stream) OVERRIDE;
2098 Representation representation() const {
2099 return hydrogen()->field_representation();
2104 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2106 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2107 inputs_[0] = context;
2108 inputs_[1] = object;
2112 LOperand* context() { return inputs_[0]; }
2113 LOperand* object() { return inputs_[1]; }
2114 LOperand* value() { return inputs_[2]; }
2116 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2117 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2119 void PrintDataTo(StringStream* stream) OVERRIDE;
2121 Handle<Object> name() const { return hydrogen()->name(); }
2122 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2126 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2128 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2129 inputs_[0] = object;
2134 bool is_external() const { return hydrogen()->is_external(); }
2135 bool is_fixed_typed_array() const {
2136 return hydrogen()->is_fixed_typed_array();
2138 bool is_typed_elements() const {
2139 return is_external() || is_fixed_typed_array();
2141 LOperand* elements() { return inputs_[0]; }
2142 LOperand* key() { return inputs_[1]; }
2143 LOperand* value() { return inputs_[2]; }
2144 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2146 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2147 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2149 void PrintDataTo(StringStream* stream) OVERRIDE;
2150 bool NeedsCanonicalization() {
2151 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
2152 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
2155 return hydrogen()->NeedsCanonicalization();
2157 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2161 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2163 LStoreKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
2165 inputs_[0] = context;
2171 LOperand* context() { return inputs_[0]; }
2172 LOperand* object() { return inputs_[1]; }
2173 LOperand* key() { return inputs_[2]; }
2174 LOperand* value() { return inputs_[3]; }
2176 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2177 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2179 void PrintDataTo(StringStream* stream) OVERRIDE;
2181 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2185 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 1> {
2187 LTransitionElementsKind(LOperand* object, LOperand* context,
2188 LOperand* new_map_temp) {
2189 inputs_[0] = object;
2190 inputs_[1] = context;
2191 temps_[0] = new_map_temp;
2194 LOperand* context() { return inputs_[1]; }
2195 LOperand* object() { return inputs_[0]; }
2196 LOperand* new_map_temp() { return temps_[0]; }
2198 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2199 "transition-elements-kind")
2200 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2202 void PrintDataTo(StringStream* stream) OVERRIDE;
2204 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2205 Handle<Map> transitioned_map() {
2206 return hydrogen()->transitioned_map().handle();
2208 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2209 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2213 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2215 LTrapAllocationMemento(LOperand* object, LOperand* temp) {
2216 inputs_[0] = object;
2220 LOperand* object() { return inputs_[0]; }
2221 LOperand* temp() { return temps_[0]; }
2223 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
2227 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2229 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2230 inputs_[0] = context;
2235 LOperand* context() { return inputs_[0]; }
2236 LOperand* left() { return inputs_[1]; }
2237 LOperand* right() { return inputs_[2]; }
2239 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2240 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2244 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2246 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2247 inputs_[0] = context;
2248 inputs_[1] = string;
2252 LOperand* context() { return inputs_[0]; }
2253 LOperand* string() { return inputs_[1]; }
2254 LOperand* index() { return inputs_[2]; }
2256 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2257 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2261 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2263 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2264 inputs_[0] = context;
2265 inputs_[1] = char_code;
2268 LOperand* context() { return inputs_[0]; }
2269 LOperand* char_code() { return inputs_[1]; }
2271 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2272 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2276 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2278 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2280 LOperand* value() { return inputs_[0]; }
2282 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2283 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2287 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 0> {
2289 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2291 LOperand* value() { return inputs_[0]; }
2293 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2294 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2298 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 1> {
2300 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2305 LOperand* value() { return inputs_[0]; }
2306 LOperand* temp() { return temps_[0]; }
2308 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2309 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2313 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2315 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2317 LOperand* value() { return inputs_[0]; }
2319 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2323 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2325 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2327 LOperand* value() { return inputs_[0]; }
2329 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2330 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2334 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2336 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2338 LOperand* unclamped() { return inputs_[0]; }
2340 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2344 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2346 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2348 LOperand* unclamped() { return inputs_[0]; }
2350 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2354 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2356 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2357 inputs_[0] = unclamped;
2361 LOperand* unclamped() { return inputs_[0]; }
2362 LOperand* temp() { return temps_[0]; }
2364 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2368 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2370 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2372 LOperand* value() { return inputs_[0]; }
2374 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2375 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2379 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2381 LConstructDouble(LOperand* hi, LOperand* lo) {
2386 LOperand* hi() { return inputs_[0]; }
2387 LOperand* lo() { return inputs_[1]; }
2389 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2393 class LAllocate FINAL : public LTemplateInstruction<1, 2, 2> {
2395 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2397 inputs_[0] = context;
2403 LOperand* context() { return inputs_[0]; }
2404 LOperand* size() { return inputs_[1]; }
2405 LOperand* temp1() { return temps_[0]; }
2406 LOperand* temp2() { return temps_[1]; }
2408 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2409 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2413 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2415 explicit LRegExpLiteral(LOperand* context) { inputs_[0] = context; }
2417 LOperand* context() { return inputs_[0]; }
2419 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2420 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2424 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2426 explicit LFunctionLiteral(LOperand* context) { inputs_[0] = context; }
2428 LOperand* context() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2431 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2435 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2437 explicit LToFastProperties(LOperand* value) { inputs_[0] = value; }
2439 LOperand* value() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2442 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2446 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2448 LTypeof(LOperand* context, LOperand* value) {
2449 inputs_[0] = context;
2453 LOperand* context() { return inputs_[0]; }
2454 LOperand* value() { return inputs_[1]; }
2456 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2460 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2462 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2464 LOperand* value() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2467 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2469 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2471 void PrintDataTo(StringStream* stream) OVERRIDE;
2475 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
2477 explicit LIsConstructCallAndBranch(LOperand* temp) { temps_[0] = temp; }
2479 LOperand* temp() { return temps_[0]; }
2481 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2482 "is-construct-call-and-branch")
2486 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2490 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2491 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2495 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2497 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2499 LOperand* context() { return inputs_[0]; }
2501 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2502 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2504 Label* done_label() { return &done_label_; }
2511 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2513 LForInPrepareMap(LOperand* context, LOperand* object) {
2514 inputs_[0] = context;
2515 inputs_[1] = object;
2518 LOperand* context() { return inputs_[0]; }
2519 LOperand* object() { return inputs_[1]; }
2521 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2525 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2527 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2529 LOperand* map() { return inputs_[0]; }
2531 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2533 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2537 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2539 LCheckMapValue(LOperand* value, LOperand* map) {
2544 LOperand* value() { return inputs_[0]; }
2545 LOperand* map() { return inputs_[1]; }
2547 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2551 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2553 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2554 inputs_[0] = object;
2558 LOperand* object() { return inputs_[0]; }
2559 LOperand* index() { return inputs_[1]; }
2561 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2565 class LStoreFrameContext : public LTemplateInstruction<0, 1, 0> {
2567 explicit LStoreFrameContext(LOperand* context) { inputs_[0] = context; }
2569 LOperand* context() { return inputs_[0]; }
2571 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2575 class LAllocateBlockContext : public LTemplateInstruction<1, 2, 0> {
2577 LAllocateBlockContext(LOperand* context, LOperand* function) {
2578 inputs_[0] = context;
2579 inputs_[1] = function;
2582 LOperand* context() { return inputs_[0]; }
2583 LOperand* function() { return inputs_[1]; }
2585 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2587 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2588 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2592 class LChunkBuilder;
2593 class LPlatformChunk FINAL : public LChunk {
2595 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2597 int GetNextSpillIndex(RegisterKind kind);
2598 LOperand* GetNextSpillSlot(RegisterKind kind);
2602 class LChunkBuilder FINAL : public LChunkBuilderBase {
2604 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2605 : LChunkBuilderBase(info, graph),
2606 current_instruction_(NULL),
2607 current_block_(NULL),
2609 allocator_(allocator) {}
2611 // Build the sequence for the graph.
2612 LPlatformChunk* Build();
2614 // Declare methods that deal with the individual node types.
2615 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2616 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2619 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2620 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2621 LInstruction* DoRSub(HSub* instr);
2623 static bool HasMagicNumberForDivisor(int32_t divisor);
2625 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2626 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2627 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2628 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2629 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2630 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2631 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2632 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2633 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2634 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2635 LInstruction* DoDivByConstI(HDiv* instr);
2636 LInstruction* DoDivI(HDiv* instr);
2637 LInstruction* DoModByPowerOf2I(HMod* instr);
2638 LInstruction* DoModByConstI(HMod* instr);
2639 LInstruction* DoModI(HMod* instr);
2640 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2641 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2642 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2645 // Methods for getting operands for Use / Define / Temp.
2646 LUnallocated* ToUnallocated(Register reg);
2647 LUnallocated* ToUnallocated(DoubleRegister reg);
2649 // Methods for setting up define-use relationships.
2650 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2651 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2652 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2653 DoubleRegister fixed_register);
2655 // A value that is guaranteed to be allocated to a register.
2656 // Operand created by UseRegister is guaranteed to be live until the end of
2657 // instruction. This means that register allocator will not reuse it's
2658 // register for any other operand inside instruction.
2659 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2660 // instruction start. Register allocator is free to assign the same register
2661 // to some other operand used inside instruction (i.e. temporary or
2663 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2664 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2666 // An input operand in a register that may be trashed.
2667 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2669 // An input operand in a register or stack slot.
2670 MUST_USE_RESULT LOperand* Use(HValue* value);
2671 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2673 // An input operand in a register, stack slot or a constant operand.
2674 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2675 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2677 // An input operand in a register or a constant operand.
2678 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2679 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2681 // An input operand in a constant operand.
2682 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2684 // An input operand in register, stack slot or a constant operand.
2685 // Will not be moved to a register even if one is freely available.
2686 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2688 // Temporary operand that must be in a register.
2689 MUST_USE_RESULT LUnallocated* TempRegister();
2690 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2691 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2692 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2694 // Methods for setting up define-use relationships.
2695 // Return the same instruction that they are passed.
2696 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2697 LUnallocated* result);
2698 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2699 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2701 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2702 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2703 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2704 DoubleRegister reg);
2705 LInstruction* AssignEnvironment(LInstruction* instr);
2706 LInstruction* AssignPointerMap(LInstruction* instr);
2708 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2710 // By default we assume that instruction sequences generated for calls
2711 // cannot deoptimize eagerly and we do not attach environment to this
2713 LInstruction* MarkAsCall(
2714 LInstruction* instr, HInstruction* hinstr,
2715 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2717 void VisitInstruction(HInstruction* current);
2718 void AddInstruction(LInstruction* instr, HInstruction* current);
2720 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2721 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2722 LInstruction* DoArithmeticD(Token::Value op,
2723 HArithmeticBinaryOperation* instr);
2724 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2726 HInstruction* current_instruction_;
2727 HBasicBlock* current_block_;
2728 HBasicBlock* next_block_;
2729 LAllocator* allocator_;
2731 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2734 #undef DECLARE_HYDROGEN_ACCESSOR
2735 #undef DECLARE_CONCRETE_INSTRUCTION
2737 } // namespace v8::internal
2739 #endif // V8_PPC_LITHIUM_PPC_H_