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(); }
1387 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1388 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1392 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1394 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1395 : op_(op), can_deopt_(can_deopt) {
1400 Token::Value op() const { return op_; }
1401 LOperand* left() { return inputs_[0]; }
1402 LOperand* right() { return inputs_[1]; }
1403 bool can_deopt() const { return can_deopt_; }
1405 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1413 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1415 LSubI(LOperand* left, LOperand* right) {
1420 LOperand* left() { return inputs_[0]; }
1421 LOperand* right() { return inputs_[1]; }
1423 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1424 DECLARE_HYDROGEN_ACCESSOR(Sub)
1428 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1430 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1431 DECLARE_HYDROGEN_ACCESSOR(Constant)
1433 int32_t value() const { return hydrogen()->Integer32Value(); }
1437 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1439 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1440 DECLARE_HYDROGEN_ACCESSOR(Constant)
1442 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1446 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1448 explicit LConstantD(LOperand* temp) {
1452 LOperand* temp() { return temps_[0]; }
1454 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1455 DECLARE_HYDROGEN_ACCESSOR(Constant)
1457 double value() const { return hydrogen()->DoubleValue(); }
1461 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1463 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1464 DECLARE_HYDROGEN_ACCESSOR(Constant)
1466 ExternalReference value() const {
1467 return hydrogen()->ExternalReferenceValue();
1472 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1474 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1475 DECLARE_HYDROGEN_ACCESSOR(Constant)
1477 Handle<Object> value(Isolate* isolate) const {
1478 return hydrogen()->handle(isolate);
1483 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1485 explicit LBranch(LOperand* value) {
1489 LOperand* value() { return inputs_[0]; }
1491 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1492 DECLARE_HYDROGEN_ACCESSOR(Branch)
1494 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1498 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1500 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1504 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1506 explicit LCmpMapAndBranch(LOperand* value) {
1510 LOperand* value() { return inputs_[0]; }
1512 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1513 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1515 Handle<Map> map() const { return hydrogen()->map().handle(); }
1519 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1521 explicit LMapEnumLength(LOperand* value) {
1525 LOperand* value() { return inputs_[0]; }
1527 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1531 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1533 LDateField(LOperand* date, Smi* index) : index_(index) {
1537 LOperand* date() { return inputs_[0]; }
1538 Smi* index() const { return index_; }
1540 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1541 DECLARE_HYDROGEN_ACCESSOR(DateField)
1548 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1550 LSeqStringGetChar(LOperand* string, LOperand* index) {
1551 inputs_[0] = string;
1555 LOperand* string() const { return inputs_[0]; }
1556 LOperand* index() const { return inputs_[1]; }
1558 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1559 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1563 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1565 LSeqStringSetChar(LOperand* context,
1569 inputs_[0] = context;
1570 inputs_[1] = string;
1575 LOperand* string() { return inputs_[1]; }
1576 LOperand* index() { return inputs_[2]; }
1577 LOperand* value() { return inputs_[3]; }
1579 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1580 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1584 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1586 LAddI(LOperand* left, LOperand* right) {
1591 LOperand* left() { return inputs_[0]; }
1592 LOperand* right() { return inputs_[1]; }
1594 static bool UseLea(HAdd* add) {
1595 return !add->CheckFlag(HValue::kCanOverflow) &&
1596 add->BetterLeftOperand()->UseCount() > 1;
1599 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1600 DECLARE_HYDROGEN_ACCESSOR(Add)
1604 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1606 LMathMinMax(LOperand* left, LOperand* right) {
1611 LOperand* left() { return inputs_[0]; }
1612 LOperand* right() { return inputs_[1]; }
1614 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1615 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1619 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1621 LPower(LOperand* left, LOperand* right) {
1626 LOperand* left() { return inputs_[0]; }
1627 LOperand* right() { return inputs_[1]; }
1629 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1630 DECLARE_HYDROGEN_ACCESSOR(Power)
1634 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1636 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1642 Token::Value op() const { return op_; }
1643 LOperand* left() { return inputs_[0]; }
1644 LOperand* right() { return inputs_[1]; }
1646 virtual Opcode opcode() const V8_OVERRIDE {
1647 return LInstruction::kArithmeticD;
1649 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1650 virtual const char* Mnemonic() const V8_OVERRIDE;
1657 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1659 LArithmeticT(Token::Value op,
1664 inputs_[0] = context;
1669 Token::Value op() const { return op_; }
1670 LOperand* context() { return inputs_[0]; }
1671 LOperand* left() { return inputs_[1]; }
1672 LOperand* right() { return inputs_[2]; }
1674 virtual Opcode opcode() const V8_OVERRIDE {
1675 return LInstruction::kArithmeticT;
1677 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1678 virtual const char* Mnemonic() const V8_OVERRIDE;
1685 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1687 explicit LReturn(LOperand* value,
1689 LOperand* parameter_count) {
1691 inputs_[1] = context;
1692 inputs_[2] = parameter_count;
1695 LOperand* value() { return inputs_[0]; }
1696 LOperand* context() { return inputs_[1]; }
1698 bool has_constant_parameter_count() {
1699 return parameter_count()->IsConstantOperand();
1701 LConstantOperand* constant_parameter_count() {
1702 ASSERT(has_constant_parameter_count());
1703 return LConstantOperand::cast(parameter_count());
1705 LOperand* parameter_count() { return inputs_[2]; }
1707 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1708 DECLARE_HYDROGEN_ACCESSOR(Return)
1712 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1714 explicit LLoadNamedField(LOperand* object) {
1715 inputs_[0] = object;
1718 LOperand* object() { return inputs_[0]; }
1720 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1721 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1725 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1727 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1728 inputs_[0] = context;
1729 inputs_[1] = object;
1732 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1733 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1735 LOperand* context() { return inputs_[0]; }
1736 LOperand* object() { return inputs_[1]; }
1737 Handle<Object> name() const { return hydrogen()->name(); }
1741 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1743 explicit LLoadFunctionPrototype(LOperand* function) {
1744 inputs_[0] = function;
1747 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1748 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1750 LOperand* function() { return inputs_[0]; }
1754 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1756 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1757 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1759 Heap::RootListIndex index() const { return hydrogen()->index(); }
1763 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1765 LLoadKeyed(LOperand* elements, LOperand* key) {
1766 inputs_[0] = elements;
1770 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1771 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1773 bool is_external() const {
1774 return hydrogen()->is_external();
1776 bool is_fixed_typed_array() const {
1777 return hydrogen()->is_fixed_typed_array();
1779 bool is_typed_elements() const {
1780 return is_external() || is_fixed_typed_array();
1782 LOperand* elements() { return inputs_[0]; }
1783 LOperand* key() { return inputs_[1]; }
1784 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1785 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1786 ElementsKind elements_kind() const {
1787 return hydrogen()->elements_kind();
1792 inline static bool ExternalArrayOpRequiresPreScale(ElementsKind kind) {
1793 return ElementsKindToShiftSize(kind) > static_cast<int>(maximal_scale_factor);
1797 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1799 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1800 inputs_[0] = context;
1805 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1807 LOperand* context() { return inputs_[0]; }
1808 LOperand* object() { return inputs_[1]; }
1809 LOperand* key() { return inputs_[2]; }
1813 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1815 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1816 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1820 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1822 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1823 inputs_[0] = context;
1824 inputs_[1] = global_object;
1827 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1828 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1830 LOperand* context() { return inputs_[0]; }
1831 LOperand* global_object() { return inputs_[1]; }
1832 Handle<Object> name() const { return hydrogen()->name(); }
1833 bool for_typeof() const { return hydrogen()->for_typeof(); }
1837 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1839 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1844 LOperand* value() { return inputs_[0]; }
1845 LOperand* temp() { return temps_[0]; }
1847 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1848 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1852 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1854 explicit LLoadContextSlot(LOperand* context) {
1855 inputs_[0] = context;
1858 LOperand* context() { return inputs_[0]; }
1860 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1861 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1863 int slot_index() { return hydrogen()->slot_index(); }
1865 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1869 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1871 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1872 inputs_[0] = context;
1877 LOperand* context() { return inputs_[0]; }
1878 LOperand* value() { return inputs_[1]; }
1879 LOperand* temp() { return temps_[0]; }
1881 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1882 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1884 int slot_index() { return hydrogen()->slot_index(); }
1886 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1890 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1892 explicit LPushArgument(LOperand* value) {
1896 LOperand* value() { return inputs_[0]; }
1898 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1902 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1904 explicit LDrop(int count) : count_(count) { }
1906 int count() const { return count_; }
1908 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1915 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1917 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1918 inputs_[0] = function;
1919 temps_[0] = code_object;
1922 LOperand* function() { return inputs_[0]; }
1923 LOperand* code_object() { return temps_[0]; }
1925 virtual void PrintDataTo(StringStream* stream);
1927 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1928 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1932 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1934 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1935 inputs_[0] = base_object;
1936 inputs_[1] = offset;
1939 LOperand* base_object() const { return inputs_[0]; }
1940 LOperand* offset() const { return inputs_[1]; }
1942 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1944 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1948 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1950 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1951 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1955 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1957 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1958 DECLARE_HYDROGEN_ACCESSOR(Context)
1962 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1964 explicit LDeclareGlobals(LOperand* context) {
1965 inputs_[0] = context;
1968 LOperand* context() { return inputs_[0]; }
1970 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1971 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1975 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1977 explicit LCallJSFunction(LOperand* function) {
1978 inputs_[0] = function;
1981 LOperand* function() { return inputs_[0]; }
1983 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1984 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1986 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1988 int arity() const { return hydrogen()->argument_count() - 1; }
1992 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1994 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1995 ZoneList<LOperand*>& operands,
1997 : inputs_(descriptor->environment_length() + 1, zone) {
1998 ASSERT(descriptor->environment_length() + 1 == operands.length());
1999 inputs_.AddAll(operands, zone);
2002 LOperand* target() const { return inputs_[0]; }
2005 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
2006 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
2008 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2010 int arity() const { return hydrogen()->argument_count() - 1; }
2012 ZoneList<LOperand*> inputs_;
2014 // Iterator support.
2015 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
2016 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
2018 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
2019 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
2023 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2025 LInvokeFunction(LOperand* context, LOperand* function) {
2026 inputs_[0] = context;
2027 inputs_[1] = function;
2030 LOperand* context() { return inputs_[0]; }
2031 LOperand* function() { return inputs_[1]; }
2033 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
2034 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
2036 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2038 int arity() const { return hydrogen()->argument_count() - 1; }
2042 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2044 LCallFunction(LOperand* context, LOperand* function) {
2045 inputs_[0] = context;
2046 inputs_[1] = function;
2049 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
2050 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
2052 LOperand* context() { return inputs_[0]; }
2053 LOperand* function() { return inputs_[1]; }
2054 int arity() const { return hydrogen()->argument_count() - 1; }
2058 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2060 LCallNew(LOperand* context, LOperand* constructor) {
2061 inputs_[0] = context;
2062 inputs_[1] = constructor;
2065 LOperand* context() { return inputs_[0]; }
2066 LOperand* constructor() { return inputs_[1]; }
2068 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2069 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2071 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2073 int arity() const { return hydrogen()->argument_count() - 1; }
2077 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2079 LCallNewArray(LOperand* context, LOperand* constructor) {
2080 inputs_[0] = context;
2081 inputs_[1] = constructor;
2084 LOperand* context() { return inputs_[0]; }
2085 LOperand* constructor() { return inputs_[1]; }
2087 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2088 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2090 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2092 int arity() const { return hydrogen()->argument_count() - 1; }
2096 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2098 explicit LCallRuntime(LOperand* context) {
2099 inputs_[0] = context;
2102 LOperand* context() { return inputs_[0]; }
2104 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2105 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2107 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
2108 return save_doubles() == kDontSaveFPRegs;
2111 const Runtime::Function* function() const { return hydrogen()->function(); }
2112 int arity() const { return hydrogen()->argument_count(); }
2113 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2117 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2119 explicit LInteger32ToDouble(LOperand* value) {
2123 LOperand* value() { return inputs_[0]; }
2125 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2129 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2131 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
2136 LOperand* value() { return inputs_[0]; }
2137 LOperand* temp() { return temps_[0]; }
2139 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2143 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2145 explicit LNumberTagI(LOperand* value) {
2149 LOperand* value() { return inputs_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2155 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2157 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2163 LOperand* value() { return inputs_[0]; }
2164 LOperand* temp1() { return temps_[0]; }
2165 LOperand* temp2() { return temps_[1]; }
2167 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2171 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2173 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2178 LOperand* value() { return inputs_[0]; }
2179 LOperand* temp() { return temps_[0]; }
2181 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2182 DECLARE_HYDROGEN_ACCESSOR(Change)
2186 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2188 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp) {
2193 LOperand* value() { return inputs_[0]; }
2194 LOperand* temp() { return temps_[0]; }
2196 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2197 DECLARE_HYDROGEN_ACCESSOR(Change)
2201 // Sometimes truncating conversion from a tagged value to an int32.
2202 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2204 explicit LDoubleToI(LOperand* value) {
2208 LOperand* value() { return inputs_[0]; }
2210 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2211 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2213 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2217 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2219 explicit LDoubleToSmi(LOperand* value) {
2223 LOperand* value() { return inputs_[0]; }
2225 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2226 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2230 // Truncating conversion from a tagged value to an int32.
2231 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2233 LTaggedToI(LOperand* value, LOperand* temp) {
2238 LOperand* value() { return inputs_[0]; }
2239 LOperand* temp() { return temps_[0]; }
2241 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2242 DECLARE_HYDROGEN_ACCESSOR(Change)
2244 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2248 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2250 explicit LSmiTag(LOperand* value) {
2254 LOperand* value() { return inputs_[0]; }
2256 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2257 DECLARE_HYDROGEN_ACCESSOR(Change)
2261 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2263 explicit LNumberUntagD(LOperand* value) {
2267 LOperand* value() { return inputs_[0]; }
2269 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2270 DECLARE_HYDROGEN_ACCESSOR(Change);
2274 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2276 explicit LTaggedToSIMD128(LOperand* value, Representation representation)
2277 : representation_(representation) {
2281 LOperand* value() { return inputs_[0]; }
2282 Representation representation() const { return representation_; }
2284 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2285 DECLARE_HYDROGEN_ACCESSOR(Change);
2287 Representation representation_;
2291 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2293 LSmiUntag(LOperand* value, bool needs_check)
2294 : needs_check_(needs_check) {
2298 LOperand* value() { return inputs_[0]; }
2299 bool needs_check() const { return needs_check_; }
2301 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2308 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2310 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2311 inputs_[0] = object;
2316 LOperand* object() { return inputs_[0]; }
2317 LOperand* value() { return inputs_[1]; }
2318 LOperand* temp() { return temps_[0]; }
2320 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2321 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2323 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2325 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2326 Representation representation() const {
2327 return hydrogen()->field_representation();
2332 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2334 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2335 inputs_[0] = context;
2336 inputs_[1] = object;
2340 LOperand* context() { return inputs_[0]; }
2341 LOperand* object() { return inputs_[1]; }
2342 LOperand* value() { return inputs_[2]; }
2344 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2345 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2347 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2349 Handle<Object> name() const { return hydrogen()->name(); }
2350 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2354 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2356 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2357 inputs_[0] = object;
2362 bool is_external() const { return hydrogen()->is_external(); }
2363 bool is_fixed_typed_array() const {
2364 return hydrogen()->is_fixed_typed_array();
2366 bool is_typed_elements() const {
2367 return is_external() || is_fixed_typed_array();
2369 LOperand* elements() { return inputs_[0]; }
2370 LOperand* key() { return inputs_[1]; }
2371 LOperand* value() { return inputs_[2]; }
2372 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2374 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2375 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2377 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2378 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2379 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2383 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2385 LStoreKeyedGeneric(LOperand* context,
2389 inputs_[0] = context;
2390 inputs_[1] = object;
2395 LOperand* context() { return inputs_[0]; }
2396 LOperand* object() { return inputs_[1]; }
2397 LOperand* key() { return inputs_[2]; }
2398 LOperand* value() { return inputs_[3]; }
2400 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2401 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2403 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2405 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2409 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2411 LTransitionElementsKind(LOperand* object,
2413 LOperand* new_map_temp,
2415 inputs_[0] = object;
2416 inputs_[1] = context;
2417 temps_[0] = new_map_temp;
2421 LOperand* object() { return inputs_[0]; }
2422 LOperand* context() { return inputs_[1]; }
2423 LOperand* new_map_temp() { return temps_[0]; }
2424 LOperand* temp() { return temps_[1]; }
2426 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2427 "transition-elements-kind")
2428 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2430 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2432 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2433 Handle<Map> transitioned_map() {
2434 return hydrogen()->transitioned_map().handle();
2436 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2437 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2441 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2443 LTrapAllocationMemento(LOperand* object,
2445 inputs_[0] = object;
2449 LOperand* object() { return inputs_[0]; }
2450 LOperand* temp() { return temps_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2453 "trap-allocation-memento")
2457 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2459 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2460 inputs_[0] = context;
2465 LOperand* context() { return inputs_[0]; }
2466 LOperand* left() { return inputs_[1]; }
2467 LOperand* right() { return inputs_[2]; }
2469 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2470 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2474 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2476 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2477 inputs_[0] = context;
2478 inputs_[1] = string;
2482 LOperand* context() { return inputs_[0]; }
2483 LOperand* string() { return inputs_[1]; }
2484 LOperand* index() { return inputs_[2]; }
2486 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2487 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2491 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2493 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2494 inputs_[0] = context;
2495 inputs_[1] = char_code;
2498 LOperand* context() { return inputs_[0]; }
2499 LOperand* char_code() { return inputs_[1]; }
2501 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2502 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2506 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2508 explicit LCheckValue(LOperand* value) {
2512 LOperand* value() { return inputs_[0]; }
2514 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2515 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2519 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2521 explicit LCheckInstanceType(LOperand* value) {
2525 LOperand* value() { return inputs_[0]; }
2527 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2528 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2532 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2534 explicit LCheckMaps(LOperand* value) {
2538 LOperand* value() { return inputs_[0]; }
2540 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2541 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2545 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2547 explicit LCheckSmi(LOperand* value) {
2551 LOperand* value() { return inputs_[0]; }
2553 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2557 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2559 explicit LClampDToUint8(LOperand* unclamped) {
2560 inputs_[0] = unclamped;
2563 LOperand* unclamped() { return inputs_[0]; }
2565 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2569 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2571 explicit LClampIToUint8(LOperand* unclamped) {
2572 inputs_[0] = unclamped;
2575 LOperand* unclamped() { return inputs_[0]; }
2577 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2581 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2583 LClampTToUint8(LOperand* unclamped,
2584 LOperand* temp_xmm) {
2585 inputs_[0] = unclamped;
2586 temps_[0] = temp_xmm;
2589 LOperand* unclamped() { return inputs_[0]; }
2590 LOperand* temp_xmm() { return temps_[0]; }
2592 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2596 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2598 explicit LCheckNonSmi(LOperand* value) {
2602 LOperand* value() { return inputs_[0]; }
2604 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2605 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2609 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2611 explicit LDoubleBits(LOperand* value) {
2615 LOperand* value() { return inputs_[0]; }
2617 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2618 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2622 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2624 LConstructDouble(LOperand* hi, LOperand* lo) {
2629 LOperand* hi() { return inputs_[0]; }
2630 LOperand* lo() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2636 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2638 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2639 inputs_[0] = context;
2644 LOperand* context() { return inputs_[0]; }
2645 LOperand* size() { return inputs_[1]; }
2646 LOperand* temp() { return temps_[0]; }
2648 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2649 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2653 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2655 explicit LRegExpLiteral(LOperand* context) {
2656 inputs_[0] = context;
2659 LOperand* context() { return inputs_[0]; }
2661 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2662 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2666 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2668 explicit LFunctionLiteral(LOperand* context) {
2669 inputs_[0] = context;
2672 LOperand* context() { return inputs_[0]; }
2674 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2675 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2679 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2681 explicit LToFastProperties(LOperand* value) {
2685 LOperand* value() { return inputs_[0]; }
2687 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2688 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2692 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2694 LTypeof(LOperand* context, LOperand* value) {
2695 inputs_[0] = context;
2699 LOperand* context() { return inputs_[0]; }
2700 LOperand* value() { return inputs_[1]; }
2702 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2706 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2708 explicit LTypeofIsAndBranch(LOperand* value) {
2712 LOperand* value() { return inputs_[0]; }
2714 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2715 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2717 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2719 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2723 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2725 explicit LIsConstructCallAndBranch(LOperand* temp) {
2729 LOperand* temp() { return temps_[0]; }
2731 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2732 "is-construct-call-and-branch")
2733 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2737 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2741 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2744 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2748 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2750 explicit LStackCheck(LOperand* context) {
2751 inputs_[0] = context;
2754 LOperand* context() { return inputs_[0]; }
2756 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2757 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2759 Label* done_label() { return &done_label_; }
2766 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2768 LForInPrepareMap(LOperand* context, LOperand* object) {
2769 inputs_[0] = context;
2770 inputs_[1] = object;
2773 LOperand* context() { return inputs_[0]; }
2774 LOperand* object() { return inputs_[1]; }
2776 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2780 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2782 explicit LForInCacheArray(LOperand* map) {
2786 LOperand* map() { return inputs_[0]; }
2788 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2791 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2796 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2798 LCheckMapValue(LOperand* value, LOperand* map) {
2803 LOperand* value() { return inputs_[0]; }
2804 LOperand* map() { return inputs_[1]; }
2806 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2810 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2812 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2813 inputs_[0] = object;
2817 LOperand* object() { return inputs_[0]; }
2818 LOperand* index() { return inputs_[1]; }
2820 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2824 class LChunkBuilder;
2825 class LPlatformChunk V8_FINAL : public LChunk {
2827 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2828 : LChunk(info, graph),
2829 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2831 int GetNextSpillIndex(RegisterKind kind);
2832 LOperand* GetNextSpillSlot(RegisterKind kind);
2833 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2834 bool IsDehoistedKey(HValue* value) {
2835 return dehoisted_key_ids_.Contains(value->id());
2839 BitVector dehoisted_key_ids_;
2843 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2845 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2846 : LChunkBuilderBase(graph->zone()),
2851 current_instruction_(NULL),
2852 current_block_(NULL),
2854 allocator_(allocator) { }
2856 // Build the sequence for the graph.
2857 LPlatformChunk* Build();
2859 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2861 // Declare methods that deal with the individual node types.
2862 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2863 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2866 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2867 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2868 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2869 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2870 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2871 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2872 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2873 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2874 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2875 LInstruction* DoDivByConstI(HDiv* instr);
2876 LInstruction* DoDivI(HBinaryOperation* instr);
2877 LInstruction* DoModByPowerOf2I(HMod* instr);
2878 LInstruction* DoModByConstI(HMod* instr);
2879 LInstruction* DoModI(HMod* instr);
2880 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2881 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2891 LPlatformChunk* chunk() const { return chunk_; }
2892 CompilationInfo* info() const { return info_; }
2893 HGraph* graph() const { return graph_; }
2895 bool is_unused() const { return status_ == UNUSED; }
2896 bool is_building() const { return status_ == BUILDING; }
2897 bool is_done() const { return status_ == DONE; }
2898 bool is_aborted() const { return status_ == ABORTED; }
2900 void Abort(BailoutReason reason);
2902 // Methods for getting operands for Use / Define / Temp.
2903 LUnallocated* ToUnallocated(Register reg);
2904 LUnallocated* ToUnallocated(XMMRegister reg);
2906 // Methods for setting up define-use relationships.
2907 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2908 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2909 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2910 XMMRegister fixed_register);
2912 // A value that is guaranteed to be allocated to a register.
2913 // Operand created by UseRegister is guaranteed to be live until the end of
2914 // instruction. This means that register allocator will not reuse it's
2915 // register for any other operand inside instruction.
2916 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2917 // instruction start. Register allocator is free to assign the same register
2918 // to some other operand used inside instruction (i.e. temporary or
2920 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2921 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2923 // An input operand in a register that may be trashed.
2924 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2926 // An input operand in a register that may be trashed or a constant operand.
2927 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2929 // An input operand in a register or stack slot.
2930 MUST_USE_RESULT LOperand* Use(HValue* value);
2931 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2933 // An input operand in a register, stack slot or a constant operand.
2934 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2935 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2937 // An input operand in a register or a constant operand.
2938 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2939 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2941 // An input operand in a constant operand.
2942 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2944 // An input operand in register, stack slot or a constant operand.
2945 // Will not be moved to a register even if one is freely available.
2946 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2948 // Temporary operand that must be in a register.
2949 MUST_USE_RESULT LUnallocated* TempRegister();
2950 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2951 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2953 // Methods for setting up define-use relationships.
2954 // Return the same instruction that they are passed.
2955 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2956 LUnallocated* result);
2957 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2958 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2960 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2961 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2963 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2965 // Assigns an environment to an instruction. An instruction which can
2966 // deoptimize must have an environment.
2967 LInstruction* AssignEnvironment(LInstruction* instr);
2968 // Assigns a pointer map to an instruction. An instruction which can
2969 // trigger a GC or a lazy deoptimization must have a pointer map.
2970 LInstruction* AssignPointerMap(LInstruction* instr);
2972 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2974 // Marks a call for the register allocator. Assigns a pointer map to
2975 // support GC and lazy deoptimization. Assigns an environment to support
2976 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2977 LInstruction* MarkAsCall(
2978 LInstruction* instr,
2979 HInstruction* hinstr,
2980 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2982 void VisitInstruction(HInstruction* current);
2984 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2985 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2986 LInstruction* DoArithmeticD(Token::Value op,
2987 HArithmeticBinaryOperation* instr);
2988 LInstruction* DoArithmeticT(Token::Value op,
2989 HBinaryOperation* instr);
2990 void FindDehoistedKeyDefinitions(HValue* candidate);
2992 LPlatformChunk* chunk_;
2993 CompilationInfo* info_;
2994 HGraph* const graph_;
2996 HInstruction* current_instruction_;
2997 HBasicBlock* current_block_;
2998 HBasicBlock* next_block_;
2999 LAllocator* allocator_;
3001 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
3004 #undef DECLARE_HYDROGEN_ACCESSOR
3005 #undef DECLARE_CONCRETE_INSTRUCTION
3007 } } // namespace v8::int
3009 #endif // V8_X64_LITHIUM_X64_H_