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) \
102 V(HasCachedArrayIndexAndBranch) \
103 V(HasInstanceTypeAndBranch) \
104 V(InnerAllocatedObject) \
106 V(InstanceOfKnownGlobal) \
108 V(Integer32ToDouble) \
111 V(IsConstructCallAndBranch) \
112 V(IsObjectAndBranch) \
113 V(IsStringAndBranch) \
115 V(IsUndetectableAndBranch) \
119 V(LoadExternalArrayPointer) \
121 V(LoadFieldByIndex) \
122 V(LoadFunctionPrototype) \
124 V(LoadGlobalGeneric) \
126 V(LoadKeyedGeneric) \
128 V(LoadNamedGeneric) \
152 V(SeqStringGetChar) \
153 V(SeqStringSetChar) \
159 V(StoreContextSlot) \
162 V(StoreKeyedGeneric) \
164 V(StoreNamedGeneric) \
166 V(StringCharCodeAt) \
167 V(StringCharFromCode) \
168 V(StringCompareAndBranch) \
173 V(ToFastProperties) \
174 V(TransitionElementsKind) \
175 V(TrapAllocationMemento) \
177 V(TypeofIsAndBranch) \
185 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
186 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
187 return LInstruction::k##type; \
189 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
190 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
193 static L##type* cast(LInstruction* instr) { \
194 ASSERT(instr->Is##type()); \
195 return reinterpret_cast<L##type*>(instr); \
199 #define DECLARE_HYDROGEN_ACCESSOR(type) \
200 H##type* hydrogen() const { \
201 return H##type::cast(hydrogen_value()); \
205 class LInstruction : public ZoneObject {
208 : environment_(NULL),
209 hydrogen_value_(NULL),
210 bit_field_(IsCallBits::encode(false)) {
213 virtual ~LInstruction() {}
215 virtual void CompileToNative(LCodeGen* generator) = 0;
216 virtual const char* Mnemonic() const = 0;
217 virtual void PrintTo(StringStream* stream);
218 virtual void PrintDataTo(StringStream* stream);
219 virtual void PrintOutputOperandTo(StringStream* stream);
222 // Declare a unique enum value for each instruction.
223 #define DECLARE_OPCODE(type) k##type,
224 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
225 kNumberOfInstructions
226 #undef DECLARE_OPCODE
229 virtual Opcode opcode() const = 0;
231 // Declare non-virtual type testers for all leaf IR classes.
232 #define DECLARE_PREDICATE(type) \
233 bool Is##type() const { return opcode() == k##type; }
234 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
235 #undef DECLARE_PREDICATE
237 // Declare virtual predicates for instructions that don't have
239 virtual bool IsGap() const { return false; }
241 virtual bool IsControl() const { return false; }
243 void set_environment(LEnvironment* env) { environment_ = env; }
244 LEnvironment* environment() const { return environment_; }
245 bool HasEnvironment() const { return environment_ != NULL; }
247 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
248 LPointerMap* pointer_map() const { return pointer_map_.get(); }
249 bool HasPointerMap() const { return pointer_map_.is_set(); }
251 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
252 HValue* hydrogen_value() const { return hydrogen_value_; }
254 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
255 bool IsCall() const { return IsCallBits::decode(bit_field_); }
257 // Interface to the register allocator and iterators.
258 bool ClobbersTemps() const { return IsCall(); }
259 bool ClobbersRegisters() const { return IsCall(); }
260 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
262 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
264 // Interface to the register allocator and iterators.
265 bool IsMarkedAsCall() const { return IsCall(); }
267 virtual bool HasResult() const = 0;
268 virtual LOperand* result() const = 0;
270 LOperand* FirstInput() { return InputAt(0); }
271 LOperand* Output() { return HasResult() ? result() : NULL; }
273 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
281 friend class InputIterator;
282 virtual int InputCount() = 0;
283 virtual LOperand* InputAt(int i) = 0;
285 friend class TempIterator;
286 virtual int TempCount() = 0;
287 virtual LOperand* TempAt(int i) = 0;
289 class IsCallBits: public BitField<bool, 0, 1> {};
291 LEnvironment* environment_;
292 SetOncePointer<LPointerMap> pointer_map_;
293 HValue* hydrogen_value_;
298 // R = number of result operands (0 or 1).
300 class LTemplateResultInstruction : public LInstruction {
302 // Allow 0 or 1 output operands.
303 STATIC_ASSERT(R == 0 || R == 1);
304 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
305 return R != 0 && result() != NULL;
307 void set_result(LOperand* operand) { results_[0] = operand; }
308 LOperand* result() const { return results_[0]; }
311 EmbeddedContainer<LOperand*, R> results_;
315 // R = number of result operands (0 or 1).
316 // I = number of input operands.
317 // T = number of temporary operands.
318 template<int R, int I, int T>
319 class LTemplateInstruction : public LTemplateResultInstruction<R> {
321 EmbeddedContainer<LOperand*, I> inputs_;
322 EmbeddedContainer<LOperand*, T> temps_;
326 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
327 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
329 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
330 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
334 class LGap : public LTemplateInstruction<0, 0, 0> {
336 explicit LGap(HBasicBlock* block)
338 parallel_moves_[BEFORE] = NULL;
339 parallel_moves_[START] = NULL;
340 parallel_moves_[END] = NULL;
341 parallel_moves_[AFTER] = NULL;
344 // Can't use the DECLARE-macro here because of sub-classes.
345 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
346 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
347 static LGap* cast(LInstruction* instr) {
348 ASSERT(instr->IsGap());
349 return reinterpret_cast<LGap*>(instr);
352 bool IsRedundant() const;
354 HBasicBlock* block() const { return block_; }
361 FIRST_INNER_POSITION = BEFORE,
362 LAST_INNER_POSITION = AFTER
365 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
367 if (parallel_moves_[pos] == NULL) {
368 parallel_moves_[pos] = new(zone) LParallelMove(zone);
370 return parallel_moves_[pos];
373 LParallelMove* GetParallelMove(InnerPosition pos) {
374 return parallel_moves_[pos];
378 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
383 class LInstructionGap V8_FINAL : public LGap {
385 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
388 return !IsRedundant();
391 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
395 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
397 explicit LGoto(HBasicBlock* block) : block_(block) { }
399 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
400 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
401 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
402 virtual bool IsControl() const V8_OVERRIDE { return true; }
404 int block_id() const { return block_->block_id(); }
411 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
413 LLazyBailout() : gap_instructions_size_(0) { }
415 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
417 void set_gap_instructions_size(int gap_instructions_size) {
418 gap_instructions_size_ = gap_instructions_size;
420 int gap_instructions_size() { return gap_instructions_size_; }
423 int gap_instructions_size_;
427 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
429 explicit LDummy() { }
430 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
434 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
436 explicit LDummyUse(LOperand* value) {
439 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
443 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
445 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
446 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
450 class LLabel V8_FINAL : public LGap {
452 explicit LLabel(HBasicBlock* block)
453 : LGap(block), replacement_(NULL) { }
455 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
458 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
460 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
462 int block_id() const { return block()->block_id(); }
463 bool is_loop_header() const { return block()->IsLoopHeader(); }
464 bool is_osr_entry() const { return block()->is_osr_entry(); }
465 Label* label() { return &label_; }
466 LLabel* replacement() const { return replacement_; }
467 void set_replacement(LLabel* label) { replacement_ = label; }
468 bool HasReplacement() const { return replacement_ != NULL; }
472 LLabel* replacement_;
476 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
478 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
481 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
485 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
487 explicit LCallStub(LOperand* context) {
488 inputs_[0] = context;
491 LOperand* context() { return inputs_[0]; }
493 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
494 DECLARE_HYDROGEN_ACCESSOR(CallStub)
498 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
500 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
503 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
507 template<int I, int T>
508 class LControlInstruction : public LTemplateInstruction<0, I, T> {
510 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
512 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
514 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
515 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
517 int TrueDestination(LChunk* chunk) {
518 return chunk->LookupDestination(true_block_id());
520 int FalseDestination(LChunk* chunk) {
521 return chunk->LookupDestination(false_block_id());
524 Label* TrueLabel(LChunk* chunk) {
525 if (true_label_ == NULL) {
526 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
530 Label* FalseLabel(LChunk* chunk) {
531 if (false_label_ == NULL) {
532 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
538 int true_block_id() { return SuccessorAt(0)->block_id(); }
539 int false_block_id() { return SuccessorAt(1)->block_id(); }
542 HControlInstruction* hydrogen() {
543 return HControlInstruction::cast(this->hydrogen_value());
551 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
553 LWrapReceiver(LOperand* receiver, LOperand* function) {
554 inputs_[0] = receiver;
555 inputs_[1] = function;
558 LOperand* receiver() { return inputs_[0]; }
559 LOperand* function() { return inputs_[1]; }
561 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
565 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 LOperand* function() { return inputs_[0]; }
578 LOperand* receiver() { return inputs_[1]; }
579 LOperand* length() { return inputs_[2]; }
580 LOperand* elements() { return inputs_[3]; }
582 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
586 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 LOperand* arguments() { return inputs_[0]; }
595 LOperand* length() { return inputs_[1]; }
596 LOperand* index() { return inputs_[2]; }
598 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
604 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
625 LModI(LOperand* left, LOperand* right, LOperand* temp) {
631 LOperand* left() { return inputs_[0]; }
632 LOperand* right() { return inputs_[1]; }
633 LOperand* temp() { return temps_[0]; }
635 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
636 DECLARE_HYDROGEN_ACCESSOR(Mod)
640 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
642 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
648 LOperand* left() { return inputs_[0]; }
649 LOperand* right() { return inputs_[1]; }
650 LOperand* temp() { return temps_[0]; }
652 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
654 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
655 DECLARE_HYDROGEN_ACCESSOR(Div)
659 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
661 LMathFloorOfDiv(LOperand* left,
663 LOperand* temp = NULL) {
669 LOperand* left() { return inputs_[0]; }
670 LOperand* right() { return inputs_[1]; }
671 LOperand* temp() { return temps_[0]; }
673 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
674 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
678 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
680 LMulI(LOperand* left, LOperand* right) {
685 LOperand* left() { return inputs_[0]; }
686 LOperand* right() { return inputs_[1]; }
688 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
689 DECLARE_HYDROGEN_ACCESSOR(Mul)
693 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
695 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
700 LOperand* left() { return inputs_[0]; }
701 LOperand* right() { return inputs_[1]; }
703 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
704 "compare-numeric-and-branch")
705 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
707 Token::Value op() const { return hydrogen()->token(); }
708 bool is_double() const {
709 return hydrogen()->representation().IsDouble();
712 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
716 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
718 explicit LMathFloor(LOperand* value) {
722 LOperand* value() { return inputs_[0]; }
724 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
725 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
729 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
731 explicit LMathRound(LOperand* value) {
735 LOperand* value() { return inputs_[0]; }
737 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
738 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
742 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
744 explicit LMathAbs(LOperand* context, LOperand* value) {
745 inputs_[1] = context;
749 LOperand* context() { return inputs_[1]; }
750 LOperand* value() { return inputs_[0]; }
752 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
753 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
757 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
759 explicit LMathLog(LOperand* value) {
763 LOperand* value() { return inputs_[0]; }
765 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
769 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
771 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
775 ExternalReference::InitializeMathExpData();
778 LOperand* value() { return inputs_[0]; }
779 LOperand* temp1() { return temps_[0]; }
780 LOperand* temp2() { return temps_[1]; }
782 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
786 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
788 explicit LMathSqrt(LOperand* value) {
792 LOperand* value() { return inputs_[0]; }
794 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
798 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
800 explicit LMathPowHalf(LOperand* value) {
804 LOperand* value() { return inputs_[0]; }
806 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
810 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
812 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
817 LOperand* left() { return inputs_[0]; }
818 LOperand* right() { return inputs_[1]; }
820 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
824 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
826 explicit LCmpHoleAndBranch(LOperand* object) {
830 LOperand* object() { return inputs_[0]; }
832 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
833 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
837 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
839 explicit LCompareMinusZeroAndBranch(LOperand* value) {
843 LOperand* value() { return inputs_[0]; }
845 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
846 "cmp-minus-zero-and-branch")
847 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
852 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
854 explicit LIsObjectAndBranch(LOperand* value) {
858 LOperand* value() { return inputs_[0]; }
860 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
861 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
863 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
867 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
869 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
874 LOperand* value() { return inputs_[0]; }
875 LOperand* temp() { return temps_[0]; }
877 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
878 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
880 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
884 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
886 explicit LIsSmiAndBranch(LOperand* value) {
890 LOperand* value() { return inputs_[0]; }
892 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
893 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
895 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
899 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
901 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
906 LOperand* value() { return inputs_[0]; }
907 LOperand* temp() { return temps_[0]; }
909 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
910 "is-undetectable-and-branch")
911 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
913 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
917 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
919 explicit LStringCompareAndBranch(LOperand* context,
922 inputs_[0] = context;
927 LOperand* context() { return inputs_[0]; }
928 LOperand* left() { return inputs_[1]; }
929 LOperand* right() { return inputs_[2]; }
931 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
932 "string-compare-and-branch")
933 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
935 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
937 Token::Value op() const { return hydrogen()->token(); }
941 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
943 explicit LHasInstanceTypeAndBranch(LOperand* value) {
947 LOperand* value() { return inputs_[0]; }
949 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
950 "has-instance-type-and-branch")
951 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
953 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
957 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
959 explicit LGetCachedArrayIndex(LOperand* value) {
963 LOperand* value() { return inputs_[0]; }
965 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
966 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
970 class LHasCachedArrayIndexAndBranch V8_FINAL
971 : public LControlInstruction<1, 0> {
973 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
977 LOperand* value() { return inputs_[0]; }
979 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
980 "has-cached-array-index-and-branch")
981 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
983 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
987 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
989 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
995 LOperand* value() { return inputs_[0]; }
996 LOperand* temp() { return temps_[0]; }
997 LOperand* temp2() { return temps_[1]; }
999 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1000 "class-of-test-and-branch")
1001 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1003 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1007 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1009 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1010 inputs_[0] = context;
1015 LOperand* context() { return inputs_[0]; }
1016 LOperand* left() { return inputs_[1]; }
1017 LOperand* right() { return inputs_[2]; }
1019 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1020 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1022 Token::Value op() const { return hydrogen()->token(); }
1026 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1028 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1029 inputs_[0] = context;
1034 LOperand* context() { return inputs_[0]; }
1035 LOperand* left() { return inputs_[1]; }
1036 LOperand* right() { return inputs_[2]; }
1038 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1042 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1044 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1045 inputs_[0] = context;
1050 LOperand* context() { return inputs_[0]; }
1051 LOperand* value() { return inputs_[1]; }
1052 LOperand* temp() { return temps_[0]; }
1054 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1055 "instance-of-known-global")
1056 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1058 Handle<JSFunction> function() const { return hydrogen()->function(); }
1059 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1060 return lazy_deopt_env_;
1062 virtual void SetDeferredLazyDeoptimizationEnvironment(
1063 LEnvironment* env) V8_OVERRIDE {
1064 lazy_deopt_env_ = env;
1068 LEnvironment* lazy_deopt_env_;
1072 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1074 LBoundsCheck(LOperand* index, LOperand* length) {
1076 inputs_[1] = length;
1079 LOperand* index() { return inputs_[0]; }
1080 LOperand* length() { return inputs_[1]; }
1082 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1083 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1087 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1089 LBitI(LOperand* left, LOperand* right) {
1094 LOperand* left() { return inputs_[0]; }
1095 LOperand* right() { return inputs_[1]; }
1097 Token::Value op() const { return hydrogen()->op(); }
1099 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1100 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1104 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1106 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1107 : op_(op), can_deopt_(can_deopt) {
1112 Token::Value op() const { return op_; }
1113 LOperand* left() { return inputs_[0]; }
1114 LOperand* right() { return inputs_[1]; }
1115 bool can_deopt() const { return can_deopt_; }
1117 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1125 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1127 LSubI(LOperand* left, LOperand* right) {
1132 LOperand* left() { return inputs_[0]; }
1133 LOperand* right() { return inputs_[1]; }
1135 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1136 DECLARE_HYDROGEN_ACCESSOR(Sub)
1140 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1142 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1143 DECLARE_HYDROGEN_ACCESSOR(Constant)
1145 int32_t value() const { return hydrogen()->Integer32Value(); }
1149 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1151 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1152 DECLARE_HYDROGEN_ACCESSOR(Constant)
1154 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1158 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1160 explicit LConstantD(LOperand* temp) {
1164 LOperand* temp() { return temps_[0]; }
1166 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1167 DECLARE_HYDROGEN_ACCESSOR(Constant)
1169 double value() const { return hydrogen()->DoubleValue(); }
1173 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1175 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1176 DECLARE_HYDROGEN_ACCESSOR(Constant)
1178 ExternalReference value() const {
1179 return hydrogen()->ExternalReferenceValue();
1184 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1186 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1187 DECLARE_HYDROGEN_ACCESSOR(Constant)
1189 Handle<Object> value(Isolate* isolate) const {
1190 return hydrogen()->handle(isolate);
1195 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1197 explicit LBranch(LOperand* value) {
1201 LOperand* value() { return inputs_[0]; }
1203 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1204 DECLARE_HYDROGEN_ACCESSOR(Branch)
1206 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1210 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1212 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1216 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1218 explicit LCmpMapAndBranch(LOperand* value) {
1222 LOperand* value() { return inputs_[0]; }
1224 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1225 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1227 Handle<Map> map() const { return hydrogen()->map().handle(); }
1231 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1233 explicit LMapEnumLength(LOperand* value) {
1237 LOperand* value() { return inputs_[0]; }
1239 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1243 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1245 explicit LElementsKind(LOperand* value) {
1249 LOperand* value() { return inputs_[0]; }
1251 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1252 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1256 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1258 explicit LValueOf(LOperand* value) {
1262 LOperand* value() { return inputs_[0]; }
1264 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1265 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1269 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1271 LDateField(LOperand* date, Smi* index) : index_(index) {
1275 LOperand* date() { return inputs_[0]; }
1276 Smi* index() const { return index_; }
1278 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1279 DECLARE_HYDROGEN_ACCESSOR(DateField)
1286 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1288 LSeqStringGetChar(LOperand* string, LOperand* index) {
1289 inputs_[0] = string;
1293 LOperand* string() const { return inputs_[0]; }
1294 LOperand* index() const { return inputs_[1]; }
1296 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1297 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1301 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1303 LSeqStringSetChar(LOperand* context,
1307 inputs_[0] = context;
1308 inputs_[1] = string;
1313 LOperand* string() { return inputs_[1]; }
1314 LOperand* index() { return inputs_[2]; }
1315 LOperand* value() { return inputs_[3]; }
1317 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1318 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1322 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1324 explicit LThrow(LOperand* context, LOperand* value) {
1325 inputs_[0] = context;
1329 LOperand* context() { return inputs_[0]; }
1330 LOperand* value() { return inputs_[1]; }
1332 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1336 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1338 LAddI(LOperand* left, LOperand* right) {
1343 LOperand* left() { return inputs_[0]; }
1344 LOperand* right() { return inputs_[1]; }
1346 static bool UseLea(HAdd* add) {
1347 return !add->CheckFlag(HValue::kCanOverflow) &&
1348 add->BetterLeftOperand()->UseCount() > 1;
1351 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1352 DECLARE_HYDROGEN_ACCESSOR(Add)
1356 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1358 LMathMinMax(LOperand* left, LOperand* right) {
1363 LOperand* left() { return inputs_[0]; }
1364 LOperand* right() { return inputs_[1]; }
1366 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1367 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1371 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1373 LPower(LOperand* left, LOperand* right) {
1378 LOperand* left() { return inputs_[0]; }
1379 LOperand* right() { return inputs_[1]; }
1381 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1382 DECLARE_HYDROGEN_ACCESSOR(Power)
1386 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1388 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1394 Token::Value op() const { return op_; }
1395 LOperand* left() { return inputs_[0]; }
1396 LOperand* right() { return inputs_[1]; }
1398 virtual Opcode opcode() const V8_OVERRIDE {
1399 return LInstruction::kArithmeticD;
1401 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1402 virtual const char* Mnemonic() const V8_OVERRIDE;
1409 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1411 LArithmeticT(Token::Value op,
1416 inputs_[0] = context;
1421 Token::Value op() const { return op_; }
1422 LOperand* context() { return inputs_[0]; }
1423 LOperand* left() { return inputs_[1]; }
1424 LOperand* right() { return inputs_[2]; }
1426 virtual Opcode opcode() const V8_OVERRIDE {
1427 return LInstruction::kArithmeticT;
1429 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1430 virtual const char* Mnemonic() const V8_OVERRIDE;
1437 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1439 explicit LReturn(LOperand* value,
1441 LOperand* parameter_count) {
1443 inputs_[1] = context;
1444 inputs_[2] = parameter_count;
1447 LOperand* value() { return inputs_[0]; }
1448 LOperand* context() { return inputs_[1]; }
1450 bool has_constant_parameter_count() {
1451 return parameter_count()->IsConstantOperand();
1453 LConstantOperand* constant_parameter_count() {
1454 ASSERT(has_constant_parameter_count());
1455 return LConstantOperand::cast(parameter_count());
1457 LOperand* parameter_count() { return inputs_[2]; }
1459 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1460 DECLARE_HYDROGEN_ACCESSOR(Return)
1464 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1466 explicit LLoadNamedField(LOperand* object) {
1467 inputs_[0] = object;
1470 LOperand* object() { return inputs_[0]; }
1472 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1473 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1477 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1479 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1480 inputs_[0] = context;
1481 inputs_[1] = object;
1484 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1485 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1487 LOperand* context() { return inputs_[0]; }
1488 LOperand* object() { return inputs_[1]; }
1489 Handle<Object> name() const { return hydrogen()->name(); }
1493 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1495 explicit LLoadFunctionPrototype(LOperand* function) {
1496 inputs_[0] = function;
1499 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1500 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1502 LOperand* function() { return inputs_[0]; }
1506 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1508 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1509 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1511 Heap::RootListIndex index() const { return hydrogen()->index(); }
1515 class LLoadExternalArrayPointer V8_FINAL
1516 : public LTemplateInstruction<1, 1, 0> {
1518 explicit LLoadExternalArrayPointer(LOperand* object) {
1519 inputs_[0] = object;
1522 LOperand* object() { return inputs_[0]; }
1524 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1525 "load-external-array-pointer")
1529 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1531 LLoadKeyed(LOperand* elements, LOperand* key) {
1532 inputs_[0] = elements;
1536 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1537 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1539 bool is_external() const {
1540 return hydrogen()->is_external();
1542 bool is_fixed_typed_array() const {
1543 return hydrogen()->is_fixed_typed_array();
1545 bool is_typed_elements() const {
1546 return is_external() || is_fixed_typed_array();
1548 LOperand* elements() { return inputs_[0]; }
1549 LOperand* key() { return inputs_[1]; }
1550 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1551 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1552 ElementsKind elements_kind() const {
1553 return hydrogen()->elements_kind();
1558 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1560 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1561 inputs_[0] = context;
1566 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1568 LOperand* context() { return inputs_[0]; }
1569 LOperand* object() { return inputs_[1]; }
1570 LOperand* key() { return inputs_[2]; }
1574 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1576 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1577 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1581 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1583 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1584 inputs_[0] = context;
1585 inputs_[1] = global_object;
1588 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1589 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1591 LOperand* context() { return inputs_[0]; }
1592 LOperand* global_object() { return inputs_[1]; }
1593 Handle<Object> name() const { return hydrogen()->name(); }
1594 bool for_typeof() const { return hydrogen()->for_typeof(); }
1598 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1600 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1605 LOperand* value() { return inputs_[0]; }
1606 LOperand* temp() { return temps_[0]; }
1608 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1609 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1613 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1615 explicit LLoadContextSlot(LOperand* context) {
1616 inputs_[0] = context;
1619 LOperand* context() { return inputs_[0]; }
1621 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1624 int slot_index() { return hydrogen()->slot_index(); }
1626 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1630 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1632 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1633 inputs_[0] = context;
1638 LOperand* context() { return inputs_[0]; }
1639 LOperand* value() { return inputs_[1]; }
1640 LOperand* temp() { return temps_[0]; }
1642 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1643 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1645 int slot_index() { return hydrogen()->slot_index(); }
1647 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1651 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1653 explicit LPushArgument(LOperand* value) {
1657 LOperand* value() { return inputs_[0]; }
1659 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1663 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1665 explicit LDrop(int count) : count_(count) { }
1667 int count() const { return count_; }
1669 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1676 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1678 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1679 inputs_[0] = function;
1680 temps_[0] = code_object;
1683 LOperand* function() { return inputs_[0]; }
1684 LOperand* code_object() { return temps_[0]; }
1686 virtual void PrintDataTo(StringStream* stream);
1688 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1689 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1693 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1695 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1696 inputs_[0] = base_object;
1697 inputs_[1] = offset;
1700 LOperand* base_object() const { return inputs_[0]; }
1701 LOperand* offset() const { return inputs_[1]; }
1703 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1705 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1709 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1711 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1712 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1716 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1718 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1719 DECLARE_HYDROGEN_ACCESSOR(Context)
1723 class LOuterContext V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1725 explicit LOuterContext(LOperand* context) {
1726 inputs_[0] = context;
1729 LOperand* context() { return inputs_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1735 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1737 explicit LDeclareGlobals(LOperand* context) {
1738 inputs_[0] = context;
1741 LOperand* context() { return inputs_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1744 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1748 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1750 explicit LGlobalObject(LOperand* context) {
1751 inputs_[0] = context;
1754 LOperand* context() { return inputs_[0]; }
1756 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1760 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1762 explicit LGlobalReceiver(LOperand* global_object) {
1763 inputs_[0] = global_object;
1766 LOperand* global() { return inputs_[0]; }
1768 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1772 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1774 explicit LCallJSFunction(LOperand* function) {
1775 inputs_[0] = function;
1778 LOperand* function() { return inputs_[0]; }
1780 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1781 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1783 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1785 int arity() const { return hydrogen()->argument_count() - 1; }
1789 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1791 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1792 ZoneList<LOperand*>& operands,
1794 : inputs_(descriptor->environment_length() + 1, zone) {
1795 ASSERT(descriptor->environment_length() + 1 == operands.length());
1796 inputs_.AddAll(operands, zone);
1799 LOperand* target() const { return inputs_[0]; }
1802 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1803 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1805 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1807 int arity() const { return hydrogen()->argument_count() - 1; }
1809 ZoneList<LOperand*> inputs_;
1811 // Iterator support.
1812 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1813 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1815 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1816 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1820 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1822 LInvokeFunction(LOperand* context, LOperand* function) {
1823 inputs_[0] = context;
1824 inputs_[1] = function;
1827 LOperand* context() { return inputs_[0]; }
1828 LOperand* function() { return inputs_[1]; }
1830 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1831 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1833 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1835 int arity() const { return hydrogen()->argument_count() - 1; }
1839 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1841 LCallFunction(LOperand* context, LOperand* function) {
1842 inputs_[0] = context;
1843 inputs_[1] = function;
1846 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1847 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1849 LOperand* context() { return inputs_[0]; }
1850 LOperand* function() { return inputs_[1]; }
1851 int arity() const { return hydrogen()->argument_count() - 1; }
1855 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1857 LCallNew(LOperand* context, LOperand* constructor) {
1858 inputs_[0] = context;
1859 inputs_[1] = constructor;
1862 LOperand* context() { return inputs_[0]; }
1863 LOperand* constructor() { return inputs_[1]; }
1865 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1866 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1868 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1870 int arity() const { return hydrogen()->argument_count() - 1; }
1874 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1876 LCallNewArray(LOperand* context, LOperand* constructor) {
1877 inputs_[0] = context;
1878 inputs_[1] = constructor;
1881 LOperand* context() { return inputs_[0]; }
1882 LOperand* constructor() { return inputs_[1]; }
1884 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1885 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1887 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1889 int arity() const { return hydrogen()->argument_count() - 1; }
1893 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1895 explicit LCallRuntime(LOperand* context) {
1896 inputs_[0] = context;
1899 LOperand* context() { return inputs_[0]; }
1901 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1902 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1904 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1905 return save_doubles() == kDontSaveFPRegs;
1908 const Runtime::Function* function() const { return hydrogen()->function(); }
1909 int arity() const { return hydrogen()->argument_count(); }
1910 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1914 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1916 explicit LInteger32ToDouble(LOperand* value) {
1920 LOperand* value() { return inputs_[0]; }
1922 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1926 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1928 explicit LInteger32ToSmi(LOperand* value) {
1932 LOperand* value() { return inputs_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1935 DECLARE_HYDROGEN_ACCESSOR(Change)
1939 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1941 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1946 LOperand* value() { return inputs_[0]; }
1947 LOperand* temp() { return temps_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1953 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1955 explicit LUint32ToSmi(LOperand* value) {
1959 LOperand* value() { return inputs_[0]; }
1961 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1962 DECLARE_HYDROGEN_ACCESSOR(Change)
1966 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1968 explicit LNumberTagI(LOperand* value) {
1972 LOperand* value() { return inputs_[0]; }
1974 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1978 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1980 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1985 LOperand* value() { return inputs_[0]; }
1986 LOperand* temp() { return temps_[0]; }
1988 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1992 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1994 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1999 LOperand* value() { return inputs_[0]; }
2000 LOperand* temp() { return temps_[0]; }
2002 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2003 DECLARE_HYDROGEN_ACCESSOR(Change)
2007 // Sometimes truncating conversion from a tagged value to an int32.
2008 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2010 explicit LDoubleToI(LOperand* value) {
2014 LOperand* value() { return inputs_[0]; }
2016 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2017 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2019 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2023 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2025 explicit LDoubleToSmi(LOperand* value) {
2029 LOperand* value() { return inputs_[0]; }
2031 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2032 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2036 // Truncating conversion from a tagged value to an int32.
2037 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2039 LTaggedToI(LOperand* value, LOperand* temp) {
2044 LOperand* value() { return inputs_[0]; }
2045 LOperand* temp() { return temps_[0]; }
2047 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2048 DECLARE_HYDROGEN_ACCESSOR(Change)
2050 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2054 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2056 explicit LSmiTag(LOperand* value) {
2060 LOperand* value() { return inputs_[0]; }
2062 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2066 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2068 explicit LNumberUntagD(LOperand* value) {
2072 LOperand* value() { return inputs_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2075 DECLARE_HYDROGEN_ACCESSOR(Change);
2079 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2081 LSmiUntag(LOperand* value, bool needs_check)
2082 : needs_check_(needs_check) {
2086 LOperand* value() { return inputs_[0]; }
2087 bool needs_check() const { return needs_check_; }
2089 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2096 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2098 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2099 inputs_[0] = object;
2104 LOperand* object() { return inputs_[0]; }
2105 LOperand* value() { return inputs_[1]; }
2106 LOperand* temp() { return temps_[0]; }
2108 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2109 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2111 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2113 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2114 Representation representation() const {
2115 return hydrogen()->field_representation();
2120 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2122 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2123 inputs_[0] = context;
2124 inputs_[1] = object;
2128 LOperand* context() { return inputs_[0]; }
2129 LOperand* object() { return inputs_[1]; }
2130 LOperand* value() { return inputs_[2]; }
2132 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2133 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2135 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2137 Handle<Object> name() const { return hydrogen()->name(); }
2138 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2142 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2144 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2145 inputs_[0] = object;
2150 bool is_external() const { return hydrogen()->is_external(); }
2151 bool is_fixed_typed_array() const {
2152 return hydrogen()->is_fixed_typed_array();
2154 bool is_typed_elements() const {
2155 return is_external() || is_fixed_typed_array();
2157 LOperand* elements() { return inputs_[0]; }
2158 LOperand* key() { return inputs_[1]; }
2159 LOperand* value() { return inputs_[2]; }
2160 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2162 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2163 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2165 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2166 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2167 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2171 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2173 LStoreKeyedGeneric(LOperand* context,
2177 inputs_[0] = context;
2178 inputs_[1] = object;
2183 LOperand* context() { return inputs_[0]; }
2184 LOperand* object() { return inputs_[1]; }
2185 LOperand* key() { return inputs_[2]; }
2186 LOperand* value() { return inputs_[3]; }
2188 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2189 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2191 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2193 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2197 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2199 LTransitionElementsKind(LOperand* object,
2201 LOperand* new_map_temp,
2203 inputs_[0] = object;
2204 inputs_[1] = context;
2205 temps_[0] = new_map_temp;
2209 LOperand* object() { return inputs_[0]; }
2210 LOperand* context() { return inputs_[1]; }
2211 LOperand* new_map_temp() { return temps_[0]; }
2212 LOperand* temp() { return temps_[1]; }
2214 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2215 "transition-elements-kind")
2216 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2218 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2220 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2221 Handle<Map> transitioned_map() {
2222 return hydrogen()->transitioned_map().handle();
2224 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2225 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2229 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2231 LTrapAllocationMemento(LOperand* object,
2233 inputs_[0] = object;
2237 LOperand* object() { return inputs_[0]; }
2238 LOperand* temp() { return temps_[0]; }
2240 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2241 "trap-allocation-memento")
2245 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2247 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2248 inputs_[0] = context;
2253 LOperand* context() { return inputs_[0]; }
2254 LOperand* left() { return inputs_[1]; }
2255 LOperand* right() { return inputs_[2]; }
2257 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2258 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2262 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2264 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2265 inputs_[0] = context;
2266 inputs_[1] = string;
2270 LOperand* context() { return inputs_[0]; }
2271 LOperand* string() { return inputs_[1]; }
2272 LOperand* index() { return inputs_[2]; }
2274 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2275 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2279 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2281 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2282 inputs_[0] = context;
2283 inputs_[1] = char_code;
2286 LOperand* context() { return inputs_[0]; }
2287 LOperand* char_code() { return inputs_[1]; }
2289 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2290 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2294 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2296 explicit LCheckValue(LOperand* value) {
2300 LOperand* value() { return inputs_[0]; }
2302 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2303 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2307 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2309 explicit LCheckInstanceType(LOperand* value) {
2313 LOperand* value() { return inputs_[0]; }
2315 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2316 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2320 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2322 explicit LCheckMaps(LOperand* value) {
2326 LOperand* value() { return inputs_[0]; }
2328 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2329 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2333 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2335 explicit LCheckSmi(LOperand* value) {
2339 LOperand* value() { return inputs_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2345 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2347 explicit LClampDToUint8(LOperand* unclamped) {
2348 inputs_[0] = unclamped;
2351 LOperand* unclamped() { return inputs_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2357 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2359 explicit LClampIToUint8(LOperand* unclamped) {
2360 inputs_[0] = unclamped;
2363 LOperand* unclamped() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2369 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2371 LClampTToUint8(LOperand* unclamped,
2372 LOperand* temp_xmm) {
2373 inputs_[0] = unclamped;
2374 temps_[0] = temp_xmm;
2377 LOperand* unclamped() { return inputs_[0]; }
2378 LOperand* temp_xmm() { return temps_[0]; }
2380 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2384 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2386 explicit LCheckNonSmi(LOperand* value) {
2390 LOperand* value() { return inputs_[0]; }
2392 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2393 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2397 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2399 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2400 inputs_[0] = context;
2405 LOperand* context() { return inputs_[0]; }
2406 LOperand* size() { return inputs_[1]; }
2407 LOperand* temp() { return temps_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2410 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2414 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2416 explicit LRegExpLiteral(LOperand* context) {
2417 inputs_[0] = context;
2420 LOperand* context() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2423 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2427 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2429 explicit LFunctionLiteral(LOperand* context) {
2430 inputs_[0] = context;
2433 LOperand* context() { return inputs_[0]; }
2435 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2436 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2440 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2442 explicit LToFastProperties(LOperand* value) {
2446 LOperand* value() { return inputs_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2449 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2453 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2455 LTypeof(LOperand* context, LOperand* value) {
2456 inputs_[0] = context;
2460 LOperand* context() { return inputs_[0]; }
2461 LOperand* value() { return inputs_[1]; }
2463 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2467 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2469 explicit LTypeofIsAndBranch(LOperand* value) {
2473 LOperand* value() { return inputs_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2476 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2478 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2480 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2484 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2486 explicit LIsConstructCallAndBranch(LOperand* temp) {
2490 LOperand* temp() { return temps_[0]; }
2492 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2493 "is-construct-call-and-branch")
2494 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2498 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2502 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2505 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2509 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2511 explicit LStackCheck(LOperand* context) {
2512 inputs_[0] = context;
2515 LOperand* context() { return inputs_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2518 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2520 Label* done_label() { return &done_label_; }
2527 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2529 LForInPrepareMap(LOperand* context, LOperand* object) {
2530 inputs_[0] = context;
2531 inputs_[1] = object;
2534 LOperand* context() { return inputs_[0]; }
2535 LOperand* object() { return inputs_[1]; }
2537 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2541 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2543 explicit LForInCacheArray(LOperand* map) {
2547 LOperand* map() { return inputs_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2552 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2557 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2559 LCheckMapValue(LOperand* value, LOperand* map) {
2564 LOperand* value() { return inputs_[0]; }
2565 LOperand* map() { return inputs_[1]; }
2567 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2571 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2573 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2574 inputs_[0] = object;
2578 LOperand* object() { return inputs_[0]; }
2579 LOperand* index() { return inputs_[1]; }
2581 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2585 class LChunkBuilder;
2586 class LPlatformChunk V8_FINAL : public LChunk {
2588 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2589 : LChunk(info, graph) { }
2591 int GetNextSpillIndex(RegisterKind kind);
2592 LOperand* GetNextSpillSlot(RegisterKind kind);
2596 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2598 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2599 : LChunkBuilderBase(graph->zone()),
2604 current_instruction_(NULL),
2605 current_block_(NULL),
2607 allocator_(allocator),
2608 instruction_pending_deoptimization_environment_(NULL),
2609 pending_deoptimization_ast_id_(BailoutId::None()) { }
2611 // Build the sequence for the graph.
2612 LPlatformChunk* Build();
2614 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2616 // Declare methods that deal with the individual node types.
2617 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2618 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2621 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2622 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2623 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2624 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2625 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2626 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2627 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2637 LPlatformChunk* chunk() const { return chunk_; }
2638 CompilationInfo* info() const { return info_; }
2639 HGraph* graph() const { return graph_; }
2641 bool is_unused() const { return status_ == UNUSED; }
2642 bool is_building() const { return status_ == BUILDING; }
2643 bool is_done() const { return status_ == DONE; }
2644 bool is_aborted() const { return status_ == ABORTED; }
2646 void Abort(BailoutReason reason);
2648 // Methods for getting operands for Use / Define / Temp.
2649 LUnallocated* ToUnallocated(Register reg);
2650 LUnallocated* ToUnallocated(XMMRegister reg);
2652 // Methods for setting up define-use relationships.
2653 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2654 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2655 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2656 XMMRegister fixed_register);
2658 // A value that is guaranteed to be allocated to a register.
2659 // Operand created by UseRegister is guaranteed to be live until the end of
2660 // instruction. This means that register allocator will not reuse it's
2661 // register for any other operand inside instruction.
2662 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2663 // instruction start. Register allocator is free to assign the same register
2664 // to some other operand used inside instruction (i.e. temporary or
2666 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2667 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2669 // An input operand in a register that may be trashed.
2670 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2672 // An input operand in a register that may be trashed or a constant operand.
2673 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2675 // An input operand in a register or stack slot.
2676 MUST_USE_RESULT LOperand* Use(HValue* value);
2677 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2679 // An input operand in a register, stack slot or a constant operand.
2680 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2681 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2683 // An input operand in a register or a constant operand.
2684 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2685 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2687 // An input operand in a constant operand.
2688 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2690 // An input operand in register, stack slot or a constant operand.
2691 // Will not be moved to a register even if one is freely available.
2692 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2694 // Temporary operand that must be in a register.
2695 MUST_USE_RESULT LUnallocated* TempRegister();
2696 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2697 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2699 // Methods for setting up define-use relationships.
2700 // Return the same instruction that they are passed.
2701 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2702 LUnallocated* result);
2703 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2704 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2706 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2707 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2709 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2711 // Assigns an environment to an instruction. An instruction which can
2712 // deoptimize must have an environment.
2713 LInstruction* AssignEnvironment(LInstruction* instr);
2714 // Assigns a pointer map to an instruction. An instruction which can
2715 // trigger a GC or a lazy deoptimization must have a pointer map.
2716 LInstruction* AssignPointerMap(LInstruction* instr);
2718 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2720 // Marks a call for the register allocator. Assigns a pointer map to
2721 // support GC and lazy deoptimization. Assigns an environment to support
2722 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2723 LInstruction* MarkAsCall(
2724 LInstruction* instr,
2725 HInstruction* hinstr,
2726 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2728 void VisitInstruction(HInstruction* current);
2730 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2731 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2732 LInstruction* DoArithmeticD(Token::Value op,
2733 HArithmeticBinaryOperation* instr);
2734 LInstruction* DoArithmeticT(Token::Value op,
2735 HBinaryOperation* instr);
2737 LPlatformChunk* chunk_;
2738 CompilationInfo* info_;
2739 HGraph* const graph_;
2741 HInstruction* current_instruction_;
2742 HBasicBlock* current_block_;
2743 HBasicBlock* next_block_;
2744 LAllocator* allocator_;
2745 LInstruction* instruction_pending_deoptimization_environment_;
2746 BailoutId pending_deoptimization_ast_id_;
2748 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2751 #undef DECLARE_HYDROGEN_ACCESSOR
2752 #undef DECLARE_CONCRETE_INSTRUCTION
2754 } } // namespace v8::int
2756 #endif // V8_X64_LITHIUM_X64_H_