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_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_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) \
98 V(FlooringDivByConstI) \
99 V(FlooringDivByPowerOf2I) \
103 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
114 V(IsConstructCallAndBranch) \
115 V(IsObjectAndBranch) \
116 V(IsStringAndBranch) \
118 V(IsUndetectableAndBranch) \
123 V(LoadFieldByIndex) \
124 V(LoadFunctionPrototype) \
126 V(LoadGlobalGeneric) \
128 V(LoadKeyedGeneric) \
130 V(LoadNamedGeneric) \
155 V(SeqStringGetChar) \
156 V(SeqStringSetChar) \
162 V(StoreContextSlot) \
165 V(StoreKeyedGeneric) \
167 V(StoreNamedGeneric) \
169 V(StringCharCodeAt) \
170 V(StringCharFromCode) \
171 V(StringCompareAndBranch) \
175 V(ToFastProperties) \
176 V(TransitionElementsKind) \
177 V(TrapAllocationMemento) \
179 V(TypeofIsAndBranch) \
186 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
187 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
188 return LInstruction::k##type; \
190 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
191 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
194 static L##type* cast(LInstruction* instr) { \
195 ASSERT(instr->Is##type()); \
196 return reinterpret_cast<L##type*>(instr); \
200 #define DECLARE_HYDROGEN_ACCESSOR(type) \
201 H##type* hydrogen() const { \
202 return H##type::cast(hydrogen_value()); \
206 class LInstruction : public ZoneObject {
209 : environment_(NULL),
210 hydrogen_value_(NULL),
211 bit_field_(IsCallBits::encode(false)) {
214 virtual ~LInstruction() {}
216 virtual void CompileToNative(LCodeGen* generator) = 0;
217 virtual const char* Mnemonic() const = 0;
218 virtual void PrintTo(StringStream* stream);
219 virtual void PrintDataTo(StringStream* stream);
220 virtual void PrintOutputOperandTo(StringStream* stream);
223 // Declare a unique enum value for each instruction.
224 #define DECLARE_OPCODE(type) k##type,
225 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
226 kNumberOfInstructions
227 #undef DECLARE_OPCODE
230 virtual Opcode opcode() const = 0;
232 // Declare non-virtual type testers for all leaf IR classes.
233 #define DECLARE_PREDICATE(type) \
234 bool Is##type() const { return opcode() == k##type; }
235 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
236 #undef DECLARE_PREDICATE
238 // Declare virtual predicates for instructions that don't have
240 virtual bool IsGap() const { return false; }
242 virtual bool IsControl() const { return false; }
244 void set_environment(LEnvironment* env) { environment_ = env; }
245 LEnvironment* environment() const { return environment_; }
246 bool HasEnvironment() const { return environment_ != NULL; }
248 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
249 LPointerMap* pointer_map() const { return pointer_map_.get(); }
250 bool HasPointerMap() const { return pointer_map_.is_set(); }
252 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
253 HValue* hydrogen_value() const { return hydrogen_value_; }
255 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
256 bool IsCall() const { return IsCallBits::decode(bit_field_); }
258 // Interface to the register allocator and iterators.
259 bool ClobbersTemps() const { return IsCall(); }
260 bool ClobbersRegisters() const { return IsCall(); }
261 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
263 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
265 // Interface to the register allocator and iterators.
266 bool IsMarkedAsCall() const { return IsCall(); }
268 virtual bool HasResult() const = 0;
269 virtual LOperand* result() const = 0;
271 LOperand* FirstInput() { return InputAt(0); }
272 LOperand* Output() { return HasResult() ? result() : NULL; }
274 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
282 friend class InputIterator;
283 virtual int InputCount() = 0;
284 virtual LOperand* InputAt(int i) = 0;
286 friend class TempIterator;
287 virtual int TempCount() = 0;
288 virtual LOperand* TempAt(int i) = 0;
290 class IsCallBits: public BitField<bool, 0, 1> {};
292 LEnvironment* environment_;
293 SetOncePointer<LPointerMap> pointer_map_;
294 HValue* hydrogen_value_;
299 // R = number of result operands (0 or 1).
301 class LTemplateResultInstruction : public LInstruction {
303 // Allow 0 or 1 output operands.
304 STATIC_ASSERT(R == 0 || R == 1);
305 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
306 return R != 0 && result() != NULL;
308 void set_result(LOperand* operand) { results_[0] = operand; }
309 LOperand* result() const { return results_[0]; }
312 EmbeddedContainer<LOperand*, R> results_;
316 // R = number of result operands (0 or 1).
317 // I = number of input operands.
318 // T = number of temporary operands.
319 template<int R, int I, int T>
320 class LTemplateInstruction : public LTemplateResultInstruction<R> {
322 EmbeddedContainer<LOperand*, I> inputs_;
323 EmbeddedContainer<LOperand*, T> temps_;
327 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
328 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
330 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
331 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
335 class LGap : public LTemplateInstruction<0, 0, 0> {
337 explicit LGap(HBasicBlock* block)
339 parallel_moves_[BEFORE] = NULL;
340 parallel_moves_[START] = NULL;
341 parallel_moves_[END] = NULL;
342 parallel_moves_[AFTER] = NULL;
345 // Can't use the DECLARE-macro here because of sub-classes.
346 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
347 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
348 static LGap* cast(LInstruction* instr) {
349 ASSERT(instr->IsGap());
350 return reinterpret_cast<LGap*>(instr);
353 bool IsRedundant() const;
355 HBasicBlock* block() const { return block_; }
362 FIRST_INNER_POSITION = BEFORE,
363 LAST_INNER_POSITION = AFTER
366 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
368 if (parallel_moves_[pos] == NULL) {
369 parallel_moves_[pos] = new(zone) LParallelMove(zone);
371 return parallel_moves_[pos];
374 LParallelMove* GetParallelMove(InnerPosition pos) {
375 return parallel_moves_[pos];
379 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
384 class LInstructionGap V8_FINAL : public LGap {
386 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
389 return !IsRedundant();
392 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
396 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
398 explicit LGoto(HBasicBlock* block) : block_(block) { }
400 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
401 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
402 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
403 virtual bool IsControl() const V8_OVERRIDE { return true; }
405 int block_id() const { return block_->block_id(); }
412 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
414 LLazyBailout() : gap_instructions_size_(0) { }
416 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 void set_gap_instructions_size(int gap_instructions_size) {
419 gap_instructions_size_ = gap_instructions_size;
421 int gap_instructions_size() { return gap_instructions_size_; }
424 int gap_instructions_size_;
428 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
430 explicit LDummy() { }
431 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
435 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
437 explicit LDummyUse(LOperand* value) {
440 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
444 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
446 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
447 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
451 class LLabel V8_FINAL : public LGap {
453 explicit LLabel(HBasicBlock* block)
454 : LGap(block), replacement_(NULL) { }
456 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
459 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
461 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
463 int block_id() const { return block()->block_id(); }
464 bool is_loop_header() const { return block()->IsLoopHeader(); }
465 bool is_osr_entry() const { return block()->is_osr_entry(); }
466 Label* label() { return &label_; }
467 LLabel* replacement() const { return replacement_; }
468 void set_replacement(LLabel* label) { replacement_ = label; }
469 bool HasReplacement() const { return replacement_ != NULL; }
473 LLabel* replacement_;
477 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
479 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
482 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
486 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
488 explicit LCallStub(LOperand* context) {
489 inputs_[0] = context;
492 LOperand* context() { return inputs_[0]; }
494 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
495 DECLARE_HYDROGEN_ACCESSOR(CallStub)
499 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
501 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
562 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
563 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
567 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
569 LApplyArguments(LOperand* function,
572 LOperand* elements) {
573 inputs_[0] = function;
574 inputs_[1] = receiver;
576 inputs_[3] = elements;
579 LOperand* function() { return inputs_[0]; }
580 LOperand* receiver() { return inputs_[1]; }
581 LOperand* length() { return inputs_[2]; }
582 LOperand* elements() { return inputs_[3]; }
584 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
588 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
590 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
591 inputs_[0] = arguments;
596 LOperand* arguments() { return inputs_[0]; }
597 LOperand* length() { return inputs_[1]; }
598 LOperand* index() { return inputs_[2]; }
600 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
602 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
606 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
608 explicit LArgumentsLength(LOperand* elements) {
609 inputs_[0] = elements;
612 LOperand* elements() { return inputs_[0]; }
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
618 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
621 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
625 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
627 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
628 inputs_[0] = dividend;
632 LOperand* dividend() { return inputs_[0]; }
633 int32_t divisor() const { return divisor_; }
635 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
643 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
645 LModByConstI(LOperand* dividend,
649 inputs_[0] = dividend;
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
657 LOperand* temp1() { return temps_[0]; }
658 LOperand* temp2() { return temps_[1]; }
660 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
661 DECLARE_HYDROGEN_ACCESSOR(Mod)
668 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
670 LModI(LOperand* left, LOperand* right, LOperand* temp) {
676 LOperand* left() { return inputs_[0]; }
677 LOperand* right() { return inputs_[1]; }
678 LOperand* temp() { return temps_[0]; }
680 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
681 DECLARE_HYDROGEN_ACCESSOR(Mod)
685 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
687 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
688 inputs_[0] = dividend;
692 LOperand* dividend() { return inputs_[0]; }
693 int32_t divisor() const { return divisor_; }
695 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
696 DECLARE_HYDROGEN_ACCESSOR(Div)
703 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
705 LDivByConstI(LOperand* dividend,
709 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
717 LOperand* temp1() { return temps_[0]; }
718 LOperand* temp2() { return temps_[1]; }
720 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
721 DECLARE_HYDROGEN_ACCESSOR(Div)
728 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
730 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
736 LOperand* left() { return inputs_[0]; }
737 LOperand* right() { return inputs_[1]; }
738 LOperand* temp() { return temps_[0]; }
740 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
742 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
743 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
747 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
749 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
750 inputs_[0] = dividend;
754 LOperand* dividend() { return inputs_[0]; }
755 int32_t divisor() const { return divisor_; }
757 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
758 "flooring-div-by-power-of-2-i")
759 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
766 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
768 LFlooringDivByConstI(LOperand* dividend,
772 inputs_[0] = dividend;
778 LOperand* dividend() { return inputs_[0]; }
779 int32_t divisor() const { return divisor_; }
780 LOperand* temp1() { return temps_[0]; }
781 LOperand* temp2() { return temps_[0]; }
783 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
784 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
791 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
793 LMulI(LOperand* left, LOperand* right) {
798 LOperand* left() { return inputs_[0]; }
799 LOperand* right() { return inputs_[1]; }
801 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
802 DECLARE_HYDROGEN_ACCESSOR(Mul)
806 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
808 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
813 LOperand* left() { return inputs_[0]; }
814 LOperand* right() { return inputs_[1]; }
816 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
817 "compare-numeric-and-branch")
818 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
820 Token::Value op() const { return hydrogen()->token(); }
821 bool is_double() const {
822 return hydrogen()->representation().IsDouble();
825 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
829 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
831 explicit LMathFloor(LOperand* value) {
835 LOperand* value() { return inputs_[0]; }
837 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
838 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
842 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
844 explicit LMathRound(LOperand* value) {
848 LOperand* value() { return inputs_[0]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
851 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
855 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
857 explicit LMathAbs(LOperand* context, LOperand* value) {
858 inputs_[1] = context;
862 LOperand* context() { return inputs_[1]; }
863 LOperand* value() { return inputs_[0]; }
865 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
866 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
870 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
872 explicit LMathLog(LOperand* value) {
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
882 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
884 explicit LMathClz32(LOperand* value) {
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
894 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
896 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
900 ExternalReference::InitializeMathExpData();
903 LOperand* value() { return inputs_[0]; }
904 LOperand* temp1() { return temps_[0]; }
905 LOperand* temp2() { return temps_[1]; }
907 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
911 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
913 explicit LMathSqrt(LOperand* value) {
917 LOperand* value() { return inputs_[0]; }
919 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
923 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
925 explicit LMathPowHalf(LOperand* value) {
929 LOperand* value() { return inputs_[0]; }
931 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
935 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
937 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
942 LOperand* left() { return inputs_[0]; }
943 LOperand* right() { return inputs_[1]; }
945 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
949 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
951 explicit LCmpHoleAndBranch(LOperand* object) {
955 LOperand* object() { return inputs_[0]; }
957 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
958 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
962 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
964 explicit LCompareMinusZeroAndBranch(LOperand* value) {
968 LOperand* value() { return inputs_[0]; }
970 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
971 "cmp-minus-zero-and-branch")
972 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
977 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
979 explicit LIsObjectAndBranch(LOperand* value) {
983 LOperand* value() { return inputs_[0]; }
985 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
986 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
988 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
992 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
994 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
999 LOperand* value() { return inputs_[0]; }
1000 LOperand* temp() { return temps_[0]; }
1002 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1005 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1009 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1011 explicit LIsSmiAndBranch(LOperand* value) {
1015 LOperand* value() { return inputs_[0]; }
1017 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1018 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1020 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1024 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1026 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1031 LOperand* value() { return inputs_[0]; }
1032 LOperand* temp() { return temps_[0]; }
1034 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1035 "is-undetectable-and-branch")
1036 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1038 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1042 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1044 explicit LStringCompareAndBranch(LOperand* context,
1047 inputs_[0] = context;
1052 LOperand* context() { return inputs_[0]; }
1053 LOperand* left() { return inputs_[1]; }
1054 LOperand* right() { return inputs_[2]; }
1056 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1057 "string-compare-and-branch")
1058 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1060 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1062 Token::Value op() const { return hydrogen()->token(); }
1066 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1068 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1072 LOperand* value() { return inputs_[0]; }
1074 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1075 "has-instance-type-and-branch")
1076 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1078 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1082 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1084 explicit LGetCachedArrayIndex(LOperand* value) {
1088 LOperand* value() { return inputs_[0]; }
1090 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1091 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1095 class LHasCachedArrayIndexAndBranch V8_FINAL
1096 : public LControlInstruction<1, 0> {
1098 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1102 LOperand* value() { return inputs_[0]; }
1104 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1105 "has-cached-array-index-and-branch")
1106 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1108 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1112 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1114 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1120 LOperand* value() { return inputs_[0]; }
1121 LOperand* temp() { return temps_[0]; }
1122 LOperand* temp2() { return temps_[1]; }
1124 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1125 "class-of-test-and-branch")
1126 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1128 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1132 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1134 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1135 inputs_[0] = context;
1140 LOperand* context() { return inputs_[0]; }
1141 LOperand* left() { return inputs_[1]; }
1142 LOperand* right() { return inputs_[2]; }
1144 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1145 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1147 Token::Value op() const { return hydrogen()->token(); }
1151 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1153 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1154 inputs_[0] = context;
1159 LOperand* context() { return inputs_[0]; }
1160 LOperand* left() { return inputs_[1]; }
1161 LOperand* right() { return inputs_[2]; }
1163 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1167 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1169 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1170 inputs_[0] = context;
1175 LOperand* context() { return inputs_[0]; }
1176 LOperand* value() { return inputs_[1]; }
1177 LOperand* temp() { return temps_[0]; }
1179 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1180 "instance-of-known-global")
1181 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1183 Handle<JSFunction> function() const { return hydrogen()->function(); }
1184 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1185 return lazy_deopt_env_;
1187 virtual void SetDeferredLazyDeoptimizationEnvironment(
1188 LEnvironment* env) V8_OVERRIDE {
1189 lazy_deopt_env_ = env;
1193 LEnvironment* lazy_deopt_env_;
1197 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1199 LBoundsCheck(LOperand* index, LOperand* length) {
1201 inputs_[1] = length;
1204 LOperand* index() { return inputs_[0]; }
1205 LOperand* length() { return inputs_[1]; }
1207 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1208 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1212 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1214 LBitI(LOperand* left, LOperand* right) {
1219 LOperand* left() { return inputs_[0]; }
1220 LOperand* right() { return inputs_[1]; }
1222 Token::Value op() const { return hydrogen()->op(); }
1224 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1225 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1229 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1231 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1232 : op_(op), can_deopt_(can_deopt) {
1237 Token::Value op() const { return op_; }
1238 LOperand* left() { return inputs_[0]; }
1239 LOperand* right() { return inputs_[1]; }
1240 bool can_deopt() const { return can_deopt_; }
1242 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1250 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1252 LSubI(LOperand* left, LOperand* right) {
1257 LOperand* left() { return inputs_[0]; }
1258 LOperand* right() { return inputs_[1]; }
1260 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1261 DECLARE_HYDROGEN_ACCESSOR(Sub)
1265 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1267 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1268 DECLARE_HYDROGEN_ACCESSOR(Constant)
1270 int32_t value() const { return hydrogen()->Integer32Value(); }
1274 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1276 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1277 DECLARE_HYDROGEN_ACCESSOR(Constant)
1279 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1283 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1285 explicit LConstantD(LOperand* temp) {
1289 LOperand* temp() { return temps_[0]; }
1291 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1292 DECLARE_HYDROGEN_ACCESSOR(Constant)
1294 double value() const { return hydrogen()->DoubleValue(); }
1298 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 ExternalReference value() const {
1304 return hydrogen()->ExternalReferenceValue();
1309 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1311 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1312 DECLARE_HYDROGEN_ACCESSOR(Constant)
1314 Handle<Object> value(Isolate* isolate) const {
1315 return hydrogen()->handle(isolate);
1320 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1322 explicit LBranch(LOperand* value) {
1326 LOperand* value() { return inputs_[0]; }
1328 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1329 DECLARE_HYDROGEN_ACCESSOR(Branch)
1331 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1335 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1341 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1343 explicit LCmpMapAndBranch(LOperand* value) {
1347 LOperand* value() { return inputs_[0]; }
1349 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1350 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1352 Handle<Map> map() const { return hydrogen()->map().handle(); }
1356 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1358 explicit LMapEnumLength(LOperand* value) {
1362 LOperand* value() { return inputs_[0]; }
1364 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1368 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1370 LDateField(LOperand* date, Smi* index) : index_(index) {
1374 LOperand* date() { return inputs_[0]; }
1375 Smi* index() const { return index_; }
1377 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1378 DECLARE_HYDROGEN_ACCESSOR(DateField)
1385 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1387 LSeqStringGetChar(LOperand* string, LOperand* index) {
1388 inputs_[0] = string;
1392 LOperand* string() const { return inputs_[0]; }
1393 LOperand* index() const { return inputs_[1]; }
1395 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1396 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1400 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1402 LSeqStringSetChar(LOperand* context,
1406 inputs_[0] = context;
1407 inputs_[1] = string;
1412 LOperand* string() { return inputs_[1]; }
1413 LOperand* index() { return inputs_[2]; }
1414 LOperand* value() { return inputs_[3]; }
1416 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1417 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1421 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1423 LAddI(LOperand* left, LOperand* right) {
1428 LOperand* left() { return inputs_[0]; }
1429 LOperand* right() { return inputs_[1]; }
1431 static bool UseLea(HAdd* add) {
1432 return !add->CheckFlag(HValue::kCanOverflow) &&
1433 add->BetterLeftOperand()->UseCount() > 1;
1436 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1437 DECLARE_HYDROGEN_ACCESSOR(Add)
1441 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1443 LMathMinMax(LOperand* left, LOperand* right) {
1448 LOperand* left() { return inputs_[0]; }
1449 LOperand* right() { return inputs_[1]; }
1451 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1452 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1456 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1458 LPower(LOperand* left, LOperand* right) {
1463 LOperand* left() { return inputs_[0]; }
1464 LOperand* right() { return inputs_[1]; }
1466 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1467 DECLARE_HYDROGEN_ACCESSOR(Power)
1471 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1473 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1479 Token::Value op() const { return op_; }
1480 LOperand* left() { return inputs_[0]; }
1481 LOperand* right() { return inputs_[1]; }
1483 virtual Opcode opcode() const V8_OVERRIDE {
1484 return LInstruction::kArithmeticD;
1486 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1487 virtual const char* Mnemonic() const V8_OVERRIDE;
1494 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1496 LArithmeticT(Token::Value op,
1501 inputs_[0] = context;
1506 Token::Value op() const { return op_; }
1507 LOperand* context() { return inputs_[0]; }
1508 LOperand* left() { return inputs_[1]; }
1509 LOperand* right() { return inputs_[2]; }
1511 virtual Opcode opcode() const V8_OVERRIDE {
1512 return LInstruction::kArithmeticT;
1514 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1515 virtual const char* Mnemonic() const V8_OVERRIDE;
1522 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1524 explicit LReturn(LOperand* value,
1526 LOperand* parameter_count) {
1528 inputs_[1] = context;
1529 inputs_[2] = parameter_count;
1532 LOperand* value() { return inputs_[0]; }
1533 LOperand* context() { return inputs_[1]; }
1535 bool has_constant_parameter_count() {
1536 return parameter_count()->IsConstantOperand();
1538 LConstantOperand* constant_parameter_count() {
1539 ASSERT(has_constant_parameter_count());
1540 return LConstantOperand::cast(parameter_count());
1542 LOperand* parameter_count() { return inputs_[2]; }
1544 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1545 DECLARE_HYDROGEN_ACCESSOR(Return)
1549 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1551 explicit LLoadNamedField(LOperand* object) {
1552 inputs_[0] = object;
1555 LOperand* object() { return inputs_[0]; }
1557 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1558 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1562 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1564 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1565 inputs_[0] = context;
1566 inputs_[1] = object;
1569 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1570 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1572 LOperand* context() { return inputs_[0]; }
1573 LOperand* object() { return inputs_[1]; }
1574 Handle<Object> name() const { return hydrogen()->name(); }
1578 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1580 explicit LLoadFunctionPrototype(LOperand* function) {
1581 inputs_[0] = function;
1584 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1585 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1587 LOperand* function() { return inputs_[0]; }
1591 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1593 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1596 Heap::RootListIndex index() const { return hydrogen()->index(); }
1600 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1602 LLoadKeyed(LOperand* elements, LOperand* key) {
1603 inputs_[0] = elements;
1607 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1608 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1610 bool is_external() const {
1611 return hydrogen()->is_external();
1613 bool is_fixed_typed_array() const {
1614 return hydrogen()->is_fixed_typed_array();
1616 bool is_typed_elements() const {
1617 return is_external() || is_fixed_typed_array();
1619 LOperand* elements() { return inputs_[0]; }
1620 LOperand* key() { return inputs_[1]; }
1621 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1622 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1623 ElementsKind elements_kind() const {
1624 return hydrogen()->elements_kind();
1629 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1631 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1632 inputs_[0] = context;
1637 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1639 LOperand* context() { return inputs_[0]; }
1640 LOperand* object() { return inputs_[1]; }
1641 LOperand* key() { return inputs_[2]; }
1645 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1647 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1648 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1652 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1654 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1655 inputs_[0] = context;
1656 inputs_[1] = global_object;
1659 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1660 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1662 LOperand* context() { return inputs_[0]; }
1663 LOperand* global_object() { return inputs_[1]; }
1664 Handle<Object> name() const { return hydrogen()->name(); }
1665 bool for_typeof() const { return hydrogen()->for_typeof(); }
1669 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1671 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1676 LOperand* value() { return inputs_[0]; }
1677 LOperand* temp() { return temps_[0]; }
1679 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1680 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1684 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1686 explicit LLoadContextSlot(LOperand* context) {
1687 inputs_[0] = context;
1690 LOperand* context() { return inputs_[0]; }
1692 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1693 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1695 int slot_index() { return hydrogen()->slot_index(); }
1697 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1701 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1703 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1704 inputs_[0] = context;
1709 LOperand* context() { return inputs_[0]; }
1710 LOperand* value() { return inputs_[1]; }
1711 LOperand* temp() { return temps_[0]; }
1713 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1714 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1716 int slot_index() { return hydrogen()->slot_index(); }
1718 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1722 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1724 explicit LPushArgument(LOperand* value) {
1728 LOperand* value() { return inputs_[0]; }
1730 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1734 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1736 explicit LDrop(int count) : count_(count) { }
1738 int count() const { return count_; }
1740 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1747 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1749 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1750 inputs_[0] = function;
1751 temps_[0] = code_object;
1754 LOperand* function() { return inputs_[0]; }
1755 LOperand* code_object() { return temps_[0]; }
1757 virtual void PrintDataTo(StringStream* stream);
1759 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1760 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1764 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1766 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1767 inputs_[0] = base_object;
1768 inputs_[1] = offset;
1771 LOperand* base_object() const { return inputs_[0]; }
1772 LOperand* offset() const { return inputs_[1]; }
1774 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1776 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1780 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1782 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1783 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1787 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1789 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1790 DECLARE_HYDROGEN_ACCESSOR(Context)
1794 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1796 explicit LDeclareGlobals(LOperand* context) {
1797 inputs_[0] = context;
1800 LOperand* context() { return inputs_[0]; }
1802 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1803 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1807 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1809 explicit LCallJSFunction(LOperand* function) {
1810 inputs_[0] = function;
1813 LOperand* function() { return inputs_[0]; }
1815 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1816 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1818 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1820 int arity() const { return hydrogen()->argument_count() - 1; }
1824 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1826 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1827 ZoneList<LOperand*>& operands,
1829 : inputs_(descriptor->environment_length() + 1, zone) {
1830 ASSERT(descriptor->environment_length() + 1 == operands.length());
1831 inputs_.AddAll(operands, zone);
1834 LOperand* target() const { return inputs_[0]; }
1837 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1838 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1840 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1842 int arity() const { return hydrogen()->argument_count() - 1; }
1844 ZoneList<LOperand*> inputs_;
1846 // Iterator support.
1847 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1848 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1850 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1851 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1855 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1857 LInvokeFunction(LOperand* context, LOperand* function) {
1858 inputs_[0] = context;
1859 inputs_[1] = function;
1862 LOperand* context() { return inputs_[0]; }
1863 LOperand* function() { return inputs_[1]; }
1865 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1866 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1868 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1870 int arity() const { return hydrogen()->argument_count() - 1; }
1874 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1876 LCallFunction(LOperand* context, LOperand* function) {
1877 inputs_[0] = context;
1878 inputs_[1] = function;
1881 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1882 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1884 LOperand* context() { return inputs_[0]; }
1885 LOperand* function() { return inputs_[1]; }
1886 int arity() const { return hydrogen()->argument_count() - 1; }
1890 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1892 LCallNew(LOperand* context, LOperand* constructor) {
1893 inputs_[0] = context;
1894 inputs_[1] = constructor;
1897 LOperand* context() { return inputs_[0]; }
1898 LOperand* constructor() { return inputs_[1]; }
1900 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1901 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1903 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1905 int arity() const { return hydrogen()->argument_count() - 1; }
1909 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1911 LCallNewArray(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(CallNewArray, "call-new-array")
1920 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1922 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1924 int arity() const { return hydrogen()->argument_count() - 1; }
1928 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1930 explicit LCallRuntime(LOperand* context) {
1931 inputs_[0] = context;
1934 LOperand* context() { return inputs_[0]; }
1936 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1937 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1939 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1940 return save_doubles() == kDontSaveFPRegs;
1943 const Runtime::Function* function() const { return hydrogen()->function(); }
1944 int arity() const { return hydrogen()->argument_count(); }
1945 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1949 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1951 explicit LInteger32ToDouble(LOperand* value) {
1955 LOperand* value() { return inputs_[0]; }
1957 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1961 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1963 explicit LInteger32ToSmi(LOperand* value) {
1967 LOperand* value() { return inputs_[0]; }
1969 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1970 DECLARE_HYDROGEN_ACCESSOR(Change)
1974 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1976 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1981 LOperand* value() { return inputs_[0]; }
1982 LOperand* temp() { return temps_[0]; }
1984 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1988 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1990 explicit LUint32ToSmi(LOperand* value) {
1994 LOperand* value() { return inputs_[0]; }
1996 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1997 DECLARE_HYDROGEN_ACCESSOR(Change)
2001 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2003 explicit LNumberTagI(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2013 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp1() { return temps_[0]; }
2023 LOperand* temp2() { return temps_[1]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2029 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2031 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2036 LOperand* value() { return inputs_[0]; }
2037 LOperand* temp() { return temps_[0]; }
2039 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2040 DECLARE_HYDROGEN_ACCESSOR(Change)
2044 // Sometimes truncating conversion from a tagged value to an int32.
2045 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2047 explicit LDoubleToI(LOperand* value) {
2051 LOperand* value() { return inputs_[0]; }
2053 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2054 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2056 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2060 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2062 explicit LDoubleToSmi(LOperand* value) {
2066 LOperand* value() { return inputs_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2069 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 // Truncating conversion from a tagged value to an int32.
2074 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2076 LTaggedToI(LOperand* value, LOperand* temp) {
2081 LOperand* value() { return inputs_[0]; }
2082 LOperand* temp() { return temps_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2085 DECLARE_HYDROGEN_ACCESSOR(Change)
2087 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2091 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2093 explicit LSmiTag(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2103 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2105 explicit LNumberUntagD(LOperand* value) {
2109 LOperand* value() { return inputs_[0]; }
2111 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2112 DECLARE_HYDROGEN_ACCESSOR(Change);
2116 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2118 LSmiUntag(LOperand* value, bool needs_check)
2119 : needs_check_(needs_check) {
2123 LOperand* value() { return inputs_[0]; }
2124 bool needs_check() const { return needs_check_; }
2126 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2133 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2135 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2136 inputs_[0] = object;
2141 LOperand* object() { return inputs_[0]; }
2142 LOperand* value() { return inputs_[1]; }
2143 LOperand* temp() { return temps_[0]; }
2145 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2146 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2148 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2150 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2151 Representation representation() const {
2152 return hydrogen()->field_representation();
2157 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2159 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2160 inputs_[0] = context;
2161 inputs_[1] = object;
2165 LOperand* context() { return inputs_[0]; }
2166 LOperand* object() { return inputs_[1]; }
2167 LOperand* value() { return inputs_[2]; }
2169 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2170 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2172 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2174 Handle<Object> name() const { return hydrogen()->name(); }
2175 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2179 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2181 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2182 inputs_[0] = object;
2187 bool is_external() const { return hydrogen()->is_external(); }
2188 bool is_fixed_typed_array() const {
2189 return hydrogen()->is_fixed_typed_array();
2191 bool is_typed_elements() const {
2192 return is_external() || is_fixed_typed_array();
2194 LOperand* elements() { return inputs_[0]; }
2195 LOperand* key() { return inputs_[1]; }
2196 LOperand* value() { return inputs_[2]; }
2197 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2199 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2200 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2202 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2203 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2204 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2208 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2210 LStoreKeyedGeneric(LOperand* context,
2214 inputs_[0] = context;
2215 inputs_[1] = object;
2220 LOperand* context() { return inputs_[0]; }
2221 LOperand* object() { return inputs_[1]; }
2222 LOperand* key() { return inputs_[2]; }
2223 LOperand* value() { return inputs_[3]; }
2225 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2226 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2228 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2230 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2234 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2236 LTransitionElementsKind(LOperand* object,
2238 LOperand* new_map_temp,
2240 inputs_[0] = object;
2241 inputs_[1] = context;
2242 temps_[0] = new_map_temp;
2246 LOperand* object() { return inputs_[0]; }
2247 LOperand* context() { return inputs_[1]; }
2248 LOperand* new_map_temp() { return temps_[0]; }
2249 LOperand* temp() { return temps_[1]; }
2251 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2252 "transition-elements-kind")
2253 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2255 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2257 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2258 Handle<Map> transitioned_map() {
2259 return hydrogen()->transitioned_map().handle();
2261 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2262 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2266 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2268 LTrapAllocationMemento(LOperand* object,
2270 inputs_[0] = object;
2274 LOperand* object() { return inputs_[0]; }
2275 LOperand* temp() { return temps_[0]; }
2277 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2278 "trap-allocation-memento")
2282 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2284 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2285 inputs_[0] = context;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* left() { return inputs_[1]; }
2292 LOperand* right() { return inputs_[2]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2295 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2299 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2301 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2302 inputs_[0] = context;
2303 inputs_[1] = string;
2307 LOperand* context() { return inputs_[0]; }
2308 LOperand* string() { return inputs_[1]; }
2309 LOperand* index() { return inputs_[2]; }
2311 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2312 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2316 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2318 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2319 inputs_[0] = context;
2320 inputs_[1] = char_code;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* char_code() { return inputs_[1]; }
2326 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2327 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2331 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckValue(LOperand* value) {
2337 LOperand* value() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2340 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2344 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2346 explicit LCheckInstanceType(LOperand* value) {
2350 LOperand* value() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2353 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2357 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2359 explicit LCheckMaps(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2366 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2370 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2372 explicit LCheckSmi(LOperand* value) {
2376 LOperand* value() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2382 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2384 explicit LClampDToUint8(LOperand* unclamped) {
2385 inputs_[0] = unclamped;
2388 LOperand* unclamped() { return inputs_[0]; }
2390 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2394 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2396 explicit LClampIToUint8(LOperand* unclamped) {
2397 inputs_[0] = unclamped;
2400 LOperand* unclamped() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2406 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2408 LClampTToUint8(LOperand* unclamped,
2409 LOperand* temp_xmm) {
2410 inputs_[0] = unclamped;
2411 temps_[0] = temp_xmm;
2414 LOperand* unclamped() { return inputs_[0]; }
2415 LOperand* temp_xmm() { return temps_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2421 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2423 explicit LCheckNonSmi(LOperand* value) {
2427 LOperand* value() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2430 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2434 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2436 explicit LDoubleBits(LOperand* value) {
2440 LOperand* value() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2443 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2447 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2449 LConstructDouble(LOperand* hi, LOperand* lo) {
2454 LOperand* hi() { return inputs_[0]; }
2455 LOperand* lo() { return inputs_[1]; }
2457 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2461 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2463 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2464 inputs_[0] = context;
2469 LOperand* context() { return inputs_[0]; }
2470 LOperand* size() { return inputs_[1]; }
2471 LOperand* temp() { return temps_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2474 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2478 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2480 explicit LRegExpLiteral(LOperand* context) {
2481 inputs_[0] = context;
2484 LOperand* context() { return inputs_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2487 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2491 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2493 explicit LFunctionLiteral(LOperand* context) {
2494 inputs_[0] = context;
2497 LOperand* context() { return inputs_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2500 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2504 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2506 explicit LToFastProperties(LOperand* value) {
2510 LOperand* value() { return inputs_[0]; }
2512 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2513 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2517 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2519 LTypeof(LOperand* context, LOperand* value) {
2520 inputs_[0] = context;
2524 LOperand* context() { return inputs_[0]; }
2525 LOperand* value() { return inputs_[1]; }
2527 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2531 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2533 explicit LTypeofIsAndBranch(LOperand* value) {
2537 LOperand* value() { return inputs_[0]; }
2539 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2540 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2542 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2544 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2548 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2550 explicit LIsConstructCallAndBranch(LOperand* temp) {
2554 LOperand* temp() { return temps_[0]; }
2556 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2557 "is-construct-call-and-branch")
2558 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2562 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2566 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2569 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2573 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2575 explicit LStackCheck(LOperand* context) {
2576 inputs_[0] = context;
2579 LOperand* context() { return inputs_[0]; }
2581 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2582 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2584 Label* done_label() { return &done_label_; }
2591 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2593 LForInPrepareMap(LOperand* context, LOperand* object) {
2594 inputs_[0] = context;
2595 inputs_[1] = object;
2598 LOperand* context() { return inputs_[0]; }
2599 LOperand* object() { return inputs_[1]; }
2601 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2605 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2607 explicit LForInCacheArray(LOperand* map) {
2611 LOperand* map() { return inputs_[0]; }
2613 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2616 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2621 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2623 LCheckMapValue(LOperand* value, LOperand* map) {
2628 LOperand* value() { return inputs_[0]; }
2629 LOperand* map() { return inputs_[1]; }
2631 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2635 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2637 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2638 inputs_[0] = object;
2642 LOperand* object() { return inputs_[0]; }
2643 LOperand* index() { return inputs_[1]; }
2645 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2649 class LChunkBuilder;
2650 class LPlatformChunk V8_FINAL : public LChunk {
2652 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2653 : LChunk(info, graph) { }
2655 int GetNextSpillIndex(RegisterKind kind);
2656 LOperand* GetNextSpillSlot(RegisterKind kind);
2660 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2662 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2663 : LChunkBuilderBase(graph->zone()),
2668 current_instruction_(NULL),
2669 current_block_(NULL),
2671 allocator_(allocator),
2672 instruction_pending_deoptimization_environment_(NULL),
2673 pending_deoptimization_ast_id_(BailoutId::None()) { }
2675 // Build the sequence for the graph.
2676 LPlatformChunk* Build();
2678 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2680 // Declare methods that deal with the individual node types.
2681 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2682 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2685 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2686 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2687 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2688 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2689 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2690 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2691 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2692 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2693 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2694 LInstruction* DoDivByConstI(HDiv* instr);
2695 LInstruction* DoDivI(HBinaryOperation* instr);
2696 LInstruction* DoModByPowerOf2I(HMod* instr);
2697 LInstruction* DoModByConstI(HMod* instr);
2698 LInstruction* DoModI(HMod* instr);
2699 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2700 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2710 LPlatformChunk* chunk() const { return chunk_; }
2711 CompilationInfo* info() const { return info_; }
2712 HGraph* graph() const { return graph_; }
2714 bool is_unused() const { return status_ == UNUSED; }
2715 bool is_building() const { return status_ == BUILDING; }
2716 bool is_done() const { return status_ == DONE; }
2717 bool is_aborted() const { return status_ == ABORTED; }
2719 void Abort(BailoutReason reason);
2721 // Methods for getting operands for Use / Define / Temp.
2722 LUnallocated* ToUnallocated(Register reg);
2723 LUnallocated* ToUnallocated(XMMRegister reg);
2725 // Methods for setting up define-use relationships.
2726 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2727 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2728 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2729 XMMRegister fixed_register);
2731 // A value that is guaranteed to be allocated to a register.
2732 // Operand created by UseRegister is guaranteed to be live until the end of
2733 // instruction. This means that register allocator will not reuse it's
2734 // register for any other operand inside instruction.
2735 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2736 // instruction start. Register allocator is free to assign the same register
2737 // to some other operand used inside instruction (i.e. temporary or
2739 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2740 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2742 // An input operand in a register that may be trashed.
2743 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2745 // An input operand in a register that may be trashed or a constant operand.
2746 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2748 // An input operand in a register or stack slot.
2749 MUST_USE_RESULT LOperand* Use(HValue* value);
2750 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2752 // An input operand in a register, stack slot or a constant operand.
2753 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2754 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2756 // An input operand in a register or a constant operand.
2757 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2758 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2760 // An input operand in a constant operand.
2761 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2763 // An input operand in register, stack slot or a constant operand.
2764 // Will not be moved to a register even if one is freely available.
2765 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2767 // Temporary operand that must be in a register.
2768 MUST_USE_RESULT LUnallocated* TempRegister();
2769 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2770 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2772 // Methods for setting up define-use relationships.
2773 // Return the same instruction that they are passed.
2774 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2775 LUnallocated* result);
2776 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2777 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2779 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2780 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2782 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2784 // Assigns an environment to an instruction. An instruction which can
2785 // deoptimize must have an environment.
2786 LInstruction* AssignEnvironment(LInstruction* instr);
2787 // Assigns a pointer map to an instruction. An instruction which can
2788 // trigger a GC or a lazy deoptimization must have a pointer map.
2789 LInstruction* AssignPointerMap(LInstruction* instr);
2791 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2793 // Marks a call for the register allocator. Assigns a pointer map to
2794 // support GC and lazy deoptimization. Assigns an environment to support
2795 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2796 LInstruction* MarkAsCall(
2797 LInstruction* instr,
2798 HInstruction* hinstr,
2799 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2801 void VisitInstruction(HInstruction* current);
2803 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2804 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2805 LInstruction* DoArithmeticD(Token::Value op,
2806 HArithmeticBinaryOperation* instr);
2807 LInstruction* DoArithmeticT(Token::Value op,
2808 HBinaryOperation* instr);
2810 LPlatformChunk* chunk_;
2811 CompilationInfo* info_;
2812 HGraph* const graph_;
2814 HInstruction* current_instruction_;
2815 HBasicBlock* current_block_;
2816 HBasicBlock* next_block_;
2817 LAllocator* allocator_;
2818 LInstruction* instruction_pending_deoptimization_environment_;
2819 BailoutId pending_deoptimization_ast_id_;
2821 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2824 #undef DECLARE_HYDROGEN_ACCESSOR
2825 #undef DECLARE_CONCRETE_INSTRUCTION
2827 } } // namespace v8::int
2829 #endif // V8_X64_LITHIUM_X64_H_