1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
98 V(GetCachedArrayIndex) \
100 V(HasCachedArrayIndexAndBranch) \
101 V(HasInstanceTypeAndBranch) \
102 V(InnerAllocatedObject) \
104 V(InstanceOfKnownGlobal) \
106 V(Integer32ToDouble) \
109 V(IsConstructCallAndBranch) \
110 V(IsObjectAndBranch) \
111 V(IsStringAndBranch) \
113 V(IsUndetectableAndBranch) \
117 V(LoadExternalArrayPointer) \
119 V(LoadFieldByIndex) \
120 V(LoadFunctionPrototype) \
122 V(LoadGlobalGeneric) \
124 V(LoadKeyedGeneric) \
126 V(LoadNamedGeneric) \
149 V(SeqStringGetChar) \
150 V(SeqStringSetChar) \
156 V(StoreContextSlot) \
159 V(StoreKeyedGeneric) \
161 V(StoreNamedGeneric) \
163 V(StringCharCodeAt) \
164 V(StringCharFromCode) \
165 V(StringCompareAndBranch) \
170 V(ToFastProperties) \
171 V(TransitionElementsKind) \
172 V(TrapAllocationMemento) \
174 V(TypeofIsAndBranch) \
182 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
183 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
184 return LInstruction::k##type; \
186 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
187 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
190 static L##type* cast(LInstruction* instr) { \
191 ASSERT(instr->Is##type()); \
192 return reinterpret_cast<L##type*>(instr); \
196 #define DECLARE_HYDROGEN_ACCESSOR(type) \
197 H##type* hydrogen() const { \
198 return H##type::cast(hydrogen_value()); \
202 class LInstruction : public ZoneObject {
205 : environment_(NULL),
206 hydrogen_value_(NULL),
207 bit_field_(IsCallBits::encode(false)) {
210 virtual ~LInstruction() {}
212 virtual void CompileToNative(LCodeGen* generator) = 0;
213 virtual const char* Mnemonic() const = 0;
214 virtual void PrintTo(StringStream* stream);
215 virtual void PrintDataTo(StringStream* stream);
216 virtual void PrintOutputOperandTo(StringStream* stream);
219 // Declare a unique enum value for each instruction.
220 #define DECLARE_OPCODE(type) k##type,
221 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
222 kNumberOfInstructions
223 #undef DECLARE_OPCODE
226 virtual Opcode opcode() const = 0;
228 // Declare non-virtual type testers for all leaf IR classes.
229 #define DECLARE_PREDICATE(type) \
230 bool Is##type() const { return opcode() == k##type; }
231 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
232 #undef DECLARE_PREDICATE
234 // Declare virtual predicates for instructions that don't have
236 virtual bool IsGap() const { return false; }
238 virtual bool IsControl() const { return false; }
240 void set_environment(LEnvironment* env) { environment_ = env; }
241 LEnvironment* environment() const { return environment_; }
242 bool HasEnvironment() const { return environment_ != NULL; }
244 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
245 LPointerMap* pointer_map() const { return pointer_map_.get(); }
246 bool HasPointerMap() const { return pointer_map_.is_set(); }
248 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
249 HValue* hydrogen_value() const { return hydrogen_value_; }
251 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
252 bool IsCall() const { return IsCallBits::decode(bit_field_); }
254 // Interface to the register allocator and iterators.
255 bool ClobbersTemps() const { return IsCall(); }
256 bool ClobbersRegisters() const { return IsCall(); }
257 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
259 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
261 // Interface to the register allocator and iterators.
262 bool IsMarkedAsCall() const { return IsCall(); }
264 virtual bool HasResult() const = 0;
265 virtual LOperand* result() const = 0;
267 LOperand* FirstInput() { return InputAt(0); }
268 LOperand* Output() { return HasResult() ? result() : NULL; }
270 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
278 friend class InputIterator;
279 virtual int InputCount() = 0;
280 virtual LOperand* InputAt(int i) = 0;
282 friend class TempIterator;
283 virtual int TempCount() = 0;
284 virtual LOperand* TempAt(int i) = 0;
286 class IsCallBits: public BitField<bool, 0, 1> {};
288 LEnvironment* environment_;
289 SetOncePointer<LPointerMap> pointer_map_;
290 HValue* hydrogen_value_;
295 // R = number of result operands (0 or 1).
297 class LTemplateResultInstruction : public LInstruction {
299 // Allow 0 or 1 output operands.
300 STATIC_ASSERT(R == 0 || R == 1);
301 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
302 return R != 0 && result() != NULL;
304 void set_result(LOperand* operand) { results_[0] = operand; }
305 LOperand* result() const { return results_[0]; }
308 EmbeddedContainer<LOperand*, R> results_;
312 // R = number of result operands (0 or 1).
313 // I = number of input operands.
314 // T = number of temporary operands.
315 template<int R, int I, int T>
316 class LTemplateInstruction : public LTemplateResultInstruction<R> {
318 EmbeddedContainer<LOperand*, I> inputs_;
319 EmbeddedContainer<LOperand*, T> temps_;
323 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
324 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
326 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
327 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
331 class LGap : public LTemplateInstruction<0, 0, 0> {
333 explicit LGap(HBasicBlock* block)
335 parallel_moves_[BEFORE] = NULL;
336 parallel_moves_[START] = NULL;
337 parallel_moves_[END] = NULL;
338 parallel_moves_[AFTER] = NULL;
341 // Can't use the DECLARE-macro here because of sub-classes.
342 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
343 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
344 static LGap* cast(LInstruction* instr) {
345 ASSERT(instr->IsGap());
346 return reinterpret_cast<LGap*>(instr);
349 bool IsRedundant() const;
351 HBasicBlock* block() const { return block_; }
358 FIRST_INNER_POSITION = BEFORE,
359 LAST_INNER_POSITION = AFTER
362 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
364 if (parallel_moves_[pos] == NULL) {
365 parallel_moves_[pos] = new(zone) LParallelMove(zone);
367 return parallel_moves_[pos];
370 LParallelMove* GetParallelMove(InnerPosition pos) {
371 return parallel_moves_[pos];
375 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
380 class LInstructionGap V8_FINAL : public LGap {
382 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
384 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
385 return !IsRedundant();
388 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
392 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
394 explicit LGoto(HBasicBlock* block) : block_(block) { }
396 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
397 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
398 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
399 virtual bool IsControl() const V8_OVERRIDE { return true; }
401 int block_id() const { return block_->block_id(); }
408 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
410 LLazyBailout() : gap_instructions_size_(0) { }
412 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
414 void set_gap_instructions_size(int gap_instructions_size) {
415 gap_instructions_size_ = gap_instructions_size;
417 int gap_instructions_size() { return gap_instructions_size_; }
420 int gap_instructions_size_;
424 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
426 explicit LDummy() { }
427 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
431 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
433 explicit LDummyUse(LOperand* value) {
436 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
440 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
442 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
443 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
447 class LLabel V8_FINAL : public LGap {
449 explicit LLabel(HBasicBlock* block)
450 : LGap(block), replacement_(NULL) { }
452 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
455 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
457 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
459 int block_id() const { return block()->block_id(); }
460 bool is_loop_header() const { return block()->IsLoopHeader(); }
461 bool is_osr_entry() const { return block()->is_osr_entry(); }
462 Label* label() { return &label_; }
463 LLabel* replacement() const { return replacement_; }
464 void set_replacement(LLabel* label) { replacement_ = label; }
465 bool HasReplacement() const { return replacement_ != NULL; }
469 LLabel* replacement_;
473 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
475 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
478 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
482 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
484 explicit LCallStub(LOperand* context) {
485 inputs_[0] = context;
488 LOperand* context() { return inputs_[0]; }
490 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
491 DECLARE_HYDROGEN_ACCESSOR(CallStub)
495 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
497 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
500 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
504 template<int I, int T>
505 class LControlInstruction : public LTemplateInstruction<0, I, T> {
507 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
509 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
511 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
512 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
514 int TrueDestination(LChunk* chunk) {
515 return chunk->LookupDestination(true_block_id());
517 int FalseDestination(LChunk* chunk) {
518 return chunk->LookupDestination(false_block_id());
521 Label* TrueLabel(LChunk* chunk) {
522 if (true_label_ == NULL) {
523 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
527 Label* FalseLabel(LChunk* chunk) {
528 if (false_label_ == NULL) {
529 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
535 int true_block_id() { return SuccessorAt(0)->block_id(); }
536 int false_block_id() { return SuccessorAt(1)->block_id(); }
539 HControlInstruction* hydrogen() {
540 return HControlInstruction::cast(this->hydrogen_value());
548 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
550 LWrapReceiver(LOperand* receiver, LOperand* function) {
551 inputs_[0] = receiver;
552 inputs_[1] = function;
555 LOperand* receiver() { return inputs_[0]; }
556 LOperand* function() { return inputs_[1]; }
558 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
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 LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
768 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
772 ExternalReference::InitializeMathExpData();
775 LOperand* value() { return inputs_[0]; }
776 LOperand* temp1() { return temps_[0]; }
777 LOperand* temp2() { return temps_[1]; }
779 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
783 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
785 explicit LMathSqrt(LOperand* value) {
789 LOperand* value() { return inputs_[0]; }
791 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
795 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
797 explicit LMathPowHalf(LOperand* value) {
801 LOperand* value() { return inputs_[0]; }
803 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
807 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
809 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
814 LOperand* left() { return inputs_[0]; }
815 LOperand* right() { return inputs_[1]; }
817 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
821 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
823 explicit LCmpHoleAndBranch(LOperand* object) {
827 LOperand* object() { return inputs_[0]; }
829 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
830 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
834 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
836 explicit LCompareMinusZeroAndBranch(LOperand* value) {
840 LOperand* value() { return inputs_[0]; }
842 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
843 "cmp-minus-zero-and-branch")
844 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
849 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
851 explicit LIsObjectAndBranch(LOperand* value) {
855 LOperand* value() { return inputs_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
858 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
860 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
864 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
866 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
871 LOperand* value() { return inputs_[0]; }
872 LOperand* temp() { return temps_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
875 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
877 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
881 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
883 explicit LIsSmiAndBranch(LOperand* value) {
887 LOperand* value() { return inputs_[0]; }
889 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
890 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
892 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
896 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
898 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
903 LOperand* value() { return inputs_[0]; }
904 LOperand* temp() { return temps_[0]; }
906 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
907 "is-undetectable-and-branch")
908 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
910 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
914 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
916 explicit LStringCompareAndBranch(LOperand* context,
919 inputs_[0] = context;
924 LOperand* context() { return inputs_[0]; }
925 LOperand* left() { return inputs_[1]; }
926 LOperand* right() { return inputs_[2]; }
928 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
929 "string-compare-and-branch")
930 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
932 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
934 Token::Value op() const { return hydrogen()->token(); }
938 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
940 explicit LHasInstanceTypeAndBranch(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
947 "has-instance-type-and-branch")
948 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
950 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
954 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
956 explicit LGetCachedArrayIndex(LOperand* value) {
960 LOperand* value() { return inputs_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
963 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
967 class LHasCachedArrayIndexAndBranch V8_FINAL
968 : public LControlInstruction<1, 0> {
970 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
974 LOperand* value() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
977 "has-cached-array-index-and-branch")
978 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
980 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
984 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
986 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
992 LOperand* value() { return inputs_[0]; }
993 LOperand* temp() { return temps_[0]; }
994 LOperand* temp2() { return temps_[1]; }
996 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
997 "class-of-test-and-branch")
998 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1000 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1004 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1006 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1007 inputs_[0] = context;
1012 LOperand* context() { return inputs_[0]; }
1013 LOperand* left() { return inputs_[1]; }
1014 LOperand* right() { return inputs_[2]; }
1016 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1019 Token::Value op() const { return hydrogen()->token(); }
1023 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1025 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1026 inputs_[0] = context;
1031 LOperand* context() { return inputs_[0]; }
1032 LOperand* left() { return inputs_[1]; }
1033 LOperand* right() { return inputs_[2]; }
1035 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1039 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1041 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1042 inputs_[0] = context;
1047 LOperand* context() { return inputs_[0]; }
1048 LOperand* value() { return inputs_[1]; }
1049 LOperand* temp() { return temps_[0]; }
1051 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1052 "instance-of-known-global")
1053 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1055 Handle<JSFunction> function() const { return hydrogen()->function(); }
1056 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1057 return lazy_deopt_env_;
1059 virtual void SetDeferredLazyDeoptimizationEnvironment(
1060 LEnvironment* env) V8_OVERRIDE {
1061 lazy_deopt_env_ = env;
1065 LEnvironment* lazy_deopt_env_;
1069 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1071 LBoundsCheck(LOperand* index, LOperand* length) {
1073 inputs_[1] = length;
1076 LOperand* index() { return inputs_[0]; }
1077 LOperand* length() { return inputs_[1]; }
1079 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1080 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1084 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1086 LBitI(LOperand* left, LOperand* right) {
1091 LOperand* left() { return inputs_[0]; }
1092 LOperand* right() { return inputs_[1]; }
1094 Token::Value op() const { return hydrogen()->op(); }
1096 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1097 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1101 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1103 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1104 : op_(op), can_deopt_(can_deopt) {
1109 Token::Value op() const { return op_; }
1110 LOperand* left() { return inputs_[0]; }
1111 LOperand* right() { return inputs_[1]; }
1112 bool can_deopt() const { return can_deopt_; }
1114 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1122 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1124 LSubI(LOperand* left, LOperand* right) {
1129 LOperand* left() { return inputs_[0]; }
1130 LOperand* right() { return inputs_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1133 DECLARE_HYDROGEN_ACCESSOR(Sub)
1137 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1139 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1140 DECLARE_HYDROGEN_ACCESSOR(Constant)
1142 int32_t value() const { return hydrogen()->Integer32Value(); }
1146 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1148 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1149 DECLARE_HYDROGEN_ACCESSOR(Constant)
1151 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1155 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1157 explicit LConstantD(LOperand* temp) {
1161 LOperand* temp() { return temps_[0]; }
1163 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1164 DECLARE_HYDROGEN_ACCESSOR(Constant)
1166 double value() const { return hydrogen()->DoubleValue(); }
1170 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1172 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1173 DECLARE_HYDROGEN_ACCESSOR(Constant)
1175 ExternalReference value() const {
1176 return hydrogen()->ExternalReferenceValue();
1181 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1183 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1184 DECLARE_HYDROGEN_ACCESSOR(Constant)
1186 Handle<Object> value(Isolate* isolate) const {
1187 return hydrogen()->handle(isolate);
1192 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1194 explicit LBranch(LOperand* value) {
1198 LOperand* value() { return inputs_[0]; }
1200 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1201 DECLARE_HYDROGEN_ACCESSOR(Branch)
1203 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1207 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1209 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1213 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1215 explicit LCmpMapAndBranch(LOperand* value) {
1219 LOperand* value() { return inputs_[0]; }
1221 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1222 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1224 Handle<Map> map() const { return hydrogen()->map().handle(); }
1228 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1230 explicit LMapEnumLength(LOperand* value) {
1234 LOperand* value() { return inputs_[0]; }
1236 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1240 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1242 explicit LElementsKind(LOperand* value) {
1246 LOperand* value() { return inputs_[0]; }
1248 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1249 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1253 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1255 explicit LValueOf(LOperand* value) {
1259 LOperand* value() { return inputs_[0]; }
1261 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1262 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1266 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1268 LDateField(LOperand* date, Smi* index) : index_(index) {
1272 LOperand* date() { return inputs_[0]; }
1273 Smi* index() const { return index_; }
1275 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1276 DECLARE_HYDROGEN_ACCESSOR(DateField)
1283 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1285 LSeqStringGetChar(LOperand* string, LOperand* index) {
1286 inputs_[0] = string;
1290 LOperand* string() const { return inputs_[0]; }
1291 LOperand* index() const { return inputs_[1]; }
1293 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1294 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1298 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1300 LSeqStringSetChar(LOperand* context,
1304 inputs_[0] = context;
1305 inputs_[1] = string;
1310 LOperand* string() { return inputs_[1]; }
1311 LOperand* index() { return inputs_[2]; }
1312 LOperand* value() { return inputs_[3]; }
1314 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1315 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1319 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1321 explicit LThrow(LOperand* context, LOperand* value) {
1322 inputs_[0] = context;
1326 LOperand* context() { return inputs_[0]; }
1327 LOperand* value() { return inputs_[1]; }
1329 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1333 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1335 LAddI(LOperand* left, LOperand* right) {
1340 LOperand* left() { return inputs_[0]; }
1341 LOperand* right() { return inputs_[1]; }
1343 static bool UseLea(HAdd* add) {
1344 return !add->CheckFlag(HValue::kCanOverflow) &&
1345 add->BetterLeftOperand()->UseCount() > 1;
1348 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1349 DECLARE_HYDROGEN_ACCESSOR(Add)
1353 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1355 LMathMinMax(LOperand* left, LOperand* right) {
1360 LOperand* left() { return inputs_[0]; }
1361 LOperand* right() { return inputs_[1]; }
1363 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1364 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1368 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1370 LPower(LOperand* left, LOperand* right) {
1375 LOperand* left() { return inputs_[0]; }
1376 LOperand* right() { return inputs_[1]; }
1378 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1379 DECLARE_HYDROGEN_ACCESSOR(Power)
1383 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1385 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1391 Token::Value op() const { return op_; }
1392 LOperand* left() { return inputs_[0]; }
1393 LOperand* right() { return inputs_[1]; }
1395 virtual Opcode opcode() const V8_OVERRIDE {
1396 return LInstruction::kArithmeticD;
1398 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1399 virtual const char* Mnemonic() const V8_OVERRIDE;
1406 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1408 LArithmeticT(Token::Value op,
1413 inputs_[0] = context;
1418 Token::Value op() const { return op_; }
1419 LOperand* context() { return inputs_[0]; }
1420 LOperand* left() { return inputs_[1]; }
1421 LOperand* right() { return inputs_[2]; }
1423 virtual Opcode opcode() const V8_OVERRIDE {
1424 return LInstruction::kArithmeticT;
1426 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1427 virtual const char* Mnemonic() const V8_OVERRIDE;
1434 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1436 explicit LReturn(LOperand* value,
1438 LOperand* parameter_count) {
1440 inputs_[1] = context;
1441 inputs_[2] = parameter_count;
1444 LOperand* value() { return inputs_[0]; }
1445 LOperand* context() { return inputs_[1]; }
1447 bool has_constant_parameter_count() {
1448 return parameter_count()->IsConstantOperand();
1450 LConstantOperand* constant_parameter_count() {
1451 ASSERT(has_constant_parameter_count());
1452 return LConstantOperand::cast(parameter_count());
1454 LOperand* parameter_count() { return inputs_[2]; }
1456 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1457 DECLARE_HYDROGEN_ACCESSOR(Return)
1461 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1463 explicit LLoadNamedField(LOperand* object) {
1464 inputs_[0] = object;
1467 LOperand* object() { return inputs_[0]; }
1469 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1470 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1474 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1476 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1477 inputs_[0] = context;
1478 inputs_[1] = object;
1481 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1482 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1484 LOperand* context() { return inputs_[0]; }
1485 LOperand* object() { return inputs_[1]; }
1486 Handle<Object> name() const { return hydrogen()->name(); }
1490 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1492 explicit LLoadFunctionPrototype(LOperand* function) {
1493 inputs_[0] = function;
1496 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1497 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1499 LOperand* function() { return inputs_[0]; }
1503 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1505 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1506 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1508 Heap::RootListIndex index() const { return hydrogen()->index(); }
1512 class LLoadExternalArrayPointer V8_FINAL
1513 : public LTemplateInstruction<1, 1, 0> {
1515 explicit LLoadExternalArrayPointer(LOperand* object) {
1516 inputs_[0] = object;
1519 LOperand* object() { return inputs_[0]; }
1521 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1522 "load-external-array-pointer")
1526 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1528 LLoadKeyed(LOperand* elements, LOperand* key) {
1529 inputs_[0] = elements;
1533 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1534 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1536 bool is_external() const {
1537 return hydrogen()->is_external();
1539 bool is_fixed_typed_array() const {
1540 return hydrogen()->is_fixed_typed_array();
1542 bool is_typed_elements() const {
1543 return is_external() || is_fixed_typed_array();
1545 LOperand* elements() { return inputs_[0]; }
1546 LOperand* key() { return inputs_[1]; }
1547 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1548 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1549 ElementsKind elements_kind() const {
1550 return hydrogen()->elements_kind();
1555 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1557 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1558 inputs_[0] = context;
1563 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1565 LOperand* context() { return inputs_[0]; }
1566 LOperand* object() { return inputs_[1]; }
1567 LOperand* key() { return inputs_[2]; }
1571 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1573 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1574 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1578 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1580 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1581 inputs_[0] = context;
1582 inputs_[1] = global_object;
1585 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1586 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1588 LOperand* context() { return inputs_[0]; }
1589 LOperand* global_object() { return inputs_[1]; }
1590 Handle<Object> name() const { return hydrogen()->name(); }
1591 bool for_typeof() const { return hydrogen()->for_typeof(); }
1595 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1597 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1602 LOperand* value() { return inputs_[0]; }
1603 LOperand* temp() { return temps_[0]; }
1605 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1606 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1610 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1612 explicit LLoadContextSlot(LOperand* context) {
1613 inputs_[0] = context;
1616 LOperand* context() { return inputs_[0]; }
1618 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1619 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1621 int slot_index() { return hydrogen()->slot_index(); }
1623 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1627 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1629 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1630 inputs_[0] = context;
1635 LOperand* context() { return inputs_[0]; }
1636 LOperand* value() { return inputs_[1]; }
1637 LOperand* temp() { return temps_[0]; }
1639 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1640 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1642 int slot_index() { return hydrogen()->slot_index(); }
1644 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1648 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1650 explicit LPushArgument(LOperand* value) {
1654 LOperand* value() { return inputs_[0]; }
1656 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1660 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1662 explicit LDrop(int count) : count_(count) { }
1664 int count() const { return count_; }
1666 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1673 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1675 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1676 inputs_[0] = function;
1677 temps_[0] = code_object;
1680 LOperand* function() { return inputs_[0]; }
1681 LOperand* code_object() { return temps_[0]; }
1683 virtual void PrintDataTo(StringStream* stream);
1685 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1686 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1690 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1692 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1693 inputs_[0] = base_object;
1694 inputs_[1] = offset;
1697 LOperand* base_object() const { return inputs_[0]; }
1698 LOperand* offset() const { return inputs_[1]; }
1700 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1702 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1706 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1708 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1709 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1713 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1715 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1716 DECLARE_HYDROGEN_ACCESSOR(Context)
1720 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1722 explicit LDeclareGlobals(LOperand* context) {
1723 inputs_[0] = context;
1726 LOperand* context() { return inputs_[0]; }
1728 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1729 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1733 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1735 explicit LCallJSFunction(LOperand* function) {
1736 inputs_[0] = function;
1739 LOperand* function() { return inputs_[0]; }
1741 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1742 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1744 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1746 int arity() const { return hydrogen()->argument_count() - 1; }
1750 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1752 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1753 ZoneList<LOperand*>& operands,
1755 : inputs_(descriptor->environment_length() + 1, zone) {
1756 ASSERT(descriptor->environment_length() + 1 == operands.length());
1757 inputs_.AddAll(operands, zone);
1760 LOperand* target() const { return inputs_[0]; }
1763 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1764 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1766 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1768 int arity() const { return hydrogen()->argument_count() - 1; }
1770 ZoneList<LOperand*> inputs_;
1772 // Iterator support.
1773 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1774 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1776 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1777 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1781 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1783 LInvokeFunction(LOperand* context, LOperand* function) {
1784 inputs_[0] = context;
1785 inputs_[1] = function;
1788 LOperand* context() { return inputs_[0]; }
1789 LOperand* function() { return inputs_[1]; }
1791 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1792 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1794 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1796 int arity() const { return hydrogen()->argument_count() - 1; }
1800 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1802 LCallFunction(LOperand* context, LOperand* function) {
1803 inputs_[0] = context;
1804 inputs_[1] = function;
1807 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1808 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1810 LOperand* context() { return inputs_[0]; }
1811 LOperand* function() { return inputs_[1]; }
1812 int arity() const { return hydrogen()->argument_count() - 1; }
1816 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1818 LCallNew(LOperand* context, LOperand* constructor) {
1819 inputs_[0] = context;
1820 inputs_[1] = constructor;
1823 LOperand* context() { return inputs_[0]; }
1824 LOperand* constructor() { return inputs_[1]; }
1826 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1827 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1831 int arity() const { return hydrogen()->argument_count() - 1; }
1835 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1837 LCallNewArray(LOperand* context, LOperand* constructor) {
1838 inputs_[0] = context;
1839 inputs_[1] = constructor;
1842 LOperand* context() { return inputs_[0]; }
1843 LOperand* constructor() { return inputs_[1]; }
1845 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1846 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1848 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1850 int arity() const { return hydrogen()->argument_count() - 1; }
1854 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1856 explicit LCallRuntime(LOperand* context) {
1857 inputs_[0] = context;
1860 LOperand* context() { return inputs_[0]; }
1862 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1863 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1865 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1866 return save_doubles() == kDontSaveFPRegs;
1869 const Runtime::Function* function() const { return hydrogen()->function(); }
1870 int arity() const { return hydrogen()->argument_count(); }
1871 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1875 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1877 explicit LInteger32ToDouble(LOperand* value) {
1881 LOperand* value() { return inputs_[0]; }
1883 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1887 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1889 explicit LInteger32ToSmi(LOperand* value) {
1893 LOperand* value() { return inputs_[0]; }
1895 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1896 DECLARE_HYDROGEN_ACCESSOR(Change)
1900 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1902 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1907 LOperand* value() { return inputs_[0]; }
1908 LOperand* temp() { return temps_[0]; }
1910 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1914 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1916 explicit LUint32ToSmi(LOperand* value) {
1920 LOperand* value() { return inputs_[0]; }
1922 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1923 DECLARE_HYDROGEN_ACCESSOR(Change)
1927 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1929 explicit LNumberTagI(LOperand* value) {
1933 LOperand* value() { return inputs_[0]; }
1935 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1939 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1941 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1946 LOperand* value() { return inputs_[0]; }
1947 LOperand* temp() { return temps_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1953 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1955 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1960 LOperand* value() { return inputs_[0]; }
1961 LOperand* temp() { return temps_[0]; }
1963 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1964 DECLARE_HYDROGEN_ACCESSOR(Change)
1968 // Sometimes truncating conversion from a tagged value to an int32.
1969 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1971 explicit LDoubleToI(LOperand* value) {
1975 LOperand* value() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1978 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1980 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1984 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1986 explicit LDoubleToSmi(LOperand* value) {
1990 LOperand* value() { return inputs_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1993 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1997 // Truncating conversion from a tagged value to an int32.
1998 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2000 LTaggedToI(LOperand* value, LOperand* temp) {
2005 LOperand* value() { return inputs_[0]; }
2006 LOperand* temp() { return temps_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2009 DECLARE_HYDROGEN_ACCESSOR(Change)
2011 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2015 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2017 explicit LSmiTag(LOperand* value) {
2021 LOperand* value() { return inputs_[0]; }
2023 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2027 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2029 explicit LNumberUntagD(LOperand* value) {
2033 LOperand* value() { return inputs_[0]; }
2035 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2036 DECLARE_HYDROGEN_ACCESSOR(Change);
2040 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2042 LSmiUntag(LOperand* value, bool needs_check)
2043 : needs_check_(needs_check) {
2047 LOperand* value() { return inputs_[0]; }
2048 bool needs_check() const { return needs_check_; }
2050 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2057 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2059 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2060 inputs_[0] = object;
2065 LOperand* object() { return inputs_[0]; }
2066 LOperand* value() { return inputs_[1]; }
2067 LOperand* temp() { return temps_[0]; }
2069 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2070 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2072 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2074 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2075 Representation representation() const {
2076 return hydrogen()->field_representation();
2081 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2083 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2084 inputs_[0] = context;
2085 inputs_[1] = object;
2089 LOperand* context() { return inputs_[0]; }
2090 LOperand* object() { return inputs_[1]; }
2091 LOperand* value() { return inputs_[2]; }
2093 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2094 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2096 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2098 Handle<Object> name() const { return hydrogen()->name(); }
2099 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2103 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2105 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2106 inputs_[0] = object;
2111 bool is_external() const { return hydrogen()->is_external(); }
2112 bool is_fixed_typed_array() const {
2113 return hydrogen()->is_fixed_typed_array();
2115 bool is_typed_elements() const {
2116 return is_external() || is_fixed_typed_array();
2118 LOperand* elements() { return inputs_[0]; }
2119 LOperand* key() { return inputs_[1]; }
2120 LOperand* value() { return inputs_[2]; }
2121 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2123 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2124 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2126 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2127 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2128 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2132 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2134 LStoreKeyedGeneric(LOperand* context,
2138 inputs_[0] = context;
2139 inputs_[1] = object;
2144 LOperand* context() { return inputs_[0]; }
2145 LOperand* object() { return inputs_[1]; }
2146 LOperand* key() { return inputs_[2]; }
2147 LOperand* value() { return inputs_[3]; }
2149 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2150 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2152 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2154 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2158 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2160 LTransitionElementsKind(LOperand* object,
2162 LOperand* new_map_temp,
2164 inputs_[0] = object;
2165 inputs_[1] = context;
2166 temps_[0] = new_map_temp;
2170 LOperand* object() { return inputs_[0]; }
2171 LOperand* context() { return inputs_[1]; }
2172 LOperand* new_map_temp() { return temps_[0]; }
2173 LOperand* temp() { return temps_[1]; }
2175 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2176 "transition-elements-kind")
2177 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2179 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2181 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2182 Handle<Map> transitioned_map() {
2183 return hydrogen()->transitioned_map().handle();
2185 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2186 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2190 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2192 LTrapAllocationMemento(LOperand* object,
2194 inputs_[0] = object;
2198 LOperand* object() { return inputs_[0]; }
2199 LOperand* temp() { return temps_[0]; }
2201 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2202 "trap-allocation-memento")
2206 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2208 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2209 inputs_[0] = context;
2214 LOperand* context() { return inputs_[0]; }
2215 LOperand* left() { return inputs_[1]; }
2216 LOperand* right() { return inputs_[2]; }
2218 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2219 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2223 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2225 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2226 inputs_[0] = context;
2227 inputs_[1] = string;
2231 LOperand* context() { return inputs_[0]; }
2232 LOperand* string() { return inputs_[1]; }
2233 LOperand* index() { return inputs_[2]; }
2235 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2236 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2240 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2242 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2243 inputs_[0] = context;
2244 inputs_[1] = char_code;
2247 LOperand* context() { return inputs_[0]; }
2248 LOperand* char_code() { return inputs_[1]; }
2250 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2251 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2255 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2257 explicit LCheckValue(LOperand* value) {
2261 LOperand* value() { return inputs_[0]; }
2263 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2264 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2268 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2270 explicit LCheckInstanceType(LOperand* value) {
2274 LOperand* value() { return inputs_[0]; }
2276 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2277 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2281 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2283 explicit LCheckMaps(LOperand* value) {
2287 LOperand* value() { return inputs_[0]; }
2289 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2290 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2294 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2296 explicit LCheckSmi(LOperand* value) {
2300 LOperand* value() { return inputs_[0]; }
2302 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2306 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2308 explicit LClampDToUint8(LOperand* unclamped) {
2309 inputs_[0] = unclamped;
2312 LOperand* unclamped() { return inputs_[0]; }
2314 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2318 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2320 explicit LClampIToUint8(LOperand* unclamped) {
2321 inputs_[0] = unclamped;
2324 LOperand* unclamped() { return inputs_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2330 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2332 LClampTToUint8(LOperand* unclamped,
2333 LOperand* temp_xmm) {
2334 inputs_[0] = unclamped;
2335 temps_[0] = temp_xmm;
2338 LOperand* unclamped() { return inputs_[0]; }
2339 LOperand* temp_xmm() { return temps_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2345 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2347 explicit LCheckNonSmi(LOperand* value) {
2351 LOperand* value() { return inputs_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2354 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2358 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2360 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2361 inputs_[0] = context;
2366 LOperand* context() { return inputs_[0]; }
2367 LOperand* size() { return inputs_[1]; }
2368 LOperand* temp() { return temps_[0]; }
2370 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2371 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2375 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2377 explicit LRegExpLiteral(LOperand* context) {
2378 inputs_[0] = context;
2381 LOperand* context() { return inputs_[0]; }
2383 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2384 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2388 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2390 explicit LFunctionLiteral(LOperand* context) {
2391 inputs_[0] = context;
2394 LOperand* context() { return inputs_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2397 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2401 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2403 explicit LToFastProperties(LOperand* value) {
2407 LOperand* value() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2410 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2414 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2416 LTypeof(LOperand* context, LOperand* value) {
2417 inputs_[0] = context;
2421 LOperand* context() { return inputs_[0]; }
2422 LOperand* value() { return inputs_[1]; }
2424 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2428 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2430 explicit LTypeofIsAndBranch(LOperand* value) {
2434 LOperand* value() { return inputs_[0]; }
2436 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2437 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2439 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2441 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2445 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2447 explicit LIsConstructCallAndBranch(LOperand* temp) {
2451 LOperand* temp() { return temps_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2454 "is-construct-call-and-branch")
2455 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2459 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2463 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2466 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2470 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2472 explicit LStackCheck(LOperand* context) {
2473 inputs_[0] = context;
2476 LOperand* context() { return inputs_[0]; }
2478 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2479 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2481 Label* done_label() { return &done_label_; }
2488 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2490 LForInPrepareMap(LOperand* context, LOperand* object) {
2491 inputs_[0] = context;
2492 inputs_[1] = object;
2495 LOperand* context() { return inputs_[0]; }
2496 LOperand* object() { return inputs_[1]; }
2498 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2502 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2504 explicit LForInCacheArray(LOperand* map) {
2508 LOperand* map() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2513 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2518 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2520 LCheckMapValue(LOperand* value, LOperand* map) {
2525 LOperand* value() { return inputs_[0]; }
2526 LOperand* map() { return inputs_[1]; }
2528 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2532 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2534 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2535 inputs_[0] = object;
2539 LOperand* object() { return inputs_[0]; }
2540 LOperand* index() { return inputs_[1]; }
2542 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2546 class LChunkBuilder;
2547 class LPlatformChunk V8_FINAL : public LChunk {
2549 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2550 : LChunk(info, graph) { }
2552 int GetNextSpillIndex(RegisterKind kind);
2553 LOperand* GetNextSpillSlot(RegisterKind kind);
2557 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2559 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2560 : LChunkBuilderBase(graph->zone()),
2565 current_instruction_(NULL),
2566 current_block_(NULL),
2568 allocator_(allocator),
2569 instruction_pending_deoptimization_environment_(NULL),
2570 pending_deoptimization_ast_id_(BailoutId::None()) { }
2572 // Build the sequence for the graph.
2573 LPlatformChunk* Build();
2575 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2577 // Declare methods that deal with the individual node types.
2578 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2579 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2582 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2583 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2584 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2585 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2586 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2587 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2588 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2598 LPlatformChunk* chunk() const { return chunk_; }
2599 CompilationInfo* info() const { return info_; }
2600 HGraph* graph() const { return graph_; }
2602 bool is_unused() const { return status_ == UNUSED; }
2603 bool is_building() const { return status_ == BUILDING; }
2604 bool is_done() const { return status_ == DONE; }
2605 bool is_aborted() const { return status_ == ABORTED; }
2607 void Abort(BailoutReason reason);
2609 // Methods for getting operands for Use / Define / Temp.
2610 LUnallocated* ToUnallocated(Register reg);
2611 LUnallocated* ToUnallocated(XMMRegister reg);
2613 // Methods for setting up define-use relationships.
2614 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2615 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2616 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2617 XMMRegister fixed_register);
2619 // A value that is guaranteed to be allocated to a register.
2620 // Operand created by UseRegister is guaranteed to be live until the end of
2621 // instruction. This means that register allocator will not reuse it's
2622 // register for any other operand inside instruction.
2623 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2624 // instruction start. Register allocator is free to assign the same register
2625 // to some other operand used inside instruction (i.e. temporary or
2627 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2628 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2630 // An input operand in a register that may be trashed.
2631 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2633 // An input operand in a register that may be trashed or a constant operand.
2634 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2636 // An input operand in a register or stack slot.
2637 MUST_USE_RESULT LOperand* Use(HValue* value);
2638 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2640 // An input operand in a register, stack slot or a constant operand.
2641 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2642 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2644 // An input operand in a register or a constant operand.
2645 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2646 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2648 // An input operand in a constant operand.
2649 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2651 // An input operand in register, stack slot or a constant operand.
2652 // Will not be moved to a register even if one is freely available.
2653 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2655 // Temporary operand that must be in a register.
2656 MUST_USE_RESULT LUnallocated* TempRegister();
2657 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2658 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2660 // Methods for setting up define-use relationships.
2661 // Return the same instruction that they are passed.
2662 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2663 LUnallocated* result);
2664 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2665 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2667 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2668 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2670 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2672 // Assigns an environment to an instruction. An instruction which can
2673 // deoptimize must have an environment.
2674 LInstruction* AssignEnvironment(LInstruction* instr);
2675 // Assigns a pointer map to an instruction. An instruction which can
2676 // trigger a GC or a lazy deoptimization must have a pointer map.
2677 LInstruction* AssignPointerMap(LInstruction* instr);
2679 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2681 // Marks a call for the register allocator. Assigns a pointer map to
2682 // support GC and lazy deoptimization. Assigns an environment to support
2683 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2684 LInstruction* MarkAsCall(
2685 LInstruction* instr,
2686 HInstruction* hinstr,
2687 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2689 void VisitInstruction(HInstruction* current);
2691 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2692 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2693 LInstruction* DoArithmeticD(Token::Value op,
2694 HArithmeticBinaryOperation* instr);
2695 LInstruction* DoArithmeticT(Token::Value op,
2696 HBinaryOperation* instr);
2698 LPlatformChunk* chunk_;
2699 CompilationInfo* info_;
2700 HGraph* const graph_;
2702 HInstruction* current_instruction_;
2703 HBasicBlock* current_block_;
2704 HBasicBlock* next_block_;
2705 LAllocator* allocator_;
2706 LInstruction* instruction_pending_deoptimization_environment_;
2707 BailoutId pending_deoptimization_ast_id_;
2709 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2712 #undef DECLARE_HYDROGEN_ACCESSOR
2713 #undef DECLARE_CONCRETE_INSTRUCTION
2715 } } // namespace v8::int
2717 #endif // V8_X64_LITHIUM_X64_H_