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(GetCachedArrayIndex) \
100 V(HasCachedArrayIndexAndBranch) \
101 V(HasInstanceTypeAndBranch) \
102 V(InnerAllocatedObject) \
104 V(InstanceOfKnownGlobal) \
106 V(Integer32ToDouble) \
109 V(IsConstructCallAndBranch) \
110 V(IsObjectAndBranch) \
111 V(IsStringAndBranch) \
113 V(IsUndetectableAndBranch) \
118 V(LoadFieldByIndex) \
119 V(LoadFunctionPrototype) \
121 V(LoadGlobalGeneric) \
123 V(LoadKeyedGeneric) \
125 V(LoadNamedGeneric) \
148 V(SeqStringGetChar) \
149 V(SeqStringSetChar) \
155 V(StoreContextSlot) \
158 V(StoreKeyedGeneric) \
160 V(StoreNamedGeneric) \
162 V(StringCharCodeAt) \
163 V(StringCharFromCode) \
164 V(StringCompareAndBranch) \
169 V(ToFastProperties) \
170 V(TransitionElementsKind) \
171 V(TrapAllocationMemento) \
173 V(TypeofIsAndBranch) \
181 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
182 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
183 return LInstruction::k##type; \
185 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
186 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
189 static L##type* cast(LInstruction* instr) { \
190 ASSERT(instr->Is##type()); \
191 return reinterpret_cast<L##type*>(instr); \
195 #define DECLARE_HYDROGEN_ACCESSOR(type) \
196 H##type* hydrogen() const { \
197 return H##type::cast(hydrogen_value()); \
201 class LInstruction : public ZoneObject {
204 : environment_(NULL),
205 hydrogen_value_(NULL),
206 bit_field_(IsCallBits::encode(false)) {
209 virtual ~LInstruction() {}
211 virtual void CompileToNative(LCodeGen* generator) = 0;
212 virtual const char* Mnemonic() const = 0;
213 virtual void PrintTo(StringStream* stream);
214 virtual void PrintDataTo(StringStream* stream);
215 virtual void PrintOutputOperandTo(StringStream* stream);
218 // Declare a unique enum value for each instruction.
219 #define DECLARE_OPCODE(type) k##type,
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
221 kNumberOfInstructions
222 #undef DECLARE_OPCODE
225 virtual Opcode opcode() const = 0;
227 // Declare non-virtual type testers for all leaf IR classes.
228 #define DECLARE_PREDICATE(type) \
229 bool Is##type() const { return opcode() == k##type; }
230 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
231 #undef DECLARE_PREDICATE
233 // Declare virtual predicates for instructions that don't have
235 virtual bool IsGap() const { return false; }
237 virtual bool IsControl() const { return false; }
239 void set_environment(LEnvironment* env) { environment_ = env; }
240 LEnvironment* environment() const { return environment_; }
241 bool HasEnvironment() const { return environment_ != NULL; }
243 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
244 LPointerMap* pointer_map() const { return pointer_map_.get(); }
245 bool HasPointerMap() const { return pointer_map_.is_set(); }
247 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
248 HValue* hydrogen_value() const { return hydrogen_value_; }
250 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
251 bool IsCall() const { return IsCallBits::decode(bit_field_); }
253 // Interface to the register allocator and iterators.
254 bool ClobbersTemps() const { return IsCall(); }
255 bool ClobbersRegisters() const { return IsCall(); }
256 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
258 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
260 // Interface to the register allocator and iterators.
261 bool IsMarkedAsCall() const { return IsCall(); }
263 virtual bool HasResult() const = 0;
264 virtual LOperand* result() const = 0;
266 LOperand* FirstInput() { return InputAt(0); }
267 LOperand* Output() { return HasResult() ? result() : NULL; }
269 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
277 friend class InputIterator;
278 virtual int InputCount() = 0;
279 virtual LOperand* InputAt(int i) = 0;
281 friend class TempIterator;
282 virtual int TempCount() = 0;
283 virtual LOperand* TempAt(int i) = 0;
285 class IsCallBits: public BitField<bool, 0, 1> {};
287 LEnvironment* environment_;
288 SetOncePointer<LPointerMap> pointer_map_;
289 HValue* hydrogen_value_;
294 // R = number of result operands (0 or 1).
296 class LTemplateResultInstruction : public LInstruction {
298 // Allow 0 or 1 output operands.
299 STATIC_ASSERT(R == 0 || R == 1);
300 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
301 return R != 0 && result() != NULL;
303 void set_result(LOperand* operand) { results_[0] = operand; }
304 LOperand* result() const { return results_[0]; }
307 EmbeddedContainer<LOperand*, R> results_;
311 // R = number of result operands (0 or 1).
312 // I = number of input operands.
313 // T = number of temporary operands.
314 template<int R, int I, int T>
315 class LTemplateInstruction : public LTemplateResultInstruction<R> {
317 EmbeddedContainer<LOperand*, I> inputs_;
318 EmbeddedContainer<LOperand*, T> temps_;
322 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
323 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
325 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
326 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
330 class LGap : public LTemplateInstruction<0, 0, 0> {
332 explicit LGap(HBasicBlock* block)
334 parallel_moves_[BEFORE] = NULL;
335 parallel_moves_[START] = NULL;
336 parallel_moves_[END] = NULL;
337 parallel_moves_[AFTER] = NULL;
340 // Can't use the DECLARE-macro here because of sub-classes.
341 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
342 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
343 static LGap* cast(LInstruction* instr) {
344 ASSERT(instr->IsGap());
345 return reinterpret_cast<LGap*>(instr);
348 bool IsRedundant() const;
350 HBasicBlock* block() const { return block_; }
357 FIRST_INNER_POSITION = BEFORE,
358 LAST_INNER_POSITION = AFTER
361 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
363 if (parallel_moves_[pos] == NULL) {
364 parallel_moves_[pos] = new(zone) LParallelMove(zone);
366 return parallel_moves_[pos];
369 LParallelMove* GetParallelMove(InnerPosition pos) {
370 return parallel_moves_[pos];
374 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
379 class LInstructionGap V8_FINAL : public LGap {
381 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
383 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
384 return !IsRedundant();
387 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
391 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
398 virtual bool IsControl() const V8_OVERRIDE { return true; }
400 int block_id() const { return block_->block_id(); }
407 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
409 LLazyBailout() : gap_instructions_size_(0) { }
411 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
413 void set_gap_instructions_size(int gap_instructions_size) {
414 gap_instructions_size_ = gap_instructions_size;
416 int gap_instructions_size() { return gap_instructions_size_; }
419 int gap_instructions_size_;
423 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
425 explicit LDummy() { }
426 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
430 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
432 explicit LDummyUse(LOperand* value) {
435 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
439 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
441 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
442 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
446 class LLabel V8_FINAL : public LGap {
448 explicit LLabel(HBasicBlock* block)
449 : LGap(block), replacement_(NULL) { }
451 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
454 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
456 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
458 int block_id() const { return block()->block_id(); }
459 bool is_loop_header() const { return block()->IsLoopHeader(); }
460 bool is_osr_entry() const { return block()->is_osr_entry(); }
461 Label* label() { return &label_; }
462 LLabel* replacement() const { return replacement_; }
463 void set_replacement(LLabel* label) { replacement_ = label; }
464 bool HasReplacement() const { return replacement_ != NULL; }
468 LLabel* replacement_;
472 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
474 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
477 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
481 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
483 explicit LCallStub(LOperand* context) {
484 inputs_[0] = context;
487 LOperand* context() { return inputs_[0]; }
489 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
490 DECLARE_HYDROGEN_ACCESSOR(CallStub)
494 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
496 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
499 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
503 template<int I, int T>
504 class LControlInstruction : public LTemplateInstruction<0, I, T> {
506 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
508 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
510 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
511 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
513 int TrueDestination(LChunk* chunk) {
514 return chunk->LookupDestination(true_block_id());
516 int FalseDestination(LChunk* chunk) {
517 return chunk->LookupDestination(false_block_id());
520 Label* TrueLabel(LChunk* chunk) {
521 if (true_label_ == NULL) {
522 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
526 Label* FalseLabel(LChunk* chunk) {
527 if (false_label_ == NULL) {
528 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
534 int true_block_id() { return SuccessorAt(0)->block_id(); }
535 int false_block_id() { return SuccessorAt(1)->block_id(); }
538 HControlInstruction* hydrogen() {
539 return HControlInstruction::cast(this->hydrogen_value());
547 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
549 LWrapReceiver(LOperand* receiver, LOperand* function) {
550 inputs_[0] = receiver;
551 inputs_[1] = function;
554 LOperand* receiver() { return inputs_[0]; }
555 LOperand* function() { return inputs_[1]; }
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
561 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
563 LApplyArguments(LOperand* function,
566 LOperand* elements) {
567 inputs_[0] = function;
568 inputs_[1] = receiver;
570 inputs_[3] = elements;
573 LOperand* function() { return inputs_[0]; }
574 LOperand* receiver() { return inputs_[1]; }
575 LOperand* length() { return inputs_[2]; }
576 LOperand* elements() { return inputs_[3]; }
578 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
582 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
584 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
585 inputs_[0] = arguments;
590 LOperand* arguments() { return inputs_[0]; }
591 LOperand* length() { return inputs_[1]; }
592 LOperand* index() { return inputs_[2]; }
594 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
596 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
600 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
602 explicit LArgumentsLength(LOperand* elements) {
603 inputs_[0] = elements;
606 LOperand* elements() { return inputs_[0]; }
608 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
612 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
614 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
615 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
619 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
621 LModI(LOperand* left, LOperand* right, LOperand* temp) {
627 LOperand* left() { return inputs_[0]; }
628 LOperand* right() { return inputs_[1]; }
629 LOperand* temp() { return temps_[0]; }
631 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
632 DECLARE_HYDROGEN_ACCESSOR(Mod)
636 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
638 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
644 LOperand* left() { return inputs_[0]; }
645 LOperand* right() { return inputs_[1]; }
646 LOperand* temp() { return temps_[0]; }
648 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
650 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
651 DECLARE_HYDROGEN_ACCESSOR(Div)
655 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
657 LMathFloorOfDiv(LOperand* left,
659 LOperand* temp = NULL) {
665 LOperand* left() { return inputs_[0]; }
666 LOperand* right() { return inputs_[1]; }
667 LOperand* temp() { return temps_[0]; }
669 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
670 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
674 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
676 LMulI(LOperand* left, LOperand* right) {
681 LOperand* left() { return inputs_[0]; }
682 LOperand* right() { return inputs_[1]; }
684 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
685 DECLARE_HYDROGEN_ACCESSOR(Mul)
689 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
691 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
696 LOperand* left() { return inputs_[0]; }
697 LOperand* right() { return inputs_[1]; }
699 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
700 "compare-numeric-and-branch")
701 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
703 Token::Value op() const { return hydrogen()->token(); }
704 bool is_double() const {
705 return hydrogen()->representation().IsDouble();
708 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
712 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
714 explicit LMathFloor(LOperand* value) {
718 LOperand* value() { return inputs_[0]; }
720 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
721 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
725 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
727 explicit LMathRound(LOperand* value) {
731 LOperand* value() { return inputs_[0]; }
733 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
734 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
738 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
740 explicit LMathAbs(LOperand* context, LOperand* value) {
741 inputs_[1] = context;
745 LOperand* context() { return inputs_[1]; }
746 LOperand* value() { return inputs_[0]; }
748 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
749 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
753 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
755 explicit LMathLog(LOperand* value) {
759 LOperand* value() { return inputs_[0]; }
761 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
765 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
767 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
771 ExternalReference::InitializeMathExpData();
774 LOperand* value() { return inputs_[0]; }
775 LOperand* temp1() { return temps_[0]; }
776 LOperand* temp2() { return temps_[1]; }
778 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
782 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
784 explicit LMathSqrt(LOperand* value) {
788 LOperand* value() { return inputs_[0]; }
790 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
794 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
796 explicit LMathPowHalf(LOperand* value) {
800 LOperand* value() { return inputs_[0]; }
802 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
806 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
808 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
813 LOperand* left() { return inputs_[0]; }
814 LOperand* right() { return inputs_[1]; }
816 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
820 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
822 explicit LCmpHoleAndBranch(LOperand* object) {
826 LOperand* object() { return inputs_[0]; }
828 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
829 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
833 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
835 explicit LCompareMinusZeroAndBranch(LOperand* value) {
839 LOperand* value() { return inputs_[0]; }
841 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
842 "cmp-minus-zero-and-branch")
843 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
848 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
850 explicit LIsObjectAndBranch(LOperand* value) {
854 LOperand* value() { return inputs_[0]; }
856 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
857 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
859 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
863 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
865 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
870 LOperand* value() { return inputs_[0]; }
871 LOperand* temp() { return temps_[0]; }
873 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
874 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
876 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
880 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
882 explicit LIsSmiAndBranch(LOperand* value) {
886 LOperand* value() { return inputs_[0]; }
888 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
889 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
891 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
895 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
897 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
902 LOperand* value() { return inputs_[0]; }
903 LOperand* temp() { return temps_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
906 "is-undetectable-and-branch")
907 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
909 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
913 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
915 explicit LStringCompareAndBranch(LOperand* context,
918 inputs_[0] = context;
923 LOperand* context() { return inputs_[0]; }
924 LOperand* left() { return inputs_[1]; }
925 LOperand* right() { return inputs_[2]; }
927 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
928 "string-compare-and-branch")
929 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
931 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
933 Token::Value op() const { return hydrogen()->token(); }
937 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
939 explicit LHasInstanceTypeAndBranch(LOperand* value) {
943 LOperand* value() { return inputs_[0]; }
945 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
946 "has-instance-type-and-branch")
947 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
949 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
953 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
955 explicit LGetCachedArrayIndex(LOperand* value) {
959 LOperand* value() { return inputs_[0]; }
961 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
962 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
966 class LHasCachedArrayIndexAndBranch V8_FINAL
967 : public LControlInstruction<1, 0> {
969 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
973 LOperand* value() { return inputs_[0]; }
975 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
976 "has-cached-array-index-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
979 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
983 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
985 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
991 LOperand* value() { return inputs_[0]; }
992 LOperand* temp() { return temps_[0]; }
993 LOperand* temp2() { return temps_[1]; }
995 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
996 "class-of-test-and-branch")
997 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
999 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1003 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1005 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1006 inputs_[0] = context;
1011 LOperand* context() { return inputs_[0]; }
1012 LOperand* left() { return inputs_[1]; }
1013 LOperand* right() { return inputs_[2]; }
1015 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1016 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1018 Token::Value op() const { return hydrogen()->token(); }
1022 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1024 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1025 inputs_[0] = context;
1030 LOperand* context() { return inputs_[0]; }
1031 LOperand* left() { return inputs_[1]; }
1032 LOperand* right() { return inputs_[2]; }
1034 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1038 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1040 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1041 inputs_[0] = context;
1046 LOperand* context() { return inputs_[0]; }
1047 LOperand* value() { return inputs_[1]; }
1048 LOperand* temp() { return temps_[0]; }
1050 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1051 "instance-of-known-global")
1052 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1054 Handle<JSFunction> function() const { return hydrogen()->function(); }
1055 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1056 return lazy_deopt_env_;
1058 virtual void SetDeferredLazyDeoptimizationEnvironment(
1059 LEnvironment* env) V8_OVERRIDE {
1060 lazy_deopt_env_ = env;
1064 LEnvironment* lazy_deopt_env_;
1068 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1070 LBoundsCheck(LOperand* index, LOperand* length) {
1072 inputs_[1] = length;
1075 LOperand* index() { return inputs_[0]; }
1076 LOperand* length() { return inputs_[1]; }
1078 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1079 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1083 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1085 LBitI(LOperand* left, LOperand* right) {
1090 LOperand* left() { return inputs_[0]; }
1091 LOperand* right() { return inputs_[1]; }
1093 Token::Value op() const { return hydrogen()->op(); }
1095 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1096 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1100 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1102 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1103 : op_(op), can_deopt_(can_deopt) {
1108 Token::Value op() const { return op_; }
1109 LOperand* left() { return inputs_[0]; }
1110 LOperand* right() { return inputs_[1]; }
1111 bool can_deopt() const { return can_deopt_; }
1113 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1121 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1123 LSubI(LOperand* left, LOperand* right) {
1128 LOperand* left() { return inputs_[0]; }
1129 LOperand* right() { return inputs_[1]; }
1131 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1132 DECLARE_HYDROGEN_ACCESSOR(Sub)
1136 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1138 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1139 DECLARE_HYDROGEN_ACCESSOR(Constant)
1141 int32_t value() const { return hydrogen()->Integer32Value(); }
1145 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1147 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1148 DECLARE_HYDROGEN_ACCESSOR(Constant)
1150 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1154 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1156 explicit LConstantD(LOperand* temp) {
1160 LOperand* temp() { return temps_[0]; }
1162 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1163 DECLARE_HYDROGEN_ACCESSOR(Constant)
1165 double value() const { return hydrogen()->DoubleValue(); }
1169 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1171 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1172 DECLARE_HYDROGEN_ACCESSOR(Constant)
1174 ExternalReference value() const {
1175 return hydrogen()->ExternalReferenceValue();
1180 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1182 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1183 DECLARE_HYDROGEN_ACCESSOR(Constant)
1185 Handle<Object> value(Isolate* isolate) const {
1186 return hydrogen()->handle(isolate);
1191 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1193 explicit LBranch(LOperand* value) {
1197 LOperand* value() { return inputs_[0]; }
1199 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1200 DECLARE_HYDROGEN_ACCESSOR(Branch)
1202 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1206 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1208 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1212 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1214 explicit LCmpMapAndBranch(LOperand* value) {
1218 LOperand* value() { return inputs_[0]; }
1220 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1221 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1223 Handle<Map> map() const { return hydrogen()->map().handle(); }
1227 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1229 explicit LMapEnumLength(LOperand* value) {
1233 LOperand* value() { return inputs_[0]; }
1235 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1239 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1241 explicit LElementsKind(LOperand* value) {
1245 LOperand* value() { return inputs_[0]; }
1247 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1248 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1252 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1254 explicit LValueOf(LOperand* value) {
1258 LOperand* value() { return inputs_[0]; }
1260 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1261 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1265 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1267 LDateField(LOperand* date, Smi* index) : index_(index) {
1271 LOperand* date() { return inputs_[0]; }
1272 Smi* index() const { return index_; }
1274 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1275 DECLARE_HYDROGEN_ACCESSOR(DateField)
1282 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1284 LSeqStringGetChar(LOperand* string, LOperand* index) {
1285 inputs_[0] = string;
1289 LOperand* string() const { return inputs_[0]; }
1290 LOperand* index() const { return inputs_[1]; }
1292 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1293 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1297 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1299 LSeqStringSetChar(LOperand* context,
1303 inputs_[0] = context;
1304 inputs_[1] = string;
1309 LOperand* string() { return inputs_[1]; }
1310 LOperand* index() { return inputs_[2]; }
1311 LOperand* value() { return inputs_[3]; }
1313 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1314 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1318 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1320 explicit LThrow(LOperand* context, LOperand* value) {
1321 inputs_[0] = context;
1325 LOperand* context() { return inputs_[0]; }
1326 LOperand* value() { return inputs_[1]; }
1328 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1332 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1334 LAddI(LOperand* left, LOperand* right) {
1339 LOperand* left() { return inputs_[0]; }
1340 LOperand* right() { return inputs_[1]; }
1342 static bool UseLea(HAdd* add) {
1343 return !add->CheckFlag(HValue::kCanOverflow) &&
1344 add->BetterLeftOperand()->UseCount() > 1;
1347 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1348 DECLARE_HYDROGEN_ACCESSOR(Add)
1352 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1354 LMathMinMax(LOperand* left, LOperand* right) {
1359 LOperand* left() { return inputs_[0]; }
1360 LOperand* right() { return inputs_[1]; }
1362 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1363 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1367 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1369 LPower(LOperand* left, LOperand* right) {
1374 LOperand* left() { return inputs_[0]; }
1375 LOperand* right() { return inputs_[1]; }
1377 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1378 DECLARE_HYDROGEN_ACCESSOR(Power)
1382 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1384 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1390 Token::Value op() const { return op_; }
1391 LOperand* left() { return inputs_[0]; }
1392 LOperand* right() { return inputs_[1]; }
1394 virtual Opcode opcode() const V8_OVERRIDE {
1395 return LInstruction::kArithmeticD;
1397 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1398 virtual const char* Mnemonic() const V8_OVERRIDE;
1405 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1407 LArithmeticT(Token::Value op,
1412 inputs_[0] = context;
1417 Token::Value op() const { return op_; }
1418 LOperand* context() { return inputs_[0]; }
1419 LOperand* left() { return inputs_[1]; }
1420 LOperand* right() { return inputs_[2]; }
1422 virtual Opcode opcode() const V8_OVERRIDE {
1423 return LInstruction::kArithmeticT;
1425 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1426 virtual const char* Mnemonic() const V8_OVERRIDE;
1433 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1435 explicit LReturn(LOperand* value,
1437 LOperand* parameter_count) {
1439 inputs_[1] = context;
1440 inputs_[2] = parameter_count;
1443 LOperand* value() { return inputs_[0]; }
1444 LOperand* context() { return inputs_[1]; }
1446 bool has_constant_parameter_count() {
1447 return parameter_count()->IsConstantOperand();
1449 LConstantOperand* constant_parameter_count() {
1450 ASSERT(has_constant_parameter_count());
1451 return LConstantOperand::cast(parameter_count());
1453 LOperand* parameter_count() { return inputs_[2]; }
1455 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1456 DECLARE_HYDROGEN_ACCESSOR(Return)
1460 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1462 explicit LLoadNamedField(LOperand* object) {
1463 inputs_[0] = object;
1466 LOperand* object() { return inputs_[0]; }
1468 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1469 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1473 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1475 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1476 inputs_[0] = context;
1477 inputs_[1] = object;
1480 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1481 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1483 LOperand* context() { return inputs_[0]; }
1484 LOperand* object() { return inputs_[1]; }
1485 Handle<Object> name() const { return hydrogen()->name(); }
1489 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1491 explicit LLoadFunctionPrototype(LOperand* function) {
1492 inputs_[0] = function;
1495 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1496 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1498 LOperand* function() { return inputs_[0]; }
1502 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1504 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1505 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1507 Heap::RootListIndex index() const { return hydrogen()->index(); }
1511 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1513 LLoadKeyed(LOperand* elements, LOperand* key) {
1514 inputs_[0] = elements;
1518 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1519 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1521 bool is_external() const {
1522 return hydrogen()->is_external();
1524 bool is_fixed_typed_array() const {
1525 return hydrogen()->is_fixed_typed_array();
1527 bool is_typed_elements() const {
1528 return is_external() || is_fixed_typed_array();
1530 LOperand* elements() { return inputs_[0]; }
1531 LOperand* key() { return inputs_[1]; }
1532 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1533 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1534 ElementsKind elements_kind() const {
1535 return hydrogen()->elements_kind();
1540 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1542 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1543 inputs_[0] = context;
1548 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1550 LOperand* context() { return inputs_[0]; }
1551 LOperand* object() { return inputs_[1]; }
1552 LOperand* key() { return inputs_[2]; }
1556 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1558 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1559 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1563 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1565 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1566 inputs_[0] = context;
1567 inputs_[1] = global_object;
1570 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1571 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1573 LOperand* context() { return inputs_[0]; }
1574 LOperand* global_object() { return inputs_[1]; }
1575 Handle<Object> name() const { return hydrogen()->name(); }
1576 bool for_typeof() const { return hydrogen()->for_typeof(); }
1580 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1582 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1587 LOperand* value() { return inputs_[0]; }
1588 LOperand* temp() { return temps_[0]; }
1590 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1591 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1595 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1597 explicit LLoadContextSlot(LOperand* context) {
1598 inputs_[0] = context;
1601 LOperand* context() { return inputs_[0]; }
1603 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1604 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1606 int slot_index() { return hydrogen()->slot_index(); }
1608 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1612 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1614 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1615 inputs_[0] = context;
1620 LOperand* context() { return inputs_[0]; }
1621 LOperand* value() { return inputs_[1]; }
1622 LOperand* temp() { return temps_[0]; }
1624 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1625 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1627 int slot_index() { return hydrogen()->slot_index(); }
1629 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1633 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1635 explicit LPushArgument(LOperand* value) {
1639 LOperand* value() { return inputs_[0]; }
1641 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1645 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1647 explicit LDrop(int count) : count_(count) { }
1649 int count() const { return count_; }
1651 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1658 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1660 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1661 inputs_[0] = function;
1662 temps_[0] = code_object;
1665 LOperand* function() { return inputs_[0]; }
1666 LOperand* code_object() { return temps_[0]; }
1668 virtual void PrintDataTo(StringStream* stream);
1670 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1671 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1675 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1677 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1678 inputs_[0] = base_object;
1679 inputs_[1] = offset;
1682 LOperand* base_object() const { return inputs_[0]; }
1683 LOperand* offset() const { return inputs_[1]; }
1685 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1687 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1691 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1693 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1694 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1698 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1700 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1701 DECLARE_HYDROGEN_ACCESSOR(Context)
1705 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1707 explicit LDeclareGlobals(LOperand* context) {
1708 inputs_[0] = context;
1711 LOperand* context() { return inputs_[0]; }
1713 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1714 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1718 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1720 explicit LCallJSFunction(LOperand* function) {
1721 inputs_[0] = function;
1724 LOperand* function() { return inputs_[0]; }
1726 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1727 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1729 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1731 int arity() const { return hydrogen()->argument_count() - 1; }
1735 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1737 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1738 ZoneList<LOperand*>& operands,
1740 : inputs_(descriptor->environment_length() + 1, zone) {
1741 ASSERT(descriptor->environment_length() + 1 == operands.length());
1742 inputs_.AddAll(operands, zone);
1745 LOperand* target() const { return inputs_[0]; }
1748 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1749 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1751 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1753 int arity() const { return hydrogen()->argument_count() - 1; }
1755 ZoneList<LOperand*> inputs_;
1757 // Iterator support.
1758 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1759 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1761 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1762 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1766 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1768 LInvokeFunction(LOperand* context, LOperand* function) {
1769 inputs_[0] = context;
1770 inputs_[1] = function;
1773 LOperand* context() { return inputs_[0]; }
1774 LOperand* function() { return inputs_[1]; }
1776 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1777 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1779 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1781 int arity() const { return hydrogen()->argument_count() - 1; }
1785 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1787 LCallFunction(LOperand* context, LOperand* function) {
1788 inputs_[0] = context;
1789 inputs_[1] = function;
1792 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1793 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1795 LOperand* context() { return inputs_[0]; }
1796 LOperand* function() { return inputs_[1]; }
1797 int arity() const { return hydrogen()->argument_count() - 1; }
1801 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1803 LCallNew(LOperand* context, LOperand* constructor) {
1804 inputs_[0] = context;
1805 inputs_[1] = constructor;
1808 LOperand* context() { return inputs_[0]; }
1809 LOperand* constructor() { return inputs_[1]; }
1811 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1812 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1814 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1816 int arity() const { return hydrogen()->argument_count() - 1; }
1820 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1822 LCallNewArray(LOperand* context, LOperand* constructor) {
1823 inputs_[0] = context;
1824 inputs_[1] = constructor;
1827 LOperand* context() { return inputs_[0]; }
1828 LOperand* constructor() { return inputs_[1]; }
1830 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1831 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1833 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1835 int arity() const { return hydrogen()->argument_count() - 1; }
1839 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1841 explicit LCallRuntime(LOperand* context) {
1842 inputs_[0] = context;
1845 LOperand* context() { return inputs_[0]; }
1847 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1848 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1850 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1851 return save_doubles() == kDontSaveFPRegs;
1854 const Runtime::Function* function() const { return hydrogen()->function(); }
1855 int arity() const { return hydrogen()->argument_count(); }
1856 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1860 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1862 explicit LInteger32ToDouble(LOperand* value) {
1866 LOperand* value() { return inputs_[0]; }
1868 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1872 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1874 explicit LInteger32ToSmi(LOperand* value) {
1878 LOperand* value() { return inputs_[0]; }
1880 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1881 DECLARE_HYDROGEN_ACCESSOR(Change)
1885 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1887 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1892 LOperand* value() { return inputs_[0]; }
1893 LOperand* temp() { return temps_[0]; }
1895 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1899 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1901 explicit LUint32ToSmi(LOperand* value) {
1905 LOperand* value() { return inputs_[0]; }
1907 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1908 DECLARE_HYDROGEN_ACCESSOR(Change)
1912 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1914 explicit LNumberTagI(LOperand* value) {
1918 LOperand* value() { return inputs_[0]; }
1920 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1924 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1926 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1931 LOperand* value() { return inputs_[0]; }
1932 LOperand* temp() { return temps_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1938 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1940 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1945 LOperand* value() { return inputs_[0]; }
1946 LOperand* temp() { return temps_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1949 DECLARE_HYDROGEN_ACCESSOR(Change)
1953 // Sometimes truncating conversion from a tagged value to an int32.
1954 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1956 explicit LDoubleToI(LOperand* value) {
1960 LOperand* value() { return inputs_[0]; }
1962 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1963 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1965 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1969 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1971 explicit LDoubleToSmi(LOperand* value) {
1975 LOperand* value() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1978 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1982 // Truncating conversion from a tagged value to an int32.
1983 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1985 LTaggedToI(LOperand* value, LOperand* temp) {
1990 LOperand* value() { return inputs_[0]; }
1991 LOperand* temp() { return temps_[0]; }
1993 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1994 DECLARE_HYDROGEN_ACCESSOR(Change)
1996 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2000 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2002 explicit LSmiTag(LOperand* value) {
2006 LOperand* value() { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2012 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2014 explicit LNumberUntagD(LOperand* value) {
2018 LOperand* value() { return inputs_[0]; }
2020 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2021 DECLARE_HYDROGEN_ACCESSOR(Change);
2025 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2027 LSmiUntag(LOperand* value, bool needs_check)
2028 : needs_check_(needs_check) {
2032 LOperand* value() { return inputs_[0]; }
2033 bool needs_check() const { return needs_check_; }
2035 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2042 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2044 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2045 inputs_[0] = object;
2050 LOperand* object() { return inputs_[0]; }
2051 LOperand* value() { return inputs_[1]; }
2052 LOperand* temp() { return temps_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2055 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2057 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2059 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2060 Representation representation() const {
2061 return hydrogen()->field_representation();
2066 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2068 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2069 inputs_[0] = context;
2070 inputs_[1] = object;
2074 LOperand* context() { return inputs_[0]; }
2075 LOperand* object() { return inputs_[1]; }
2076 LOperand* value() { return inputs_[2]; }
2078 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2079 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2081 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2083 Handle<Object> name() const { return hydrogen()->name(); }
2084 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2088 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2090 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2091 inputs_[0] = object;
2096 bool is_external() const { return hydrogen()->is_external(); }
2097 bool is_fixed_typed_array() const {
2098 return hydrogen()->is_fixed_typed_array();
2100 bool is_typed_elements() const {
2101 return is_external() || is_fixed_typed_array();
2103 LOperand* elements() { return inputs_[0]; }
2104 LOperand* key() { return inputs_[1]; }
2105 LOperand* value() { return inputs_[2]; }
2106 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2108 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2109 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2111 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2112 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2113 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2117 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2119 LStoreKeyedGeneric(LOperand* context,
2123 inputs_[0] = context;
2124 inputs_[1] = object;
2129 LOperand* context() { return inputs_[0]; }
2130 LOperand* object() { return inputs_[1]; }
2131 LOperand* key() { return inputs_[2]; }
2132 LOperand* value() { return inputs_[3]; }
2134 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2135 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2137 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2139 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2143 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2145 LTransitionElementsKind(LOperand* object,
2147 LOperand* new_map_temp,
2149 inputs_[0] = object;
2150 inputs_[1] = context;
2151 temps_[0] = new_map_temp;
2155 LOperand* object() { return inputs_[0]; }
2156 LOperand* context() { return inputs_[1]; }
2157 LOperand* new_map_temp() { return temps_[0]; }
2158 LOperand* temp() { return temps_[1]; }
2160 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2161 "transition-elements-kind")
2162 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2164 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2166 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2167 Handle<Map> transitioned_map() {
2168 return hydrogen()->transitioned_map().handle();
2170 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2171 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2175 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2177 LTrapAllocationMemento(LOperand* object,
2179 inputs_[0] = object;
2183 LOperand* object() { return inputs_[0]; }
2184 LOperand* temp() { return temps_[0]; }
2186 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2187 "trap-allocation-memento")
2191 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2193 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2194 inputs_[0] = context;
2199 LOperand* context() { return inputs_[0]; }
2200 LOperand* left() { return inputs_[1]; }
2201 LOperand* right() { return inputs_[2]; }
2203 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2204 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2208 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2210 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2211 inputs_[0] = context;
2212 inputs_[1] = string;
2216 LOperand* context() { return inputs_[0]; }
2217 LOperand* string() { return inputs_[1]; }
2218 LOperand* index() { return inputs_[2]; }
2220 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2221 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2225 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2227 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2228 inputs_[0] = context;
2229 inputs_[1] = char_code;
2232 LOperand* context() { return inputs_[0]; }
2233 LOperand* char_code() { return inputs_[1]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2236 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2240 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2242 explicit LCheckValue(LOperand* value) {
2246 LOperand* value() { return inputs_[0]; }
2248 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2249 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2253 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2255 explicit LCheckInstanceType(LOperand* value) {
2259 LOperand* value() { return inputs_[0]; }
2261 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2262 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2266 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2268 explicit LCheckMaps(LOperand* value) {
2272 LOperand* value() { return inputs_[0]; }
2274 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2275 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2279 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2281 explicit LCheckSmi(LOperand* value) {
2285 LOperand* value() { return inputs_[0]; }
2287 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2291 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2293 explicit LClampDToUint8(LOperand* unclamped) {
2294 inputs_[0] = unclamped;
2297 LOperand* unclamped() { return inputs_[0]; }
2299 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2303 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2305 explicit LClampIToUint8(LOperand* unclamped) {
2306 inputs_[0] = unclamped;
2309 LOperand* unclamped() { return inputs_[0]; }
2311 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2315 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2317 LClampTToUint8(LOperand* unclamped,
2318 LOperand* temp_xmm) {
2319 inputs_[0] = unclamped;
2320 temps_[0] = temp_xmm;
2323 LOperand* unclamped() { return inputs_[0]; }
2324 LOperand* temp_xmm() { return temps_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2330 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2332 explicit LCheckNonSmi(LOperand* value) {
2336 LOperand* value() { return inputs_[0]; }
2338 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2339 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2343 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2345 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2346 inputs_[0] = context;
2351 LOperand* context() { return inputs_[0]; }
2352 LOperand* size() { return inputs_[1]; }
2353 LOperand* temp() { return temps_[0]; }
2355 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2356 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2360 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2362 explicit LRegExpLiteral(LOperand* context) {
2363 inputs_[0] = context;
2366 LOperand* context() { return inputs_[0]; }
2368 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2369 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2373 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2375 explicit LFunctionLiteral(LOperand* context) {
2376 inputs_[0] = context;
2379 LOperand* context() { return inputs_[0]; }
2381 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2382 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2386 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2388 explicit LToFastProperties(LOperand* value) {
2392 LOperand* value() { return inputs_[0]; }
2394 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2395 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2399 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2401 LTypeof(LOperand* context, LOperand* value) {
2402 inputs_[0] = context;
2406 LOperand* context() { return inputs_[0]; }
2407 LOperand* value() { return inputs_[1]; }
2409 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2413 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2415 explicit LTypeofIsAndBranch(LOperand* value) {
2419 LOperand* value() { return inputs_[0]; }
2421 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2422 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2424 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2426 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2430 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2432 explicit LIsConstructCallAndBranch(LOperand* temp) {
2436 LOperand* temp() { return temps_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2439 "is-construct-call-and-branch")
2440 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2444 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2448 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2451 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2455 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2457 explicit LStackCheck(LOperand* context) {
2458 inputs_[0] = context;
2461 LOperand* context() { return inputs_[0]; }
2463 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2464 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2466 Label* done_label() { return &done_label_; }
2473 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2475 LForInPrepareMap(LOperand* context, LOperand* object) {
2476 inputs_[0] = context;
2477 inputs_[1] = object;
2480 LOperand* context() { return inputs_[0]; }
2481 LOperand* object() { return inputs_[1]; }
2483 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2487 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2489 explicit LForInCacheArray(LOperand* map) {
2493 LOperand* map() { return inputs_[0]; }
2495 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2498 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2503 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2505 LCheckMapValue(LOperand* value, LOperand* map) {
2510 LOperand* value() { return inputs_[0]; }
2511 LOperand* map() { return inputs_[1]; }
2513 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2517 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2519 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2520 inputs_[0] = object;
2524 LOperand* object() { return inputs_[0]; }
2525 LOperand* index() { return inputs_[1]; }
2527 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2531 class LChunkBuilder;
2532 class LPlatformChunk V8_FINAL : public LChunk {
2534 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2535 : LChunk(info, graph) { }
2537 int GetNextSpillIndex(RegisterKind kind);
2538 LOperand* GetNextSpillSlot(RegisterKind kind);
2542 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2544 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2545 : LChunkBuilderBase(graph->zone()),
2550 current_instruction_(NULL),
2551 current_block_(NULL),
2553 allocator_(allocator),
2554 instruction_pending_deoptimization_environment_(NULL),
2555 pending_deoptimization_ast_id_(BailoutId::None()) { }
2557 // Build the sequence for the graph.
2558 LPlatformChunk* Build();
2560 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2562 // Declare methods that deal with the individual node types.
2563 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2564 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2567 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2568 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2569 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2570 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2571 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2572 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2573 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2583 LPlatformChunk* chunk() const { return chunk_; }
2584 CompilationInfo* info() const { return info_; }
2585 HGraph* graph() const { return graph_; }
2587 bool is_unused() const { return status_ == UNUSED; }
2588 bool is_building() const { return status_ == BUILDING; }
2589 bool is_done() const { return status_ == DONE; }
2590 bool is_aborted() const { return status_ == ABORTED; }
2592 void Abort(BailoutReason reason);
2594 // Methods for getting operands for Use / Define / Temp.
2595 LUnallocated* ToUnallocated(Register reg);
2596 LUnallocated* ToUnallocated(XMMRegister reg);
2598 // Methods for setting up define-use relationships.
2599 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2600 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2601 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2602 XMMRegister fixed_register);
2604 // A value that is guaranteed to be allocated to a register.
2605 // Operand created by UseRegister is guaranteed to be live until the end of
2606 // instruction. This means that register allocator will not reuse it's
2607 // register for any other operand inside instruction.
2608 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2609 // instruction start. Register allocator is free to assign the same register
2610 // to some other operand used inside instruction (i.e. temporary or
2612 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2613 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2615 // An input operand in a register that may be trashed.
2616 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2618 // An input operand in a register that may be trashed or a constant operand.
2619 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2621 // An input operand in a register or stack slot.
2622 MUST_USE_RESULT LOperand* Use(HValue* value);
2623 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2625 // An input operand in a register, stack slot or a constant operand.
2626 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2627 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2629 // An input operand in a register or a constant operand.
2630 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2631 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2633 // An input operand in a constant operand.
2634 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2636 // An input operand in register, stack slot or a constant operand.
2637 // Will not be moved to a register even if one is freely available.
2638 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2640 // Temporary operand that must be in a register.
2641 MUST_USE_RESULT LUnallocated* TempRegister();
2642 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2643 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2645 // Methods for setting up define-use relationships.
2646 // Return the same instruction that they are passed.
2647 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2648 LUnallocated* result);
2649 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2650 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2652 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2653 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2655 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2657 // Assigns an environment to an instruction. An instruction which can
2658 // deoptimize must have an environment.
2659 LInstruction* AssignEnvironment(LInstruction* instr);
2660 // Assigns a pointer map to an instruction. An instruction which can
2661 // trigger a GC or a lazy deoptimization must have a pointer map.
2662 LInstruction* AssignPointerMap(LInstruction* instr);
2664 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2666 // Marks a call for the register allocator. Assigns a pointer map to
2667 // support GC and lazy deoptimization. Assigns an environment to support
2668 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2669 LInstruction* MarkAsCall(
2670 LInstruction* instr,
2671 HInstruction* hinstr,
2672 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2674 void VisitInstruction(HInstruction* current);
2676 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2677 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2678 LInstruction* DoArithmeticD(Token::Value op,
2679 HArithmeticBinaryOperation* instr);
2680 LInstruction* DoArithmeticT(Token::Value op,
2681 HBinaryOperation* instr);
2683 LPlatformChunk* chunk_;
2684 CompilationInfo* info_;
2685 HGraph* const graph_;
2687 HInstruction* current_instruction_;
2688 HBasicBlock* current_block_;
2689 HBasicBlock* next_block_;
2690 LAllocator* allocator_;
2691 LInstruction* instruction_pending_deoptimization_environment_;
2692 BailoutId pending_deoptimization_ast_id_;
2694 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2697 #undef DECLARE_HYDROGEN_ACCESSOR
2698 #undef DECLARE_CONCRETE_INSTRUCTION
2700 } } // namespace v8::int
2702 #endif // V8_X64_LITHIUM_X64_H_