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) \
99 V(GetCachedArrayIndex) \
101 V(HasCachedArrayIndexAndBranch) \
102 V(HasInstanceTypeAndBranch) \
103 V(InnerAllocatedObject) \
105 V(InstanceOfKnownGlobal) \
107 V(Integer32ToDouble) \
110 V(IsConstructCallAndBranch) \
111 V(IsObjectAndBranch) \
112 V(IsStringAndBranch) \
114 V(IsUndetectableAndBranch) \
119 V(LoadFieldByIndex) \
120 V(LoadFunctionPrototype) \
122 V(LoadGlobalGeneric) \
124 V(LoadKeyedGeneric) \
126 V(LoadNamedGeneric) \
150 V(SeqStringGetChar) \
151 V(SeqStringSetChar) \
157 V(StoreContextSlot) \
160 V(StoreKeyedGeneric) \
162 V(StoreNamedGeneric) \
164 V(StringCharCodeAt) \
165 V(StringCharFromCode) \
166 V(StringCompareAndBranch) \
170 V(ToFastProperties) \
171 V(TransitionElementsKind) \
172 V(TrapAllocationMemento) \
174 V(TypeofIsAndBranch) \
181 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
182 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
183 return LInstruction::k##type; \
185 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
186 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
189 static L##type* cast(LInstruction* instr) { \
190 ASSERT(instr->Is##type()); \
191 return reinterpret_cast<L##type*>(instr); \
195 #define DECLARE_HYDROGEN_ACCESSOR(type) \
196 H##type* hydrogen() const { \
197 return H##type::cast(hydrogen_value()); \
201 class LInstruction : public ZoneObject {
204 : environment_(NULL),
205 hydrogen_value_(NULL),
206 bit_field_(IsCallBits::encode(false)) {
209 virtual ~LInstruction() {}
211 virtual void CompileToNative(LCodeGen* generator) = 0;
212 virtual const char* Mnemonic() const = 0;
213 virtual void PrintTo(StringStream* stream);
214 virtual void PrintDataTo(StringStream* stream);
215 virtual void PrintOutputOperandTo(StringStream* stream);
218 // Declare a unique enum value for each instruction.
219 #define DECLARE_OPCODE(type) k##type,
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
221 kNumberOfInstructions
222 #undef DECLARE_OPCODE
225 virtual Opcode opcode() const = 0;
227 // Declare non-virtual type testers for all leaf IR classes.
228 #define DECLARE_PREDICATE(type) \
229 bool Is##type() const { return opcode() == k##type; }
230 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
231 #undef DECLARE_PREDICATE
233 // Declare virtual predicates for instructions that don't have
235 virtual bool IsGap() const { return false; }
237 virtual bool IsControl() const { return false; }
239 void set_environment(LEnvironment* env) { environment_ = env; }
240 LEnvironment* environment() const { return environment_; }
241 bool HasEnvironment() const { return environment_ != NULL; }
243 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
244 LPointerMap* pointer_map() const { return pointer_map_.get(); }
245 bool HasPointerMap() const { return pointer_map_.is_set(); }
247 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
248 HValue* hydrogen_value() const { return hydrogen_value_; }
250 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
251 bool IsCall() const { return IsCallBits::decode(bit_field_); }
253 // Interface to the register allocator and iterators.
254 bool ClobbersTemps() const { return IsCall(); }
255 bool ClobbersRegisters() const { return IsCall(); }
256 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
258 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
260 // Interface to the register allocator and iterators.
261 bool IsMarkedAsCall() const { return IsCall(); }
263 virtual bool HasResult() const = 0;
264 virtual LOperand* result() const = 0;
266 LOperand* FirstInput() { return InputAt(0); }
267 LOperand* Output() { return HasResult() ? result() : NULL; }
269 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
277 friend class InputIterator;
278 virtual int InputCount() = 0;
279 virtual LOperand* InputAt(int i) = 0;
281 friend class TempIterator;
282 virtual int TempCount() = 0;
283 virtual LOperand* TempAt(int i) = 0;
285 class IsCallBits: public BitField<bool, 0, 1> {};
287 LEnvironment* environment_;
288 SetOncePointer<LPointerMap> pointer_map_;
289 HValue* hydrogen_value_;
294 // R = number of result operands (0 or 1).
296 class LTemplateResultInstruction : public LInstruction {
298 // Allow 0 or 1 output operands.
299 STATIC_ASSERT(R == 0 || R == 1);
300 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
301 return R != 0 && result() != NULL;
303 void set_result(LOperand* operand) { results_[0] = operand; }
304 LOperand* result() const { return results_[0]; }
307 EmbeddedContainer<LOperand*, R> results_;
311 // R = number of result operands (0 or 1).
312 // I = number of input operands.
313 // T = number of temporary operands.
314 template<int R, int I, int T>
315 class LTemplateInstruction : public LTemplateResultInstruction<R> {
317 EmbeddedContainer<LOperand*, I> inputs_;
318 EmbeddedContainer<LOperand*, T> temps_;
322 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
323 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
325 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
326 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
330 class LGap : public LTemplateInstruction<0, 0, 0> {
332 explicit LGap(HBasicBlock* block)
334 parallel_moves_[BEFORE] = NULL;
335 parallel_moves_[START] = NULL;
336 parallel_moves_[END] = NULL;
337 parallel_moves_[AFTER] = NULL;
340 // Can't use the DECLARE-macro here because of sub-classes.
341 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
342 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
343 static LGap* cast(LInstruction* instr) {
344 ASSERT(instr->IsGap());
345 return reinterpret_cast<LGap*>(instr);
348 bool IsRedundant() const;
350 HBasicBlock* block() const { return block_; }
357 FIRST_INNER_POSITION = BEFORE,
358 LAST_INNER_POSITION = AFTER
361 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
363 if (parallel_moves_[pos] == NULL) {
364 parallel_moves_[pos] = new(zone) LParallelMove(zone);
366 return parallel_moves_[pos];
369 LParallelMove* GetParallelMove(InnerPosition pos) {
370 return parallel_moves_[pos];
374 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
379 class LInstructionGap V8_FINAL : public LGap {
381 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
383 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
384 return !IsRedundant();
387 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
391 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
398 virtual bool IsControl() const V8_OVERRIDE { return true; }
400 int block_id() const { return block_->block_id(); }
407 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
409 LLazyBailout() : gap_instructions_size_(0) { }
411 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
413 void set_gap_instructions_size(int gap_instructions_size) {
414 gap_instructions_size_ = gap_instructions_size;
416 int gap_instructions_size() { return gap_instructions_size_; }
419 int gap_instructions_size_;
423 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
425 explicit LDummy() { }
426 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
430 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
432 explicit LDummyUse(LOperand* value) {
435 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
439 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
441 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
442 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
446 class LLabel V8_FINAL : public LGap {
448 explicit LLabel(HBasicBlock* block)
449 : LGap(block), replacement_(NULL) { }
451 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
454 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
456 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
458 int block_id() const { return block()->block_id(); }
459 bool is_loop_header() const { return block()->IsLoopHeader(); }
460 bool is_osr_entry() const { return block()->is_osr_entry(); }
461 Label* label() { return &label_; }
462 LLabel* replacement() const { return replacement_; }
463 void set_replacement(LLabel* label) { replacement_ = label; }
464 bool HasReplacement() const { return replacement_ != NULL; }
468 LLabel* replacement_;
472 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
474 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
477 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
481 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
483 explicit LCallStub(LOperand* context) {
484 inputs_[0] = context;
487 LOperand* context() { return inputs_[0]; }
489 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
490 DECLARE_HYDROGEN_ACCESSOR(CallStub)
494 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
496 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
499 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
503 template<int I, int T>
504 class LControlInstruction : public LTemplateInstruction<0, I, T> {
506 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
508 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
510 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
511 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
513 int TrueDestination(LChunk* chunk) {
514 return chunk->LookupDestination(true_block_id());
516 int FalseDestination(LChunk* chunk) {
517 return chunk->LookupDestination(false_block_id());
520 Label* TrueLabel(LChunk* chunk) {
521 if (true_label_ == NULL) {
522 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
526 Label* FalseLabel(LChunk* chunk) {
527 if (false_label_ == NULL) {
528 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
534 int true_block_id() { return SuccessorAt(0)->block_id(); }
535 int false_block_id() { return SuccessorAt(1)->block_id(); }
538 HControlInstruction* hydrogen() {
539 return HControlInstruction::cast(this->hydrogen_value());
547 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
549 LWrapReceiver(LOperand* receiver, LOperand* function) {
550 inputs_[0] = receiver;
551 inputs_[1] = function;
554 LOperand* receiver() { return inputs_[0]; }
555 LOperand* function() { return inputs_[1]; }
557 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
558 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
562 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
564 LApplyArguments(LOperand* function,
567 LOperand* elements) {
568 inputs_[0] = function;
569 inputs_[1] = receiver;
571 inputs_[3] = elements;
574 LOperand* function() { return inputs_[0]; }
575 LOperand* receiver() { return inputs_[1]; }
576 LOperand* length() { return inputs_[2]; }
577 LOperand* elements() { return inputs_[3]; }
579 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
583 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
585 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
586 inputs_[0] = arguments;
591 LOperand* arguments() { return inputs_[0]; }
592 LOperand* length() { return inputs_[1]; }
593 LOperand* index() { return inputs_[2]; }
595 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
597 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
601 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
603 explicit LArgumentsLength(LOperand* elements) {
604 inputs_[0] = elements;
607 LOperand* elements() { return inputs_[0]; }
609 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
613 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
616 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
620 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
622 LModI(LOperand* left, LOperand* right, LOperand* temp) {
628 LOperand* left() { return inputs_[0]; }
629 LOperand* right() { return inputs_[1]; }
630 LOperand* temp() { return temps_[0]; }
632 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
633 DECLARE_HYDROGEN_ACCESSOR(Mod)
637 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
639 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
645 LOperand* left() { return inputs_[0]; }
646 LOperand* right() { return inputs_[1]; }
647 LOperand* temp() { return temps_[0]; }
649 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
651 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
652 DECLARE_HYDROGEN_ACCESSOR(Div)
656 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
658 LMathFloorOfDiv(LOperand* left,
660 LOperand* temp = NULL) {
666 LOperand* left() { return inputs_[0]; }
667 LOperand* right() { return inputs_[1]; }
668 LOperand* temp() { return temps_[0]; }
670 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
671 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
675 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
677 LMulI(LOperand* left, LOperand* right) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
685 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
686 DECLARE_HYDROGEN_ACCESSOR(Mul)
690 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
692 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
697 LOperand* left() { return inputs_[0]; }
698 LOperand* right() { return inputs_[1]; }
700 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
701 "compare-numeric-and-branch")
702 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
704 Token::Value op() const { return hydrogen()->token(); }
705 bool is_double() const {
706 return hydrogen()->representation().IsDouble();
709 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
713 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
715 explicit LMathFloor(LOperand* value) {
719 LOperand* value() { return inputs_[0]; }
721 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
722 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
726 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
728 explicit LMathRound(LOperand* value) {
732 LOperand* value() { return inputs_[0]; }
734 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
735 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
739 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
741 explicit LMathAbs(LOperand* context, LOperand* value) {
742 inputs_[1] = context;
746 LOperand* context() { return inputs_[1]; }
747 LOperand* value() { return inputs_[0]; }
749 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
750 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
754 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
756 explicit LMathLog(LOperand* value) {
760 LOperand* value() { return inputs_[0]; }
762 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
766 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
768 explicit LMathClz32(LOperand* value) {
772 LOperand* value() { return inputs_[0]; }
774 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
778 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
780 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
784 ExternalReference::InitializeMathExpData();
787 LOperand* value() { return inputs_[0]; }
788 LOperand* temp1() { return temps_[0]; }
789 LOperand* temp2() { return temps_[1]; }
791 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
795 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
797 explicit LMathSqrt(LOperand* value) {
801 LOperand* value() { return inputs_[0]; }
803 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
807 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
809 explicit LMathPowHalf(LOperand* value) {
813 LOperand* value() { return inputs_[0]; }
815 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
819 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
821 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
833 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
835 explicit LCmpHoleAndBranch(LOperand* object) {
839 LOperand* object() { return inputs_[0]; }
841 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
842 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
846 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
848 explicit LCompareMinusZeroAndBranch(LOperand* value) {
852 LOperand* value() { return inputs_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
855 "cmp-minus-zero-and-branch")
856 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
861 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
863 explicit LIsObjectAndBranch(LOperand* value) {
867 LOperand* value() { return inputs_[0]; }
869 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
870 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
872 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
876 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
878 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
883 LOperand* value() { return inputs_[0]; }
884 LOperand* temp() { return temps_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
887 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
889 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
893 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
895 explicit LIsSmiAndBranch(LOperand* value) {
899 LOperand* value() { return inputs_[0]; }
901 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
902 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
904 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
908 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
910 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
915 LOperand* value() { return inputs_[0]; }
916 LOperand* temp() { return temps_[0]; }
918 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
919 "is-undetectable-and-branch")
920 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
922 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
926 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
928 explicit LStringCompareAndBranch(LOperand* context,
931 inputs_[0] = context;
936 LOperand* context() { return inputs_[0]; }
937 LOperand* left() { return inputs_[1]; }
938 LOperand* right() { return inputs_[2]; }
940 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
941 "string-compare-and-branch")
942 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
944 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
946 Token::Value op() const { return hydrogen()->token(); }
950 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
952 explicit LHasInstanceTypeAndBranch(LOperand* value) {
956 LOperand* value() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
959 "has-instance-type-and-branch")
960 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
962 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
966 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
968 explicit LGetCachedArrayIndex(LOperand* value) {
972 LOperand* value() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
975 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
979 class LHasCachedArrayIndexAndBranch V8_FINAL
980 : public LControlInstruction<1, 0> {
982 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
986 LOperand* value() { return inputs_[0]; }
988 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
989 "has-cached-array-index-and-branch")
990 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
992 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
996 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
998 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1004 LOperand* value() { return inputs_[0]; }
1005 LOperand* temp() { return temps_[0]; }
1006 LOperand* temp2() { return temps_[1]; }
1008 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1009 "class-of-test-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1012 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1016 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1018 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1019 inputs_[0] = context;
1024 LOperand* context() { return inputs_[0]; }
1025 LOperand* left() { return inputs_[1]; }
1026 LOperand* right() { return inputs_[2]; }
1028 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1029 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1031 Token::Value op() const { return hydrogen()->token(); }
1035 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1037 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1038 inputs_[0] = context;
1043 LOperand* context() { return inputs_[0]; }
1044 LOperand* left() { return inputs_[1]; }
1045 LOperand* right() { return inputs_[2]; }
1047 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1051 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1053 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1054 inputs_[0] = context;
1059 LOperand* context() { return inputs_[0]; }
1060 LOperand* value() { return inputs_[1]; }
1061 LOperand* temp() { return temps_[0]; }
1063 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1064 "instance-of-known-global")
1065 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1067 Handle<JSFunction> function() const { return hydrogen()->function(); }
1068 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1069 return lazy_deopt_env_;
1071 virtual void SetDeferredLazyDeoptimizationEnvironment(
1072 LEnvironment* env) V8_OVERRIDE {
1073 lazy_deopt_env_ = env;
1077 LEnvironment* lazy_deopt_env_;
1081 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1083 LBoundsCheck(LOperand* index, LOperand* length) {
1085 inputs_[1] = length;
1088 LOperand* index() { return inputs_[0]; }
1089 LOperand* length() { return inputs_[1]; }
1091 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1092 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1096 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1098 LBitI(LOperand* left, LOperand* right) {
1103 LOperand* left() { return inputs_[0]; }
1104 LOperand* right() { return inputs_[1]; }
1106 Token::Value op() const { return hydrogen()->op(); }
1108 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1109 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1113 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1115 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1116 : op_(op), can_deopt_(can_deopt) {
1121 Token::Value op() const { return op_; }
1122 LOperand* left() { return inputs_[0]; }
1123 LOperand* right() { return inputs_[1]; }
1124 bool can_deopt() const { return can_deopt_; }
1126 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1134 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1136 LSubI(LOperand* left, LOperand* right) {
1141 LOperand* left() { return inputs_[0]; }
1142 LOperand* right() { return inputs_[1]; }
1144 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1145 DECLARE_HYDROGEN_ACCESSOR(Sub)
1149 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1151 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1152 DECLARE_HYDROGEN_ACCESSOR(Constant)
1154 int32_t value() const { return hydrogen()->Integer32Value(); }
1158 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1160 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1161 DECLARE_HYDROGEN_ACCESSOR(Constant)
1163 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1167 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1169 explicit LConstantD(LOperand* temp) {
1173 LOperand* temp() { return temps_[0]; }
1175 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1176 DECLARE_HYDROGEN_ACCESSOR(Constant)
1178 double value() const { return hydrogen()->DoubleValue(); }
1182 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1184 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1185 DECLARE_HYDROGEN_ACCESSOR(Constant)
1187 ExternalReference value() const {
1188 return hydrogen()->ExternalReferenceValue();
1193 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1195 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1196 DECLARE_HYDROGEN_ACCESSOR(Constant)
1198 Handle<Object> value(Isolate* isolate) const {
1199 return hydrogen()->handle(isolate);
1204 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1206 explicit LBranch(LOperand* value) {
1210 LOperand* value() { return inputs_[0]; }
1212 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1213 DECLARE_HYDROGEN_ACCESSOR(Branch)
1215 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1219 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1221 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1225 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1227 explicit LCmpMapAndBranch(LOperand* value) {
1231 LOperand* value() { return inputs_[0]; }
1233 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1234 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1236 Handle<Map> map() const { return hydrogen()->map().handle(); }
1240 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1242 explicit LMapEnumLength(LOperand* value) {
1246 LOperand* value() { return inputs_[0]; }
1248 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1252 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1254 LDateField(LOperand* date, Smi* index) : index_(index) {
1258 LOperand* date() { return inputs_[0]; }
1259 Smi* index() const { return index_; }
1261 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1262 DECLARE_HYDROGEN_ACCESSOR(DateField)
1269 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1271 LSeqStringGetChar(LOperand* string, LOperand* index) {
1272 inputs_[0] = string;
1276 LOperand* string() const { return inputs_[0]; }
1277 LOperand* index() const { return inputs_[1]; }
1279 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1280 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1284 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1286 LSeqStringSetChar(LOperand* context,
1290 inputs_[0] = context;
1291 inputs_[1] = string;
1296 LOperand* string() { return inputs_[1]; }
1297 LOperand* index() { return inputs_[2]; }
1298 LOperand* value() { return inputs_[3]; }
1300 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1301 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1305 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1307 LAddI(LOperand* left, LOperand* right) {
1312 LOperand* left() { return inputs_[0]; }
1313 LOperand* right() { return inputs_[1]; }
1315 static bool UseLea(HAdd* add) {
1316 return !add->CheckFlag(HValue::kCanOverflow) &&
1317 add->BetterLeftOperand()->UseCount() > 1;
1320 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1321 DECLARE_HYDROGEN_ACCESSOR(Add)
1325 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1327 LMathMinMax(LOperand* left, LOperand* right) {
1332 LOperand* left() { return inputs_[0]; }
1333 LOperand* right() { return inputs_[1]; }
1335 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1336 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1340 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1342 LPower(LOperand* left, LOperand* right) {
1347 LOperand* left() { return inputs_[0]; }
1348 LOperand* right() { return inputs_[1]; }
1350 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1351 DECLARE_HYDROGEN_ACCESSOR(Power)
1355 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1357 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1363 Token::Value op() const { return op_; }
1364 LOperand* left() { return inputs_[0]; }
1365 LOperand* right() { return inputs_[1]; }
1367 virtual Opcode opcode() const V8_OVERRIDE {
1368 return LInstruction::kArithmeticD;
1370 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1371 virtual const char* Mnemonic() const V8_OVERRIDE;
1378 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1380 LArithmeticT(Token::Value op,
1385 inputs_[0] = context;
1390 Token::Value op() const { return op_; }
1391 LOperand* context() { return inputs_[0]; }
1392 LOperand* left() { return inputs_[1]; }
1393 LOperand* right() { return inputs_[2]; }
1395 virtual Opcode opcode() const V8_OVERRIDE {
1396 return LInstruction::kArithmeticT;
1398 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1399 virtual const char* Mnemonic() const V8_OVERRIDE;
1406 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1408 explicit LReturn(LOperand* value,
1410 LOperand* parameter_count) {
1412 inputs_[1] = context;
1413 inputs_[2] = parameter_count;
1416 LOperand* value() { return inputs_[0]; }
1417 LOperand* context() { return inputs_[1]; }
1419 bool has_constant_parameter_count() {
1420 return parameter_count()->IsConstantOperand();
1422 LConstantOperand* constant_parameter_count() {
1423 ASSERT(has_constant_parameter_count());
1424 return LConstantOperand::cast(parameter_count());
1426 LOperand* parameter_count() { return inputs_[2]; }
1428 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1429 DECLARE_HYDROGEN_ACCESSOR(Return)
1433 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1435 explicit LLoadNamedField(LOperand* object) {
1436 inputs_[0] = object;
1439 LOperand* object() { return inputs_[0]; }
1441 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1442 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1446 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1448 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1449 inputs_[0] = context;
1450 inputs_[1] = object;
1453 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1454 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1456 LOperand* context() { return inputs_[0]; }
1457 LOperand* object() { return inputs_[1]; }
1458 Handle<Object> name() const { return hydrogen()->name(); }
1462 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1464 explicit LLoadFunctionPrototype(LOperand* function) {
1465 inputs_[0] = function;
1468 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1469 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1471 LOperand* function() { return inputs_[0]; }
1475 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1477 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1478 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1480 Heap::RootListIndex index() const { return hydrogen()->index(); }
1484 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1486 LLoadKeyed(LOperand* elements, LOperand* key) {
1487 inputs_[0] = elements;
1491 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1492 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1494 bool is_external() const {
1495 return hydrogen()->is_external();
1497 bool is_fixed_typed_array() const {
1498 return hydrogen()->is_fixed_typed_array();
1500 bool is_typed_elements() const {
1501 return is_external() || is_fixed_typed_array();
1503 LOperand* elements() { return inputs_[0]; }
1504 LOperand* key() { return inputs_[1]; }
1505 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1506 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1507 ElementsKind elements_kind() const {
1508 return hydrogen()->elements_kind();
1513 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1515 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1516 inputs_[0] = context;
1521 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1523 LOperand* context() { return inputs_[0]; }
1524 LOperand* object() { return inputs_[1]; }
1525 LOperand* key() { return inputs_[2]; }
1529 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1531 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1532 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1536 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1538 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1539 inputs_[0] = context;
1540 inputs_[1] = global_object;
1543 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1544 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1546 LOperand* context() { return inputs_[0]; }
1547 LOperand* global_object() { return inputs_[1]; }
1548 Handle<Object> name() const { return hydrogen()->name(); }
1549 bool for_typeof() const { return hydrogen()->for_typeof(); }
1553 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1555 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1560 LOperand* value() { return inputs_[0]; }
1561 LOperand* temp() { return temps_[0]; }
1563 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1564 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1568 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1570 explicit LLoadContextSlot(LOperand* context) {
1571 inputs_[0] = context;
1574 LOperand* context() { return inputs_[0]; }
1576 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1577 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1579 int slot_index() { return hydrogen()->slot_index(); }
1581 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1585 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1587 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1588 inputs_[0] = context;
1593 LOperand* context() { return inputs_[0]; }
1594 LOperand* value() { return inputs_[1]; }
1595 LOperand* temp() { return temps_[0]; }
1597 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1598 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1600 int slot_index() { return hydrogen()->slot_index(); }
1602 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1606 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1608 explicit LPushArgument(LOperand* value) {
1612 LOperand* value() { return inputs_[0]; }
1614 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1618 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1620 explicit LDrop(int count) : count_(count) { }
1622 int count() const { return count_; }
1624 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1631 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1633 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1634 inputs_[0] = function;
1635 temps_[0] = code_object;
1638 LOperand* function() { return inputs_[0]; }
1639 LOperand* code_object() { return temps_[0]; }
1641 virtual void PrintDataTo(StringStream* stream);
1643 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1644 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1648 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1650 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1651 inputs_[0] = base_object;
1652 inputs_[1] = offset;
1655 LOperand* base_object() const { return inputs_[0]; }
1656 LOperand* offset() const { return inputs_[1]; }
1658 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1660 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1664 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1666 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1667 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1671 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1673 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1674 DECLARE_HYDROGEN_ACCESSOR(Context)
1678 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1680 explicit LDeclareGlobals(LOperand* context) {
1681 inputs_[0] = context;
1684 LOperand* context() { return inputs_[0]; }
1686 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1687 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1691 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1693 explicit LCallJSFunction(LOperand* function) {
1694 inputs_[0] = function;
1697 LOperand* function() { return inputs_[0]; }
1699 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1700 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1702 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1704 int arity() const { return hydrogen()->argument_count() - 1; }
1708 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1710 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1711 ZoneList<LOperand*>& operands,
1713 : inputs_(descriptor->environment_length() + 1, zone) {
1714 ASSERT(descriptor->environment_length() + 1 == operands.length());
1715 inputs_.AddAll(operands, zone);
1718 LOperand* target() const { return inputs_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1722 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1724 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1726 int arity() const { return hydrogen()->argument_count() - 1; }
1728 ZoneList<LOperand*> inputs_;
1730 // Iterator support.
1731 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1732 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1734 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1735 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1739 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1741 LInvokeFunction(LOperand* context, LOperand* function) {
1742 inputs_[0] = context;
1743 inputs_[1] = function;
1746 LOperand* context() { return inputs_[0]; }
1747 LOperand* function() { return inputs_[1]; }
1749 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1750 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1752 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1754 int arity() const { return hydrogen()->argument_count() - 1; }
1758 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1760 LCallFunction(LOperand* context, LOperand* function) {
1761 inputs_[0] = context;
1762 inputs_[1] = function;
1765 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1766 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1768 LOperand* context() { return inputs_[0]; }
1769 LOperand* function() { return inputs_[1]; }
1770 int arity() const { return hydrogen()->argument_count() - 1; }
1774 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1776 LCallNew(LOperand* context, LOperand* constructor) {
1777 inputs_[0] = context;
1778 inputs_[1] = constructor;
1781 LOperand* context() { return inputs_[0]; }
1782 LOperand* constructor() { return inputs_[1]; }
1784 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1785 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1787 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1789 int arity() const { return hydrogen()->argument_count() - 1; }
1793 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1795 LCallNewArray(LOperand* context, LOperand* constructor) {
1796 inputs_[0] = context;
1797 inputs_[1] = constructor;
1800 LOperand* context() { return inputs_[0]; }
1801 LOperand* constructor() { return inputs_[1]; }
1803 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1804 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1806 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1808 int arity() const { return hydrogen()->argument_count() - 1; }
1812 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1814 explicit LCallRuntime(LOperand* context) {
1815 inputs_[0] = context;
1818 LOperand* context() { return inputs_[0]; }
1820 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1821 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1823 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1824 return save_doubles() == kDontSaveFPRegs;
1827 const Runtime::Function* function() const { return hydrogen()->function(); }
1828 int arity() const { return hydrogen()->argument_count(); }
1829 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1833 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1835 explicit LInteger32ToDouble(LOperand* value) {
1839 LOperand* value() { return inputs_[0]; }
1841 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1845 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1847 explicit LInteger32ToSmi(LOperand* value) {
1851 LOperand* value() { return inputs_[0]; }
1853 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1854 DECLARE_HYDROGEN_ACCESSOR(Change)
1858 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1860 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1865 LOperand* value() { return inputs_[0]; }
1866 LOperand* temp() { return temps_[0]; }
1868 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1872 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1874 explicit LUint32ToSmi(LOperand* value) {
1878 LOperand* value() { return inputs_[0]; }
1880 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1881 DECLARE_HYDROGEN_ACCESSOR(Change)
1885 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1887 explicit LNumberTagI(LOperand* value) {
1891 LOperand* value() { return inputs_[0]; }
1893 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1897 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1899 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1905 LOperand* value() { return inputs_[0]; }
1906 LOperand* temp1() { return temps_[0]; }
1907 LOperand* temp2() { return temps_[1]; }
1909 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1913 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1915 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1920 LOperand* value() { return inputs_[0]; }
1921 LOperand* temp() { return temps_[0]; }
1923 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1924 DECLARE_HYDROGEN_ACCESSOR(Change)
1928 // Sometimes truncating conversion from a tagged value to an int32.
1929 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1931 explicit LDoubleToI(LOperand* value) {
1935 LOperand* value() { return inputs_[0]; }
1937 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1938 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1940 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1944 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1946 explicit LDoubleToSmi(LOperand* value) {
1950 LOperand* value() { return inputs_[0]; }
1952 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1953 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1957 // Truncating conversion from a tagged value to an int32.
1958 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1960 LTaggedToI(LOperand* value, LOperand* temp) {
1965 LOperand* value() { return inputs_[0]; }
1966 LOperand* temp() { return temps_[0]; }
1968 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1969 DECLARE_HYDROGEN_ACCESSOR(Change)
1971 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1975 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1977 explicit LSmiTag(LOperand* value) {
1981 LOperand* value() { return inputs_[0]; }
1983 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1987 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1989 explicit LNumberUntagD(LOperand* value) {
1993 LOperand* value() { return inputs_[0]; }
1995 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1996 DECLARE_HYDROGEN_ACCESSOR(Change);
2000 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2002 LSmiUntag(LOperand* value, bool needs_check)
2003 : needs_check_(needs_check) {
2007 LOperand* value() { return inputs_[0]; }
2008 bool needs_check() const { return needs_check_; }
2010 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2017 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2019 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2020 inputs_[0] = object;
2025 LOperand* object() { return inputs_[0]; }
2026 LOperand* value() { return inputs_[1]; }
2027 LOperand* temp() { return temps_[0]; }
2029 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2030 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2032 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2034 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2035 Representation representation() const {
2036 return hydrogen()->field_representation();
2041 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2043 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2044 inputs_[0] = context;
2045 inputs_[1] = object;
2049 LOperand* context() { return inputs_[0]; }
2050 LOperand* object() { return inputs_[1]; }
2051 LOperand* value() { return inputs_[2]; }
2053 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2054 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2056 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2058 Handle<Object> name() const { return hydrogen()->name(); }
2059 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2063 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2065 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2066 inputs_[0] = object;
2071 bool is_external() const { return hydrogen()->is_external(); }
2072 bool is_fixed_typed_array() const {
2073 return hydrogen()->is_fixed_typed_array();
2075 bool is_typed_elements() const {
2076 return is_external() || is_fixed_typed_array();
2078 LOperand* elements() { return inputs_[0]; }
2079 LOperand* key() { return inputs_[1]; }
2080 LOperand* value() { return inputs_[2]; }
2081 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2083 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2084 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2087 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2088 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2092 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2094 LStoreKeyedGeneric(LOperand* context,
2098 inputs_[0] = context;
2099 inputs_[1] = object;
2104 LOperand* context() { return inputs_[0]; }
2105 LOperand* object() { return inputs_[1]; }
2106 LOperand* key() { return inputs_[2]; }
2107 LOperand* value() { return inputs_[3]; }
2109 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2110 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2112 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2114 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2118 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2120 LTransitionElementsKind(LOperand* object,
2122 LOperand* new_map_temp,
2124 inputs_[0] = object;
2125 inputs_[1] = context;
2126 temps_[0] = new_map_temp;
2130 LOperand* object() { return inputs_[0]; }
2131 LOperand* context() { return inputs_[1]; }
2132 LOperand* new_map_temp() { return temps_[0]; }
2133 LOperand* temp() { return temps_[1]; }
2135 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2136 "transition-elements-kind")
2137 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2139 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2141 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2142 Handle<Map> transitioned_map() {
2143 return hydrogen()->transitioned_map().handle();
2145 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2146 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2150 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2152 LTrapAllocationMemento(LOperand* object,
2154 inputs_[0] = object;
2158 LOperand* object() { return inputs_[0]; }
2159 LOperand* temp() { return temps_[0]; }
2161 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2162 "trap-allocation-memento")
2166 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2168 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2169 inputs_[0] = context;
2174 LOperand* context() { return inputs_[0]; }
2175 LOperand* left() { return inputs_[1]; }
2176 LOperand* right() { return inputs_[2]; }
2178 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2179 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2183 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2185 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2186 inputs_[0] = context;
2187 inputs_[1] = string;
2191 LOperand* context() { return inputs_[0]; }
2192 LOperand* string() { return inputs_[1]; }
2193 LOperand* index() { return inputs_[2]; }
2195 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2196 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2200 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2202 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2203 inputs_[0] = context;
2204 inputs_[1] = char_code;
2207 LOperand* context() { return inputs_[0]; }
2208 LOperand* char_code() { return inputs_[1]; }
2210 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2211 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2215 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2217 explicit LCheckValue(LOperand* value) {
2221 LOperand* value() { return inputs_[0]; }
2223 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2224 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2228 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2230 explicit LCheckInstanceType(LOperand* value) {
2234 LOperand* value() { return inputs_[0]; }
2236 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2237 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2241 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2243 explicit LCheckMaps(LOperand* value) {
2247 LOperand* value() { return inputs_[0]; }
2249 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2250 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2254 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2256 explicit LCheckSmi(LOperand* value) {
2260 LOperand* value() { return inputs_[0]; }
2262 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2266 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2268 explicit LClampDToUint8(LOperand* unclamped) {
2269 inputs_[0] = unclamped;
2272 LOperand* unclamped() { return inputs_[0]; }
2274 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2278 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2280 explicit LClampIToUint8(LOperand* unclamped) {
2281 inputs_[0] = unclamped;
2284 LOperand* unclamped() { return inputs_[0]; }
2286 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2290 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2292 LClampTToUint8(LOperand* unclamped,
2293 LOperand* temp_xmm) {
2294 inputs_[0] = unclamped;
2295 temps_[0] = temp_xmm;
2298 LOperand* unclamped() { return inputs_[0]; }
2299 LOperand* temp_xmm() { return temps_[0]; }
2301 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2305 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2307 explicit LCheckNonSmi(LOperand* value) {
2311 LOperand* value() { return inputs_[0]; }
2313 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2314 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2318 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2320 explicit LDoubleBits(LOperand* value) {
2324 LOperand* value() { return inputs_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2327 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2331 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2333 LConstructDouble(LOperand* hi, LOperand* lo) {
2338 LOperand* hi() { return inputs_[0]; }
2339 LOperand* lo() { return inputs_[1]; }
2341 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2345 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2347 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2348 inputs_[0] = context;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* size() { return inputs_[1]; }
2355 LOperand* temp() { return temps_[0]; }
2357 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2358 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2362 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2364 explicit LRegExpLiteral(LOperand* context) {
2365 inputs_[0] = context;
2368 LOperand* context() { return inputs_[0]; }
2370 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2371 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2375 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2377 explicit LFunctionLiteral(LOperand* context) {
2378 inputs_[0] = context;
2381 LOperand* context() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2384 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2388 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2390 explicit LToFastProperties(LOperand* value) {
2394 LOperand* value() { return inputs_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2397 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2401 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2403 LTypeof(LOperand* context, LOperand* value) {
2404 inputs_[0] = context;
2408 LOperand* context() { return inputs_[0]; }
2409 LOperand* value() { return inputs_[1]; }
2411 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2415 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2417 explicit LTypeofIsAndBranch(LOperand* value) {
2421 LOperand* value() { return inputs_[0]; }
2423 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2424 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2426 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2428 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2432 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2434 explicit LIsConstructCallAndBranch(LOperand* temp) {
2438 LOperand* temp() { return temps_[0]; }
2440 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2441 "is-construct-call-and-branch")
2442 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2446 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2450 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2453 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2457 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2459 explicit LStackCheck(LOperand* context) {
2460 inputs_[0] = context;
2463 LOperand* context() { return inputs_[0]; }
2465 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2466 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2468 Label* done_label() { return &done_label_; }
2475 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2477 LForInPrepareMap(LOperand* context, LOperand* object) {
2478 inputs_[0] = context;
2479 inputs_[1] = object;
2482 LOperand* context() { return inputs_[0]; }
2483 LOperand* object() { return inputs_[1]; }
2485 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2489 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2491 explicit LForInCacheArray(LOperand* map) {
2495 LOperand* map() { return inputs_[0]; }
2497 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2500 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2505 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2507 LCheckMapValue(LOperand* value, LOperand* map) {
2512 LOperand* value() { return inputs_[0]; }
2513 LOperand* map() { return inputs_[1]; }
2515 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2519 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2521 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2522 inputs_[0] = object;
2526 LOperand* object() { return inputs_[0]; }
2527 LOperand* index() { return inputs_[1]; }
2529 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2533 class LChunkBuilder;
2534 class LPlatformChunk V8_FINAL : public LChunk {
2536 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2537 : LChunk(info, graph) { }
2539 int GetNextSpillIndex(RegisterKind kind);
2540 LOperand* GetNextSpillSlot(RegisterKind kind);
2544 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2546 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2547 : LChunkBuilderBase(graph->zone()),
2552 current_instruction_(NULL),
2553 current_block_(NULL),
2555 allocator_(allocator),
2556 instruction_pending_deoptimization_environment_(NULL),
2557 pending_deoptimization_ast_id_(BailoutId::None()) { }
2559 // Build the sequence for the graph.
2560 LPlatformChunk* Build();
2562 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2564 // Declare methods that deal with the individual node types.
2565 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2566 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2569 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2570 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2571 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2572 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2573 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2574 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2575 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2576 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2586 LPlatformChunk* chunk() const { return chunk_; }
2587 CompilationInfo* info() const { return info_; }
2588 HGraph* graph() const { return graph_; }
2590 bool is_unused() const { return status_ == UNUSED; }
2591 bool is_building() const { return status_ == BUILDING; }
2592 bool is_done() const { return status_ == DONE; }
2593 bool is_aborted() const { return status_ == ABORTED; }
2595 void Abort(BailoutReason reason);
2597 // Methods for getting operands for Use / Define / Temp.
2598 LUnallocated* ToUnallocated(Register reg);
2599 LUnallocated* ToUnallocated(XMMRegister reg);
2601 // Methods for setting up define-use relationships.
2602 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2603 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2604 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2605 XMMRegister fixed_register);
2607 // A value that is guaranteed to be allocated to a register.
2608 // Operand created by UseRegister is guaranteed to be live until the end of
2609 // instruction. This means that register allocator will not reuse it's
2610 // register for any other operand inside instruction.
2611 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2612 // instruction start. Register allocator is free to assign the same register
2613 // to some other operand used inside instruction (i.e. temporary or
2615 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2616 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2618 // An input operand in a register that may be trashed.
2619 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2621 // An input operand in a register that may be trashed or a constant operand.
2622 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2624 // An input operand in a register or stack slot.
2625 MUST_USE_RESULT LOperand* Use(HValue* value);
2626 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2628 // An input operand in a register, stack slot or a constant operand.
2629 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2630 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2632 // An input operand in a register or a constant operand.
2633 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2634 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2636 // An input operand in a constant operand.
2637 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2639 // An input operand in register, stack slot or a constant operand.
2640 // Will not be moved to a register even if one is freely available.
2641 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2643 // Temporary operand that must be in a register.
2644 MUST_USE_RESULT LUnallocated* TempRegister();
2645 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2646 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2648 // Methods for setting up define-use relationships.
2649 // Return the same instruction that they are passed.
2650 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2651 LUnallocated* result);
2652 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2653 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2655 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2656 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2658 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2660 // Assigns an environment to an instruction. An instruction which can
2661 // deoptimize must have an environment.
2662 LInstruction* AssignEnvironment(LInstruction* instr);
2663 // Assigns a pointer map to an instruction. An instruction which can
2664 // trigger a GC or a lazy deoptimization must have a pointer map.
2665 LInstruction* AssignPointerMap(LInstruction* instr);
2667 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2669 // Marks a call for the register allocator. Assigns a pointer map to
2670 // support GC and lazy deoptimization. Assigns an environment to support
2671 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2672 LInstruction* MarkAsCall(
2673 LInstruction* instr,
2674 HInstruction* hinstr,
2675 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2677 void VisitInstruction(HInstruction* current);
2679 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2680 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2681 LInstruction* DoArithmeticD(Token::Value op,
2682 HArithmeticBinaryOperation* instr);
2683 LInstruction* DoArithmeticT(Token::Value op,
2684 HBinaryOperation* instr);
2686 LPlatformChunk* chunk_;
2687 CompilationInfo* info_;
2688 HGraph* const graph_;
2690 HInstruction* current_instruction_;
2691 HBasicBlock* current_block_;
2692 HBasicBlock* next_block_;
2693 LAllocator* allocator_;
2694 LInstruction* instruction_pending_deoptimization_environment_;
2695 BailoutId pending_deoptimization_ast_id_;
2697 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2700 #undef DECLARE_HYDROGEN_ACCESSOR
2701 #undef DECLARE_CONCRETE_INSTRUCTION
2703 } } // namespace v8::int
2705 #endif // V8_X64_LITHIUM_X64_H_