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) \
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) \
147 V(SeqStringGetChar) \
148 V(SeqStringSetChar) \
154 V(StoreContextSlot) \
157 V(StoreKeyedGeneric) \
159 V(StoreNamedGeneric) \
161 V(StringCharCodeAt) \
162 V(StringCharFromCode) \
163 V(StringCompareAndBranch) \
168 V(ToFastProperties) \
169 V(TransitionElementsKind) \
170 V(TrapAllocationMemento) \
172 V(TypeofIsAndBranch) \
179 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
180 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
181 return LInstruction::k##type; \
183 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
184 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
187 static L##type* cast(LInstruction* instr) { \
188 ASSERT(instr->Is##type()); \
189 return reinterpret_cast<L##type*>(instr); \
193 #define DECLARE_HYDROGEN_ACCESSOR(type) \
194 H##type* hydrogen() const { \
195 return H##type::cast(hydrogen_value()); \
199 class LInstruction : public ZoneObject {
202 : environment_(NULL),
203 hydrogen_value_(NULL),
204 bit_field_(IsCallBits::encode(false)) {
207 virtual ~LInstruction() {}
209 virtual void CompileToNative(LCodeGen* generator) = 0;
210 virtual const char* Mnemonic() const = 0;
211 virtual void PrintTo(StringStream* stream);
212 virtual void PrintDataTo(StringStream* stream);
213 virtual void PrintOutputOperandTo(StringStream* stream);
216 // Declare a unique enum value for each instruction.
217 #define DECLARE_OPCODE(type) k##type,
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
219 kNumberOfInstructions
220 #undef DECLARE_OPCODE
223 virtual Opcode opcode() const = 0;
225 // Declare non-virtual type testers for all leaf IR classes.
226 #define DECLARE_PREDICATE(type) \
227 bool Is##type() const { return opcode() == k##type; }
228 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
229 #undef DECLARE_PREDICATE
231 // Declare virtual predicates for instructions that don't have
233 virtual bool IsGap() const { return false; }
235 virtual bool IsControl() const { return false; }
237 void set_environment(LEnvironment* env) { environment_ = env; }
238 LEnvironment* environment() const { return environment_; }
239 bool HasEnvironment() const { return environment_ != NULL; }
241 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
242 LPointerMap* pointer_map() const { return pointer_map_.get(); }
243 bool HasPointerMap() const { return pointer_map_.is_set(); }
245 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
246 HValue* hydrogen_value() const { return hydrogen_value_; }
248 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
249 bool IsCall() const { return IsCallBits::decode(bit_field_); }
251 // Interface to the register allocator and iterators.
252 bool ClobbersTemps() const { return IsCall(); }
253 bool ClobbersRegisters() const { return IsCall(); }
254 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
256 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
258 // Interface to the register allocator and iterators.
259 bool IsMarkedAsCall() const { return IsCall(); }
261 virtual bool HasResult() const = 0;
262 virtual LOperand* result() const = 0;
264 LOperand* FirstInput() { return InputAt(0); }
265 LOperand* Output() { return HasResult() ? result() : NULL; }
267 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
275 friend class InputIterator;
276 virtual int InputCount() = 0;
277 virtual LOperand* InputAt(int i) = 0;
279 friend class TempIterator;
280 virtual int TempCount() = 0;
281 virtual LOperand* TempAt(int i) = 0;
283 class IsCallBits: public BitField<bool, 0, 1> {};
285 LEnvironment* environment_;
286 SetOncePointer<LPointerMap> pointer_map_;
287 HValue* hydrogen_value_;
292 // R = number of result operands (0 or 1).
294 class LTemplateResultInstruction : public LInstruction {
296 // Allow 0 or 1 output operands.
297 STATIC_ASSERT(R == 0 || R == 1);
298 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
299 return R != 0 && result() != NULL;
301 void set_result(LOperand* operand) { results_[0] = operand; }
302 LOperand* result() const { return results_[0]; }
305 EmbeddedContainer<LOperand*, R> results_;
309 // R = number of result operands (0 or 1).
310 // I = number of input operands.
311 // T = number of temporary operands.
312 template<int R, int I, int T>
313 class LTemplateInstruction : public LTemplateResultInstruction<R> {
315 EmbeddedContainer<LOperand*, I> inputs_;
316 EmbeddedContainer<LOperand*, T> temps_;
320 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
321 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
323 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
324 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
328 class LGap : public LTemplateInstruction<0, 0, 0> {
330 explicit LGap(HBasicBlock* block)
332 parallel_moves_[BEFORE] = NULL;
333 parallel_moves_[START] = NULL;
334 parallel_moves_[END] = NULL;
335 parallel_moves_[AFTER] = NULL;
338 // Can't use the DECLARE-macro here because of sub-classes.
339 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
340 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
341 static LGap* cast(LInstruction* instr) {
342 ASSERT(instr->IsGap());
343 return reinterpret_cast<LGap*>(instr);
346 bool IsRedundant() const;
348 HBasicBlock* block() const { return block_; }
355 FIRST_INNER_POSITION = BEFORE,
356 LAST_INNER_POSITION = AFTER
359 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
361 if (parallel_moves_[pos] == NULL) {
362 parallel_moves_[pos] = new(zone) LParallelMove(zone);
364 return parallel_moves_[pos];
367 LParallelMove* GetParallelMove(InnerPosition pos) {
368 return parallel_moves_[pos];
372 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
377 class LInstructionGap V8_FINAL : public LGap {
379 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
381 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
382 return !IsRedundant();
385 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
389 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
391 explicit LGoto(HBasicBlock* block) : block_(block) { }
393 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
394 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
395 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
396 virtual bool IsControl() const V8_OVERRIDE { return true; }
398 int block_id() const { return block_->block_id(); }
405 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
407 LLazyBailout() : gap_instructions_size_(0) { }
409 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
411 void set_gap_instructions_size(int gap_instructions_size) {
412 gap_instructions_size_ = gap_instructions_size;
414 int gap_instructions_size() { return gap_instructions_size_; }
417 int gap_instructions_size_;
421 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
423 explicit LDummy() { }
424 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
428 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
430 explicit LDummyUse(LOperand* value) {
433 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
437 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
439 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
440 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
444 class LLabel V8_FINAL : public LGap {
446 explicit LLabel(HBasicBlock* block)
447 : LGap(block), replacement_(NULL) { }
449 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
452 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
454 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
456 int block_id() const { return block()->block_id(); }
457 bool is_loop_header() const { return block()->IsLoopHeader(); }
458 bool is_osr_entry() const { return block()->is_osr_entry(); }
459 Label* label() { return &label_; }
460 LLabel* replacement() const { return replacement_; }
461 void set_replacement(LLabel* label) { replacement_ = label; }
462 bool HasReplacement() const { return replacement_ != NULL; }
466 LLabel* replacement_;
470 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
472 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
475 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
479 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
481 explicit LCallStub(LOperand* context) {
482 inputs_[0] = context;
485 LOperand* context() { return inputs_[0]; }
487 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
488 DECLARE_HYDROGEN_ACCESSOR(CallStub)
492 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
494 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
497 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
501 template<int I, int T>
502 class LControlInstruction : public LTemplateInstruction<0, I, T> {
504 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
506 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
508 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
509 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
511 int TrueDestination(LChunk* chunk) {
512 return chunk->LookupDestination(true_block_id());
514 int FalseDestination(LChunk* chunk) {
515 return chunk->LookupDestination(false_block_id());
518 Label* TrueLabel(LChunk* chunk) {
519 if (true_label_ == NULL) {
520 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
524 Label* FalseLabel(LChunk* chunk) {
525 if (false_label_ == NULL) {
526 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
532 int true_block_id() { return SuccessorAt(0)->block_id(); }
533 int false_block_id() { return SuccessorAt(1)->block_id(); }
536 HControlInstruction* hydrogen() {
537 return HControlInstruction::cast(this->hydrogen_value());
545 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
547 LWrapReceiver(LOperand* receiver, LOperand* function) {
548 inputs_[0] = receiver;
549 inputs_[1] = function;
552 LOperand* receiver() { return inputs_[0]; }
553 LOperand* function() { return inputs_[1]; }
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
559 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
561 LApplyArguments(LOperand* function,
564 LOperand* elements) {
565 inputs_[0] = function;
566 inputs_[1] = receiver;
568 inputs_[3] = elements;
571 LOperand* function() { return inputs_[0]; }
572 LOperand* receiver() { return inputs_[1]; }
573 LOperand* length() { return inputs_[2]; }
574 LOperand* elements() { return inputs_[3]; }
576 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
580 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
582 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
583 inputs_[0] = arguments;
588 LOperand* arguments() { return inputs_[0]; }
589 LOperand* length() { return inputs_[1]; }
590 LOperand* index() { return inputs_[2]; }
592 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
594 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
598 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
600 explicit LArgumentsLength(LOperand* elements) {
601 inputs_[0] = elements;
604 LOperand* elements() { return inputs_[0]; }
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
610 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
613 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
617 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
619 LModI(LOperand* left, LOperand* right, LOperand* temp) {
625 LOperand* left() { return inputs_[0]; }
626 LOperand* right() { return inputs_[1]; }
627 LOperand* temp() { return temps_[0]; }
629 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
630 DECLARE_HYDROGEN_ACCESSOR(Mod)
634 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
636 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
642 LOperand* left() { return inputs_[0]; }
643 LOperand* right() { return inputs_[1]; }
644 LOperand* temp() { return temps_[0]; }
646 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
648 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
649 DECLARE_HYDROGEN_ACCESSOR(Div)
653 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
655 LMathFloorOfDiv(LOperand* left,
657 LOperand* temp = NULL) {
663 LOperand* left() { return inputs_[0]; }
664 LOperand* right() { return inputs_[1]; }
665 LOperand* temp() { return temps_[0]; }
667 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
668 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
672 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
674 LMulI(LOperand* left, LOperand* right) {
679 LOperand* left() { return inputs_[0]; }
680 LOperand* right() { return inputs_[1]; }
682 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mul)
687 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
689 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
694 LOperand* left() { return inputs_[0]; }
695 LOperand* right() { return inputs_[1]; }
697 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
698 "compare-numeric-and-branch")
699 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
701 Token::Value op() const { return hydrogen()->token(); }
702 bool is_double() const {
703 return hydrogen()->representation().IsDouble();
706 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
710 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
712 explicit LMathFloor(LOperand* value) {
716 LOperand* value() { return inputs_[0]; }
718 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
719 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
723 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
725 explicit LMathRound(LOperand* value) {
729 LOperand* value() { return inputs_[0]; }
731 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
732 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
736 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
738 explicit LMathAbs(LOperand* context, LOperand* value) {
739 inputs_[1] = context;
743 LOperand* context() { return inputs_[1]; }
744 LOperand* value() { return inputs_[0]; }
746 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
747 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
751 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
753 explicit LMathLog(LOperand* value) {
757 LOperand* value() { return inputs_[0]; }
759 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
763 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
765 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
769 ExternalReference::InitializeMathExpData();
772 LOperand* value() { return inputs_[0]; }
773 LOperand* temp1() { return temps_[0]; }
774 LOperand* temp2() { return temps_[1]; }
776 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
780 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
782 explicit LMathSqrt(LOperand* value) {
786 LOperand* value() { return inputs_[0]; }
788 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
792 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
794 explicit LMathPowHalf(LOperand* value) {
798 LOperand* value() { return inputs_[0]; }
800 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
804 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
806 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
818 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
820 explicit LCmpHoleAndBranch(LOperand* object) {
824 LOperand* object() { return inputs_[0]; }
826 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
827 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
831 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
833 explicit LCompareMinusZeroAndBranch(LOperand* value) {
837 LOperand* value() { return inputs_[0]; }
839 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
840 "cmp-minus-zero-and-branch")
841 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
846 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
848 explicit LIsObjectAndBranch(LOperand* value) {
852 LOperand* value() { return inputs_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
855 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
857 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
861 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
863 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
868 LOperand* value() { return inputs_[0]; }
869 LOperand* temp() { return temps_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
872 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
874 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
878 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
880 explicit LIsSmiAndBranch(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
887 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
889 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
893 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
895 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
900 LOperand* value() { return inputs_[0]; }
901 LOperand* temp() { return temps_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
904 "is-undetectable-and-branch")
905 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
907 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
911 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
913 explicit LStringCompareAndBranch(LOperand* context,
916 inputs_[0] = context;
921 LOperand* context() { return inputs_[0]; }
922 LOperand* left() { return inputs_[1]; }
923 LOperand* right() { return inputs_[2]; }
925 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
926 "string-compare-and-branch")
927 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
929 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
931 Token::Value op() const { return hydrogen()->token(); }
935 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
937 explicit LHasInstanceTypeAndBranch(LOperand* value) {
941 LOperand* value() { return inputs_[0]; }
943 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
944 "has-instance-type-and-branch")
945 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
947 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
951 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
953 explicit LGetCachedArrayIndex(LOperand* value) {
957 LOperand* value() { return inputs_[0]; }
959 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
960 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
964 class LHasCachedArrayIndexAndBranch V8_FINAL
965 : public LControlInstruction<1, 0> {
967 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
971 LOperand* value() { return inputs_[0]; }
973 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
974 "has-cached-array-index-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
977 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
981 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
983 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
989 LOperand* value() { return inputs_[0]; }
990 LOperand* temp() { return temps_[0]; }
991 LOperand* temp2() { return temps_[1]; }
993 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
994 "class-of-test-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
997 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1001 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1003 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1004 inputs_[0] = context;
1009 LOperand* context() { return inputs_[0]; }
1010 LOperand* left() { return inputs_[1]; }
1011 LOperand* right() { return inputs_[2]; }
1013 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1014 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1016 Token::Value op() const { return hydrogen()->token(); }
1020 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1022 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1023 inputs_[0] = context;
1028 LOperand* context() { return inputs_[0]; }
1029 LOperand* left() { return inputs_[1]; }
1030 LOperand* right() { return inputs_[2]; }
1032 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1036 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1038 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1039 inputs_[0] = context;
1044 LOperand* context() { return inputs_[0]; }
1045 LOperand* value() { return inputs_[1]; }
1046 LOperand* temp() { return temps_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1049 "instance-of-known-global")
1050 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1052 Handle<JSFunction> function() const { return hydrogen()->function(); }
1053 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1054 return lazy_deopt_env_;
1056 virtual void SetDeferredLazyDeoptimizationEnvironment(
1057 LEnvironment* env) V8_OVERRIDE {
1058 lazy_deopt_env_ = env;
1062 LEnvironment* lazy_deopt_env_;
1066 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1068 LBoundsCheck(LOperand* index, LOperand* length) {
1070 inputs_[1] = length;
1073 LOperand* index() { return inputs_[0]; }
1074 LOperand* length() { return inputs_[1]; }
1076 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1077 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1081 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1083 LBitI(LOperand* left, LOperand* right) {
1088 LOperand* left() { return inputs_[0]; }
1089 LOperand* right() { return inputs_[1]; }
1091 Token::Value op() const { return hydrogen()->op(); }
1093 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1094 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1098 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1100 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1101 : op_(op), can_deopt_(can_deopt) {
1106 Token::Value op() const { return op_; }
1107 LOperand* left() { return inputs_[0]; }
1108 LOperand* right() { return inputs_[1]; }
1109 bool can_deopt() const { return can_deopt_; }
1111 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1119 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1121 LSubI(LOperand* left, LOperand* right) {
1126 LOperand* left() { return inputs_[0]; }
1127 LOperand* right() { return inputs_[1]; }
1129 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1130 DECLARE_HYDROGEN_ACCESSOR(Sub)
1134 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1136 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1137 DECLARE_HYDROGEN_ACCESSOR(Constant)
1139 int32_t value() const { return hydrogen()->Integer32Value(); }
1143 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1145 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1146 DECLARE_HYDROGEN_ACCESSOR(Constant)
1148 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1152 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1154 explicit LConstantD(LOperand* temp) {
1158 LOperand* temp() { return temps_[0]; }
1160 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1161 DECLARE_HYDROGEN_ACCESSOR(Constant)
1163 double value() const { return hydrogen()->DoubleValue(); }
1167 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1169 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1170 DECLARE_HYDROGEN_ACCESSOR(Constant)
1172 ExternalReference value() const {
1173 return hydrogen()->ExternalReferenceValue();
1178 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1180 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1181 DECLARE_HYDROGEN_ACCESSOR(Constant)
1183 Handle<Object> value(Isolate* isolate) const {
1184 return hydrogen()->handle(isolate);
1189 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1191 explicit LBranch(LOperand* value) {
1195 LOperand* value() { return inputs_[0]; }
1197 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1198 DECLARE_HYDROGEN_ACCESSOR(Branch)
1200 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1204 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1206 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1210 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1212 explicit LCmpMapAndBranch(LOperand* value) {
1216 LOperand* value() { return inputs_[0]; }
1218 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1219 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1221 Handle<Map> map() const { return hydrogen()->map().handle(); }
1225 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1227 explicit LMapEnumLength(LOperand* value) {
1231 LOperand* value() { return inputs_[0]; }
1233 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1237 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1239 LDateField(LOperand* date, Smi* index) : index_(index) {
1243 LOperand* date() { return inputs_[0]; }
1244 Smi* index() const { return index_; }
1246 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1247 DECLARE_HYDROGEN_ACCESSOR(DateField)
1254 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1256 LSeqStringGetChar(LOperand* string, LOperand* index) {
1257 inputs_[0] = string;
1261 LOperand* string() const { return inputs_[0]; }
1262 LOperand* index() const { return inputs_[1]; }
1264 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1265 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1269 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1271 LSeqStringSetChar(LOperand* context,
1275 inputs_[0] = context;
1276 inputs_[1] = string;
1281 LOperand* string() { return inputs_[1]; }
1282 LOperand* index() { return inputs_[2]; }
1283 LOperand* value() { return inputs_[3]; }
1285 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1286 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1290 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1292 explicit LThrow(LOperand* context, LOperand* value) {
1293 inputs_[0] = context;
1297 LOperand* context() { return inputs_[0]; }
1298 LOperand* value() { return inputs_[1]; }
1300 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1304 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1306 LAddI(LOperand* left, LOperand* right) {
1311 LOperand* left() { return inputs_[0]; }
1312 LOperand* right() { return inputs_[1]; }
1314 static bool UseLea(HAdd* add) {
1315 return !add->CheckFlag(HValue::kCanOverflow) &&
1316 add->BetterLeftOperand()->UseCount() > 1;
1319 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1320 DECLARE_HYDROGEN_ACCESSOR(Add)
1324 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1326 LMathMinMax(LOperand* left, LOperand* right) {
1331 LOperand* left() { return inputs_[0]; }
1332 LOperand* right() { return inputs_[1]; }
1334 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1335 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1339 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1341 LPower(LOperand* left, LOperand* right) {
1346 LOperand* left() { return inputs_[0]; }
1347 LOperand* right() { return inputs_[1]; }
1349 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1350 DECLARE_HYDROGEN_ACCESSOR(Power)
1354 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1356 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1362 Token::Value op() const { return op_; }
1363 LOperand* left() { return inputs_[0]; }
1364 LOperand* right() { return inputs_[1]; }
1366 virtual Opcode opcode() const V8_OVERRIDE {
1367 return LInstruction::kArithmeticD;
1369 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1370 virtual const char* Mnemonic() const V8_OVERRIDE;
1377 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1379 LArithmeticT(Token::Value op,
1384 inputs_[0] = context;
1389 Token::Value op() const { return op_; }
1390 LOperand* context() { return inputs_[0]; }
1391 LOperand* left() { return inputs_[1]; }
1392 LOperand* right() { return inputs_[2]; }
1394 virtual Opcode opcode() const V8_OVERRIDE {
1395 return LInstruction::kArithmeticT;
1397 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1398 virtual const char* Mnemonic() const V8_OVERRIDE;
1405 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1407 explicit LReturn(LOperand* value,
1409 LOperand* parameter_count) {
1411 inputs_[1] = context;
1412 inputs_[2] = parameter_count;
1415 LOperand* value() { return inputs_[0]; }
1416 LOperand* context() { return inputs_[1]; }
1418 bool has_constant_parameter_count() {
1419 return parameter_count()->IsConstantOperand();
1421 LConstantOperand* constant_parameter_count() {
1422 ASSERT(has_constant_parameter_count());
1423 return LConstantOperand::cast(parameter_count());
1425 LOperand* parameter_count() { return inputs_[2]; }
1427 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1428 DECLARE_HYDROGEN_ACCESSOR(Return)
1432 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1434 explicit LLoadNamedField(LOperand* object) {
1435 inputs_[0] = object;
1438 LOperand* object() { return inputs_[0]; }
1440 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1441 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1445 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1447 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1448 inputs_[0] = context;
1449 inputs_[1] = object;
1452 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1453 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1455 LOperand* context() { return inputs_[0]; }
1456 LOperand* object() { return inputs_[1]; }
1457 Handle<Object> name() const { return hydrogen()->name(); }
1461 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1463 explicit LLoadFunctionPrototype(LOperand* function) {
1464 inputs_[0] = function;
1467 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1468 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1470 LOperand* function() { return inputs_[0]; }
1474 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1476 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1477 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1479 Heap::RootListIndex index() const { return hydrogen()->index(); }
1483 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1485 LLoadKeyed(LOperand* elements, LOperand* key) {
1486 inputs_[0] = elements;
1490 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1491 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1493 bool is_external() const {
1494 return hydrogen()->is_external();
1496 bool is_fixed_typed_array() const {
1497 return hydrogen()->is_fixed_typed_array();
1499 bool is_typed_elements() const {
1500 return is_external() || is_fixed_typed_array();
1502 LOperand* elements() { return inputs_[0]; }
1503 LOperand* key() { return inputs_[1]; }
1504 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1505 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1506 ElementsKind elements_kind() const {
1507 return hydrogen()->elements_kind();
1512 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1514 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1515 inputs_[0] = context;
1520 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1522 LOperand* context() { return inputs_[0]; }
1523 LOperand* object() { return inputs_[1]; }
1524 LOperand* key() { return inputs_[2]; }
1528 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1530 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1531 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1535 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1537 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1538 inputs_[0] = context;
1539 inputs_[1] = global_object;
1542 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1543 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1545 LOperand* context() { return inputs_[0]; }
1546 LOperand* global_object() { return inputs_[1]; }
1547 Handle<Object> name() const { return hydrogen()->name(); }
1548 bool for_typeof() const { return hydrogen()->for_typeof(); }
1552 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1554 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1559 LOperand* value() { return inputs_[0]; }
1560 LOperand* temp() { return temps_[0]; }
1562 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1563 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1567 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1569 explicit LLoadContextSlot(LOperand* context) {
1570 inputs_[0] = context;
1573 LOperand* context() { return inputs_[0]; }
1575 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1576 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1578 int slot_index() { return hydrogen()->slot_index(); }
1580 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1584 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1586 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1587 inputs_[0] = context;
1592 LOperand* context() { return inputs_[0]; }
1593 LOperand* value() { return inputs_[1]; }
1594 LOperand* temp() { return temps_[0]; }
1596 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1597 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1599 int slot_index() { return hydrogen()->slot_index(); }
1601 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1605 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1607 explicit LPushArgument(LOperand* value) {
1611 LOperand* value() { return inputs_[0]; }
1613 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1617 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1619 explicit LDrop(int count) : count_(count) { }
1621 int count() const { return count_; }
1623 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1630 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1632 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1633 inputs_[0] = function;
1634 temps_[0] = code_object;
1637 LOperand* function() { return inputs_[0]; }
1638 LOperand* code_object() { return temps_[0]; }
1640 virtual void PrintDataTo(StringStream* stream);
1642 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1643 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1647 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1649 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1650 inputs_[0] = base_object;
1651 inputs_[1] = offset;
1654 LOperand* base_object() const { return inputs_[0]; }
1655 LOperand* offset() const { return inputs_[1]; }
1657 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1659 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1663 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1665 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1666 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1670 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1672 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1673 DECLARE_HYDROGEN_ACCESSOR(Context)
1677 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1679 explicit LDeclareGlobals(LOperand* context) {
1680 inputs_[0] = context;
1683 LOperand* context() { return inputs_[0]; }
1685 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1686 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1690 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1692 explicit LCallJSFunction(LOperand* function) {
1693 inputs_[0] = function;
1696 LOperand* function() { return inputs_[0]; }
1698 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1699 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1701 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1703 int arity() const { return hydrogen()->argument_count() - 1; }
1707 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1709 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1710 ZoneList<LOperand*>& operands,
1712 : inputs_(descriptor->environment_length() + 1, zone) {
1713 ASSERT(descriptor->environment_length() + 1 == operands.length());
1714 inputs_.AddAll(operands, zone);
1717 LOperand* target() const { return inputs_[0]; }
1720 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1721 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1723 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1725 int arity() const { return hydrogen()->argument_count() - 1; }
1727 ZoneList<LOperand*> inputs_;
1729 // Iterator support.
1730 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1731 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1733 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1734 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1738 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1740 LInvokeFunction(LOperand* context, LOperand* function) {
1741 inputs_[0] = context;
1742 inputs_[1] = function;
1745 LOperand* context() { return inputs_[0]; }
1746 LOperand* function() { return inputs_[1]; }
1748 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1749 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1751 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1753 int arity() const { return hydrogen()->argument_count() - 1; }
1757 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1759 LCallFunction(LOperand* context, LOperand* function) {
1760 inputs_[0] = context;
1761 inputs_[1] = function;
1764 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1765 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1767 LOperand* context() { return inputs_[0]; }
1768 LOperand* function() { return inputs_[1]; }
1769 int arity() const { return hydrogen()->argument_count() - 1; }
1773 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1775 LCallNew(LOperand* context, LOperand* constructor) {
1776 inputs_[0] = context;
1777 inputs_[1] = constructor;
1780 LOperand* context() { return inputs_[0]; }
1781 LOperand* constructor() { return inputs_[1]; }
1783 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1784 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1786 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1788 int arity() const { return hydrogen()->argument_count() - 1; }
1792 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1794 LCallNewArray(LOperand* context, LOperand* constructor) {
1795 inputs_[0] = context;
1796 inputs_[1] = constructor;
1799 LOperand* context() { return inputs_[0]; }
1800 LOperand* constructor() { return inputs_[1]; }
1802 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1803 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1805 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1807 int arity() const { return hydrogen()->argument_count() - 1; }
1811 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1813 explicit LCallRuntime(LOperand* context) {
1814 inputs_[0] = context;
1817 LOperand* context() { return inputs_[0]; }
1819 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1820 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1822 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1823 return save_doubles() == kDontSaveFPRegs;
1826 const Runtime::Function* function() const { return hydrogen()->function(); }
1827 int arity() const { return hydrogen()->argument_count(); }
1828 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1832 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1834 explicit LInteger32ToDouble(LOperand* value) {
1838 LOperand* value() { return inputs_[0]; }
1840 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1844 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1846 explicit LInteger32ToSmi(LOperand* value) {
1850 LOperand* value() { return inputs_[0]; }
1852 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1853 DECLARE_HYDROGEN_ACCESSOR(Change)
1857 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1859 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1864 LOperand* value() { return inputs_[0]; }
1865 LOperand* temp() { return temps_[0]; }
1867 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1871 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1873 explicit LUint32ToSmi(LOperand* value) {
1877 LOperand* value() { return inputs_[0]; }
1879 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1880 DECLARE_HYDROGEN_ACCESSOR(Change)
1884 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1886 explicit LNumberTagI(LOperand* value) {
1890 LOperand* value() { return inputs_[0]; }
1892 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1896 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1898 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1903 LOperand* value() { return inputs_[0]; }
1904 LOperand* temp() { return temps_[0]; }
1906 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1910 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1912 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1917 LOperand* value() { return inputs_[0]; }
1918 LOperand* temp() { return temps_[0]; }
1920 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1921 DECLARE_HYDROGEN_ACCESSOR(Change)
1925 // Sometimes truncating conversion from a tagged value to an int32.
1926 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1928 explicit LDoubleToI(LOperand* value) {
1932 LOperand* value() { return inputs_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1935 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1937 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1941 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1943 explicit LDoubleToSmi(LOperand* value) {
1947 LOperand* value() { return inputs_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1950 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1954 // Truncating conversion from a tagged value to an int32.
1955 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1957 LTaggedToI(LOperand* value, LOperand* temp) {
1962 LOperand* value() { return inputs_[0]; }
1963 LOperand* temp() { return temps_[0]; }
1965 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1966 DECLARE_HYDROGEN_ACCESSOR(Change)
1968 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1972 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1974 explicit LSmiTag(LOperand* value) {
1978 LOperand* value() { return inputs_[0]; }
1980 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1984 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1986 explicit LNumberUntagD(LOperand* value) {
1990 LOperand* value() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1993 DECLARE_HYDROGEN_ACCESSOR(Change);
1997 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1999 LSmiUntag(LOperand* value, bool needs_check)
2000 : needs_check_(needs_check) {
2004 LOperand* value() { return inputs_[0]; }
2005 bool needs_check() const { return needs_check_; }
2007 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2014 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2016 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2017 inputs_[0] = object;
2022 LOperand* object() { return inputs_[0]; }
2023 LOperand* value() { return inputs_[1]; }
2024 LOperand* temp() { return temps_[0]; }
2026 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2027 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2029 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2031 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2032 Representation representation() const {
2033 return hydrogen()->field_representation();
2038 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2040 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2041 inputs_[0] = context;
2042 inputs_[1] = object;
2046 LOperand* context() { return inputs_[0]; }
2047 LOperand* object() { return inputs_[1]; }
2048 LOperand* value() { return inputs_[2]; }
2050 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2051 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2053 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2055 Handle<Object> name() const { return hydrogen()->name(); }
2056 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2060 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2062 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2063 inputs_[0] = object;
2068 bool is_external() const { return hydrogen()->is_external(); }
2069 bool is_fixed_typed_array() const {
2070 return hydrogen()->is_fixed_typed_array();
2072 bool is_typed_elements() const {
2073 return is_external() || is_fixed_typed_array();
2075 LOperand* elements() { return inputs_[0]; }
2076 LOperand* key() { return inputs_[1]; }
2077 LOperand* value() { return inputs_[2]; }
2078 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2080 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2081 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2083 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2084 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2085 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2089 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2091 LStoreKeyedGeneric(LOperand* context,
2095 inputs_[0] = context;
2096 inputs_[1] = object;
2101 LOperand* context() { return inputs_[0]; }
2102 LOperand* object() { return inputs_[1]; }
2103 LOperand* key() { return inputs_[2]; }
2104 LOperand* value() { return inputs_[3]; }
2106 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2107 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2109 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2111 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2115 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2117 LTransitionElementsKind(LOperand* object,
2119 LOperand* new_map_temp,
2121 inputs_[0] = object;
2122 inputs_[1] = context;
2123 temps_[0] = new_map_temp;
2127 LOperand* object() { return inputs_[0]; }
2128 LOperand* context() { return inputs_[1]; }
2129 LOperand* new_map_temp() { return temps_[0]; }
2130 LOperand* temp() { return temps_[1]; }
2132 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2133 "transition-elements-kind")
2134 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2138 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2139 Handle<Map> transitioned_map() {
2140 return hydrogen()->transitioned_map().handle();
2142 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2143 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2147 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2149 LTrapAllocationMemento(LOperand* object,
2151 inputs_[0] = object;
2155 LOperand* object() { return inputs_[0]; }
2156 LOperand* temp() { return temps_[0]; }
2158 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2159 "trap-allocation-memento")
2163 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2165 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2166 inputs_[0] = context;
2171 LOperand* context() { return inputs_[0]; }
2172 LOperand* left() { return inputs_[1]; }
2173 LOperand* right() { return inputs_[2]; }
2175 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2176 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2180 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2182 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2183 inputs_[0] = context;
2184 inputs_[1] = string;
2188 LOperand* context() { return inputs_[0]; }
2189 LOperand* string() { return inputs_[1]; }
2190 LOperand* index() { return inputs_[2]; }
2192 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2193 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2197 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2199 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2200 inputs_[0] = context;
2201 inputs_[1] = char_code;
2204 LOperand* context() { return inputs_[0]; }
2205 LOperand* char_code() { return inputs_[1]; }
2207 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2208 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2212 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2214 explicit LCheckValue(LOperand* value) {
2218 LOperand* value() { return inputs_[0]; }
2220 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2221 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2225 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2227 explicit LCheckInstanceType(LOperand* value) {
2231 LOperand* value() { return inputs_[0]; }
2233 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2234 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2238 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2240 explicit LCheckMaps(LOperand* value) {
2244 LOperand* value() { return inputs_[0]; }
2246 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2247 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2251 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2253 explicit LCheckSmi(LOperand* value) {
2257 LOperand* value() { return inputs_[0]; }
2259 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2263 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2265 explicit LClampDToUint8(LOperand* unclamped) {
2266 inputs_[0] = unclamped;
2269 LOperand* unclamped() { return inputs_[0]; }
2271 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2275 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2277 explicit LClampIToUint8(LOperand* unclamped) {
2278 inputs_[0] = unclamped;
2281 LOperand* unclamped() { return inputs_[0]; }
2283 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2287 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2289 LClampTToUint8(LOperand* unclamped,
2290 LOperand* temp_xmm) {
2291 inputs_[0] = unclamped;
2292 temps_[0] = temp_xmm;
2295 LOperand* unclamped() { return inputs_[0]; }
2296 LOperand* temp_xmm() { return temps_[0]; }
2298 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2302 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2304 explicit LCheckNonSmi(LOperand* value) {
2308 LOperand* value() { return inputs_[0]; }
2310 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2311 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2315 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2317 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2318 inputs_[0] = context;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* size() { return inputs_[1]; }
2325 LOperand* temp() { return temps_[0]; }
2327 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2328 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2332 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2334 explicit LRegExpLiteral(LOperand* context) {
2335 inputs_[0] = context;
2338 LOperand* context() { return inputs_[0]; }
2340 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2341 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2345 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2347 explicit LFunctionLiteral(LOperand* context) {
2348 inputs_[0] = context;
2351 LOperand* context() { return inputs_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2354 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2358 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2360 explicit LToFastProperties(LOperand* value) {
2364 LOperand* value() { return inputs_[0]; }
2366 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2367 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2371 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2373 LTypeof(LOperand* context, LOperand* value) {
2374 inputs_[0] = context;
2378 LOperand* context() { return inputs_[0]; }
2379 LOperand* value() { return inputs_[1]; }
2381 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2385 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2387 explicit LTypeofIsAndBranch(LOperand* value) {
2391 LOperand* value() { return inputs_[0]; }
2393 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2394 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2396 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2398 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2402 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2404 explicit LIsConstructCallAndBranch(LOperand* temp) {
2408 LOperand* temp() { return temps_[0]; }
2410 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2411 "is-construct-call-and-branch")
2412 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2416 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2420 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2423 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2427 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2429 explicit LStackCheck(LOperand* context) {
2430 inputs_[0] = context;
2433 LOperand* context() { return inputs_[0]; }
2435 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2436 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2438 Label* done_label() { return &done_label_; }
2445 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2447 LForInPrepareMap(LOperand* context, LOperand* object) {
2448 inputs_[0] = context;
2449 inputs_[1] = object;
2452 LOperand* context() { return inputs_[0]; }
2453 LOperand* object() { return inputs_[1]; }
2455 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2459 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2461 explicit LForInCacheArray(LOperand* map) {
2465 LOperand* map() { return inputs_[0]; }
2467 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2470 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2475 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2477 LCheckMapValue(LOperand* value, LOperand* map) {
2482 LOperand* value() { return inputs_[0]; }
2483 LOperand* map() { return inputs_[1]; }
2485 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2489 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2491 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2492 inputs_[0] = object;
2496 LOperand* object() { return inputs_[0]; }
2497 LOperand* index() { return inputs_[1]; }
2499 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2503 class LChunkBuilder;
2504 class LPlatformChunk V8_FINAL : public LChunk {
2506 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2507 : LChunk(info, graph) { }
2509 int GetNextSpillIndex(RegisterKind kind);
2510 LOperand* GetNextSpillSlot(RegisterKind kind);
2514 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2516 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2517 : LChunkBuilderBase(graph->zone()),
2522 current_instruction_(NULL),
2523 current_block_(NULL),
2525 allocator_(allocator),
2526 instruction_pending_deoptimization_environment_(NULL),
2527 pending_deoptimization_ast_id_(BailoutId::None()) { }
2529 // Build the sequence for the graph.
2530 LPlatformChunk* Build();
2532 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2534 // Declare methods that deal with the individual node types.
2535 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2536 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2539 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2540 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2541 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2542 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2543 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2544 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2545 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2555 LPlatformChunk* chunk() const { return chunk_; }
2556 CompilationInfo* info() const { return info_; }
2557 HGraph* graph() const { return graph_; }
2559 bool is_unused() const { return status_ == UNUSED; }
2560 bool is_building() const { return status_ == BUILDING; }
2561 bool is_done() const { return status_ == DONE; }
2562 bool is_aborted() const { return status_ == ABORTED; }
2564 void Abort(BailoutReason reason);
2566 // Methods for getting operands for Use / Define / Temp.
2567 LUnallocated* ToUnallocated(Register reg);
2568 LUnallocated* ToUnallocated(XMMRegister reg);
2570 // Methods for setting up define-use relationships.
2571 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2572 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2573 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2574 XMMRegister fixed_register);
2576 // A value that is guaranteed to be allocated to a register.
2577 // Operand created by UseRegister is guaranteed to be live until the end of
2578 // instruction. This means that register allocator will not reuse it's
2579 // register for any other operand inside instruction.
2580 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2581 // instruction start. Register allocator is free to assign the same register
2582 // to some other operand used inside instruction (i.e. temporary or
2584 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2585 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2587 // An input operand in a register that may be trashed.
2588 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2590 // An input operand in a register that may be trashed or a constant operand.
2591 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2593 // An input operand in a register or stack slot.
2594 MUST_USE_RESULT LOperand* Use(HValue* value);
2595 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2597 // An input operand in a register, stack slot or a constant operand.
2598 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2599 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2601 // An input operand in a register or a constant operand.
2602 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2603 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2605 // An input operand in a constant operand.
2606 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2608 // An input operand in register, stack slot or a constant operand.
2609 // Will not be moved to a register even if one is freely available.
2610 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2612 // Temporary operand that must be in a register.
2613 MUST_USE_RESULT LUnallocated* TempRegister();
2614 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2615 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2617 // Methods for setting up define-use relationships.
2618 // Return the same instruction that they are passed.
2619 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2620 LUnallocated* result);
2621 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2622 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2624 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2625 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2627 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2629 // Assigns an environment to an instruction. An instruction which can
2630 // deoptimize must have an environment.
2631 LInstruction* AssignEnvironment(LInstruction* instr);
2632 // Assigns a pointer map to an instruction. An instruction which can
2633 // trigger a GC or a lazy deoptimization must have a pointer map.
2634 LInstruction* AssignPointerMap(LInstruction* instr);
2636 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2638 // Marks a call for the register allocator. Assigns a pointer map to
2639 // support GC and lazy deoptimization. Assigns an environment to support
2640 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2641 LInstruction* MarkAsCall(
2642 LInstruction* instr,
2643 HInstruction* hinstr,
2644 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2646 void VisitInstruction(HInstruction* current);
2648 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2649 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2650 LInstruction* DoArithmeticD(Token::Value op,
2651 HArithmeticBinaryOperation* instr);
2652 LInstruction* DoArithmeticT(Token::Value op,
2653 HBinaryOperation* instr);
2655 LPlatformChunk* chunk_;
2656 CompilationInfo* info_;
2657 HGraph* const graph_;
2659 HInstruction* current_instruction_;
2660 HBasicBlock* current_block_;
2661 HBasicBlock* next_block_;
2662 LAllocator* allocator_;
2663 LInstruction* instruction_pending_deoptimization_environment_;
2664 BailoutId pending_deoptimization_ast_id_;
2666 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2669 #undef DECLARE_HYDROGEN_ACCESSOR
2670 #undef DECLARE_CONCRETE_INSTRUCTION
2672 } } // namespace v8::int
2674 #endif // V8_X64_LITHIUM_X64_H_