1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
97 V(GetCachedArrayIndex) \
99 V(HasCachedArrayIndexAndBranch) \
100 V(HasInstanceTypeAndBranch) \
101 V(InnerAllocatedObject) \
103 V(InstanceOfKnownGlobal) \
105 V(Integer32ToDouble) \
108 V(IsConstructCallAndBranch) \
109 V(IsObjectAndBranch) \
110 V(IsStringAndBranch) \
112 V(IsUndetectableAndBranch) \
117 V(LoadFieldByIndex) \
118 V(LoadFunctionPrototype) \
120 V(LoadGlobalGeneric) \
122 V(LoadKeyedGeneric) \
124 V(LoadNamedGeneric) \
148 V(SeqStringGetChar) \
149 V(SeqStringSetChar) \
155 V(StoreContextSlot) \
158 V(StoreKeyedGeneric) \
160 V(StoreNamedGeneric) \
162 V(StringCharCodeAt) \
163 V(StringCharFromCode) \
164 V(StringCompareAndBranch) \
168 V(ToFastProperties) \
169 V(TransitionElementsKind) \
170 V(TrapAllocationMemento) \
172 V(TypeofIsAndBranch) \
179 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
180 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
181 return LInstruction::k##type; \
183 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
184 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
187 static L##type* cast(LInstruction* instr) { \
188 ASSERT(instr->Is##type()); \
189 return reinterpret_cast<L##type*>(instr); \
193 #define DECLARE_HYDROGEN_ACCESSOR(type) \
194 H##type* hydrogen() const { \
195 return H##type::cast(hydrogen_value()); \
199 class LInstruction : public ZoneObject {
202 : environment_(NULL),
203 hydrogen_value_(NULL),
204 bit_field_(IsCallBits::encode(false)) {
207 virtual ~LInstruction() {}
209 virtual void CompileToNative(LCodeGen* generator) = 0;
210 virtual const char* Mnemonic() const = 0;
211 virtual void PrintTo(StringStream* stream);
212 virtual void PrintDataTo(StringStream* stream);
213 virtual void PrintOutputOperandTo(StringStream* stream);
216 // Declare a unique enum value for each instruction.
217 #define DECLARE_OPCODE(type) k##type,
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
219 kNumberOfInstructions
220 #undef DECLARE_OPCODE
223 virtual Opcode opcode() const = 0;
225 // Declare non-virtual type testers for all leaf IR classes.
226 #define DECLARE_PREDICATE(type) \
227 bool Is##type() const { return opcode() == k##type; }
228 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
229 #undef DECLARE_PREDICATE
231 // Declare virtual predicates for instructions that don't have
233 virtual bool IsGap() const { return false; }
235 virtual bool IsControl() const { return false; }
237 void set_environment(LEnvironment* env) { environment_ = env; }
238 LEnvironment* environment() const { return environment_; }
239 bool HasEnvironment() const { return environment_ != NULL; }
241 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
242 LPointerMap* pointer_map() const { return pointer_map_.get(); }
243 bool HasPointerMap() const { return pointer_map_.is_set(); }
245 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
246 HValue* hydrogen_value() const { return hydrogen_value_; }
248 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
249 bool IsCall() const { return IsCallBits::decode(bit_field_); }
251 // Interface to the register allocator and iterators.
252 bool ClobbersTemps() const { return IsCall(); }
253 bool ClobbersRegisters() const { return IsCall(); }
254 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
256 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
258 // Interface to the register allocator and iterators.
259 bool IsMarkedAsCall() const { return IsCall(); }
261 virtual bool HasResult() const = 0;
262 virtual LOperand* result() const = 0;
264 LOperand* FirstInput() { return InputAt(0); }
265 LOperand* Output() { return HasResult() ? result() : NULL; }
267 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
275 friend class InputIterator;
276 virtual int InputCount() = 0;
277 virtual LOperand* InputAt(int i) = 0;
279 friend class TempIterator;
280 virtual int TempCount() = 0;
281 virtual LOperand* TempAt(int i) = 0;
283 class IsCallBits: public BitField<bool, 0, 1> {};
285 LEnvironment* environment_;
286 SetOncePointer<LPointerMap> pointer_map_;
287 HValue* hydrogen_value_;
292 // R = number of result operands (0 or 1).
294 class LTemplateResultInstruction : public LInstruction {
296 // Allow 0 or 1 output operands.
297 STATIC_ASSERT(R == 0 || R == 1);
298 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
299 return R != 0 && result() != NULL;
301 void set_result(LOperand* operand) { results_[0] = operand; }
302 LOperand* result() const { return results_[0]; }
305 EmbeddedContainer<LOperand*, R> results_;
309 // R = number of result operands (0 or 1).
310 // I = number of input operands.
311 // T = number of temporary operands.
312 template<int R, int I, int T>
313 class LTemplateInstruction : public LTemplateResultInstruction<R> {
315 EmbeddedContainer<LOperand*, I> inputs_;
316 EmbeddedContainer<LOperand*, T> temps_;
320 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
321 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
323 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
324 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
328 class LGap : public LTemplateInstruction<0, 0, 0> {
330 explicit LGap(HBasicBlock* block)
332 parallel_moves_[BEFORE] = NULL;
333 parallel_moves_[START] = NULL;
334 parallel_moves_[END] = NULL;
335 parallel_moves_[AFTER] = NULL;
338 // Can't use the DECLARE-macro here because of sub-classes.
339 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
340 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
341 static LGap* cast(LInstruction* instr) {
342 ASSERT(instr->IsGap());
343 return reinterpret_cast<LGap*>(instr);
346 bool IsRedundant() const;
348 HBasicBlock* block() const { return block_; }
355 FIRST_INNER_POSITION = BEFORE,
356 LAST_INNER_POSITION = AFTER
359 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
361 if (parallel_moves_[pos] == NULL) {
362 parallel_moves_[pos] = new(zone) LParallelMove(zone);
364 return parallel_moves_[pos];
367 LParallelMove* GetParallelMove(InnerPosition pos) {
368 return parallel_moves_[pos];
372 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
377 class LInstructionGap V8_FINAL : public LGap {
379 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
381 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
382 return !IsRedundant();
385 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
389 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
391 explicit LGoto(HBasicBlock* block) : block_(block) { }
393 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
394 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
395 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
396 virtual bool IsControl() const V8_OVERRIDE { return true; }
398 int block_id() const { return block_->block_id(); }
405 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
407 LLazyBailout() : gap_instructions_size_(0) { }
409 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
411 void set_gap_instructions_size(int gap_instructions_size) {
412 gap_instructions_size_ = gap_instructions_size;
414 int gap_instructions_size() { return gap_instructions_size_; }
417 int gap_instructions_size_;
421 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
423 explicit LDummy() { }
424 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
428 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
430 explicit LDummyUse(LOperand* value) {
433 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
437 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
439 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
440 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
444 class LLabel V8_FINAL : public LGap {
446 explicit LLabel(HBasicBlock* block)
447 : LGap(block), replacement_(NULL) { }
449 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
452 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
454 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
456 int block_id() const { return block()->block_id(); }
457 bool is_loop_header() const { return block()->IsLoopHeader(); }
458 bool is_osr_entry() const { return block()->is_osr_entry(); }
459 Label* label() { return &label_; }
460 LLabel* replacement() const { return replacement_; }
461 void set_replacement(LLabel* label) { replacement_ = label; }
462 bool HasReplacement() const { return replacement_ != NULL; }
466 LLabel* replacement_;
470 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
472 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
475 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
479 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
481 explicit LCallStub(LOperand* context) {
482 inputs_[0] = context;
485 LOperand* context() { return inputs_[0]; }
487 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
488 DECLARE_HYDROGEN_ACCESSOR(CallStub)
492 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
494 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
497 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
501 template<int I, int T>
502 class LControlInstruction : public LTemplateInstruction<0, I, T> {
504 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
506 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
508 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
509 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
511 int TrueDestination(LChunk* chunk) {
512 return chunk->LookupDestination(true_block_id());
514 int FalseDestination(LChunk* chunk) {
515 return chunk->LookupDestination(false_block_id());
518 Label* TrueLabel(LChunk* chunk) {
519 if (true_label_ == NULL) {
520 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
524 Label* FalseLabel(LChunk* chunk) {
525 if (false_label_ == NULL) {
526 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
532 int true_block_id() { return SuccessorAt(0)->block_id(); }
533 int false_block_id() { return SuccessorAt(1)->block_id(); }
536 HControlInstruction* hydrogen() {
537 return HControlInstruction::cast(this->hydrogen_value());
545 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
547 LWrapReceiver(LOperand* receiver, LOperand* function) {
548 inputs_[0] = receiver;
549 inputs_[1] = function;
552 LOperand* receiver() { return inputs_[0]; }
553 LOperand* function() { return inputs_[1]; }
555 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
556 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
560 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
562 LApplyArguments(LOperand* function,
565 LOperand* elements) {
566 inputs_[0] = function;
567 inputs_[1] = receiver;
569 inputs_[3] = elements;
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
583 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
584 inputs_[0] = arguments;
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
599 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
601 explicit LArgumentsLength(LOperand* elements) {
602 inputs_[0] = elements;
605 LOperand* elements() { return inputs_[0]; }
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
611 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
614 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
618 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
620 LModI(LOperand* left, LOperand* right, LOperand* temp) {
626 LOperand* left() { return inputs_[0]; }
627 LOperand* right() { return inputs_[1]; }
628 LOperand* temp() { return temps_[0]; }
630 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
631 DECLARE_HYDROGEN_ACCESSOR(Mod)
635 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
637 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
643 LOperand* left() { return inputs_[0]; }
644 LOperand* right() { return inputs_[1]; }
645 LOperand* temp() { return temps_[0]; }
647 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
649 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
650 DECLARE_HYDROGEN_ACCESSOR(Div)
654 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
656 LMathFloorOfDiv(LOperand* left,
658 LOperand* temp = NULL) {
664 LOperand* left() { return inputs_[0]; }
665 LOperand* right() { return inputs_[1]; }
666 LOperand* temp() { return temps_[0]; }
668 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
669 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
673 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
675 LMulI(LOperand* left, LOperand* right) {
680 LOperand* left() { return inputs_[0]; }
681 LOperand* right() { return inputs_[1]; }
683 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
684 DECLARE_HYDROGEN_ACCESSOR(Mul)
688 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
690 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
695 LOperand* left() { return inputs_[0]; }
696 LOperand* right() { return inputs_[1]; }
698 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
699 "compare-numeric-and-branch")
700 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
702 Token::Value op() const { return hydrogen()->token(); }
703 bool is_double() const {
704 return hydrogen()->representation().IsDouble();
707 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
711 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
713 explicit LMathFloor(LOperand* value) {
717 LOperand* value() { return inputs_[0]; }
719 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
720 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
724 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
726 explicit LMathRound(LOperand* value) {
730 LOperand* value() { return inputs_[0]; }
732 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
733 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
737 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
739 explicit LMathAbs(LOperand* context, LOperand* value) {
740 inputs_[1] = context;
744 LOperand* context() { return inputs_[1]; }
745 LOperand* value() { return inputs_[0]; }
747 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
748 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
752 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
754 explicit LMathLog(LOperand* value) {
758 LOperand* value() { return inputs_[0]; }
760 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
764 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
766 explicit LMathClz32(LOperand* value) {
770 LOperand* value() { return inputs_[0]; }
772 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
776 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
778 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
782 ExternalReference::InitializeMathExpData();
785 LOperand* value() { return inputs_[0]; }
786 LOperand* temp1() { return temps_[0]; }
787 LOperand* temp2() { return temps_[1]; }
789 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
793 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
795 explicit LMathSqrt(LOperand* value) {
799 LOperand* value() { return inputs_[0]; }
801 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
805 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
807 explicit LMathPowHalf(LOperand* value) {
811 LOperand* value() { return inputs_[0]; }
813 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
817 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
819 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
824 LOperand* left() { return inputs_[0]; }
825 LOperand* right() { return inputs_[1]; }
827 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
831 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
833 explicit LCmpHoleAndBranch(LOperand* object) {
837 LOperand* object() { return inputs_[0]; }
839 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
840 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
844 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
846 explicit LCompareMinusZeroAndBranch(LOperand* value) {
850 LOperand* value() { return inputs_[0]; }
852 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
853 "cmp-minus-zero-and-branch")
854 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
859 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
861 explicit LIsObjectAndBranch(LOperand* value) {
865 LOperand* value() { return inputs_[0]; }
867 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
868 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
870 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
874 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
876 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
881 LOperand* value() { return inputs_[0]; }
882 LOperand* temp() { return temps_[0]; }
884 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
885 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
887 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
891 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
893 explicit LIsSmiAndBranch(LOperand* value) {
897 LOperand* value() { return inputs_[0]; }
899 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
900 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
902 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
906 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
908 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
913 LOperand* value() { return inputs_[0]; }
914 LOperand* temp() { return temps_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
917 "is-undetectable-and-branch")
918 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
920 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
924 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
926 explicit LStringCompareAndBranch(LOperand* context,
929 inputs_[0] = context;
934 LOperand* context() { return inputs_[0]; }
935 LOperand* left() { return inputs_[1]; }
936 LOperand* right() { return inputs_[2]; }
938 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
939 "string-compare-and-branch")
940 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
942 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
944 Token::Value op() const { return hydrogen()->token(); }
948 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
950 explicit LHasInstanceTypeAndBranch(LOperand* value) {
954 LOperand* value() { return inputs_[0]; }
956 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
957 "has-instance-type-and-branch")
958 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
960 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
964 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
966 explicit LGetCachedArrayIndex(LOperand* value) {
970 LOperand* value() { return inputs_[0]; }
972 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
973 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
977 class LHasCachedArrayIndexAndBranch V8_FINAL
978 : public LControlInstruction<1, 0> {
980 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
984 LOperand* value() { return inputs_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
987 "has-cached-array-index-and-branch")
988 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
990 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
994 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
996 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1002 LOperand* value() { return inputs_[0]; }
1003 LOperand* temp() { return temps_[0]; }
1004 LOperand* temp2() { return temps_[1]; }
1006 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1007 "class-of-test-and-branch")
1008 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1010 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1014 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1016 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1017 inputs_[0] = context;
1022 LOperand* context() { return inputs_[0]; }
1023 LOperand* left() { return inputs_[1]; }
1024 LOperand* right() { return inputs_[2]; }
1026 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1027 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1029 Token::Value op() const { return hydrogen()->token(); }
1033 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1035 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1036 inputs_[0] = context;
1041 LOperand* context() { return inputs_[0]; }
1042 LOperand* left() { return inputs_[1]; }
1043 LOperand* right() { return inputs_[2]; }
1045 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1049 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1051 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1052 inputs_[0] = context;
1057 LOperand* context() { return inputs_[0]; }
1058 LOperand* value() { return inputs_[1]; }
1059 LOperand* temp() { return temps_[0]; }
1061 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1062 "instance-of-known-global")
1063 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1065 Handle<JSFunction> function() const { return hydrogen()->function(); }
1066 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1067 return lazy_deopt_env_;
1069 virtual void SetDeferredLazyDeoptimizationEnvironment(
1070 LEnvironment* env) V8_OVERRIDE {
1071 lazy_deopt_env_ = env;
1075 LEnvironment* lazy_deopt_env_;
1079 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1081 LBoundsCheck(LOperand* index, LOperand* length) {
1083 inputs_[1] = length;
1086 LOperand* index() { return inputs_[0]; }
1087 LOperand* length() { return inputs_[1]; }
1089 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1090 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1094 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1096 LBitI(LOperand* left, LOperand* right) {
1101 LOperand* left() { return inputs_[0]; }
1102 LOperand* right() { return inputs_[1]; }
1104 Token::Value op() const { return hydrogen()->op(); }
1106 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1107 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1111 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1113 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1114 : op_(op), can_deopt_(can_deopt) {
1119 Token::Value op() const { return op_; }
1120 LOperand* left() { return inputs_[0]; }
1121 LOperand* right() { return inputs_[1]; }
1122 bool can_deopt() const { return can_deopt_; }
1124 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1132 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1134 LSubI(LOperand* left, LOperand* right) {
1139 LOperand* left() { return inputs_[0]; }
1140 LOperand* right() { return inputs_[1]; }
1142 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1143 DECLARE_HYDROGEN_ACCESSOR(Sub)
1147 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1149 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1150 DECLARE_HYDROGEN_ACCESSOR(Constant)
1152 int32_t value() const { return hydrogen()->Integer32Value(); }
1156 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1158 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1159 DECLARE_HYDROGEN_ACCESSOR(Constant)
1161 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1165 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1167 explicit LConstantD(LOperand* temp) {
1171 LOperand* temp() { return temps_[0]; }
1173 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1174 DECLARE_HYDROGEN_ACCESSOR(Constant)
1176 double value() const { return hydrogen()->DoubleValue(); }
1180 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1182 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1183 DECLARE_HYDROGEN_ACCESSOR(Constant)
1185 ExternalReference value() const {
1186 return hydrogen()->ExternalReferenceValue();
1191 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1193 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1194 DECLARE_HYDROGEN_ACCESSOR(Constant)
1196 Handle<Object> value(Isolate* isolate) const {
1197 return hydrogen()->handle(isolate);
1202 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1204 explicit LBranch(LOperand* value) {
1208 LOperand* value() { return inputs_[0]; }
1210 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1211 DECLARE_HYDROGEN_ACCESSOR(Branch)
1213 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1217 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1219 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1223 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1225 explicit LCmpMapAndBranch(LOperand* value) {
1229 LOperand* value() { return inputs_[0]; }
1231 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1232 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1234 Handle<Map> map() const { return hydrogen()->map().handle(); }
1238 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1240 explicit LMapEnumLength(LOperand* value) {
1244 LOperand* value() { return inputs_[0]; }
1246 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1250 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1252 LDateField(LOperand* date, Smi* index) : index_(index) {
1256 LOperand* date() { return inputs_[0]; }
1257 Smi* index() const { return index_; }
1259 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1260 DECLARE_HYDROGEN_ACCESSOR(DateField)
1267 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1269 LSeqStringGetChar(LOperand* string, LOperand* index) {
1270 inputs_[0] = string;
1274 LOperand* string() const { return inputs_[0]; }
1275 LOperand* index() const { return inputs_[1]; }
1277 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1278 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1282 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1284 LSeqStringSetChar(LOperand* context,
1288 inputs_[0] = context;
1289 inputs_[1] = string;
1294 LOperand* string() { return inputs_[1]; }
1295 LOperand* index() { return inputs_[2]; }
1296 LOperand* value() { return inputs_[3]; }
1298 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1299 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1303 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1305 LAddI(LOperand* left, LOperand* right) {
1310 LOperand* left() { return inputs_[0]; }
1311 LOperand* right() { return inputs_[1]; }
1313 static bool UseLea(HAdd* add) {
1314 return !add->CheckFlag(HValue::kCanOverflow) &&
1315 add->BetterLeftOperand()->UseCount() > 1;
1318 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1319 DECLARE_HYDROGEN_ACCESSOR(Add)
1323 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1325 LMathMinMax(LOperand* left, LOperand* right) {
1330 LOperand* left() { return inputs_[0]; }
1331 LOperand* right() { return inputs_[1]; }
1333 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1334 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1338 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1340 LPower(LOperand* left, LOperand* right) {
1345 LOperand* left() { return inputs_[0]; }
1346 LOperand* right() { return inputs_[1]; }
1348 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1349 DECLARE_HYDROGEN_ACCESSOR(Power)
1353 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1355 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1361 Token::Value op() const { return op_; }
1362 LOperand* left() { return inputs_[0]; }
1363 LOperand* right() { return inputs_[1]; }
1365 virtual Opcode opcode() const V8_OVERRIDE {
1366 return LInstruction::kArithmeticD;
1368 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1369 virtual const char* Mnemonic() const V8_OVERRIDE;
1376 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1378 LArithmeticT(Token::Value op,
1383 inputs_[0] = context;
1388 Token::Value op() const { return op_; }
1389 LOperand* context() { return inputs_[0]; }
1390 LOperand* left() { return inputs_[1]; }
1391 LOperand* right() { return inputs_[2]; }
1393 virtual Opcode opcode() const V8_OVERRIDE {
1394 return LInstruction::kArithmeticT;
1396 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1397 virtual const char* Mnemonic() const V8_OVERRIDE;
1404 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1406 explicit LReturn(LOperand* value,
1408 LOperand* parameter_count) {
1410 inputs_[1] = context;
1411 inputs_[2] = parameter_count;
1414 LOperand* value() { return inputs_[0]; }
1415 LOperand* context() { return inputs_[1]; }
1417 bool has_constant_parameter_count() {
1418 return parameter_count()->IsConstantOperand();
1420 LConstantOperand* constant_parameter_count() {
1421 ASSERT(has_constant_parameter_count());
1422 return LConstantOperand::cast(parameter_count());
1424 LOperand* parameter_count() { return inputs_[2]; }
1426 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1427 DECLARE_HYDROGEN_ACCESSOR(Return)
1431 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1433 explicit LLoadNamedField(LOperand* object) {
1434 inputs_[0] = object;
1437 LOperand* object() { return inputs_[0]; }
1439 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1440 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1444 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1446 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1447 inputs_[0] = context;
1448 inputs_[1] = object;
1451 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1452 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1454 LOperand* context() { return inputs_[0]; }
1455 LOperand* object() { return inputs_[1]; }
1456 Handle<Object> name() const { return hydrogen()->name(); }
1460 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1462 explicit LLoadFunctionPrototype(LOperand* function) {
1463 inputs_[0] = function;
1466 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1467 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1469 LOperand* function() { return inputs_[0]; }
1473 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1475 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1476 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1478 Heap::RootListIndex index() const { return hydrogen()->index(); }
1482 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LLoadKeyed(LOperand* elements, LOperand* key) {
1485 inputs_[0] = elements;
1489 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1490 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1492 bool is_external() const {
1493 return hydrogen()->is_external();
1495 bool is_fixed_typed_array() const {
1496 return hydrogen()->is_fixed_typed_array();
1498 bool is_typed_elements() const {
1499 return is_external() || is_fixed_typed_array();
1501 LOperand* elements() { return inputs_[0]; }
1502 LOperand* key() { return inputs_[1]; }
1503 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1504 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1505 ElementsKind elements_kind() const {
1506 return hydrogen()->elements_kind();
1511 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1513 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1514 inputs_[0] = context;
1519 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1521 LOperand* context() { return inputs_[0]; }
1522 LOperand* object() { return inputs_[1]; }
1523 LOperand* key() { return inputs_[2]; }
1527 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1529 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1530 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1534 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1536 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1537 inputs_[0] = context;
1538 inputs_[1] = global_object;
1541 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1542 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1544 LOperand* context() { return inputs_[0]; }
1545 LOperand* global_object() { return inputs_[1]; }
1546 Handle<Object> name() const { return hydrogen()->name(); }
1547 bool for_typeof() const { return hydrogen()->for_typeof(); }
1551 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1553 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1558 LOperand* value() { return inputs_[0]; }
1559 LOperand* temp() { return temps_[0]; }
1561 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1562 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1566 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1568 explicit LLoadContextSlot(LOperand* context) {
1569 inputs_[0] = context;
1572 LOperand* context() { return inputs_[0]; }
1574 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1575 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1577 int slot_index() { return hydrogen()->slot_index(); }
1579 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1583 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1585 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1586 inputs_[0] = context;
1591 LOperand* context() { return inputs_[0]; }
1592 LOperand* value() { return inputs_[1]; }
1593 LOperand* temp() { return temps_[0]; }
1595 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1596 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1598 int slot_index() { return hydrogen()->slot_index(); }
1600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1604 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1606 explicit LPushArgument(LOperand* value) {
1610 LOperand* value() { return inputs_[0]; }
1612 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1616 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1618 explicit LDrop(int count) : count_(count) { }
1620 int count() const { return count_; }
1622 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1629 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1631 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1632 inputs_[0] = function;
1633 temps_[0] = code_object;
1636 LOperand* function() { return inputs_[0]; }
1637 LOperand* code_object() { return temps_[0]; }
1639 virtual void PrintDataTo(StringStream* stream);
1641 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1642 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1646 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1648 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1649 inputs_[0] = base_object;
1650 inputs_[1] = offset;
1653 LOperand* base_object() const { return inputs_[0]; }
1654 LOperand* offset() const { return inputs_[1]; }
1656 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1658 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1662 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1664 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1665 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1669 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1671 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1672 DECLARE_HYDROGEN_ACCESSOR(Context)
1676 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1678 explicit LDeclareGlobals(LOperand* context) {
1679 inputs_[0] = context;
1682 LOperand* context() { return inputs_[0]; }
1684 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1685 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1689 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1691 explicit LCallJSFunction(LOperand* function) {
1692 inputs_[0] = function;
1695 LOperand* function() { return inputs_[0]; }
1697 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1698 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1700 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1702 int arity() const { return hydrogen()->argument_count() - 1; }
1706 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1708 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1709 ZoneList<LOperand*>& operands,
1711 : inputs_(descriptor->environment_length() + 1, zone) {
1712 ASSERT(descriptor->environment_length() + 1 == operands.length());
1713 inputs_.AddAll(operands, zone);
1716 LOperand* target() const { return inputs_[0]; }
1719 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1720 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1722 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1724 int arity() const { return hydrogen()->argument_count() - 1; }
1726 ZoneList<LOperand*> inputs_;
1728 // Iterator support.
1729 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1730 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1732 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1733 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1737 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1739 LInvokeFunction(LOperand* context, LOperand* function) {
1740 inputs_[0] = context;
1741 inputs_[1] = function;
1744 LOperand* context() { return inputs_[0]; }
1745 LOperand* function() { return inputs_[1]; }
1747 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1748 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1750 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1752 int arity() const { return hydrogen()->argument_count() - 1; }
1756 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1758 LCallFunction(LOperand* context, LOperand* function) {
1759 inputs_[0] = context;
1760 inputs_[1] = function;
1763 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1764 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1766 LOperand* context() { return inputs_[0]; }
1767 LOperand* function() { return inputs_[1]; }
1768 int arity() const { return hydrogen()->argument_count() - 1; }
1772 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1774 LCallNew(LOperand* context, LOperand* constructor) {
1775 inputs_[0] = context;
1776 inputs_[1] = constructor;
1779 LOperand* context() { return inputs_[0]; }
1780 LOperand* constructor() { return inputs_[1]; }
1782 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1783 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1785 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1787 int arity() const { return hydrogen()->argument_count() - 1; }
1791 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1793 LCallNewArray(LOperand* context, LOperand* constructor) {
1794 inputs_[0] = context;
1795 inputs_[1] = constructor;
1798 LOperand* context() { return inputs_[0]; }
1799 LOperand* constructor() { return inputs_[1]; }
1801 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1802 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1804 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1806 int arity() const { return hydrogen()->argument_count() - 1; }
1810 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1812 explicit LCallRuntime(LOperand* context) {
1813 inputs_[0] = context;
1816 LOperand* context() { return inputs_[0]; }
1818 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1819 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1821 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1822 return save_doubles() == kDontSaveFPRegs;
1825 const Runtime::Function* function() const { return hydrogen()->function(); }
1826 int arity() const { return hydrogen()->argument_count(); }
1827 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1831 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1833 explicit LInteger32ToDouble(LOperand* value) {
1837 LOperand* value() { return inputs_[0]; }
1839 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1843 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1845 explicit LInteger32ToSmi(LOperand* value) {
1849 LOperand* value() { return inputs_[0]; }
1851 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1852 DECLARE_HYDROGEN_ACCESSOR(Change)
1856 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1858 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1863 LOperand* value() { return inputs_[0]; }
1864 LOperand* temp() { return temps_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1870 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1872 explicit LUint32ToSmi(LOperand* value) {
1876 LOperand* value() { return inputs_[0]; }
1878 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1879 DECLARE_HYDROGEN_ACCESSOR(Change)
1883 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1885 explicit LNumberTagI(LOperand* value) {
1889 LOperand* value() { return inputs_[0]; }
1891 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1895 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1897 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1902 LOperand* value() { return inputs_[0]; }
1903 LOperand* temp() { return temps_[0]; }
1905 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1909 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1911 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1916 LOperand* value() { return inputs_[0]; }
1917 LOperand* temp() { return temps_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1920 DECLARE_HYDROGEN_ACCESSOR(Change)
1924 // Sometimes truncating conversion from a tagged value to an int32.
1925 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1927 explicit LDoubleToI(LOperand* value) {
1931 LOperand* value() { return inputs_[0]; }
1933 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1934 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1936 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1940 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1942 explicit LDoubleToSmi(LOperand* value) {
1946 LOperand* value() { return inputs_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1949 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1953 // Truncating conversion from a tagged value to an int32.
1954 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1956 LTaggedToI(LOperand* value, LOperand* temp) {
1961 LOperand* value() { return inputs_[0]; }
1962 LOperand* temp() { return temps_[0]; }
1964 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1965 DECLARE_HYDROGEN_ACCESSOR(Change)
1967 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1971 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1973 explicit LSmiTag(LOperand* value) {
1977 LOperand* value() { return inputs_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1983 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1985 explicit LNumberUntagD(LOperand* value) {
1989 LOperand* value() { return inputs_[0]; }
1991 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1992 DECLARE_HYDROGEN_ACCESSOR(Change);
1996 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1998 LSmiUntag(LOperand* value, bool needs_check)
1999 : needs_check_(needs_check) {
2003 LOperand* value() { return inputs_[0]; }
2004 bool needs_check() const { return needs_check_; }
2006 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2013 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2015 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2016 inputs_[0] = object;
2021 LOperand* object() { return inputs_[0]; }
2022 LOperand* value() { return inputs_[1]; }
2023 LOperand* temp() { return temps_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2026 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2030 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2031 Representation representation() const {
2032 return hydrogen()->field_representation();
2037 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2039 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2040 inputs_[0] = context;
2041 inputs_[1] = object;
2045 LOperand* context() { return inputs_[0]; }
2046 LOperand* object() { return inputs_[1]; }
2047 LOperand* value() { return inputs_[2]; }
2049 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2050 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2052 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2054 Handle<Object> name() const { return hydrogen()->name(); }
2055 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2059 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2061 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2062 inputs_[0] = object;
2067 bool is_external() const { return hydrogen()->is_external(); }
2068 bool is_fixed_typed_array() const {
2069 return hydrogen()->is_fixed_typed_array();
2071 bool is_typed_elements() const {
2072 return is_external() || is_fixed_typed_array();
2074 LOperand* elements() { return inputs_[0]; }
2075 LOperand* key() { return inputs_[1]; }
2076 LOperand* value() { return inputs_[2]; }
2077 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2079 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2080 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2082 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2083 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2084 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2088 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2090 LStoreKeyedGeneric(LOperand* context,
2094 inputs_[0] = context;
2095 inputs_[1] = object;
2100 LOperand* context() { return inputs_[0]; }
2101 LOperand* object() { return inputs_[1]; }
2102 LOperand* key() { return inputs_[2]; }
2103 LOperand* value() { return inputs_[3]; }
2105 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2106 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2108 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2110 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2114 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2116 LTransitionElementsKind(LOperand* object,
2118 LOperand* new_map_temp,
2120 inputs_[0] = object;
2121 inputs_[1] = context;
2122 temps_[0] = new_map_temp;
2126 LOperand* object() { return inputs_[0]; }
2127 LOperand* context() { return inputs_[1]; }
2128 LOperand* new_map_temp() { return temps_[0]; }
2129 LOperand* temp() { return temps_[1]; }
2131 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2132 "transition-elements-kind")
2133 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2135 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2137 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2138 Handle<Map> transitioned_map() {
2139 return hydrogen()->transitioned_map().handle();
2141 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2142 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2146 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2148 LTrapAllocationMemento(LOperand* object,
2150 inputs_[0] = object;
2154 LOperand* object() { return inputs_[0]; }
2155 LOperand* temp() { return temps_[0]; }
2157 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2158 "trap-allocation-memento")
2162 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2164 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2165 inputs_[0] = context;
2170 LOperand* context() { return inputs_[0]; }
2171 LOperand* left() { return inputs_[1]; }
2172 LOperand* right() { return inputs_[2]; }
2174 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2175 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2179 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2181 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2182 inputs_[0] = context;
2183 inputs_[1] = string;
2187 LOperand* context() { return inputs_[0]; }
2188 LOperand* string() { return inputs_[1]; }
2189 LOperand* index() { return inputs_[2]; }
2191 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2192 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2196 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2198 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2199 inputs_[0] = context;
2200 inputs_[1] = char_code;
2203 LOperand* context() { return inputs_[0]; }
2204 LOperand* char_code() { return inputs_[1]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2207 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2211 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2213 explicit LCheckValue(LOperand* value) {
2217 LOperand* value() { return inputs_[0]; }
2219 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2220 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2224 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2226 explicit LCheckInstanceType(LOperand* value) {
2230 LOperand* value() { return inputs_[0]; }
2232 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2233 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2237 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2239 explicit LCheckMaps(LOperand* value) {
2243 LOperand* value() { return inputs_[0]; }
2245 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2246 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2250 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2252 explicit LCheckSmi(LOperand* value) {
2256 LOperand* value() { return inputs_[0]; }
2258 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2262 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2264 explicit LClampDToUint8(LOperand* unclamped) {
2265 inputs_[0] = unclamped;
2268 LOperand* unclamped() { return inputs_[0]; }
2270 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2274 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2276 explicit LClampIToUint8(LOperand* unclamped) {
2277 inputs_[0] = unclamped;
2280 LOperand* unclamped() { return inputs_[0]; }
2282 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2286 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2288 LClampTToUint8(LOperand* unclamped,
2289 LOperand* temp_xmm) {
2290 inputs_[0] = unclamped;
2291 temps_[0] = temp_xmm;
2294 LOperand* unclamped() { return inputs_[0]; }
2295 LOperand* temp_xmm() { return temps_[0]; }
2297 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2301 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2303 explicit LCheckNonSmi(LOperand* value) {
2307 LOperand* value() { return inputs_[0]; }
2309 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2310 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2314 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2316 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2317 inputs_[0] = context;
2322 LOperand* context() { return inputs_[0]; }
2323 LOperand* size() { return inputs_[1]; }
2324 LOperand* temp() { return temps_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2327 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2331 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2333 explicit LRegExpLiteral(LOperand* context) {
2334 inputs_[0] = context;
2337 LOperand* context() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2340 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2344 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2346 explicit LFunctionLiteral(LOperand* context) {
2347 inputs_[0] = context;
2350 LOperand* context() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2353 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2357 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2359 explicit LToFastProperties(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2366 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2370 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2372 LTypeof(LOperand* context, LOperand* value) {
2373 inputs_[0] = context;
2377 LOperand* context() { return inputs_[0]; }
2378 LOperand* value() { return inputs_[1]; }
2380 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2384 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2386 explicit LTypeofIsAndBranch(LOperand* value) {
2390 LOperand* value() { return inputs_[0]; }
2392 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2393 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2395 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2397 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2401 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2403 explicit LIsConstructCallAndBranch(LOperand* temp) {
2407 LOperand* temp() { return temps_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2410 "is-construct-call-and-branch")
2411 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2415 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2419 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2422 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2426 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2428 explicit LStackCheck(LOperand* context) {
2429 inputs_[0] = context;
2432 LOperand* context() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2435 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2437 Label* done_label() { return &done_label_; }
2444 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2446 LForInPrepareMap(LOperand* context, LOperand* object) {
2447 inputs_[0] = context;
2448 inputs_[1] = object;
2451 LOperand* context() { return inputs_[0]; }
2452 LOperand* object() { return inputs_[1]; }
2454 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2458 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2460 explicit LForInCacheArray(LOperand* map) {
2464 LOperand* map() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2469 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2474 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2476 LCheckMapValue(LOperand* value, LOperand* map) {
2481 LOperand* value() { return inputs_[0]; }
2482 LOperand* map() { return inputs_[1]; }
2484 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2488 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2490 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2491 inputs_[0] = object;
2495 LOperand* object() { return inputs_[0]; }
2496 LOperand* index() { return inputs_[1]; }
2498 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2502 class LChunkBuilder;
2503 class LPlatformChunk V8_FINAL : public LChunk {
2505 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2506 : LChunk(info, graph) { }
2508 int GetNextSpillIndex(RegisterKind kind);
2509 LOperand* GetNextSpillSlot(RegisterKind kind);
2513 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2515 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2516 : LChunkBuilderBase(graph->zone()),
2521 current_instruction_(NULL),
2522 current_block_(NULL),
2524 allocator_(allocator),
2525 instruction_pending_deoptimization_environment_(NULL),
2526 pending_deoptimization_ast_id_(BailoutId::None()) { }
2528 // Build the sequence for the graph.
2529 LPlatformChunk* Build();
2531 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2533 // Declare methods that deal with the individual node types.
2534 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2535 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2538 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2539 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2540 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2541 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2542 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2543 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2544 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2545 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2555 LPlatformChunk* chunk() const { return chunk_; }
2556 CompilationInfo* info() const { return info_; }
2557 HGraph* graph() const { return graph_; }
2559 bool is_unused() const { return status_ == UNUSED; }
2560 bool is_building() const { return status_ == BUILDING; }
2561 bool is_done() const { return status_ == DONE; }
2562 bool is_aborted() const { return status_ == ABORTED; }
2564 void Abort(BailoutReason reason);
2566 // Methods for getting operands for Use / Define / Temp.
2567 LUnallocated* ToUnallocated(Register reg);
2568 LUnallocated* ToUnallocated(XMMRegister reg);
2570 // Methods for setting up define-use relationships.
2571 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2572 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2573 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2574 XMMRegister fixed_register);
2576 // A value that is guaranteed to be allocated to a register.
2577 // Operand created by UseRegister is guaranteed to be live until the end of
2578 // instruction. This means that register allocator will not reuse it's
2579 // register for any other operand inside instruction.
2580 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2581 // instruction start. Register allocator is free to assign the same register
2582 // to some other operand used inside instruction (i.e. temporary or
2584 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2585 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2587 // An input operand in a register that may be trashed.
2588 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2590 // An input operand in a register that may be trashed or a constant operand.
2591 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2593 // An input operand in a register or stack slot.
2594 MUST_USE_RESULT LOperand* Use(HValue* value);
2595 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2597 // An input operand in a register, stack slot or a constant operand.
2598 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2599 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2601 // An input operand in a register or a constant operand.
2602 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2603 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2605 // An input operand in a constant operand.
2606 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2608 // An input operand in register, stack slot or a constant operand.
2609 // Will not be moved to a register even if one is freely available.
2610 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2612 // Temporary operand that must be in a register.
2613 MUST_USE_RESULT LUnallocated* TempRegister();
2614 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2615 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2617 // Methods for setting up define-use relationships.
2618 // Return the same instruction that they are passed.
2619 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2620 LUnallocated* result);
2621 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2622 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2624 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2625 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2627 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2629 // Assigns an environment to an instruction. An instruction which can
2630 // deoptimize must have an environment.
2631 LInstruction* AssignEnvironment(LInstruction* instr);
2632 // Assigns a pointer map to an instruction. An instruction which can
2633 // trigger a GC or a lazy deoptimization must have a pointer map.
2634 LInstruction* AssignPointerMap(LInstruction* instr);
2636 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2638 // Marks a call for the register allocator. Assigns a pointer map to
2639 // support GC and lazy deoptimization. Assigns an environment to support
2640 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2641 LInstruction* MarkAsCall(
2642 LInstruction* instr,
2643 HInstruction* hinstr,
2644 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2646 void VisitInstruction(HInstruction* current);
2648 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2649 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2650 LInstruction* DoArithmeticD(Token::Value op,
2651 HArithmeticBinaryOperation* instr);
2652 LInstruction* DoArithmeticT(Token::Value op,
2653 HBinaryOperation* instr);
2655 LPlatformChunk* chunk_;
2656 CompilationInfo* info_;
2657 HGraph* const graph_;
2659 HInstruction* current_instruction_;
2660 HBasicBlock* current_block_;
2661 HBasicBlock* next_block_;
2662 LAllocator* allocator_;
2663 LInstruction* instruction_pending_deoptimization_environment_;
2664 BailoutId pending_deoptimization_ast_id_;
2666 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2669 #undef DECLARE_HYDROGEN_ACCESSOR
2670 #undef DECLARE_CONCRETE_INSTRUCTION
2672 } } // namespace v8::int
2674 #endif // V8_X64_LITHIUM_X64_H_