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(FlooringDivByConstI) \
99 V(FlooringDivByPowerOf2I) \
103 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
113 V(IsConstructCallAndBranch) \
114 V(IsObjectAndBranch) \
115 V(IsStringAndBranch) \
117 V(IsUndetectableAndBranch) \
122 V(LoadFieldByIndex) \
123 V(LoadFunctionPrototype) \
125 V(LoadGlobalGeneric) \
127 V(LoadKeyedGeneric) \
129 V(LoadNamedGeneric) \
142 V(NullarySIMDOperation) \
143 V(UnarySIMDOperation) \
144 V(BinarySIMDOperation) \
145 V(TernarySIMDOperation) \
146 V(QuarternarySIMDOperation) \
161 V(SeqStringGetChar) \
162 V(SeqStringSetChar) \
168 V(StoreContextSlot) \
171 V(StoreKeyedGeneric) \
173 V(StoreNamedGeneric) \
175 V(StringCharCodeAt) \
176 V(StringCharFromCode) \
177 V(StringCompareAndBranch) \
181 V(ToFastProperties) \
182 V(TransitionElementsKind) \
183 V(TrapAllocationMemento) \
185 V(TypeofIsAndBranch) \
191 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
192 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
193 return LInstruction::k##type; \
195 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
196 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
199 static L##type* cast(LInstruction* instr) { \
200 ASSERT(instr->Is##type()); \
201 return reinterpret_cast<L##type*>(instr); \
205 #define DECLARE_HYDROGEN_ACCESSOR(type) \
206 H##type* hydrogen() const { \
207 return H##type::cast(hydrogen_value()); \
211 class LInstruction : public ZoneObject {
214 : environment_(NULL),
215 hydrogen_value_(NULL),
216 bit_field_(IsCallBits::encode(false)) {
219 virtual ~LInstruction() {}
221 virtual void CompileToNative(LCodeGen* generator) = 0;
222 virtual const char* Mnemonic() const = 0;
223 virtual void PrintTo(StringStream* stream);
224 virtual void PrintDataTo(StringStream* stream);
225 virtual void PrintOutputOperandTo(StringStream* stream);
228 // Declare a unique enum value for each instruction.
229 #define DECLARE_OPCODE(type) k##type,
230 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
231 kNumberOfInstructions
232 #undef DECLARE_OPCODE
235 virtual Opcode opcode() const = 0;
237 // Declare non-virtual type testers for all leaf IR classes.
238 #define DECLARE_PREDICATE(type) \
239 bool Is##type() const { return opcode() == k##type; }
240 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
241 #undef DECLARE_PREDICATE
243 // Declare virtual predicates for instructions that don't have
245 virtual bool IsGap() const { return false; }
247 virtual bool IsControl() const { return false; }
249 void set_environment(LEnvironment* env) { environment_ = env; }
250 LEnvironment* environment() const { return environment_; }
251 bool HasEnvironment() const { return environment_ != NULL; }
253 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
254 LPointerMap* pointer_map() const { return pointer_map_.get(); }
255 bool HasPointerMap() const { return pointer_map_.is_set(); }
257 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
258 HValue* hydrogen_value() const { return hydrogen_value_; }
260 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
261 bool IsCall() const { return IsCallBits::decode(bit_field_); }
263 // Interface to the register allocator and iterators.
264 bool ClobbersTemps() const { return IsCall(); }
265 bool ClobbersRegisters() const { return IsCall(); }
266 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
268 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
270 // Interface to the register allocator and iterators.
271 bool IsMarkedAsCall() const { return IsCall(); }
273 virtual bool HasResult() const = 0;
274 virtual LOperand* result() const = 0;
276 LOperand* FirstInput() { return InputAt(0); }
277 LOperand* Output() { return HasResult() ? result() : NULL; }
279 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
281 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
291 friend class InputIterator;
292 virtual int InputCount() = 0;
293 virtual LOperand* InputAt(int i) = 0;
295 friend class TempIterator;
296 virtual int TempCount() = 0;
297 virtual LOperand* TempAt(int i) = 0;
299 class IsCallBits: public BitField<bool, 0, 1> {};
301 LEnvironment* environment_;
302 SetOncePointer<LPointerMap> pointer_map_;
303 HValue* hydrogen_value_;
308 // R = number of result operands (0 or 1).
310 class LTemplateResultInstruction : public LInstruction {
312 // Allow 0 or 1 output operands.
313 STATIC_ASSERT(R == 0 || R == 1);
314 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
315 return R != 0 && result() != NULL;
317 void set_result(LOperand* operand) { results_[0] = operand; }
318 LOperand* result() const { return results_[0]; }
320 virtual bool MustSignExtendResult(
321 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
324 EmbeddedContainer<LOperand*, R> results_;
328 // R = number of result operands (0 or 1).
329 // I = number of input operands.
330 // T = number of temporary operands.
331 template<int R, int I, int T>
332 class LTemplateInstruction : public LTemplateResultInstruction<R> {
334 EmbeddedContainer<LOperand*, I> inputs_;
335 EmbeddedContainer<LOperand*, T> temps_;
339 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
340 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
342 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
343 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
347 class LGap : public LTemplateInstruction<0, 0, 0> {
349 explicit LGap(HBasicBlock* block)
351 parallel_moves_[BEFORE] = NULL;
352 parallel_moves_[START] = NULL;
353 parallel_moves_[END] = NULL;
354 parallel_moves_[AFTER] = NULL;
357 // Can't use the DECLARE-macro here because of sub-classes.
358 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
359 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
360 static LGap* cast(LInstruction* instr) {
361 ASSERT(instr->IsGap());
362 return reinterpret_cast<LGap*>(instr);
365 bool IsRedundant() const;
367 HBasicBlock* block() const { return block_; }
374 FIRST_INNER_POSITION = BEFORE,
375 LAST_INNER_POSITION = AFTER
378 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
380 if (parallel_moves_[pos] == NULL) {
381 parallel_moves_[pos] = new(zone) LParallelMove(zone);
383 return parallel_moves_[pos];
386 LParallelMove* GetParallelMove(InnerPosition pos) {
387 return parallel_moves_[pos];
391 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
396 class LInstructionGap V8_FINAL : public LGap {
398 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
400 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
401 return !IsRedundant();
404 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
408 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
410 explicit LGoto(HBasicBlock* block) : block_(block) { }
412 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
413 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
414 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
415 virtual bool IsControl() const V8_OVERRIDE { return true; }
417 int block_id() const { return block_->block_id(); }
424 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
426 LLazyBailout() : gap_instructions_size_(0) { }
428 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
430 void set_gap_instructions_size(int gap_instructions_size) {
431 gap_instructions_size_ = gap_instructions_size;
433 int gap_instructions_size() { return gap_instructions_size_; }
436 int gap_instructions_size_;
440 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
442 explicit LDummy() { }
443 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
447 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
449 explicit LDummyUse(LOperand* value) {
452 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
456 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
458 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
459 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
463 class LLabel V8_FINAL : public LGap {
465 explicit LLabel(HBasicBlock* block)
466 : LGap(block), replacement_(NULL) { }
468 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
471 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
473 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
475 int block_id() const { return block()->block_id(); }
476 bool is_loop_header() const { return block()->IsLoopHeader(); }
477 bool is_osr_entry() const { return block()->is_osr_entry(); }
478 Label* label() { return &label_; }
479 LLabel* replacement() const { return replacement_; }
480 void set_replacement(LLabel* label) { replacement_ = label; }
481 bool HasReplacement() const { return replacement_ != NULL; }
485 LLabel* replacement_;
489 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
491 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
494 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
498 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
500 explicit LCallStub(LOperand* context) {
501 inputs_[0] = context;
504 LOperand* context() { return inputs_[0]; }
506 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
507 DECLARE_HYDROGEN_ACCESSOR(CallStub)
511 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
513 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
516 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
520 template<int I, int T>
521 class LControlInstruction : public LTemplateInstruction<0, I, T> {
523 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
525 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
527 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
528 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
530 int TrueDestination(LChunk* chunk) {
531 return chunk->LookupDestination(true_block_id());
533 int FalseDestination(LChunk* chunk) {
534 return chunk->LookupDestination(false_block_id());
537 Label* TrueLabel(LChunk* chunk) {
538 if (true_label_ == NULL) {
539 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
543 Label* FalseLabel(LChunk* chunk) {
544 if (false_label_ == NULL) {
545 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
551 int true_block_id() { return SuccessorAt(0)->block_id(); }
552 int false_block_id() { return SuccessorAt(1)->block_id(); }
555 HControlInstruction* hydrogen() {
556 return HControlInstruction::cast(this->hydrogen_value());
564 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
566 LWrapReceiver(LOperand* receiver, LOperand* function) {
567 inputs_[0] = receiver;
568 inputs_[1] = function;
571 LOperand* receiver() { return inputs_[0]; }
572 LOperand* function() { return inputs_[1]; }
574 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
575 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
579 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
581 LApplyArguments(LOperand* function,
584 LOperand* elements) {
585 inputs_[0] = function;
586 inputs_[1] = receiver;
588 inputs_[3] = elements;
591 LOperand* function() { return inputs_[0]; }
592 LOperand* receiver() { return inputs_[1]; }
593 LOperand* length() { return inputs_[2]; }
594 LOperand* elements() { return inputs_[3]; }
596 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
600 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
602 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
603 inputs_[0] = arguments;
608 LOperand* arguments() { return inputs_[0]; }
609 LOperand* length() { return inputs_[1]; }
610 LOperand* index() { return inputs_[2]; }
612 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
614 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
618 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
620 explicit LArgumentsLength(LOperand* elements) {
621 inputs_[0] = elements;
624 LOperand* elements() { return inputs_[0]; }
626 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
630 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
632 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
633 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
637 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
639 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
640 inputs_[0] = dividend;
644 LOperand* dividend() { return inputs_[0]; }
645 int32_t divisor() const { return divisor_; }
647 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
648 DECLARE_HYDROGEN_ACCESSOR(Mod)
655 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
657 LModByConstI(LOperand* dividend,
661 inputs_[0] = dividend;
667 LOperand* dividend() { return inputs_[0]; }
668 int32_t divisor() const { return divisor_; }
669 LOperand* temp1() { return temps_[0]; }
670 LOperand* temp2() { return temps_[1]; }
672 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
673 DECLARE_HYDROGEN_ACCESSOR(Mod)
680 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
682 LModI(LOperand* left, LOperand* right, LOperand* temp) {
688 LOperand* left() { return inputs_[0]; }
689 LOperand* right() { return inputs_[1]; }
690 LOperand* temp() { return temps_[0]; }
692 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
693 DECLARE_HYDROGEN_ACCESSOR(Mod)
697 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
699 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
700 inputs_[0] = dividend;
704 LOperand* dividend() { return inputs_[0]; }
705 int32_t divisor() const { return divisor_; }
707 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
708 DECLARE_HYDROGEN_ACCESSOR(Div)
715 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
717 LDivByConstI(LOperand* dividend,
721 inputs_[0] = dividend;
727 LOperand* dividend() { return inputs_[0]; }
728 int32_t divisor() const { return divisor_; }
729 LOperand* temp1() { return temps_[0]; }
730 LOperand* temp2() { return temps_[1]; }
732 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
733 DECLARE_HYDROGEN_ACCESSOR(Div)
740 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
742 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
748 LOperand* left() { return inputs_[0]; }
749 LOperand* right() { return inputs_[1]; }
750 LOperand* temp() { return temps_[0]; }
752 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
753 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
757 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
759 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
760 inputs_[0] = dividend;
764 LOperand* dividend() { return inputs_[0]; }
765 int32_t divisor() const { return divisor_; }
767 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
768 "flooring-div-by-power-of-2-i")
769 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
776 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
778 LFlooringDivByConstI(LOperand* dividend,
783 inputs_[0] = dividend;
790 LOperand* dividend() { return inputs_[0]; }
791 int32_t divisor() const { return divisor_; }
792 LOperand* temp1() { return temps_[0]; }
793 LOperand* temp2() { return temps_[1]; }
794 LOperand* temp3() { return temps_[2]; }
796 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
797 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
804 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
806 LMulI(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
815 DECLARE_HYDROGEN_ACCESSOR(Mul)
819 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
821 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
829 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
830 "compare-numeric-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
833 Token::Value op() const { return hydrogen()->token(); }
834 bool is_double() const {
835 return hydrogen()->representation().IsDouble();
838 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
842 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
844 explicit LMathFloor(LOperand* value) {
848 LOperand* value() { return inputs_[0]; }
850 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
851 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
855 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
857 explicit LMathRound(LOperand* value, LOperand* temp) {
862 LOperand* value() { return inputs_[0]; }
863 LOperand* temp() { return temps_[0]; }
865 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
866 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
870 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
872 explicit LMathAbs(LOperand* context, LOperand* value) {
873 inputs_[1] = context;
877 LOperand* context() { return inputs_[1]; }
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathLog(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
897 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
899 explicit LMathClz32(LOperand* value) {
903 LOperand* value() { return inputs_[0]; }
905 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
909 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
911 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
915 ExternalReference::InitializeMathExpData();
918 LOperand* value() { return inputs_[0]; }
919 LOperand* temp1() { return temps_[0]; }
920 LOperand* temp2() { return temps_[1]; }
922 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
926 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
928 explicit LMathSqrt(LOperand* value) {
932 LOperand* value() { return inputs_[0]; }
934 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
938 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
940 explicit LMathPowHalf(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
950 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
952 explicit LNullarySIMDOperation(BuiltinFunctionId op)
956 BuiltinFunctionId op() const { return op_; }
958 virtual Opcode opcode() const V8_OVERRIDE {
959 return LInstruction::kNullarySIMDOperation;
961 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
962 virtual const char* Mnemonic() const V8_OVERRIDE;
963 static LNullarySIMDOperation* cast(LInstruction* instr) {
964 ASSERT(instr->IsNullarySIMDOperation());
965 return reinterpret_cast<LNullarySIMDOperation*>(instr);
968 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
971 BuiltinFunctionId op_;
975 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
977 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
982 LOperand* value() { return inputs_[0]; }
983 BuiltinFunctionId op() const { return op_; }
985 virtual Opcode opcode() const V8_OVERRIDE {
986 return LInstruction::kUnarySIMDOperation;
988 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
989 virtual const char* Mnemonic() const V8_OVERRIDE;
990 static LUnarySIMDOperation* cast(LInstruction* instr) {
991 ASSERT(instr->IsUnarySIMDOperation());
992 return reinterpret_cast<LUnarySIMDOperation*>(instr);
995 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
998 BuiltinFunctionId op_;
1002 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1004 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
1010 LOperand* left() { return inputs_[0]; }
1011 LOperand* right() { return inputs_[1]; }
1012 BuiltinFunctionId op() const { return op_; }
1014 virtual Opcode opcode() const V8_OVERRIDE {
1015 return LInstruction::kBinarySIMDOperation;
1017 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1018 virtual const char* Mnemonic() const V8_OVERRIDE;
1019 static LBinarySIMDOperation* cast(LInstruction* instr) {
1020 ASSERT(instr->IsBinarySIMDOperation());
1021 return reinterpret_cast<LBinarySIMDOperation*>(instr);
1024 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
1027 BuiltinFunctionId op_;
1031 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1033 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
1034 BuiltinFunctionId op)
1037 inputs_[1] = second;
1041 LOperand* first() { return inputs_[0]; }
1042 LOperand* second() { return inputs_[1]; }
1043 LOperand* third() { return inputs_[2]; }
1044 BuiltinFunctionId op() const { return op_; }
1046 virtual Opcode opcode() const V8_OVERRIDE {
1047 return LInstruction::kTernarySIMDOperation;
1049 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1050 virtual const char* Mnemonic() const V8_OVERRIDE;
1051 static LTernarySIMDOperation* cast(LInstruction* instr) {
1052 ASSERT(instr->IsTernarySIMDOperation());
1053 return reinterpret_cast<LTernarySIMDOperation*>(instr);
1056 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
1059 BuiltinFunctionId op_;
1063 class LQuarternarySIMDOperation V8_FINAL
1064 : public LTemplateInstruction<1, 4, 0> {
1066 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
1067 LOperand* w, BuiltinFunctionId op)
1075 LOperand* x() { return inputs_[0]; }
1076 LOperand* y() { return inputs_[1]; }
1077 LOperand* z() { return inputs_[2]; }
1078 LOperand* w() { return inputs_[3]; }
1079 BuiltinFunctionId op() const { return op_; }
1081 virtual Opcode opcode() const V8_OVERRIDE {
1082 return LInstruction::kQuarternarySIMDOperation;
1084 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1085 virtual const char* Mnemonic() const V8_OVERRIDE;
1086 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
1087 ASSERT(instr->IsQuarternarySIMDOperation());
1088 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
1091 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
1094 BuiltinFunctionId op_;
1098 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
1100 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1105 LOperand* left() { return inputs_[0]; }
1106 LOperand* right() { return inputs_[1]; }
1108 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1112 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1114 explicit LCmpHoleAndBranch(LOperand* object) {
1115 inputs_[0] = object;
1118 LOperand* object() { return inputs_[0]; }
1120 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1121 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1125 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1127 explicit LCompareMinusZeroAndBranch(LOperand* value) {
1131 LOperand* value() { return inputs_[0]; }
1133 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1134 "cmp-minus-zero-and-branch")
1135 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1140 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1142 explicit LIsObjectAndBranch(LOperand* value) {
1146 LOperand* value() { return inputs_[0]; }
1148 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1149 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1151 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1155 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1157 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1162 LOperand* value() { return inputs_[0]; }
1163 LOperand* temp() { return temps_[0]; }
1165 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1166 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1168 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1172 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1174 explicit LIsSmiAndBranch(LOperand* value) {
1178 LOperand* value() { return inputs_[0]; }
1180 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1181 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1183 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1187 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1189 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1194 LOperand* value() { return inputs_[0]; }
1195 LOperand* temp() { return temps_[0]; }
1197 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1198 "is-undetectable-and-branch")
1199 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1201 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1205 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1207 explicit LStringCompareAndBranch(LOperand* context,
1210 inputs_[0] = context;
1215 LOperand* context() { return inputs_[0]; }
1216 LOperand* left() { return inputs_[1]; }
1217 LOperand* right() { return inputs_[2]; }
1219 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1220 "string-compare-and-branch")
1221 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1223 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1225 Token::Value op() const { return hydrogen()->token(); }
1229 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1231 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1235 LOperand* value() { return inputs_[0]; }
1237 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1238 "has-instance-type-and-branch")
1239 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1241 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1245 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1247 explicit LGetCachedArrayIndex(LOperand* value) {
1251 LOperand* value() { return inputs_[0]; }
1253 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1254 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1258 class LHasCachedArrayIndexAndBranch V8_FINAL
1259 : public LControlInstruction<1, 0> {
1261 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1265 LOperand* value() { return inputs_[0]; }
1267 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1268 "has-cached-array-index-and-branch")
1269 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1271 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1275 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1277 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1283 LOperand* value() { return inputs_[0]; }
1284 LOperand* temp() { return temps_[0]; }
1285 LOperand* temp2() { return temps_[1]; }
1287 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1288 "class-of-test-and-branch")
1289 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1291 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1295 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1297 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1298 inputs_[0] = context;
1303 LOperand* context() { return inputs_[0]; }
1304 LOperand* left() { return inputs_[1]; }
1305 LOperand* right() { return inputs_[2]; }
1307 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1308 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1310 Token::Value op() const { return hydrogen()->token(); }
1314 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1316 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1317 inputs_[0] = context;
1322 LOperand* context() { return inputs_[0]; }
1323 LOperand* left() { return inputs_[1]; }
1324 LOperand* right() { return inputs_[2]; }
1326 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1330 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1332 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1333 inputs_[0] = context;
1338 LOperand* context() { return inputs_[0]; }
1339 LOperand* value() { return inputs_[1]; }
1340 LOperand* temp() { return temps_[0]; }
1342 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1343 "instance-of-known-global")
1344 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1346 Handle<JSFunction> function() const { return hydrogen()->function(); }
1347 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1348 return lazy_deopt_env_;
1350 virtual void SetDeferredLazyDeoptimizationEnvironment(
1351 LEnvironment* env) V8_OVERRIDE {
1352 lazy_deopt_env_ = env;
1356 LEnvironment* lazy_deopt_env_;
1360 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1362 LBoundsCheck(LOperand* index, LOperand* length) {
1364 inputs_[1] = length;
1367 LOperand* index() { return inputs_[0]; }
1368 LOperand* length() { return inputs_[1]; }
1370 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1371 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1375 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1377 LBitI(LOperand* left, LOperand* right) {
1382 LOperand* left() { return inputs_[0]; }
1383 LOperand* right() { return inputs_[1]; }
1385 Token::Value op() const { return hydrogen()->op(); }
1386 bool IsInteger32() const {
1387 return hydrogen()->representation().IsInteger32();
1390 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1391 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1395 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1397 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1398 : op_(op), can_deopt_(can_deopt) {
1403 Token::Value op() const { return op_; }
1404 LOperand* left() { return inputs_[0]; }
1405 LOperand* right() { return inputs_[1]; }
1406 bool can_deopt() const { return can_deopt_; }
1408 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1416 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1418 LSubI(LOperand* left, LOperand* right) {
1423 LOperand* left() { return inputs_[0]; }
1424 LOperand* right() { return inputs_[1]; }
1426 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1427 DECLARE_HYDROGEN_ACCESSOR(Sub)
1431 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1433 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1434 DECLARE_HYDROGEN_ACCESSOR(Constant)
1436 int32_t value() const { return hydrogen()->Integer32Value(); }
1440 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1442 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1443 DECLARE_HYDROGEN_ACCESSOR(Constant)
1445 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1449 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1451 explicit LConstantD(LOperand* temp) {
1455 LOperand* temp() { return temps_[0]; }
1457 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1458 DECLARE_HYDROGEN_ACCESSOR(Constant)
1460 double value() const { return hydrogen()->DoubleValue(); }
1464 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1466 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1467 DECLARE_HYDROGEN_ACCESSOR(Constant)
1469 ExternalReference value() const {
1470 return hydrogen()->ExternalReferenceValue();
1475 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1477 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1478 DECLARE_HYDROGEN_ACCESSOR(Constant)
1480 Handle<Object> value(Isolate* isolate) const {
1481 return hydrogen()->handle(isolate);
1486 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1488 explicit LBranch(LOperand* value) {
1492 LOperand* value() { return inputs_[0]; }
1494 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1495 DECLARE_HYDROGEN_ACCESSOR(Branch)
1497 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1501 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1503 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1507 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1509 explicit LCmpMapAndBranch(LOperand* value) {
1513 LOperand* value() { return inputs_[0]; }
1515 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1516 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1518 Handle<Map> map() const { return hydrogen()->map().handle(); }
1522 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1524 explicit LMapEnumLength(LOperand* value) {
1528 LOperand* value() { return inputs_[0]; }
1530 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1534 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1536 LDateField(LOperand* date, Smi* index) : index_(index) {
1540 LOperand* date() { return inputs_[0]; }
1541 Smi* index() const { return index_; }
1543 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1544 DECLARE_HYDROGEN_ACCESSOR(DateField)
1551 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1553 LSeqStringGetChar(LOperand* string, LOperand* index) {
1554 inputs_[0] = string;
1558 LOperand* string() const { return inputs_[0]; }
1559 LOperand* index() const { return inputs_[1]; }
1561 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1562 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1566 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1568 LSeqStringSetChar(LOperand* context,
1572 inputs_[0] = context;
1573 inputs_[1] = string;
1578 LOperand* string() { return inputs_[1]; }
1579 LOperand* index() { return inputs_[2]; }
1580 LOperand* value() { return inputs_[3]; }
1582 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1583 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1587 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1589 LAddI(LOperand* left, LOperand* right) {
1594 LOperand* left() { return inputs_[0]; }
1595 LOperand* right() { return inputs_[1]; }
1597 static bool UseLea(HAdd* add) {
1598 return !add->CheckFlag(HValue::kCanOverflow) &&
1599 add->BetterLeftOperand()->UseCount() > 1;
1602 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1603 DECLARE_HYDROGEN_ACCESSOR(Add)
1607 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1609 LMathMinMax(LOperand* left, LOperand* right) {
1614 LOperand* left() { return inputs_[0]; }
1615 LOperand* right() { return inputs_[1]; }
1617 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1618 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1622 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1624 LPower(LOperand* left, LOperand* right) {
1629 LOperand* left() { return inputs_[0]; }
1630 LOperand* right() { return inputs_[1]; }
1632 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1633 DECLARE_HYDROGEN_ACCESSOR(Power)
1637 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1639 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1645 Token::Value op() const { return op_; }
1646 LOperand* left() { return inputs_[0]; }
1647 LOperand* right() { return inputs_[1]; }
1649 virtual Opcode opcode() const V8_OVERRIDE {
1650 return LInstruction::kArithmeticD;
1652 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1653 virtual const char* Mnemonic() const V8_OVERRIDE;
1660 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1662 LArithmeticT(Token::Value op,
1667 inputs_[0] = context;
1672 Token::Value op() const { return op_; }
1673 LOperand* context() { return inputs_[0]; }
1674 LOperand* left() { return inputs_[1]; }
1675 LOperand* right() { return inputs_[2]; }
1677 virtual Opcode opcode() const V8_OVERRIDE {
1678 return LInstruction::kArithmeticT;
1680 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1681 virtual const char* Mnemonic() const V8_OVERRIDE;
1688 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1690 explicit LReturn(LOperand* value,
1692 LOperand* parameter_count) {
1694 inputs_[1] = context;
1695 inputs_[2] = parameter_count;
1698 LOperand* value() { return inputs_[0]; }
1699 LOperand* context() { return inputs_[1]; }
1701 bool has_constant_parameter_count() {
1702 return parameter_count()->IsConstantOperand();
1704 LConstantOperand* constant_parameter_count() {
1705 ASSERT(has_constant_parameter_count());
1706 return LConstantOperand::cast(parameter_count());
1708 LOperand* parameter_count() { return inputs_[2]; }
1710 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1711 DECLARE_HYDROGEN_ACCESSOR(Return)
1715 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1717 explicit LLoadNamedField(LOperand* object) {
1718 inputs_[0] = object;
1721 LOperand* object() { return inputs_[0]; }
1723 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1724 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1728 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1730 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1731 inputs_[0] = context;
1732 inputs_[1] = object;
1735 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1736 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1738 LOperand* context() { return inputs_[0]; }
1739 LOperand* object() { return inputs_[1]; }
1740 Handle<Object> name() const { return hydrogen()->name(); }
1744 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1746 explicit LLoadFunctionPrototype(LOperand* function) {
1747 inputs_[0] = function;
1750 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1751 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1753 LOperand* function() { return inputs_[0]; }
1757 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1759 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1760 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1762 Heap::RootListIndex index() const { return hydrogen()->index(); }
1766 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1768 LLoadKeyed(LOperand* elements, LOperand* key) {
1769 inputs_[0] = elements;
1773 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1774 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1776 bool is_external() const {
1777 return hydrogen()->is_external();
1779 bool is_fixed_typed_array() const {
1780 return hydrogen()->is_fixed_typed_array();
1782 bool is_typed_elements() const {
1783 return is_external() || is_fixed_typed_array();
1785 LOperand* elements() { return inputs_[0]; }
1786 LOperand* key() { return inputs_[1]; }
1787 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1788 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1789 ElementsKind elements_kind() const {
1790 return hydrogen()->elements_kind();
1795 inline static bool ExternalArrayOpRequiresPreScale(ElementsKind kind) {
1796 return ElementsKindToShiftSize(kind) > static_cast<int>(maximal_scale_factor);
1800 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1802 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1803 inputs_[0] = context;
1808 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1810 LOperand* context() { return inputs_[0]; }
1811 LOperand* object() { return inputs_[1]; }
1812 LOperand* key() { return inputs_[2]; }
1816 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1818 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1819 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1823 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1825 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1826 inputs_[0] = context;
1827 inputs_[1] = global_object;
1830 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1831 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1833 LOperand* context() { return inputs_[0]; }
1834 LOperand* global_object() { return inputs_[1]; }
1835 Handle<Object> name() const { return hydrogen()->name(); }
1836 bool for_typeof() const { return hydrogen()->for_typeof(); }
1840 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1842 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1847 LOperand* value() { return inputs_[0]; }
1848 LOperand* temp() { return temps_[0]; }
1850 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1851 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1855 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1857 explicit LLoadContextSlot(LOperand* context) {
1858 inputs_[0] = context;
1861 LOperand* context() { return inputs_[0]; }
1863 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1864 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1866 int slot_index() { return hydrogen()->slot_index(); }
1868 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1872 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1874 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1875 inputs_[0] = context;
1880 LOperand* context() { return inputs_[0]; }
1881 LOperand* value() { return inputs_[1]; }
1882 LOperand* temp() { return temps_[0]; }
1884 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1885 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1887 int slot_index() { return hydrogen()->slot_index(); }
1889 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1893 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1895 explicit LPushArgument(LOperand* value) {
1899 LOperand* value() { return inputs_[0]; }
1901 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1905 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1907 explicit LDrop(int count) : count_(count) { }
1909 int count() const { return count_; }
1911 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1918 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1920 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1921 inputs_[0] = function;
1922 temps_[0] = code_object;
1925 LOperand* function() { return inputs_[0]; }
1926 LOperand* code_object() { return temps_[0]; }
1928 virtual void PrintDataTo(StringStream* stream);
1930 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1931 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1935 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1937 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1938 inputs_[0] = base_object;
1939 inputs_[1] = offset;
1942 LOperand* base_object() const { return inputs_[0]; }
1943 LOperand* offset() const { return inputs_[1]; }
1945 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1947 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1951 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1953 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1954 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1958 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1960 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1961 DECLARE_HYDROGEN_ACCESSOR(Context)
1965 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1967 explicit LDeclareGlobals(LOperand* context) {
1968 inputs_[0] = context;
1971 LOperand* context() { return inputs_[0]; }
1973 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1974 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1978 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1980 explicit LCallJSFunction(LOperand* function) {
1981 inputs_[0] = function;
1984 LOperand* function() { return inputs_[0]; }
1986 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1987 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1989 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1991 int arity() const { return hydrogen()->argument_count() - 1; }
1995 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1997 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1998 ZoneList<LOperand*>& operands,
2000 : inputs_(descriptor->environment_length() + 1, zone) {
2001 ASSERT(descriptor->environment_length() + 1 == operands.length());
2002 inputs_.AddAll(operands, zone);
2005 LOperand* target() const { return inputs_[0]; }
2008 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2009 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2011 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2013 int arity() const { return hydrogen()->argument_count() - 1; }
2015 ZoneList<LOperand*> inputs_;
2017 // Iterator support.
2018 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2019 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2021 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2022 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2026 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2028 LInvokeFunction(LOperand* context, LOperand* function) {
2029 inputs_[0] = context;
2030 inputs_[1] = function;
2033 LOperand* context() { return inputs_[0]; }
2034 LOperand* function() { return inputs_[1]; }
2036 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2037 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2039 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2041 int arity() const { return hydrogen()->argument_count() - 1; }
2045 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2047 LCallFunction(LOperand* context, LOperand* function) {
2048 inputs_[0] = context;
2049 inputs_[1] = function;
2052 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2053 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2055 LOperand* context() { return inputs_[0]; }
2056 LOperand* function() { return inputs_[1]; }
2057 int arity() const { return hydrogen()->argument_count() - 1; }
2061 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2063 LCallNew(LOperand* context, LOperand* constructor) {
2064 inputs_[0] = context;
2065 inputs_[1] = constructor;
2068 LOperand* context() { return inputs_[0]; }
2069 LOperand* constructor() { return inputs_[1]; }
2071 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2072 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2074 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2076 int arity() const { return hydrogen()->argument_count() - 1; }
2080 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2082 LCallNewArray(LOperand* context, LOperand* constructor) {
2083 inputs_[0] = context;
2084 inputs_[1] = constructor;
2087 LOperand* context() { return inputs_[0]; }
2088 LOperand* constructor() { return inputs_[1]; }
2090 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2091 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2093 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2095 int arity() const { return hydrogen()->argument_count() - 1; }
2099 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2101 explicit LCallRuntime(LOperand* context) {
2102 inputs_[0] = context;
2105 LOperand* context() { return inputs_[0]; }
2107 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2108 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2110 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
2111 return save_doubles() == kDontSaveFPRegs;
2114 const Runtime::Function* function() const { return hydrogen()->function(); }
2115 int arity() const { return hydrogen()->argument_count(); }
2116 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2120 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2122 explicit LInteger32ToDouble(LOperand* value) {
2126 LOperand* value() { return inputs_[0]; }
2128 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2132 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2134 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
2139 LOperand* value() { return inputs_[0]; }
2140 LOperand* temp() { return temps_[0]; }
2142 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2146 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2148 explicit LNumberTagI(LOperand* value) {
2152 LOperand* value() { return inputs_[0]; }
2154 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2158 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2160 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2166 LOperand* value() { return inputs_[0]; }
2167 LOperand* temp1() { return temps_[0]; }
2168 LOperand* temp2() { return temps_[1]; }
2170 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2174 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2176 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2181 LOperand* value() { return inputs_[0]; }
2182 LOperand* temp() { return temps_[0]; }
2184 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2185 DECLARE_HYDROGEN_ACCESSOR(Change)
2189 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2191 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp) {
2196 LOperand* value() { return inputs_[0]; }
2197 LOperand* temp() { return temps_[0]; }
2199 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2200 DECLARE_HYDROGEN_ACCESSOR(Change)
2204 // Sometimes truncating conversion from a tagged value to an int32.
2205 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2207 explicit LDoubleToI(LOperand* value) {
2211 LOperand* value() { return inputs_[0]; }
2213 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2214 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2216 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2220 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2222 explicit LDoubleToSmi(LOperand* value) {
2226 LOperand* value() { return inputs_[0]; }
2228 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2229 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2233 // Truncating conversion from a tagged value to an int32.
2234 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2236 LTaggedToI(LOperand* value, LOperand* temp) {
2241 LOperand* value() { return inputs_[0]; }
2242 LOperand* temp() { return temps_[0]; }
2244 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2245 DECLARE_HYDROGEN_ACCESSOR(Change)
2247 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2251 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2253 explicit LSmiTag(LOperand* value) {
2257 LOperand* value() { return inputs_[0]; }
2259 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2260 DECLARE_HYDROGEN_ACCESSOR(Change)
2264 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2266 explicit LNumberUntagD(LOperand* value) {
2270 LOperand* value() { return inputs_[0]; }
2272 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2273 DECLARE_HYDROGEN_ACCESSOR(Change);
2277 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2279 explicit LTaggedToSIMD128(LOperand* value, Representation representation)
2280 : representation_(representation) {
2284 LOperand* value() { return inputs_[0]; }
2285 Representation representation() const { return representation_; }
2287 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2288 DECLARE_HYDROGEN_ACCESSOR(Change);
2290 Representation representation_;
2294 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2296 LSmiUntag(LOperand* value, bool needs_check)
2297 : needs_check_(needs_check) {
2301 LOperand* value() { return inputs_[0]; }
2302 bool needs_check() const { return needs_check_; }
2304 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2311 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2313 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2314 inputs_[0] = object;
2319 LOperand* object() { return inputs_[0]; }
2320 LOperand* value() { return inputs_[1]; }
2321 LOperand* temp() { return temps_[0]; }
2323 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2324 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2326 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2328 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2329 Representation representation() const {
2330 return hydrogen()->field_representation();
2335 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2337 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2338 inputs_[0] = context;
2339 inputs_[1] = object;
2343 LOperand* context() { return inputs_[0]; }
2344 LOperand* object() { return inputs_[1]; }
2345 LOperand* value() { return inputs_[2]; }
2347 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2348 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2350 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2352 Handle<Object> name() const { return hydrogen()->name(); }
2353 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2357 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2359 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2360 inputs_[0] = object;
2365 bool is_external() const { return hydrogen()->is_external(); }
2366 bool is_fixed_typed_array() const {
2367 return hydrogen()->is_fixed_typed_array();
2369 bool is_typed_elements() const {
2370 return is_external() || is_fixed_typed_array();
2372 LOperand* elements() { return inputs_[0]; }
2373 LOperand* key() { return inputs_[1]; }
2374 LOperand* value() { return inputs_[2]; }
2375 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2377 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2378 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2380 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2381 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2382 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2386 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2388 LStoreKeyedGeneric(LOperand* context,
2392 inputs_[0] = context;
2393 inputs_[1] = object;
2398 LOperand* context() { return inputs_[0]; }
2399 LOperand* object() { return inputs_[1]; }
2400 LOperand* key() { return inputs_[2]; }
2401 LOperand* value() { return inputs_[3]; }
2403 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2404 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2406 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2408 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2412 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2414 LTransitionElementsKind(LOperand* object,
2416 LOperand* new_map_temp,
2418 inputs_[0] = object;
2419 inputs_[1] = context;
2420 temps_[0] = new_map_temp;
2424 LOperand* object() { return inputs_[0]; }
2425 LOperand* context() { return inputs_[1]; }
2426 LOperand* new_map_temp() { return temps_[0]; }
2427 LOperand* temp() { return temps_[1]; }
2429 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2430 "transition-elements-kind")
2431 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2433 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2435 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2436 Handle<Map> transitioned_map() {
2437 return hydrogen()->transitioned_map().handle();
2439 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2440 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2444 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2446 LTrapAllocationMemento(LOperand* object,
2448 inputs_[0] = object;
2452 LOperand* object() { return inputs_[0]; }
2453 LOperand* temp() { return temps_[0]; }
2455 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2456 "trap-allocation-memento")
2460 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2462 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2463 inputs_[0] = context;
2468 LOperand* context() { return inputs_[0]; }
2469 LOperand* left() { return inputs_[1]; }
2470 LOperand* right() { return inputs_[2]; }
2472 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2473 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2477 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2479 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2480 inputs_[0] = context;
2481 inputs_[1] = string;
2485 LOperand* context() { return inputs_[0]; }
2486 LOperand* string() { return inputs_[1]; }
2487 LOperand* index() { return inputs_[2]; }
2489 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2490 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2494 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2496 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2497 inputs_[0] = context;
2498 inputs_[1] = char_code;
2501 LOperand* context() { return inputs_[0]; }
2502 LOperand* char_code() { return inputs_[1]; }
2504 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2505 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2509 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2511 explicit LCheckValue(LOperand* value) {
2515 LOperand* value() { return inputs_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2518 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2522 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2524 explicit LCheckInstanceType(LOperand* value) {
2528 LOperand* value() { return inputs_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2531 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2535 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2537 explicit LCheckMaps(LOperand* value) {
2541 LOperand* value() { return inputs_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2544 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2548 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2550 explicit LCheckSmi(LOperand* value) {
2554 LOperand* value() { return inputs_[0]; }
2556 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2560 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2562 explicit LClampDToUint8(LOperand* unclamped) {
2563 inputs_[0] = unclamped;
2566 LOperand* unclamped() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2572 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2574 explicit LClampIToUint8(LOperand* unclamped) {
2575 inputs_[0] = unclamped;
2578 LOperand* unclamped() { return inputs_[0]; }
2580 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2584 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2586 LClampTToUint8(LOperand* unclamped,
2587 LOperand* temp_xmm) {
2588 inputs_[0] = unclamped;
2589 temps_[0] = temp_xmm;
2592 LOperand* unclamped() { return inputs_[0]; }
2593 LOperand* temp_xmm() { return temps_[0]; }
2595 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2599 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2601 explicit LCheckNonSmi(LOperand* value) {
2605 LOperand* value() { return inputs_[0]; }
2607 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2608 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2612 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2614 explicit LDoubleBits(LOperand* value) {
2618 LOperand* value() { return inputs_[0]; }
2620 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2621 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2625 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2627 LConstructDouble(LOperand* hi, LOperand* lo) {
2632 LOperand* hi() { return inputs_[0]; }
2633 LOperand* lo() { return inputs_[1]; }
2635 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2639 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2641 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2642 inputs_[0] = context;
2647 LOperand* context() { return inputs_[0]; }
2648 LOperand* size() { return inputs_[1]; }
2649 LOperand* temp() { return temps_[0]; }
2651 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2652 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2656 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2658 explicit LRegExpLiteral(LOperand* context) {
2659 inputs_[0] = context;
2662 LOperand* context() { return inputs_[0]; }
2664 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2665 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2669 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2671 explicit LFunctionLiteral(LOperand* context) {
2672 inputs_[0] = context;
2675 LOperand* context() { return inputs_[0]; }
2677 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2678 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2682 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2684 explicit LToFastProperties(LOperand* value) {
2688 LOperand* value() { return inputs_[0]; }
2690 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2691 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2695 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2697 LTypeof(LOperand* context, LOperand* value) {
2698 inputs_[0] = context;
2702 LOperand* context() { return inputs_[0]; }
2703 LOperand* value() { return inputs_[1]; }
2705 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2709 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2711 explicit LTypeofIsAndBranch(LOperand* value) {
2715 LOperand* value() { return inputs_[0]; }
2717 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2718 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2720 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2722 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2726 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2728 explicit LIsConstructCallAndBranch(LOperand* temp) {
2732 LOperand* temp() { return temps_[0]; }
2734 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2735 "is-construct-call-and-branch")
2736 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2740 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2744 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2747 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2751 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2753 explicit LStackCheck(LOperand* context) {
2754 inputs_[0] = context;
2757 LOperand* context() { return inputs_[0]; }
2759 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2760 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2762 Label* done_label() { return &done_label_; }
2769 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2771 LForInPrepareMap(LOperand* context, LOperand* object) {
2772 inputs_[0] = context;
2773 inputs_[1] = object;
2776 LOperand* context() { return inputs_[0]; }
2777 LOperand* object() { return inputs_[1]; }
2779 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2783 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2785 explicit LForInCacheArray(LOperand* map) {
2789 LOperand* map() { return inputs_[0]; }
2791 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2794 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2799 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2801 LCheckMapValue(LOperand* value, LOperand* map) {
2806 LOperand* value() { return inputs_[0]; }
2807 LOperand* map() { return inputs_[1]; }
2809 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2813 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2815 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2816 inputs_[0] = object;
2820 LOperand* object() { return inputs_[0]; }
2821 LOperand* index() { return inputs_[1]; }
2823 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2827 class LChunkBuilder;
2828 class LPlatformChunk V8_FINAL : public LChunk {
2830 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2831 : LChunk(info, graph),
2832 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2834 int GetNextSpillIndex(RegisterKind kind);
2835 LOperand* GetNextSpillSlot(RegisterKind kind);
2836 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2837 bool IsDehoistedKey(HValue* value) {
2838 return dehoisted_key_ids_.Contains(value->id());
2842 BitVector dehoisted_key_ids_;
2846 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2848 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2849 : LChunkBuilderBase(graph->zone()),
2854 current_instruction_(NULL),
2855 current_block_(NULL),
2857 allocator_(allocator) { }
2859 // Build the sequence for the graph.
2860 LPlatformChunk* Build();
2862 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2864 // Declare methods that deal with the individual node types.
2865 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2866 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2869 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2870 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2871 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2872 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2873 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2874 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2875 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2876 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2877 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2878 LInstruction* DoDivByConstI(HDiv* instr);
2879 LInstruction* DoDivI(HBinaryOperation* instr);
2880 LInstruction* DoModByPowerOf2I(HMod* instr);
2881 LInstruction* DoModByConstI(HMod* instr);
2882 LInstruction* DoModI(HMod* instr);
2883 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2884 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2894 LPlatformChunk* chunk() const { return chunk_; }
2895 CompilationInfo* info() const { return info_; }
2896 HGraph* graph() const { return graph_; }
2898 bool is_unused() const { return status_ == UNUSED; }
2899 bool is_building() const { return status_ == BUILDING; }
2900 bool is_done() const { return status_ == DONE; }
2901 bool is_aborted() const { return status_ == ABORTED; }
2903 void Abort(BailoutReason reason);
2905 // Methods for getting operands for Use / Define / Temp.
2906 LUnallocated* ToUnallocated(Register reg);
2907 LUnallocated* ToUnallocated(XMMRegister reg);
2909 // Methods for setting up define-use relationships.
2910 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2911 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2912 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2913 XMMRegister fixed_register);
2915 // A value that is guaranteed to be allocated to a register.
2916 // Operand created by UseRegister is guaranteed to be live until the end of
2917 // instruction. This means that register allocator will not reuse it's
2918 // register for any other operand inside instruction.
2919 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2920 // instruction start. Register allocator is free to assign the same register
2921 // to some other operand used inside instruction (i.e. temporary or
2923 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2924 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2926 // An input operand in a register that may be trashed.
2927 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2929 // An input operand in a register that may be trashed or a constant operand.
2930 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2932 // An input operand in a register or stack slot.
2933 MUST_USE_RESULT LOperand* Use(HValue* value);
2934 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2936 // An input operand in a register, stack slot or a constant operand.
2937 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2938 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2940 // An input operand in a register or a constant operand.
2941 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2942 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2944 // An input operand in a constant operand.
2945 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2947 // An input operand in register, stack slot or a constant operand.
2948 // Will not be moved to a register even if one is freely available.
2949 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2951 // Temporary operand that must be in a register.
2952 MUST_USE_RESULT LUnallocated* TempRegister();
2953 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2954 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2956 // Methods for setting up define-use relationships.
2957 // Return the same instruction that they are passed.
2958 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2959 LUnallocated* result);
2960 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2961 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2963 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2964 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2966 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2968 // Assigns an environment to an instruction. An instruction which can
2969 // deoptimize must have an environment.
2970 LInstruction* AssignEnvironment(LInstruction* instr);
2971 // Assigns a pointer map to an instruction. An instruction which can
2972 // trigger a GC or a lazy deoptimization must have a pointer map.
2973 LInstruction* AssignPointerMap(LInstruction* instr);
2975 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2977 // Marks a call for the register allocator. Assigns a pointer map to
2978 // support GC and lazy deoptimization. Assigns an environment to support
2979 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2980 LInstruction* MarkAsCall(
2981 LInstruction* instr,
2982 HInstruction* hinstr,
2983 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2985 void VisitInstruction(HInstruction* current);
2987 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2988 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2989 LInstruction* DoArithmeticD(Token::Value op,
2990 HArithmeticBinaryOperation* instr);
2991 LInstruction* DoArithmeticT(Token::Value op,
2992 HBinaryOperation* instr);
2993 void FindDehoistedKeyDefinitions(HValue* candidate);
2995 LPlatformChunk* chunk_;
2996 CompilationInfo* info_;
2997 HGraph* const graph_;
2999 HInstruction* current_instruction_;
3000 HBasicBlock* current_block_;
3001 HBasicBlock* next_block_;
3002 LAllocator* allocator_;
3004 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3007 #undef DECLARE_HYDROGEN_ACCESSOR
3008 #undef DECLARE_CONCRETE_INSTRUCTION
3010 } } // namespace v8::int
3012 #endif // V8_X64_LITHIUM_X64_H_