1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_MIPS_LITHIUM_MIPS_H_
29 #define V8_MIPS_LITHIUM_MIPS_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
97 V(GetCachedArrayIndex) \
99 V(HasCachedArrayIndexAndBranch) \
100 V(HasInstanceTypeAndBranch) \
101 V(InnerAllocatedObject) \
103 V(InstanceOfKnownGlobal) \
105 V(Integer32ToDouble) \
108 V(IsConstructCallAndBranch) \
109 V(IsObjectAndBranch) \
110 V(IsStringAndBranch) \
112 V(IsUndetectableAndBranch) \
117 V(LoadFieldByIndex) \
118 V(LoadFunctionPrototype) \
120 V(LoadGlobalGeneric) \
122 V(LoadKeyedGeneric) \
124 V(LoadNamedGeneric) \
148 V(SeqStringGetChar) \
149 V(SeqStringSetChar) \
155 V(StoreContextSlot) \
158 V(StoreKeyedGeneric) \
160 V(StoreNamedGeneric) \
162 V(StringCharCodeAt) \
163 V(StringCharFromCode) \
164 V(StringCompareAndBranch) \
168 V(ToFastProperties) \
169 V(TransitionElementsKind) \
170 V(TrapAllocationMemento) \
172 V(TypeofIsAndBranch) \
178 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
179 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
180 return LInstruction::k##type; \
182 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
183 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
186 static L##type* cast(LInstruction* instr) { \
187 ASSERT(instr->Is##type()); \
188 return reinterpret_cast<L##type*>(instr); \
192 #define DECLARE_HYDROGEN_ACCESSOR(type) \
193 H##type* hydrogen() const { \
194 return H##type::cast(hydrogen_value()); \
198 class LInstruction : public ZoneObject {
201 : environment_(NULL),
202 hydrogen_value_(NULL),
203 bit_field_(IsCallBits::encode(false)) {
206 virtual ~LInstruction() {}
208 virtual void CompileToNative(LCodeGen* generator) = 0;
209 virtual const char* Mnemonic() const = 0;
210 virtual void PrintTo(StringStream* stream);
211 virtual void PrintDataTo(StringStream* stream);
212 virtual void PrintOutputOperandTo(StringStream* stream);
215 // Declare a unique enum value for each instruction.
216 #define DECLARE_OPCODE(type) k##type,
217 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
218 kNumberOfInstructions
219 #undef DECLARE_OPCODE
222 virtual Opcode opcode() const = 0;
224 // Declare non-virtual type testers for all leaf IR classes.
225 #define DECLARE_PREDICATE(type) \
226 bool Is##type() const { return opcode() == k##type; }
227 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
228 #undef DECLARE_PREDICATE
230 // Declare virtual predicates for instructions that don't have
232 virtual bool IsGap() const { return false; }
234 virtual bool IsControl() const { return false; }
236 void set_environment(LEnvironment* env) { environment_ = env; }
237 LEnvironment* environment() const { return environment_; }
238 bool HasEnvironment() const { return environment_ != NULL; }
240 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
241 LPointerMap* pointer_map() const { return pointer_map_.get(); }
242 bool HasPointerMap() const { return pointer_map_.is_set(); }
244 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
245 HValue* hydrogen_value() const { return hydrogen_value_; }
247 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
249 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
250 bool IsCall() const { return IsCallBits::decode(bit_field_); }
252 // Interface to the register allocator and iterators.
253 bool ClobbersTemps() const { return IsCall(); }
254 bool ClobbersRegisters() const { return IsCall(); }
255 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
257 // Interface to the register allocator and iterators.
258 bool IsMarkedAsCall() const { return IsCall(); }
260 virtual bool HasResult() const = 0;
261 virtual LOperand* result() const = 0;
263 LOperand* FirstInput() { return InputAt(0); }
264 LOperand* Output() { return HasResult() ? result() : NULL; }
266 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
273 // Iterator interface.
274 friend class InputIterator;
275 virtual int InputCount() = 0;
276 virtual LOperand* InputAt(int i) = 0;
278 friend class TempIterator;
279 virtual int TempCount() = 0;
280 virtual LOperand* TempAt(int i) = 0;
282 class IsCallBits: public BitField<bool, 0, 1> {};
284 LEnvironment* environment_;
285 SetOncePointer<LPointerMap> pointer_map_;
286 HValue* hydrogen_value_;
291 // R = number of result operands (0 or 1).
293 class LTemplateResultInstruction : public LInstruction {
295 // Allow 0 or 1 output operands.
296 STATIC_ASSERT(R == 0 || R == 1);
297 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
298 return R != 0 && result() != NULL;
300 void set_result(LOperand* operand) { results_[0] = operand; }
301 LOperand* result() const { return results_[0]; }
304 EmbeddedContainer<LOperand*, R> results_;
308 // R = number of result operands (0 or 1).
309 // I = number of input operands.
310 // T = number of temporary operands.
311 template<int R, int I, int T>
312 class LTemplateInstruction : public LTemplateResultInstruction<R> {
314 EmbeddedContainer<LOperand*, I> inputs_;
315 EmbeddedContainer<LOperand*, T> temps_;
319 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
320 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
322 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
323 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
327 class LGap : public LTemplateInstruction<0, 0, 0> {
329 explicit LGap(HBasicBlock* block)
331 parallel_moves_[BEFORE] = NULL;
332 parallel_moves_[START] = NULL;
333 parallel_moves_[END] = NULL;
334 parallel_moves_[AFTER] = NULL;
337 // Can't use the DECLARE-macro here because of sub-classes.
338 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
339 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
340 static LGap* cast(LInstruction* instr) {
341 ASSERT(instr->IsGap());
342 return reinterpret_cast<LGap*>(instr);
345 bool IsRedundant() const;
347 HBasicBlock* block() const { return block_; }
354 FIRST_INNER_POSITION = BEFORE,
355 LAST_INNER_POSITION = AFTER
358 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
359 if (parallel_moves_[pos] == NULL) {
360 parallel_moves_[pos] = new(zone) LParallelMove(zone);
362 return parallel_moves_[pos];
365 LParallelMove* GetParallelMove(InnerPosition pos) {
366 return parallel_moves_[pos];
370 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
375 class LInstructionGap V8_FINAL : public LGap {
377 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
379 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
380 return !IsRedundant();
383 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
387 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
389 explicit LGoto(HBasicBlock* block) : block_(block) { }
391 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
392 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
393 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
394 virtual bool IsControl() const V8_OVERRIDE { return true; }
396 int block_id() const { return block_->block_id(); }
403 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
405 LLazyBailout() : gap_instructions_size_(0) { }
407 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
409 void set_gap_instructions_size(int gap_instructions_size) {
410 gap_instructions_size_ = gap_instructions_size;
412 int gap_instructions_size() { return gap_instructions_size_; }
415 int gap_instructions_size_;
419 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
421 explicit LDummy() { }
422 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
426 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
428 explicit LDummyUse(LOperand* value) {
431 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
435 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
437 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
438 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
442 class LLabel V8_FINAL : public LGap {
444 explicit LLabel(HBasicBlock* block)
445 : LGap(block), replacement_(NULL) { }
447 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
450 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
452 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
454 int block_id() const { return block()->block_id(); }
455 bool is_loop_header() const { return block()->IsLoopHeader(); }
456 bool is_osr_entry() const { return block()->is_osr_entry(); }
457 Label* label() { return &label_; }
458 LLabel* replacement() const { return replacement_; }
459 void set_replacement(LLabel* label) { replacement_ = label; }
460 bool HasReplacement() const { return replacement_ != NULL; }
464 LLabel* replacement_;
468 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
470 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
473 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
477 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
479 explicit LCallStub(LOperand* context) {
480 inputs_[0] = context;
483 LOperand* context() { return inputs_[0]; }
485 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
486 DECLARE_HYDROGEN_ACCESSOR(CallStub)
490 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
492 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
495 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
499 template<int I, int T>
500 class LControlInstruction : public LTemplateInstruction<0, I, T> {
502 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
504 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
506 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
507 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
509 int TrueDestination(LChunk* chunk) {
510 return chunk->LookupDestination(true_block_id());
512 int FalseDestination(LChunk* chunk) {
513 return chunk->LookupDestination(false_block_id());
516 Label* TrueLabel(LChunk* chunk) {
517 if (true_label_ == NULL) {
518 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
522 Label* FalseLabel(LChunk* chunk) {
523 if (false_label_ == NULL) {
524 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
530 int true_block_id() { return SuccessorAt(0)->block_id(); }
531 int false_block_id() { return SuccessorAt(1)->block_id(); }
534 HControlInstruction* hydrogen() {
535 return HControlInstruction::cast(this->hydrogen_value());
543 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
545 LWrapReceiver(LOperand* receiver, LOperand* function) {
546 inputs_[0] = receiver;
547 inputs_[1] = function;
550 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
551 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
553 LOperand* receiver() { return inputs_[0]; }
554 LOperand* function() { return inputs_[1]; }
558 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
560 LApplyArguments(LOperand* function,
563 LOperand* elements) {
564 inputs_[0] = function;
565 inputs_[1] = receiver;
567 inputs_[3] = elements;
570 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
579 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
581 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
582 inputs_[0] = arguments;
587 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
597 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
599 explicit LArgumentsLength(LOperand* elements) {
600 inputs_[0] = elements;
603 LOperand* elements() { return inputs_[0]; }
605 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
609 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
611 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
612 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
616 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 3> {
618 // Used when the right hand is a constant power of 2.
619 LModI(LOperand* left,
628 // Used for the standard case.
629 LModI(LOperand* left,
641 LOperand* left() { return inputs_[0]; }
642 LOperand* right() { return inputs_[1]; }
643 LOperand* temp() { return temps_[0]; }
644 LOperand* temp2() { return temps_[1]; }
645 LOperand* temp3() { return temps_[2]; }
647 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
648 DECLARE_HYDROGEN_ACCESSOR(Mod)
652 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
654 LDivI(LOperand* left, LOperand* right) {
659 LOperand* left() { return inputs_[0]; }
660 LOperand* right() { return inputs_[1]; }
662 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
663 DECLARE_HYDROGEN_ACCESSOR(Div)
667 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
669 LMathFloorOfDiv(LOperand* left,
671 LOperand* temp = NULL) {
677 LOperand* left() { return inputs_[0]; }
678 LOperand* right() { return inputs_[1]; }
679 LOperand* temp() { return temps_[0]; }
681 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
682 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
686 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
688 LMulI(LOperand* left, LOperand* right) {
693 LOperand* left() { return inputs_[0]; }
694 LOperand* right() { return inputs_[1]; }
696 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
697 DECLARE_HYDROGEN_ACCESSOR(Mul)
701 // Instruction for computing multiplier * multiplicand + addend.
702 class LMultiplyAddD V8_FINAL : public LTemplateInstruction<1, 3, 0> {
704 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
705 LOperand* multiplicand) {
707 inputs_[1] = multiplier;
708 inputs_[2] = multiplicand;
711 LOperand* addend() { return inputs_[0]; }
712 LOperand* multiplier() { return inputs_[1]; }
713 LOperand* multiplicand() { return inputs_[2]; }
715 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
719 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
721 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
725 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
727 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
732 LOperand* left() { return inputs_[0]; }
733 LOperand* right() { return inputs_[1]; }
735 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
736 "compare-numeric-and-branch")
737 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
739 Token::Value op() const { return hydrogen()->token(); }
740 bool is_double() const {
741 return hydrogen()->representation().IsDouble();
744 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
748 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 1> {
750 LMathFloor(LOperand* value, LOperand* temp) {
755 LOperand* value() { return inputs_[0]; }
756 LOperand* temp() { return temps_[0]; }
758 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
759 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
763 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
765 LMathRound(LOperand* value, LOperand* temp) {
770 LOperand* value() { return inputs_[0]; }
771 LOperand* temp() { return temps_[0]; }
773 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
774 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
778 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
780 LMathAbs(LOperand* context, LOperand* value) {
781 inputs_[1] = context;
785 LOperand* context() { return inputs_[1]; }
786 LOperand* value() { return inputs_[0]; }
788 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
789 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
793 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
795 explicit LMathLog(LOperand* value) {
799 LOperand* value() { return inputs_[0]; }
801 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
805 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 3> {
807 LMathExp(LOperand* value,
808 LOperand* double_temp,
814 temps_[2] = double_temp;
815 ExternalReference::InitializeMathExpData();
818 LOperand* value() { return inputs_[0]; }
819 LOperand* temp1() { return temps_[0]; }
820 LOperand* temp2() { return temps_[1]; }
821 LOperand* double_temp() { return temps_[2]; }
823 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
827 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
829 explicit LMathSqrt(LOperand* value) {
833 LOperand* value() { return inputs_[0]; }
835 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
839 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
841 LMathPowHalf(LOperand* value, LOperand* temp) {
846 LOperand* value() { return inputs_[0]; }
847 LOperand* temp() { return temps_[0]; }
849 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
853 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
855 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
860 LOperand* left() { return inputs_[0]; }
861 LOperand* right() { return inputs_[1]; }
863 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
864 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
868 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
870 explicit LCmpHoleAndBranch(LOperand* object) {
874 LOperand* object() { return inputs_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
877 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
881 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 1> {
883 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
888 LOperand* value() { return inputs_[0]; }
889 LOperand* temp() { return temps_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
892 "cmp-minus-zero-and-branch")
893 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
897 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
899 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
904 LOperand* value() { return inputs_[0]; }
905 LOperand* temp() { return temps_[0]; }
907 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
908 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
910 virtual void PrintDataTo(StringStream* stream);
914 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
916 LIsStringAndBranch(LOperand* value, LOperand* temp) {
921 LOperand* value() { return inputs_[0]; }
922 LOperand* temp() { return temps_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
925 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
927 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
931 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
933 explicit LIsSmiAndBranch(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
940 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
942 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
946 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
948 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
953 LOperand* value() { return inputs_[0]; }
954 LOperand* temp() { return temps_[0]; }
956 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
957 "is-undetectable-and-branch")
958 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
960 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
964 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
966 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
967 inputs_[0] = context;
972 LOperand* context() { return inputs_[0]; }
973 LOperand* left() { return inputs_[1]; }
974 LOperand* right() { return inputs_[2]; }
976 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
977 "string-compare-and-branch")
978 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
980 Token::Value op() const { return hydrogen()->token(); }
982 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
986 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
988 explicit LHasInstanceTypeAndBranch(LOperand* value) {
992 LOperand* value() { return inputs_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
995 "has-instance-type-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
998 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1002 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1004 explicit LGetCachedArrayIndex(LOperand* value) {
1008 LOperand* value() { return inputs_[0]; }
1010 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1011 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1015 class LHasCachedArrayIndexAndBranch V8_FINAL
1016 : public LControlInstruction<1, 0> {
1018 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1022 LOperand* value() { return inputs_[0]; }
1024 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1025 "has-cached-array-index-and-branch")
1026 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1034 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1039 LOperand* value() { return inputs_[0]; }
1040 LOperand* temp() { return temps_[0]; }
1042 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1043 "class-of-test-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1052 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1053 inputs_[0] = context;
1058 LOperand* context() { return inputs_[0]; }
1059 LOperand* left() { return inputs_[1]; }
1060 LOperand* right() { return inputs_[2]; }
1062 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1063 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1065 Token::Value op() const { return hydrogen()->token(); }
1069 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1071 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1072 inputs_[0] = context;
1077 LOperand* context() { return inputs_[0]; }
1078 LOperand* left() { return inputs_[1]; }
1079 LOperand* right() { return inputs_[2]; }
1081 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1085 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1087 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1088 inputs_[0] = context;
1093 LOperand* context() { return inputs_[0]; }
1094 LOperand* value() { return inputs_[1]; }
1095 LOperand* temp() { return temps_[0]; }
1097 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1098 "instance-of-known-global")
1099 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1101 Handle<JSFunction> function() const { return hydrogen()->function(); }
1102 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1103 return lazy_deopt_env_;
1105 virtual void SetDeferredLazyDeoptimizationEnvironment(
1106 LEnvironment* env) V8_OVERRIDE {
1107 lazy_deopt_env_ = env;
1111 LEnvironment* lazy_deopt_env_;
1115 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1117 LBoundsCheck(LOperand* index, LOperand* length) {
1119 inputs_[1] = length;
1122 LOperand* index() { return inputs_[0]; }
1123 LOperand* length() { return inputs_[1]; }
1125 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1126 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1130 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1132 LBitI(LOperand* left, LOperand* right) {
1137 LOperand* left() { return inputs_[0]; }
1138 LOperand* right() { return inputs_[1]; }
1140 Token::Value op() const { return hydrogen()->op(); }
1142 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1143 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1147 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1149 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1150 : op_(op), can_deopt_(can_deopt) {
1155 Token::Value op() const { return op_; }
1156 LOperand* left() { return inputs_[0]; }
1157 LOperand* right() { return inputs_[1]; }
1158 bool can_deopt() const { return can_deopt_; }
1160 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1168 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1170 LSubI(LOperand* left, LOperand* right) {
1175 LOperand* left() { return inputs_[0]; }
1176 LOperand* right() { return inputs_[1]; }
1178 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1179 DECLARE_HYDROGEN_ACCESSOR(Sub)
1183 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1185 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1186 DECLARE_HYDROGEN_ACCESSOR(Constant)
1188 int32_t value() const { return hydrogen()->Integer32Value(); }
1192 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1194 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1195 DECLARE_HYDROGEN_ACCESSOR(Constant)
1197 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1201 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1203 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1204 DECLARE_HYDROGEN_ACCESSOR(Constant)
1206 double value() const { return hydrogen()->DoubleValue(); }
1210 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1212 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1213 DECLARE_HYDROGEN_ACCESSOR(Constant)
1215 ExternalReference value() const {
1216 return hydrogen()->ExternalReferenceValue();
1221 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1223 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1224 DECLARE_HYDROGEN_ACCESSOR(Constant)
1226 Handle<Object> value(Isolate* isolate) const {
1227 return hydrogen()->handle(isolate);
1232 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1234 explicit LBranch(LOperand* value) {
1238 LOperand* value() { return inputs_[0]; }
1240 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1241 DECLARE_HYDROGEN_ACCESSOR(Branch)
1243 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1247 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1249 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1254 LOperand* value() { return inputs_[0]; }
1255 LOperand* temp() { return temps_[0]; }
1257 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1258 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1260 Handle<Map> map() const { return hydrogen()->map().handle(); }
1264 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1266 explicit LMapEnumLength(LOperand* value) {
1270 LOperand* value() { return inputs_[0]; }
1272 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1276 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1278 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1283 LOperand* date() { return inputs_[0]; }
1284 LOperand* temp() { return temps_[0]; }
1285 Smi* index() const { return index_; }
1287 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1288 DECLARE_HYDROGEN_ACCESSOR(DateField)
1295 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1297 LSeqStringGetChar(LOperand* string, LOperand* index) {
1298 inputs_[0] = string;
1302 LOperand* string() const { return inputs_[0]; }
1303 LOperand* index() const { return inputs_[1]; }
1305 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1306 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1310 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1312 LSeqStringSetChar(LOperand* context,
1316 inputs_[0] = context;
1317 inputs_[1] = string;
1322 LOperand* string() { return inputs_[1]; }
1323 LOperand* index() { return inputs_[2]; }
1324 LOperand* value() { return inputs_[3]; }
1326 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1327 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1331 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1333 LAddI(LOperand* left, LOperand* right) {
1338 LOperand* left() { return inputs_[0]; }
1339 LOperand* right() { return inputs_[1]; }
1341 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1342 DECLARE_HYDROGEN_ACCESSOR(Add)
1346 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1348 LMathMinMax(LOperand* left, LOperand* right) {
1353 LOperand* left() { return inputs_[0]; }
1354 LOperand* right() { return inputs_[1]; }
1356 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1357 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1361 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1363 LPower(LOperand* left, LOperand* right) {
1368 LOperand* left() { return inputs_[0]; }
1369 LOperand* right() { return inputs_[1]; }
1371 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1372 DECLARE_HYDROGEN_ACCESSOR(Power)
1376 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1378 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1384 Token::Value op() const { return op_; }
1385 LOperand* left() { return inputs_[0]; }
1386 LOperand* right() { return inputs_[1]; }
1388 virtual Opcode opcode() const V8_OVERRIDE {
1389 return LInstruction::kArithmeticD;
1391 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1392 virtual const char* Mnemonic() const V8_OVERRIDE;
1399 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1401 LArithmeticT(Token::Value op,
1406 inputs_[0] = context;
1411 LOperand* context() { return inputs_[0]; }
1412 LOperand* left() { return inputs_[1]; }
1413 LOperand* right() { return inputs_[2]; }
1414 Token::Value op() const { return op_; }
1416 virtual Opcode opcode() const V8_FINAL { return LInstruction::kArithmeticT; }
1417 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1418 virtual const char* Mnemonic() const V8_OVERRIDE;
1425 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1427 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1429 inputs_[1] = context;
1430 inputs_[2] = parameter_count;
1433 LOperand* value() { return inputs_[0]; }
1435 bool has_constant_parameter_count() {
1436 return parameter_count()->IsConstantOperand();
1438 LConstantOperand* constant_parameter_count() {
1439 ASSERT(has_constant_parameter_count());
1440 return LConstantOperand::cast(parameter_count());
1442 LOperand* parameter_count() { return inputs_[2]; }
1444 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1448 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1450 explicit LLoadNamedField(LOperand* object) {
1451 inputs_[0] = object;
1454 LOperand* object() { return inputs_[0]; }
1456 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1457 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1461 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1463 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1464 inputs_[0] = context;
1465 inputs_[1] = object;
1468 LOperand* context() { return inputs_[0]; }
1469 LOperand* object() { return inputs_[1]; }
1471 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1472 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1474 Handle<Object> name() const { return hydrogen()->name(); }
1478 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1480 explicit LLoadFunctionPrototype(LOperand* function) {
1481 inputs_[0] = function;
1484 LOperand* function() { return inputs_[0]; }
1486 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1487 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1491 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1493 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1494 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1496 Heap::RootListIndex index() const { return hydrogen()->index(); }
1500 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1502 LLoadKeyed(LOperand* elements, LOperand* key) {
1503 inputs_[0] = elements;
1507 LOperand* elements() { return inputs_[0]; }
1508 LOperand* key() { return inputs_[1]; }
1509 ElementsKind elements_kind() const {
1510 return hydrogen()->elements_kind();
1512 bool is_external() const {
1513 return hydrogen()->is_external();
1515 bool is_fixed_typed_array() const {
1516 return hydrogen()->is_fixed_typed_array();
1518 bool is_typed_elements() const {
1519 return is_external() || is_fixed_typed_array();
1522 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1523 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1525 virtual void PrintDataTo(StringStream* stream);
1526 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1530 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1532 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key) {
1533 inputs_[0] = context;
1534 inputs_[1] = object;
1538 LOperand* context() { return inputs_[0]; }
1539 LOperand* object() { return inputs_[1]; }
1540 LOperand* key() { return inputs_[2]; }
1542 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1546 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1548 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1549 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1553 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1555 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1556 inputs_[0] = context;
1557 inputs_[1] = global_object;
1560 LOperand* context() { return inputs_[0]; }
1561 LOperand* global_object() { return inputs_[1]; }
1563 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1564 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1566 Handle<Object> name() const { return hydrogen()->name(); }
1567 bool for_typeof() const { return hydrogen()->for_typeof(); }
1571 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1573 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1578 LOperand* value() { return inputs_[0]; }
1579 LOperand* temp() { return temps_[0]; }
1581 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1582 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1586 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1588 explicit LLoadContextSlot(LOperand* context) {
1589 inputs_[0] = context;
1592 LOperand* context() { return inputs_[0]; }
1594 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1597 int slot_index() { return hydrogen()->slot_index(); }
1599 virtual void PrintDataTo(StringStream* stream);
1603 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1605 LStoreContextSlot(LOperand* context, LOperand* value) {
1606 inputs_[0] = context;
1610 LOperand* context() { return inputs_[0]; }
1611 LOperand* value() { return inputs_[1]; }
1613 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1614 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1616 int slot_index() { return hydrogen()->slot_index(); }
1618 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1622 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1624 explicit LPushArgument(LOperand* value) {
1628 LOperand* value() { return inputs_[0]; }
1630 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1634 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1636 explicit LDrop(int count) : count_(count) { }
1638 int count() const { return count_; }
1640 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1647 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1649 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1650 inputs_[0] = function;
1651 temps_[0] = code_object;
1654 LOperand* function() { return inputs_[0]; }
1655 LOperand* code_object() { return temps_[0]; }
1657 virtual void PrintDataTo(StringStream* stream);
1659 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1660 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1664 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1666 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1667 inputs_[0] = base_object;
1668 inputs_[1] = offset;
1671 LOperand* base_object() const { return inputs_[0]; }
1672 LOperand* offset() const { return inputs_[1]; }
1674 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1676 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1680 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1682 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1683 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1687 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1689 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1690 DECLARE_HYDROGEN_ACCESSOR(Context)
1694 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1696 explicit LDeclareGlobals(LOperand* context) {
1697 inputs_[0] = context;
1700 LOperand* context() { return inputs_[0]; }
1702 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1703 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1707 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1709 explicit LCallJSFunction(LOperand* function) {
1710 inputs_[0] = function;
1713 LOperand* function() { return inputs_[0]; }
1715 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1716 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1718 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1720 int arity() const { return hydrogen()->argument_count() - 1; }
1724 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1726 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1727 ZoneList<LOperand*>& operands,
1729 : descriptor_(descriptor),
1730 inputs_(descriptor->environment_length() + 1, zone) {
1731 ASSERT(descriptor->environment_length() + 1 == operands.length());
1732 inputs_.AddAll(operands, zone);
1735 LOperand* target() const { return inputs_[0]; }
1737 const CallInterfaceDescriptor* descriptor() { return descriptor_; }
1740 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1741 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1743 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1745 int arity() const { return hydrogen()->argument_count() - 1; }
1747 const CallInterfaceDescriptor* descriptor_;
1748 ZoneList<LOperand*> inputs_;
1750 // Iterator support.
1751 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1752 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1754 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1755 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1759 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1761 LInvokeFunction(LOperand* context, LOperand* function) {
1762 inputs_[0] = context;
1763 inputs_[1] = function;
1766 LOperand* context() { return inputs_[0]; }
1767 LOperand* function() { return inputs_[1]; }
1769 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1770 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1774 int arity() const { return hydrogen()->argument_count() - 1; }
1778 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1780 LCallFunction(LOperand* context, LOperand* function) {
1781 inputs_[0] = context;
1782 inputs_[1] = function;
1785 LOperand* context() { return inputs_[0]; }
1786 LOperand* function() { return inputs_[1]; }
1788 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1789 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1791 int arity() const { return hydrogen()->argument_count() - 1; }
1795 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1797 LCallNew(LOperand* context, LOperand* constructor) {
1798 inputs_[0] = context;
1799 inputs_[1] = constructor;
1802 LOperand* context() { return inputs_[0]; }
1803 LOperand* constructor() { return inputs_[1]; }
1805 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1806 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1808 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1810 int arity() const { return hydrogen()->argument_count() - 1; }
1814 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1816 LCallNewArray(LOperand* context, LOperand* constructor) {
1817 inputs_[0] = context;
1818 inputs_[1] = constructor;
1821 LOperand* context() { return inputs_[0]; }
1822 LOperand* constructor() { return inputs_[1]; }
1824 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1825 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1827 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1829 int arity() const { return hydrogen()->argument_count() - 1; }
1833 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1835 explicit LCallRuntime(LOperand* context) {
1836 inputs_[0] = context;
1839 LOperand* context() { return inputs_[0]; }
1841 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1842 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1844 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1845 return save_doubles() == kDontSaveFPRegs;
1848 const Runtime::Function* function() const { return hydrogen()->function(); }
1849 int arity() const { return hydrogen()->argument_count(); }
1850 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1854 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1856 explicit LInteger32ToDouble(LOperand* value) {
1860 LOperand* value() { return inputs_[0]; }
1862 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1866 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1868 explicit LInteger32ToSmi(LOperand* value) {
1872 LOperand* value() { return inputs_[0]; }
1874 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1875 DECLARE_HYDROGEN_ACCESSOR(Change)
1879 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1881 explicit LUint32ToDouble(LOperand* value) {
1885 LOperand* value() { return inputs_[0]; }
1887 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1891 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1893 explicit LUint32ToSmi(LOperand* value) {
1897 LOperand* value() { return inputs_[0]; }
1899 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1900 DECLARE_HYDROGEN_ACCESSOR(Change)
1904 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1906 explicit LNumberTagI(LOperand* value) {
1910 LOperand* value() { return inputs_[0]; }
1912 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1916 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1918 explicit LNumberTagU(LOperand* value) {
1922 LOperand* value() { return inputs_[0]; }
1924 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1928 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1930 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1936 LOperand* value() { return inputs_[0]; }
1937 LOperand* temp() { return temps_[0]; }
1938 LOperand* temp2() { return temps_[1]; }
1940 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1941 DECLARE_HYDROGEN_ACCESSOR(Change)
1945 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1947 explicit LDoubleToSmi(LOperand* value) {
1951 LOperand* value() { return inputs_[0]; }
1953 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1954 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1956 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1960 // Sometimes truncating conversion from a tagged value to an int32.
1961 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1963 explicit LDoubleToI(LOperand* value) {
1967 LOperand* value() { return inputs_[0]; }
1969 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1970 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1972 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1976 // Truncating conversion from a tagged value to an int32.
1977 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1979 LTaggedToI(LOperand* value,
1987 LOperand* value() { return inputs_[0]; }
1988 LOperand* temp() { return temps_[0]; }
1989 LOperand* temp2() { return temps_[1]; }
1991 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1992 DECLARE_HYDROGEN_ACCESSOR(Change)
1994 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1998 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2000 explicit LSmiTag(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2010 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2012 explicit LNumberUntagD(LOperand* value) {
2016 LOperand* value() { return inputs_[0]; }
2018 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2019 DECLARE_HYDROGEN_ACCESSOR(Change)
2023 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2025 LSmiUntag(LOperand* value, bool needs_check)
2026 : needs_check_(needs_check) {
2030 LOperand* value() { return inputs_[0]; }
2031 bool needs_check() const { return needs_check_; }
2033 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2040 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2042 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2043 inputs_[0] = object;
2048 LOperand* object() { return inputs_[0]; }
2049 LOperand* value() { return inputs_[1]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2053 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2055 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2057 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2058 Representation representation() const {
2059 return hydrogen()->field_representation();
2064 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2066 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2067 inputs_[0] = context;
2068 inputs_[1] = object;
2072 LOperand* context() { return inputs_[0]; }
2073 LOperand* object() { return inputs_[1]; }
2074 LOperand* value() { return inputs_[2]; }
2076 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2077 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2079 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2081 Handle<Object> name() const { return hydrogen()->name(); }
2082 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2086 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2088 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2089 inputs_[0] = object;
2094 bool is_external() const { return hydrogen()->is_external(); }
2095 bool is_fixed_typed_array() const {
2096 return hydrogen()->is_fixed_typed_array();
2098 bool is_typed_elements() const {
2099 return is_external() || is_fixed_typed_array();
2101 LOperand* elements() { return inputs_[0]; }
2102 LOperand* key() { return inputs_[1]; }
2103 LOperand* value() { return inputs_[2]; }
2104 ElementsKind elements_kind() const {
2105 return hydrogen()->elements_kind();
2108 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2109 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2111 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2112 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2113 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2117 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2119 LStoreKeyedGeneric(LOperand* context,
2123 inputs_[0] = context;
2129 LOperand* context() { return inputs_[0]; }
2130 LOperand* object() { return inputs_[1]; }
2131 LOperand* key() { return inputs_[2]; }
2132 LOperand* value() { return inputs_[3]; }
2134 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2135 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2137 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2139 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2143 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2145 LTransitionElementsKind(LOperand* object,
2147 LOperand* new_map_temp) {
2148 inputs_[0] = object;
2149 inputs_[1] = context;
2150 temps_[0] = new_map_temp;
2153 LOperand* context() { return inputs_[1]; }
2154 LOperand* object() { return inputs_[0]; }
2155 LOperand* new_map_temp() { return temps_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2158 "transition-elements-kind")
2159 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2161 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2163 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2164 Handle<Map> transitioned_map() {
2165 return hydrogen()->transitioned_map().handle();
2167 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2168 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2172 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2174 LTrapAllocationMemento(LOperand* object,
2176 inputs_[0] = object;
2180 LOperand* object() { return inputs_[0]; }
2181 LOperand* temp() { return temps_[0]; }
2183 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2184 "trap-allocation-memento")
2188 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2190 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2191 inputs_[0] = context;
2196 LOperand* context() { return inputs_[0]; }
2197 LOperand* left() { return inputs_[1]; }
2198 LOperand* right() { return inputs_[2]; }
2200 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2201 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2206 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2208 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2209 inputs_[0] = context;
2210 inputs_[1] = string;
2214 LOperand* context() { return inputs_[0]; }
2215 LOperand* string() { return inputs_[1]; }
2216 LOperand* index() { return inputs_[2]; }
2218 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2219 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2223 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2225 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2226 inputs_[0] = context;
2227 inputs_[1] = char_code;
2230 LOperand* context() { return inputs_[0]; }
2231 LOperand* char_code() { return inputs_[1]; }
2233 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2234 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2238 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2240 explicit LCheckValue(LOperand* value) {
2244 LOperand* value() { return inputs_[0]; }
2246 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2247 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2251 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2253 explicit LCheckInstanceType(LOperand* value) {
2257 LOperand* value() { return inputs_[0]; }
2259 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2260 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2264 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2266 explicit LCheckMaps(LOperand* value) {
2270 LOperand* value() { return inputs_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2273 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2277 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2279 explicit LCheckSmi(LOperand* value) {
2283 LOperand* value() { return inputs_[0]; }
2285 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2289 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2291 explicit LCheckNonSmi(LOperand* value) {
2295 LOperand* value() { return inputs_[0]; }
2297 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2298 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2302 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2304 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2305 inputs_[0] = unclamped;
2309 LOperand* unclamped() { return inputs_[0]; }
2310 LOperand* temp() { return temps_[0]; }
2312 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2316 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2318 explicit LClampIToUint8(LOperand* unclamped) {
2319 inputs_[0] = unclamped;
2322 LOperand* unclamped() { return inputs_[0]; }
2324 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2328 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2330 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2331 inputs_[0] = unclamped;
2335 LOperand* unclamped() { return inputs_[0]; }
2336 LOperand* temp() { return temps_[0]; }
2338 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2342 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 2> {
2344 LAllocate(LOperand* context,
2348 inputs_[0] = context;
2354 LOperand* context() { return inputs_[0]; }
2355 LOperand* size() { return inputs_[1]; }
2356 LOperand* temp1() { return temps_[0]; }
2357 LOperand* temp2() { return temps_[1]; }
2359 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2360 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2364 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2366 explicit LRegExpLiteral(LOperand* context) {
2367 inputs_[0] = context;
2370 LOperand* context() { return inputs_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2373 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2377 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2379 explicit LFunctionLiteral(LOperand* context) {
2380 inputs_[0] = context;
2383 LOperand* context() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2386 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2390 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2392 explicit LToFastProperties(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2399 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2403 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2405 LTypeof(LOperand* context, LOperand* value) {
2406 inputs_[0] = context;
2410 LOperand* context() { return inputs_[0]; }
2411 LOperand* value() { return inputs_[1]; }
2413 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2417 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2419 explicit LTypeofIsAndBranch(LOperand* value) {
2423 LOperand* value() { return inputs_[0]; }
2425 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2426 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2428 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2430 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2434 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2436 explicit LIsConstructCallAndBranch(LOperand* temp) {
2440 LOperand* temp() { return temps_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2443 "is-construct-call-and-branch")
2447 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2451 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2454 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2458 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2460 explicit LStackCheck(LOperand* context) {
2461 inputs_[0] = context;
2464 LOperand* context() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2467 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2469 Label* done_label() { return &done_label_; }
2476 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2478 LForInPrepareMap(LOperand* context, LOperand* object) {
2479 inputs_[0] = context;
2480 inputs_[1] = object;
2483 LOperand* context() { return inputs_[0]; }
2484 LOperand* object() { return inputs_[1]; }
2486 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2490 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2492 explicit LForInCacheArray(LOperand* map) {
2496 LOperand* map() { return inputs_[0]; }
2498 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2501 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2506 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2508 LCheckMapValue(LOperand* value, LOperand* map) {
2513 LOperand* value() { return inputs_[0]; }
2514 LOperand* map() { return inputs_[1]; }
2516 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2520 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2522 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2523 inputs_[0] = object;
2527 LOperand* object() { return inputs_[0]; }
2528 LOperand* index() { return inputs_[1]; }
2530 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2534 class LChunkBuilder;
2535 class LPlatformChunk V8_FINAL : public LChunk {
2537 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2538 : LChunk(info, graph) { }
2540 int GetNextSpillIndex(RegisterKind kind);
2541 LOperand* GetNextSpillSlot(RegisterKind kind);
2545 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2547 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2548 : LChunkBuilderBase(graph->zone()),
2553 current_instruction_(NULL),
2554 current_block_(NULL),
2556 allocator_(allocator),
2557 position_(RelocInfo::kNoPosition),
2558 instruction_pending_deoptimization_environment_(NULL),
2559 pending_deoptimization_ast_id_(BailoutId::None()) { }
2561 // Build the sequence for the graph.
2562 LPlatformChunk* Build();
2564 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2566 // Declare methods that deal with the individual node types.
2567 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2568 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2571 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2573 static bool HasMagicNumberForDivisor(int32_t divisor);
2575 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2576 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2577 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2578 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2579 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2580 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2581 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2591 LPlatformChunk* chunk() const { return chunk_; }
2592 CompilationInfo* info() const { return info_; }
2593 HGraph* graph() const { return graph_; }
2595 bool is_unused() const { return status_ == UNUSED; }
2596 bool is_building() const { return status_ == BUILDING; }
2597 bool is_done() const { return status_ == DONE; }
2598 bool is_aborted() const { return status_ == ABORTED; }
2600 void Abort(BailoutReason reason);
2602 // Methods for getting operands for Use / Define / Temp.
2603 LUnallocated* ToUnallocated(Register reg);
2604 LUnallocated* ToUnallocated(DoubleRegister reg);
2606 // Methods for setting up define-use relationships.
2607 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2608 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2609 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2610 DoubleRegister fixed_register);
2612 // A value that is guaranteed to be allocated to a register.
2613 // Operand created by UseRegister is guaranteed to be live until the end of
2614 // instruction. This means that register allocator will not reuse it's
2615 // register for any other operand inside instruction.
2616 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2617 // instruction start. Register allocator is free to assign the same register
2618 // to some other operand used inside instruction (i.e. temporary or
2620 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2621 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2623 // An input operand in a register that may be trashed.
2624 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2626 // An input operand in a register or stack slot.
2627 MUST_USE_RESULT LOperand* Use(HValue* value);
2628 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2630 // An input operand in a register, stack slot or a constant operand.
2631 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2632 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2634 // An input operand in a register or a constant operand.
2635 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2636 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2638 // An input operand in a constant operand.
2639 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2641 // An input operand in register, stack slot or a constant operand.
2642 // Will not be moved to a register even if one is freely available.
2643 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2645 // Temporary operand that must be in a register.
2646 MUST_USE_RESULT LUnallocated* TempRegister();
2647 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2648 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2650 // Methods for setting up define-use relationships.
2651 // Return the same instruction that they are passed.
2652 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2653 LUnallocated* result);
2654 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2655 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2657 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2658 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2660 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2661 DoubleRegister reg);
2662 LInstruction* AssignEnvironment(LInstruction* instr);
2663 LInstruction* AssignPointerMap(LInstruction* instr);
2665 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2667 // By default we assume that instruction sequences generated for calls
2668 // cannot deoptimize eagerly and we do not attach environment to this
2670 LInstruction* MarkAsCall(
2671 LInstruction* instr,
2672 HInstruction* hinstr,
2673 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2675 void VisitInstruction(HInstruction* current);
2677 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2678 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2679 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2680 LInstruction* DoArithmeticD(Token::Value op,
2681 HArithmeticBinaryOperation* instr);
2682 LInstruction* DoArithmeticT(Token::Value op,
2683 HBinaryOperation* instr);
2685 LPlatformChunk* chunk_;
2686 CompilationInfo* info_;
2687 HGraph* const graph_;
2689 HInstruction* current_instruction_;
2690 HBasicBlock* current_block_;
2691 HBasicBlock* next_block_;
2692 LAllocator* allocator_;
2694 LInstruction* instruction_pending_deoptimization_environment_;
2695 BailoutId pending_deoptimization_ast_id_;
2697 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2700 #undef DECLARE_HYDROGEN_ACCESSOR
2701 #undef DECLARE_CONCRETE_INSTRUCTION
2703 } } // namespace v8::internal
2705 #endif // V8_MIPS_LITHIUM_MIPS_H_