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) \
155 V(ToFastProperties) \
156 V(TransitionElementsKind) \
157 V(TrapAllocationMemento) \
159 V(TypeofIsAndBranch) \
164 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
165 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
166 return LInstruction::k##type; \
168 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
169 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
172 static L##type* cast(LInstruction* instr) { \
173 DCHECK(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
179 H##type* hydrogen() const { \
180 return H##type::cast(hydrogen_value()); \
184 class LInstruction : public ZoneObject {
187 : environment_(NULL),
188 hydrogen_value_(NULL),
189 bit_field_(IsCallBits::encode(false)) {
192 virtual ~LInstruction() {}
194 virtual void CompileToNative(LCodeGen* generator) = 0;
195 virtual const char* Mnemonic() const = 0;
196 virtual void PrintTo(StringStream* stream);
197 virtual void PrintDataTo(StringStream* stream);
198 virtual void PrintOutputOperandTo(StringStream* stream);
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
208 virtual Opcode opcode() const = 0;
210 // Declare non-virtual type testers for all leaf IR classes.
211 #define DECLARE_PREDICATE(type) \
212 bool Is##type() const { return opcode() == k##type; }
213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
216 // Declare virtual predicates for instructions that don't have
218 virtual bool IsGap() const { return false; }
220 virtual bool IsControl() const { return false; }
222 // Try deleting this instruction if possible.
223 virtual bool TryDelete() { return false; }
225 void set_environment(LEnvironment* env) { environment_ = env; }
226 LEnvironment* environment() const { return environment_; }
227 bool HasEnvironment() const { return environment_ != NULL; }
229 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
230 LPointerMap* pointer_map() const { return pointer_map_.get(); }
231 bool HasPointerMap() const { return pointer_map_.is_set(); }
233 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
234 HValue* hydrogen_value() const { return hydrogen_value_; }
236 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
238 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
239 bool IsCall() const { return IsCallBits::decode(bit_field_); }
241 // Interface to the register allocator and iterators.
242 bool ClobbersTemps() const { return IsCall(); }
243 bool ClobbersRegisters() const { return IsCall(); }
244 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 // Interface to the register allocator and iterators.
249 bool IsMarkedAsCall() const { return IsCall(); }
251 virtual bool HasResult() const = 0;
252 virtual LOperand* result() const = 0;
254 LOperand* FirstInput() { return InputAt(0); }
255 LOperand* Output() { return HasResult() ? result() : NULL; }
257 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
263 virtual int InputCount() = 0;
264 virtual LOperand* InputAt(int i) = 0;
267 // Iterator interface.
268 friend class InputIterator;
270 friend class TempIterator;
271 virtual int TempCount() = 0;
272 virtual LOperand* TempAt(int i) = 0;
274 class IsCallBits: public BitField<bool, 0, 1> {};
276 LEnvironment* environment_;
277 SetOncePointer<LPointerMap> pointer_map_;
278 HValue* hydrogen_value_;
283 // R = number of result operands (0 or 1).
285 class LTemplateResultInstruction : public LInstruction {
287 // Allow 0 or 1 output operands.
288 STATIC_ASSERT(R == 0 || R == 1);
289 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
290 return R != 0 && result() != NULL;
292 void set_result(LOperand* operand) { results_[0] = operand; }
293 LOperand* result() const { return results_[0]; }
296 EmbeddedContainer<LOperand*, R> results_;
300 // R = number of result operands (0 or 1).
301 // I = number of input operands.
302 // T = number of temporary operands.
303 template<int R, int I, int T>
304 class LTemplateInstruction : public LTemplateResultInstruction<R> {
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
311 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
312 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
314 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
315 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
319 class LGap : public LTemplateInstruction<0, 0, 0> {
321 explicit LGap(HBasicBlock* block)
323 parallel_moves_[BEFORE] = NULL;
324 parallel_moves_[START] = NULL;
325 parallel_moves_[END] = NULL;
326 parallel_moves_[AFTER] = NULL;
329 // Can't use the DECLARE-macro here because of sub-classes.
330 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
331 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
332 static LGap* cast(LInstruction* instr) {
333 DCHECK(instr->IsGap());
334 return reinterpret_cast<LGap*>(instr);
337 bool IsRedundant() const;
339 HBasicBlock* block() const { return block_; }
346 FIRST_INNER_POSITION = BEFORE,
347 LAST_INNER_POSITION = AFTER
350 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
351 if (parallel_moves_[pos] == NULL) {
352 parallel_moves_[pos] = new(zone) LParallelMove(zone);
354 return parallel_moves_[pos];
357 LParallelMove* GetParallelMove(InnerPosition pos) {
358 return parallel_moves_[pos];
362 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 class LInstructionGap V8_FINAL : public LGap {
369 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
371 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
372 return !IsRedundant();
375 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
379 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
381 explicit LGoto(HBasicBlock* block) : block_(block) { }
383 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
384 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
385 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
386 virtual bool IsControl() const V8_OVERRIDE { return true; }
388 int block_id() const { return block_->block_id(); }
395 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
397 LLazyBailout() : gap_instructions_size_(0) { }
399 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
401 void set_gap_instructions_size(int gap_instructions_size) {
402 gap_instructions_size_ = gap_instructions_size;
404 int gap_instructions_size() { return gap_instructions_size_; }
407 int gap_instructions_size_;
411 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
418 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
420 explicit LDummyUse(LOperand* value) {
423 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
427 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
429 virtual bool IsControl() const V8_OVERRIDE { return true; }
430 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
431 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
435 class LLabel V8_FINAL : public LGap {
437 explicit LLabel(HBasicBlock* block)
438 : LGap(block), replacement_(NULL) { }
440 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
443 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
445 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
447 int block_id() const { return block()->block_id(); }
448 bool is_loop_header() const { return block()->IsLoopHeader(); }
449 bool is_osr_entry() const { return block()->is_osr_entry(); }
450 Label* label() { return &label_; }
451 LLabel* replacement() const { return replacement_; }
452 void set_replacement(LLabel* label) { replacement_ = label; }
453 bool HasReplacement() const { return replacement_ != NULL; }
457 LLabel* replacement_;
461 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
463 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
466 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
470 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
472 explicit LCallStub(LOperand* context) {
473 inputs_[0] = context;
476 LOperand* context() { return inputs_[0]; }
478 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
479 DECLARE_HYDROGEN_ACCESSOR(CallStub)
483 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
485 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
488 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
492 template<int I, int T>
493 class LControlInstruction : public LTemplateInstruction<0, I, T> {
495 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
497 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
499 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
500 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
502 int TrueDestination(LChunk* chunk) {
503 return chunk->LookupDestination(true_block_id());
505 int FalseDestination(LChunk* chunk) {
506 return chunk->LookupDestination(false_block_id());
509 Label* TrueLabel(LChunk* chunk) {
510 if (true_label_ == NULL) {
511 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
515 Label* FalseLabel(LChunk* chunk) {
516 if (false_label_ == NULL) {
517 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
523 int true_block_id() { return SuccessorAt(0)->block_id(); }
524 int false_block_id() { return SuccessorAt(1)->block_id(); }
527 HControlInstruction* hydrogen() {
528 return HControlInstruction::cast(this->hydrogen_value());
536 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
538 LWrapReceiver(LOperand* receiver, LOperand* function) {
539 inputs_[0] = receiver;
540 inputs_[1] = function;
543 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
544 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
546 LOperand* receiver() { return inputs_[0]; }
547 LOperand* function() { return inputs_[1]; }
551 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
553 LApplyArguments(LOperand* function,
556 LOperand* elements) {
557 inputs_[0] = function;
558 inputs_[1] = receiver;
560 inputs_[3] = elements;
563 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
565 LOperand* function() { return inputs_[0]; }
566 LOperand* receiver() { return inputs_[1]; }
567 LOperand* length() { return inputs_[2]; }
568 LOperand* elements() { return inputs_[3]; }
572 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
574 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
575 inputs_[0] = arguments;
580 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
582 LOperand* arguments() { return inputs_[0]; }
583 LOperand* length() { return inputs_[1]; }
584 LOperand* index() { return inputs_[2]; }
586 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
590 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
592 explicit LArgumentsLength(LOperand* elements) {
593 inputs_[0] = elements;
596 LOperand* elements() { return inputs_[0]; }
598 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
602 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
604 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
605 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
609 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
611 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
612 inputs_[0] = dividend;
616 LOperand* dividend() { return inputs_[0]; }
617 int32_t divisor() const { return divisor_; }
619 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
620 DECLARE_HYDROGEN_ACCESSOR(Mod)
627 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
629 LModByConstI(LOperand* dividend, int32_t divisor) {
630 inputs_[0] = dividend;
634 LOperand* dividend() { return inputs_[0]; }
635 int32_t divisor() const { return divisor_; }
637 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
638 DECLARE_HYDROGEN_ACCESSOR(Mod)
645 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 3> {
647 LModI(LOperand* left,
653 LOperand* left() { return inputs_[0]; }
654 LOperand* right() { return inputs_[1]; }
656 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
657 DECLARE_HYDROGEN_ACCESSOR(Mod)
661 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
663 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
664 inputs_[0] = dividend;
668 LOperand* dividend() { return inputs_[0]; }
669 int32_t divisor() const { return divisor_; }
671 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
672 DECLARE_HYDROGEN_ACCESSOR(Div)
679 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
681 LDivByConstI(LOperand* dividend, int32_t divisor) {
682 inputs_[0] = dividend;
686 LOperand* dividend() { return inputs_[0]; }
687 int32_t divisor() const { return divisor_; }
689 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
690 DECLARE_HYDROGEN_ACCESSOR(Div)
697 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
699 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
700 inputs_[0] = dividend;
701 inputs_[1] = divisor;
705 LOperand* dividend() { return inputs_[0]; }
706 LOperand* divisor() { return inputs_[1]; }
707 LOperand* temp() { return temps_[0]; }
709 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
710 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
714 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
716 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
717 inputs_[0] = dividend;
721 LOperand* dividend() { return inputs_[0]; }
722 int32_t divisor() { return divisor_; }
724 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
725 "flooring-div-by-power-of-2-i")
726 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
733 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
735 LFlooringDivByConstI(LOperand* dividend, int32_t divisor, LOperand* temp) {
736 inputs_[0] = dividend;
741 LOperand* dividend() { return inputs_[0]; }
742 int32_t divisor() const { return divisor_; }
743 LOperand* temp() { return temps_[0]; }
745 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
746 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
753 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
755 LFlooringDivI(LOperand* dividend, LOperand* divisor) {
756 inputs_[0] = dividend;
757 inputs_[1] = divisor;
760 LOperand* dividend() { return inputs_[0]; }
761 LOperand* divisor() { return inputs_[1]; }
763 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
764 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
768 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
770 LMulI(LOperand* left, LOperand* right) {
775 LOperand* left() { return inputs_[0]; }
776 LOperand* right() { return inputs_[1]; }
778 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
779 DECLARE_HYDROGEN_ACCESSOR(Mul)
783 // Instruction for computing multiplier * multiplicand + addend.
784 class LMultiplyAddD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
786 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
787 LOperand* multiplicand) {
789 inputs_[1] = multiplier;
790 inputs_[2] = multiplicand;
793 LOperand* addend() { return inputs_[0]; }
794 LOperand* multiplier() { return inputs_[1]; }
795 LOperand* multiplicand() { return inputs_[2]; }
797 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
801 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
803 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
807 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
809 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
814 LOperand* left() { return inputs_[0]; }
815 LOperand* right() { return inputs_[1]; }
817 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
818 "compare-numeric-and-branch")
819 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
821 Token::Value op() const { return hydrogen()->token(); }
822 bool is_double() const {
823 return hydrogen()->representation().IsDouble();
826 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
830 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 1> {
832 LMathFloor(LOperand* value, LOperand* temp) {
837 LOperand* value() { return inputs_[0]; }
838 LOperand* temp() { return temps_[0]; }
840 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
841 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
845 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
847 LMathRound(LOperand* value, LOperand* temp) {
852 LOperand* value() { return inputs_[0]; }
853 LOperand* temp() { return temps_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
856 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
860 class LMathFround V8_FINAL : public LTemplateInstruction<1, 1, 0> {
862 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
864 LOperand* value() { return inputs_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
870 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
872 LMathAbs(LOperand* context, LOperand* value) {
873 inputs_[1] = context;
877 LOperand* context() { return inputs_[1]; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathLog(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
897 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathClz32(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
909 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> {
911 LMathExp(LOperand* value,
912 LOperand* double_temp,
918 temps_[2] = double_temp;
919 ExternalReference::InitializeMathExpData();
922 LOperand* value() { return inputs_[0]; }
923 LOperand* temp1() { return temps_[0]; }
924 LOperand* temp2() { return temps_[1]; }
925 LOperand* double_temp() { return temps_[2]; }
927 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
931 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
933 explicit LMathSqrt(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
943 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
945 LMathPowHalf(LOperand* value, LOperand* temp) {
950 LOperand* value() { return inputs_[0]; }
951 LOperand* temp() { return temps_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
957 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
959 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
964 LOperand* left() { return inputs_[0]; }
965 LOperand* right() { return inputs_[1]; }
967 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
968 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
972 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
974 explicit LCmpHoleAndBranch(LOperand* object) {
978 LOperand* object() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
985 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
987 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
992 LOperand* value() { return inputs_[0]; }
993 LOperand* temp() { return temps_[0]; }
995 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
996 "cmp-minus-zero-and-branch")
997 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1001 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1003 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1008 LOperand* value() { return inputs_[0]; }
1009 LOperand* temp() { return temps_[0]; }
1011 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1012 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1014 virtual void PrintDataTo(StringStream* stream);
1018 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1020 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1025 LOperand* value() { return inputs_[0]; }
1026 LOperand* temp() { return temps_[0]; }
1028 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1029 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1031 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1035 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1037 explicit LIsSmiAndBranch(LOperand* value) {
1041 LOperand* value() { return inputs_[0]; }
1043 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1052 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1057 LOperand* value() { return inputs_[0]; }
1058 LOperand* temp() { return temps_[0]; }
1060 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1061 "is-undetectable-and-branch")
1062 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1064 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1068 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1070 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1071 inputs_[0] = context;
1076 LOperand* context() { return inputs_[0]; }
1077 LOperand* left() { return inputs_[1]; }
1078 LOperand* right() { return inputs_[2]; }
1080 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1081 "string-compare-and-branch")
1082 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1084 Token::Value op() const { return hydrogen()->token(); }
1086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1090 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1092 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1099 "has-instance-type-and-branch")
1100 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1102 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1106 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1108 explicit LGetCachedArrayIndex(LOperand* value) {
1112 LOperand* value() { return inputs_[0]; }
1114 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1115 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1119 class LHasCachedArrayIndexAndBranch V8_FINAL
1120 : public LControlInstruction<1, 0> {
1122 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1126 LOperand* value() { return inputs_[0]; }
1128 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1129 "has-cached-array-index-and-branch")
1130 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1132 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1136 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1138 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1143 LOperand* value() { return inputs_[0]; }
1144 LOperand* temp() { return temps_[0]; }
1146 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1147 "class-of-test-and-branch")
1148 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1150 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1154 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1156 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1157 inputs_[0] = context;
1162 LOperand* context() { return inputs_[0]; }
1163 LOperand* left() { return inputs_[1]; }
1164 LOperand* right() { return inputs_[2]; }
1166 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1167 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1169 Token::Value op() const { return hydrogen()->token(); }
1173 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1175 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1176 inputs_[0] = context;
1181 LOperand* context() { return inputs_[0]; }
1182 LOperand* left() { return inputs_[1]; }
1183 LOperand* right() { return inputs_[2]; }
1185 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1189 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1191 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1192 inputs_[0] = context;
1197 LOperand* context() { return inputs_[0]; }
1198 LOperand* value() { return inputs_[1]; }
1199 LOperand* temp() { return temps_[0]; }
1201 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1202 "instance-of-known-global")
1203 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1205 Handle<JSFunction> function() const { return hydrogen()->function(); }
1206 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1207 return lazy_deopt_env_;
1209 virtual void SetDeferredLazyDeoptimizationEnvironment(
1210 LEnvironment* env) V8_OVERRIDE {
1211 lazy_deopt_env_ = env;
1215 LEnvironment* lazy_deopt_env_;
1219 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1221 LBoundsCheck(LOperand* index, LOperand* length) {
1223 inputs_[1] = length;
1226 LOperand* index() { return inputs_[0]; }
1227 LOperand* length() { return inputs_[1]; }
1229 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1230 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1234 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1236 LBitI(LOperand* left, LOperand* right) {
1241 LOperand* left() { return inputs_[0]; }
1242 LOperand* right() { return inputs_[1]; }
1244 Token::Value op() const { return hydrogen()->op(); }
1246 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1247 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1251 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1253 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1254 : op_(op), can_deopt_(can_deopt) {
1259 Token::Value op() const { return op_; }
1260 LOperand* left() { return inputs_[0]; }
1261 LOperand* right() { return inputs_[1]; }
1262 bool can_deopt() const { return can_deopt_; }
1264 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1272 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1274 LSubI(LOperand* left, LOperand* right) {
1279 LOperand* left() { return inputs_[0]; }
1280 LOperand* right() { return inputs_[1]; }
1282 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1283 DECLARE_HYDROGEN_ACCESSOR(Sub)
1287 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1289 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1290 DECLARE_HYDROGEN_ACCESSOR(Constant)
1292 int32_t value() const { return hydrogen()->Integer32Value(); }
1296 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1298 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1299 DECLARE_HYDROGEN_ACCESSOR(Constant)
1301 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1305 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1307 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1308 DECLARE_HYDROGEN_ACCESSOR(Constant)
1310 double value() const { return hydrogen()->DoubleValue(); }
1314 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1316 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1317 DECLARE_HYDROGEN_ACCESSOR(Constant)
1319 ExternalReference value() const {
1320 return hydrogen()->ExternalReferenceValue();
1325 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1327 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1328 DECLARE_HYDROGEN_ACCESSOR(Constant)
1330 Handle<Object> value(Isolate* isolate) const {
1331 return hydrogen()->handle(isolate);
1336 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1338 explicit LBranch(LOperand* value) {
1342 LOperand* value() { return inputs_[0]; }
1344 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1345 DECLARE_HYDROGEN_ACCESSOR(Branch)
1347 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1351 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1353 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1358 LOperand* value() { return inputs_[0]; }
1359 LOperand* temp() { return temps_[0]; }
1361 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1362 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1364 Handle<Map> map() const { return hydrogen()->map().handle(); }
1368 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1370 explicit LMapEnumLength(LOperand* value) {
1374 LOperand* value() { return inputs_[0]; }
1376 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1380 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1382 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1387 LOperand* date() { return inputs_[0]; }
1388 LOperand* temp() { return temps_[0]; }
1389 Smi* index() const { return index_; }
1391 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1392 DECLARE_HYDROGEN_ACCESSOR(DateField)
1399 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1401 LSeqStringGetChar(LOperand* string, LOperand* index) {
1402 inputs_[0] = string;
1406 LOperand* string() const { return inputs_[0]; }
1407 LOperand* index() const { return inputs_[1]; }
1409 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1410 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1414 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1416 LSeqStringSetChar(LOperand* context,
1420 inputs_[0] = context;
1421 inputs_[1] = string;
1426 LOperand* string() { return inputs_[1]; }
1427 LOperand* index() { return inputs_[2]; }
1428 LOperand* value() { return inputs_[3]; }
1430 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1431 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1435 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1437 LAddI(LOperand* left, LOperand* right) {
1442 LOperand* left() { return inputs_[0]; }
1443 LOperand* right() { return inputs_[1]; }
1445 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1446 DECLARE_HYDROGEN_ACCESSOR(Add)
1450 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1452 LMathMinMax(LOperand* left, LOperand* right) {
1457 LOperand* left() { return inputs_[0]; }
1458 LOperand* right() { return inputs_[1]; }
1460 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1461 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1465 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1467 LPower(LOperand* left, LOperand* right) {
1472 LOperand* left() { return inputs_[0]; }
1473 LOperand* right() { return inputs_[1]; }
1475 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1476 DECLARE_HYDROGEN_ACCESSOR(Power)
1480 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1482 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1488 Token::Value op() const { return op_; }
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 virtual Opcode opcode() const V8_OVERRIDE {
1493 return LInstruction::kArithmeticD;
1495 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1496 virtual const char* Mnemonic() const V8_OVERRIDE;
1503 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1505 LArithmeticT(Token::Value op,
1510 inputs_[0] = context;
1515 LOperand* context() { return inputs_[0]; }
1516 LOperand* left() { return inputs_[1]; }
1517 LOperand* right() { return inputs_[2]; }
1518 Token::Value op() const { return op_; }
1520 virtual Opcode opcode() const V8_FINAL { return LInstruction::kArithmeticT; }
1521 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1522 virtual const char* Mnemonic() const V8_OVERRIDE;
1529 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1531 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1533 inputs_[1] = context;
1534 inputs_[2] = parameter_count;
1537 LOperand* value() { return inputs_[0]; }
1539 bool has_constant_parameter_count() {
1540 return parameter_count()->IsConstantOperand();
1542 LConstantOperand* constant_parameter_count() {
1543 DCHECK(has_constant_parameter_count());
1544 return LConstantOperand::cast(parameter_count());
1546 LOperand* parameter_count() { return inputs_[2]; }
1548 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1552 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1554 explicit LLoadNamedField(LOperand* object) {
1555 inputs_[0] = object;
1558 LOperand* object() { return inputs_[0]; }
1560 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1561 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1565 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1567 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1568 inputs_[0] = context;
1569 inputs_[1] = object;
1573 LOperand* context() { return inputs_[0]; }
1574 LOperand* object() { return inputs_[1]; }
1575 LOperand* temp_vector() { return temps_[0]; }
1577 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1578 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1580 Handle<Object> name() const { return hydrogen()->name(); }
1584 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1586 explicit LLoadFunctionPrototype(LOperand* function) {
1587 inputs_[0] = function;
1590 LOperand* function() { return inputs_[0]; }
1592 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1593 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1597 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1599 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1600 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1602 Heap::RootListIndex index() const { return hydrogen()->index(); }
1606 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1608 LLoadKeyed(LOperand* elements, LOperand* key) {
1609 inputs_[0] = elements;
1613 LOperand* elements() { return inputs_[0]; }
1614 LOperand* key() { return inputs_[1]; }
1615 ElementsKind elements_kind() const {
1616 return hydrogen()->elements_kind();
1618 bool is_external() const {
1619 return hydrogen()->is_external();
1621 bool is_fixed_typed_array() const {
1622 return hydrogen()->is_fixed_typed_array();
1624 bool is_typed_elements() const {
1625 return is_external() || is_fixed_typed_array();
1628 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1631 virtual void PrintDataTo(StringStream* stream);
1632 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1636 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 1> {
1638 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1640 inputs_[0] = context;
1641 inputs_[1] = object;
1646 LOperand* context() { return inputs_[0]; }
1647 LOperand* object() { return inputs_[1]; }
1648 LOperand* key() { return inputs_[2]; }
1649 LOperand* temp_vector() { return temps_[0]; }
1651 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1656 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1658 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1663 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1665 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1667 inputs_[0] = context;
1668 inputs_[1] = global_object;
1672 LOperand* context() { return inputs_[0]; }
1673 LOperand* global_object() { return inputs_[1]; }
1674 LOperand* temp_vector() { return temps_[0]; }
1676 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1677 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1679 Handle<Object> name() const { return hydrogen()->name(); }
1680 bool for_typeof() const { return hydrogen()->for_typeof(); }
1684 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1686 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1691 LOperand* value() { return inputs_[0]; }
1692 LOperand* temp() { return temps_[0]; }
1694 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1695 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1699 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1701 explicit LLoadContextSlot(LOperand* context) {
1702 inputs_[0] = context;
1705 LOperand* context() { return inputs_[0]; }
1707 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1708 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1710 int slot_index() { return hydrogen()->slot_index(); }
1712 virtual void PrintDataTo(StringStream* stream);
1716 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1718 LStoreContextSlot(LOperand* context, LOperand* value) {
1719 inputs_[0] = context;
1723 LOperand* context() { return inputs_[0]; }
1724 LOperand* value() { return inputs_[1]; }
1726 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1727 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1729 int slot_index() { return hydrogen()->slot_index(); }
1731 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1735 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1737 explicit LPushArgument(LOperand* value) {
1741 LOperand* value() { return inputs_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1747 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1749 explicit LDrop(int count) : count_(count) { }
1751 int count() const { return count_; }
1753 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1760 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 2, 0> {
1762 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1763 inputs_[0] = function;
1764 inputs_[1] = code_object;
1767 LOperand* function() { return inputs_[0]; }
1768 LOperand* code_object() { return inputs_[1]; }
1770 virtual void PrintDataTo(StringStream* stream);
1772 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1773 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1777 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1779 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1780 inputs_[0] = base_object;
1781 inputs_[1] = offset;
1784 LOperand* base_object() const { return inputs_[0]; }
1785 LOperand* offset() const { return inputs_[1]; }
1787 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1789 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1793 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1795 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1796 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1800 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1802 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1803 DECLARE_HYDROGEN_ACCESSOR(Context)
1807 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1809 explicit LDeclareGlobals(LOperand* context) {
1810 inputs_[0] = context;
1813 LOperand* context() { return inputs_[0]; }
1815 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1816 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1820 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1822 explicit LCallJSFunction(LOperand* function) {
1823 inputs_[0] = function;
1826 LOperand* function() { return inputs_[0]; }
1828 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1829 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1831 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1833 int arity() const { return hydrogen()->argument_count() - 1; }
1837 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1839 LCallWithDescriptor(const InterfaceDescriptor* descriptor,
1840 const ZoneList<LOperand*>& operands,
1842 : descriptor_(descriptor),
1843 inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
1844 DCHECK(descriptor->GetRegisterParameterCount() + 1 == operands.length());
1845 inputs_.AddAll(operands, zone);
1848 LOperand* target() const { return inputs_[0]; }
1850 const InterfaceDescriptor* descriptor() { return descriptor_; }
1853 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1854 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1856 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1858 int arity() const { return hydrogen()->argument_count() - 1; }
1860 const InterfaceDescriptor* descriptor_;
1861 ZoneList<LOperand*> inputs_;
1863 // Iterator support.
1864 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1865 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1867 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1868 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1873 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1875 LInvokeFunction(LOperand* context, LOperand* function) {
1876 inputs_[0] = context;
1877 inputs_[1] = function;
1880 LOperand* context() { return inputs_[0]; }
1881 LOperand* function() { return inputs_[1]; }
1883 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1884 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1886 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1888 int arity() const { return hydrogen()->argument_count() - 1; }
1892 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1894 LCallFunction(LOperand* context, LOperand* function) {
1895 inputs_[0] = context;
1896 inputs_[1] = function;
1899 LOperand* context() { return inputs_[0]; }
1900 LOperand* function() { return inputs_[1]; }
1902 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1903 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1905 int arity() const { return hydrogen()->argument_count() - 1; }
1909 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1911 LCallNew(LOperand* context, LOperand* constructor) {
1912 inputs_[0] = context;
1913 inputs_[1] = constructor;
1916 LOperand* context() { return inputs_[0]; }
1917 LOperand* constructor() { return inputs_[1]; }
1919 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1920 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1922 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1924 int arity() const { return hydrogen()->argument_count() - 1; }
1928 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1930 LCallNewArray(LOperand* context, LOperand* constructor) {
1931 inputs_[0] = context;
1932 inputs_[1] = constructor;
1935 LOperand* context() { return inputs_[0]; }
1936 LOperand* constructor() { return inputs_[1]; }
1938 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1939 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1941 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1943 int arity() const { return hydrogen()->argument_count() - 1; }
1947 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1949 explicit LCallRuntime(LOperand* context) {
1950 inputs_[0] = context;
1953 LOperand* context() { return inputs_[0]; }
1955 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1956 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1958 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const V8_OVERRIDE {
1959 return save_doubles() == kDontSaveFPRegs;
1962 const Runtime::Function* function() const { return hydrogen()->function(); }
1963 int arity() const { return hydrogen()->argument_count(); }
1964 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1968 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1970 explicit LInteger32ToDouble(LOperand* value) {
1974 LOperand* value() { return inputs_[0]; }
1976 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1980 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1982 explicit LUint32ToDouble(LOperand* value) {
1986 LOperand* value() { return inputs_[0]; }
1988 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1992 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1994 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2000 LOperand* value() { return inputs_[0]; }
2001 LOperand* temp1() { return temps_[0]; }
2002 LOperand* temp2() { return temps_[1]; }
2004 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2008 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2010 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
2016 LOperand* value() { return inputs_[0]; }
2017 LOperand* temp() { return temps_[0]; }
2018 LOperand* temp2() { return temps_[1]; }
2020 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2021 DECLARE_HYDROGEN_ACCESSOR(Change)
2025 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2027 explicit LDoubleToSmi(LOperand* value) {
2031 LOperand* value() { return inputs_[0]; }
2033 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2034 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2036 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2040 // Sometimes truncating conversion from a tagged value to an int32.
2041 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2043 explicit LDoubleToI(LOperand* value) {
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2050 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2052 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2056 // Truncating conversion from a tagged value to an int32.
2057 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2059 LTaggedToI(LOperand* value,
2067 LOperand* value() { return inputs_[0]; }
2068 LOperand* temp() { return temps_[0]; }
2069 LOperand* temp2() { return temps_[1]; }
2071 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2072 DECLARE_HYDROGEN_ACCESSOR(Change)
2074 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2078 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2080 explicit LSmiTag(LOperand* value) {
2084 LOperand* value() { return inputs_[0]; }
2086 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2087 DECLARE_HYDROGEN_ACCESSOR(Change)
2091 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2093 explicit LNumberUntagD(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2100 DECLARE_HYDROGEN_ACCESSOR(Change)
2104 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2106 LSmiUntag(LOperand* value, bool needs_check)
2107 : needs_check_(needs_check) {
2111 LOperand* value() { return inputs_[0]; }
2112 bool needs_check() const { return needs_check_; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2121 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2123 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2124 inputs_[0] = object;
2129 LOperand* object() { return inputs_[0]; }
2130 LOperand* value() { return inputs_[1]; }
2131 LOperand* temp() { return temps_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2134 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2138 Representation representation() const {
2139 return hydrogen()->field_representation();
2144 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2146 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2147 inputs_[0] = context;
2148 inputs_[1] = object;
2152 LOperand* context() { return inputs_[0]; }
2153 LOperand* object() { return inputs_[1]; }
2154 LOperand* value() { return inputs_[2]; }
2156 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2157 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2159 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2161 Handle<Object> name() const { return hydrogen()->name(); }
2162 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2166 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2168 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2169 inputs_[0] = object;
2174 bool is_external() const { return hydrogen()->is_external(); }
2175 bool is_fixed_typed_array() const {
2176 return hydrogen()->is_fixed_typed_array();
2178 bool is_typed_elements() const {
2179 return is_external() || is_fixed_typed_array();
2181 LOperand* elements() { return inputs_[0]; }
2182 LOperand* key() { return inputs_[1]; }
2183 LOperand* value() { return inputs_[2]; }
2184 ElementsKind elements_kind() const {
2185 return hydrogen()->elements_kind();
2188 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2189 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2191 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2192 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2193 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2197 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2199 LStoreKeyedGeneric(LOperand* context,
2203 inputs_[0] = context;
2209 LOperand* context() { return inputs_[0]; }
2210 LOperand* object() { return inputs_[1]; }
2211 LOperand* key() { return inputs_[2]; }
2212 LOperand* value() { return inputs_[3]; }
2214 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2215 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2217 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2219 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2223 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2225 LTransitionElementsKind(LOperand* object,
2227 LOperand* new_map_temp) {
2228 inputs_[0] = object;
2229 inputs_[1] = context;
2230 temps_[0] = new_map_temp;
2233 LOperand* context() { return inputs_[1]; }
2234 LOperand* object() { return inputs_[0]; }
2235 LOperand* new_map_temp() { return temps_[0]; }
2237 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2238 "transition-elements-kind")
2239 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2241 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2243 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2244 Handle<Map> transitioned_map() {
2245 return hydrogen()->transitioned_map().handle();
2247 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2248 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2252 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2254 LTrapAllocationMemento(LOperand* object,
2256 inputs_[0] = object;
2260 LOperand* object() { return inputs_[0]; }
2261 LOperand* temp() { return temps_[0]; }
2263 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2264 "trap-allocation-memento")
2268 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2270 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2271 inputs_[0] = context;
2276 LOperand* context() { return inputs_[0]; }
2277 LOperand* left() { return inputs_[1]; }
2278 LOperand* right() { return inputs_[2]; }
2280 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2281 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2286 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2288 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2289 inputs_[0] = context;
2290 inputs_[1] = string;
2294 LOperand* context() { return inputs_[0]; }
2295 LOperand* string() { return inputs_[1]; }
2296 LOperand* index() { return inputs_[2]; }
2298 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2299 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2303 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2305 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2306 inputs_[0] = context;
2307 inputs_[1] = char_code;
2310 LOperand* context() { return inputs_[0]; }
2311 LOperand* char_code() { return inputs_[1]; }
2313 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2314 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2318 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2320 explicit LCheckValue(LOperand* value) {
2324 LOperand* value() { return inputs_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2327 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2331 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckInstanceType(LOperand* value) {
2337 LOperand* value() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2340 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2344 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2346 explicit LCheckMaps(LOperand* value = NULL) {
2350 LOperand* value() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2353 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2357 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2359 explicit LCheckSmi(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2369 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2371 explicit LCheckNonSmi(LOperand* value) {
2375 LOperand* value() { return inputs_[0]; }
2377 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2378 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2382 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2384 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2385 inputs_[0] = unclamped;
2389 LOperand* unclamped() { return inputs_[0]; }
2390 LOperand* temp() { return temps_[0]; }
2392 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2396 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2398 explicit LClampIToUint8(LOperand* unclamped) {
2399 inputs_[0] = unclamped;
2402 LOperand* unclamped() { return inputs_[0]; }
2404 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2408 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2410 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2411 inputs_[0] = unclamped;
2415 LOperand* unclamped() { return inputs_[0]; }
2416 LOperand* temp() { return temps_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2422 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2424 explicit LDoubleBits(LOperand* value) {
2428 LOperand* value() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2431 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2435 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2437 LConstructDouble(LOperand* hi, LOperand* lo) {
2442 LOperand* hi() { return inputs_[0]; }
2443 LOperand* lo() { return inputs_[1]; }
2445 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2449 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 2> {
2451 LAllocate(LOperand* context,
2455 inputs_[0] = context;
2461 LOperand* context() { return inputs_[0]; }
2462 LOperand* size() { return inputs_[1]; }
2463 LOperand* temp1() { return temps_[0]; }
2464 LOperand* temp2() { return temps_[1]; }
2466 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2467 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2471 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2473 explicit LRegExpLiteral(LOperand* context) {
2474 inputs_[0] = context;
2477 LOperand* context() { return inputs_[0]; }
2479 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2480 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2484 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2486 explicit LFunctionLiteral(LOperand* context) {
2487 inputs_[0] = context;
2490 LOperand* context() { return inputs_[0]; }
2492 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2493 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2497 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2499 explicit LToFastProperties(LOperand* value) {
2503 LOperand* value() { return inputs_[0]; }
2505 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2506 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2510 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2512 LTypeof(LOperand* context, LOperand* value) {
2513 inputs_[0] = context;
2517 LOperand* context() { return inputs_[0]; }
2518 LOperand* value() { return inputs_[1]; }
2520 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2524 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2526 explicit LTypeofIsAndBranch(LOperand* value) {
2530 LOperand* value() { return inputs_[0]; }
2532 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2533 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2535 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2537 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2541 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2543 explicit LIsConstructCallAndBranch(LOperand* temp) {
2547 LOperand* temp() { return temps_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2550 "is-construct-call-and-branch")
2554 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2558 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2561 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2565 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2567 explicit LStackCheck(LOperand* context) {
2568 inputs_[0] = context;
2571 LOperand* context() { return inputs_[0]; }
2573 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2574 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2576 Label* done_label() { return &done_label_; }
2583 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2585 LForInPrepareMap(LOperand* context, LOperand* object) {
2586 inputs_[0] = context;
2587 inputs_[1] = object;
2590 LOperand* context() { return inputs_[0]; }
2591 LOperand* object() { return inputs_[1]; }
2593 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2597 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2599 explicit LForInCacheArray(LOperand* map) {
2603 LOperand* map() { return inputs_[0]; }
2605 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2608 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2613 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2615 LCheckMapValue(LOperand* value, LOperand* map) {
2620 LOperand* value() { return inputs_[0]; }
2621 LOperand* map() { return inputs_[1]; }
2623 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2627 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2629 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2630 inputs_[0] = object;
2634 LOperand* object() { return inputs_[0]; }
2635 LOperand* index() { return inputs_[1]; }
2637 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2641 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2643 explicit LStoreFrameContext(LOperand* context) {
2644 inputs_[0] = context;
2647 LOperand* context() { return inputs_[0]; }
2649 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2653 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2655 LAllocateBlockContext(LOperand* context, LOperand* function) {
2656 inputs_[0] = context;
2657 inputs_[1] = function;
2660 LOperand* context() { return inputs_[0]; }
2661 LOperand* function() { return inputs_[1]; }
2663 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2665 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2666 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2670 class LChunkBuilder;
2671 class LPlatformChunk V8_FINAL : public LChunk {
2673 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2674 : LChunk(info, graph) { }
2676 int GetNextSpillIndex(RegisterKind kind);
2677 LOperand* GetNextSpillSlot(RegisterKind kind);
2681 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2683 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2684 : LChunkBuilderBase(graph->zone()),
2689 current_instruction_(NULL),
2690 current_block_(NULL),
2692 allocator_(allocator) { }
2694 Isolate* isolate() const { return graph_->isolate(); }
2696 // Build the sequence for the graph.
2697 LPlatformChunk* Build();
2699 // Declare methods that deal with the individual node types.
2700 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2701 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2704 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2706 static bool HasMagicNumberForDivisor(int32_t divisor);
2708 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2709 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2710 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2711 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2712 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2713 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2714 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2715 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2716 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2717 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2718 LInstruction* DoDivByConstI(HDiv* instr);
2719 LInstruction* DoDivI(HDiv* instr);
2720 LInstruction* DoModByPowerOf2I(HMod* instr);
2721 LInstruction* DoModByConstI(HMod* instr);
2722 LInstruction* DoModI(HMod* instr);
2723 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2724 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2725 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2735 LPlatformChunk* chunk() const { return chunk_; }
2736 CompilationInfo* info() const { return info_; }
2737 HGraph* graph() const { return graph_; }
2739 bool is_unused() const { return status_ == UNUSED; }
2740 bool is_building() const { return status_ == BUILDING; }
2741 bool is_done() const { return status_ == DONE; }
2742 bool is_aborted() const { return status_ == ABORTED; }
2744 void Abort(BailoutReason reason);
2746 // Methods for getting operands for Use / Define / Temp.
2747 LUnallocated* ToUnallocated(Register reg);
2748 LUnallocated* ToUnallocated(DoubleRegister reg);
2750 // Methods for setting up define-use relationships.
2751 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2752 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2753 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2754 DoubleRegister fixed_register);
2756 // A value that is guaranteed to be allocated to a register.
2757 // Operand created by UseRegister is guaranteed to be live until the end of
2758 // instruction. This means that register allocator will not reuse it's
2759 // register for any other operand inside instruction.
2760 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2761 // instruction start. Register allocator is free to assign the same register
2762 // to some other operand used inside instruction (i.e. temporary or
2764 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2765 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2767 // An input operand in a register that may be trashed.
2768 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2770 // An input operand in a register or stack slot.
2771 MUST_USE_RESULT LOperand* Use(HValue* value);
2772 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2774 // An input operand in a register, stack slot or a constant operand.
2775 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2776 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2778 // An input operand in a register or a constant operand.
2779 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2780 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2782 // An input operand in a constant operand.
2783 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2785 // An input operand in register, stack slot or a constant operand.
2786 // Will not be moved to a register even if one is freely available.
2787 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2789 // Temporary operand that must be in a register.
2790 MUST_USE_RESULT LUnallocated* TempRegister();
2791 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2792 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2793 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2795 // Methods for setting up define-use relationships.
2796 // Return the same instruction that they are passed.
2797 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2798 LUnallocated* result);
2799 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2803 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2805 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2806 DoubleRegister reg);
2807 LInstruction* AssignEnvironment(LInstruction* instr);
2808 LInstruction* AssignPointerMap(LInstruction* instr);
2810 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2812 // By default we assume that instruction sequences generated for calls
2813 // cannot deoptimize eagerly and we do not attach environment to this
2815 LInstruction* MarkAsCall(
2816 LInstruction* instr,
2817 HInstruction* hinstr,
2818 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2820 void VisitInstruction(HInstruction* current);
2821 void AddInstruction(LInstruction* instr, HInstruction* current);
2823 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2824 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2825 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2826 LInstruction* DoArithmeticD(Token::Value op,
2827 HArithmeticBinaryOperation* instr);
2828 LInstruction* DoArithmeticT(Token::Value op,
2829 HBinaryOperation* instr);
2831 LPlatformChunk* chunk_;
2832 CompilationInfo* info_;
2833 HGraph* const graph_;
2835 HInstruction* current_instruction_;
2836 HBasicBlock* current_block_;
2837 HBasicBlock* next_block_;
2838 LAllocator* allocator_;
2840 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2843 #undef DECLARE_HYDROGEN_ACCESSOR
2844 #undef DECLARE_CONCRETE_INSTRUCTION
2846 } } // namespace v8::internal
2848 #endif // V8_MIPS_LITHIUM_MIPS_H_