1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
97 V(GetCachedArrayIndex) \
99 V(HasCachedArrayIndexAndBranch) \
100 V(HasInstanceTypeAndBranch) \
101 V(InnerAllocatedObject) \
103 V(InstanceOfKnownGlobal) \
105 V(Integer32ToDouble) \
108 V(IsConstructCallAndBranch) \
109 V(IsObjectAndBranch) \
110 V(IsStringAndBranch) \
112 V(IsUndetectableAndBranch) \
117 V(LoadFieldByIndex) \
118 V(LoadFunctionPrototype) \
120 V(LoadGlobalGeneric) \
122 V(LoadKeyedGeneric) \
124 V(LoadNamedGeneric) \
135 V(NullarySIMDOperation) \
136 V(UnarySIMDOperation) \
137 V(BinarySIMDOperation) \
138 V(TernarySIMDOperation) \
139 V(QuarternarySIMDOperation) \
154 V(SeqStringGetChar) \
155 V(SeqStringSetChar) \
161 V(StoreContextSlot) \
164 V(StoreKeyedGeneric) \
166 V(StoreNamedGeneric) \
168 V(StringCharCodeAt) \
169 V(StringCharFromCode) \
170 V(StringCompareAndBranch) \
174 V(ToFastProperties) \
175 V(TransitionElementsKind) \
176 V(TrapAllocationMemento) \
178 V(TypeofIsAndBranch) \
185 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
186 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
187 return LInstruction::k##type; \
189 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
190 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
193 static L##type* cast(LInstruction* instr) { \
194 ASSERT(instr->Is##type()); \
195 return reinterpret_cast<L##type*>(instr); \
199 #define DECLARE_HYDROGEN_ACCESSOR(type) \
200 H##type* hydrogen() const { \
201 return H##type::cast(hydrogen_value()); \
205 class LInstruction : public ZoneObject {
208 : environment_(NULL),
209 hydrogen_value_(NULL),
210 bit_field_(IsCallBits::encode(false)) {
213 virtual ~LInstruction() {}
215 virtual void CompileToNative(LCodeGen* generator) = 0;
216 virtual const char* Mnemonic() const = 0;
217 virtual void PrintTo(StringStream* stream);
218 virtual void PrintDataTo(StringStream* stream);
219 virtual void PrintOutputOperandTo(StringStream* stream);
222 // Declare a unique enum value for each instruction.
223 #define DECLARE_OPCODE(type) k##type,
224 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
225 kNumberOfInstructions
226 #undef DECLARE_OPCODE
229 virtual Opcode opcode() const = 0;
231 // Declare non-virtual type testers for all leaf IR classes.
232 #define DECLARE_PREDICATE(type) \
233 bool Is##type() const { return opcode() == k##type; }
234 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
235 #undef DECLARE_PREDICATE
237 // Declare virtual predicates for instructions that don't have
239 virtual bool IsGap() const { return false; }
241 virtual bool IsControl() const { return false; }
243 void set_environment(LEnvironment* env) { environment_ = env; }
244 LEnvironment* environment() const { return environment_; }
245 bool HasEnvironment() const { return environment_ != NULL; }
247 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
248 LPointerMap* pointer_map() const { return pointer_map_.get(); }
249 bool HasPointerMap() const { return pointer_map_.is_set(); }
251 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
252 HValue* hydrogen_value() const { return hydrogen_value_; }
254 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
255 bool IsCall() const { return IsCallBits::decode(bit_field_); }
257 // Interface to the register allocator and iterators.
258 bool ClobbersTemps() const { return IsCall(); }
259 bool ClobbersRegisters() const { return IsCall(); }
260 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
262 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
264 // Interface to the register allocator and iterators.
265 bool IsMarkedAsCall() const { return IsCall(); }
267 virtual bool HasResult() const = 0;
268 virtual LOperand* result() const = 0;
270 LOperand* FirstInput() { return InputAt(0); }
271 LOperand* Output() { return HasResult() ? result() : NULL; }
273 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
281 friend class InputIterator;
282 virtual int InputCount() = 0;
283 virtual LOperand* InputAt(int i) = 0;
285 friend class TempIterator;
286 virtual int TempCount() = 0;
287 virtual LOperand* TempAt(int i) = 0;
289 class IsCallBits: public BitField<bool, 0, 1> {};
291 LEnvironment* environment_;
292 SetOncePointer<LPointerMap> pointer_map_;
293 HValue* hydrogen_value_;
298 // R = number of result operands (0 or 1).
300 class LTemplateResultInstruction : public LInstruction {
302 // Allow 0 or 1 output operands.
303 STATIC_ASSERT(R == 0 || R == 1);
304 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
305 return R != 0 && result() != NULL;
307 void set_result(LOperand* operand) { results_[0] = operand; }
308 LOperand* result() const { return results_[0]; }
311 EmbeddedContainer<LOperand*, R> results_;
315 // R = number of result operands (0 or 1).
316 // I = number of input operands.
317 // T = number of temporary operands.
318 template<int R, int I, int T>
319 class LTemplateInstruction : public LTemplateResultInstruction<R> {
321 EmbeddedContainer<LOperand*, I> inputs_;
322 EmbeddedContainer<LOperand*, T> temps_;
326 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
327 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
329 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
330 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
334 class LGap : public LTemplateInstruction<0, 0, 0> {
336 explicit LGap(HBasicBlock* block)
338 parallel_moves_[BEFORE] = NULL;
339 parallel_moves_[START] = NULL;
340 parallel_moves_[END] = NULL;
341 parallel_moves_[AFTER] = NULL;
344 // Can't use the DECLARE-macro here because of sub-classes.
345 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
346 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
347 static LGap* cast(LInstruction* instr) {
348 ASSERT(instr->IsGap());
349 return reinterpret_cast<LGap*>(instr);
352 bool IsRedundant() const;
354 HBasicBlock* block() const { return block_; }
361 FIRST_INNER_POSITION = BEFORE,
362 LAST_INNER_POSITION = AFTER
365 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
367 if (parallel_moves_[pos] == NULL) {
368 parallel_moves_[pos] = new(zone) LParallelMove(zone);
370 return parallel_moves_[pos];
373 LParallelMove* GetParallelMove(InnerPosition pos) {
374 return parallel_moves_[pos];
378 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
383 class LInstructionGap V8_FINAL : public LGap {
385 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
387 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
388 return !IsRedundant();
391 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
395 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
397 explicit LGoto(HBasicBlock* block) : block_(block) { }
399 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
400 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
401 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
402 virtual bool IsControl() const V8_OVERRIDE { return true; }
404 int block_id() const { return block_->block_id(); }
411 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
413 LLazyBailout() : gap_instructions_size_(0) { }
415 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
417 void set_gap_instructions_size(int gap_instructions_size) {
418 gap_instructions_size_ = gap_instructions_size;
420 int gap_instructions_size() { return gap_instructions_size_; }
423 int gap_instructions_size_;
427 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
429 explicit LDummy() { }
430 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
434 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
436 explicit LDummyUse(LOperand* value) {
439 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
443 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
445 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
446 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
450 class LLabel V8_FINAL : public LGap {
452 explicit LLabel(HBasicBlock* block)
453 : LGap(block), replacement_(NULL) { }
455 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
458 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
460 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
462 int block_id() const { return block()->block_id(); }
463 bool is_loop_header() const { return block()->IsLoopHeader(); }
464 bool is_osr_entry() const { return block()->is_osr_entry(); }
465 Label* label() { return &label_; }
466 LLabel* replacement() const { return replacement_; }
467 void set_replacement(LLabel* label) { replacement_ = label; }
468 bool HasReplacement() const { return replacement_ != NULL; }
472 LLabel* replacement_;
476 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
478 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
481 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
485 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
487 explicit LCallStub(LOperand* context) {
488 inputs_[0] = context;
491 LOperand* context() { return inputs_[0]; }
493 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
494 DECLARE_HYDROGEN_ACCESSOR(CallStub)
498 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
500 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
503 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
507 template<int I, int T>
508 class LControlInstruction : public LTemplateInstruction<0, I, T> {
510 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
512 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
514 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
515 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
517 int TrueDestination(LChunk* chunk) {
518 return chunk->LookupDestination(true_block_id());
520 int FalseDestination(LChunk* chunk) {
521 return chunk->LookupDestination(false_block_id());
524 Label* TrueLabel(LChunk* chunk) {
525 if (true_label_ == NULL) {
526 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
530 Label* FalseLabel(LChunk* chunk) {
531 if (false_label_ == NULL) {
532 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
538 int true_block_id() { return SuccessorAt(0)->block_id(); }
539 int false_block_id() { return SuccessorAt(1)->block_id(); }
542 HControlInstruction* hydrogen() {
543 return HControlInstruction::cast(this->hydrogen_value());
551 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
553 LWrapReceiver(LOperand* receiver, LOperand* function) {
554 inputs_[0] = receiver;
555 inputs_[1] = function;
558 LOperand* receiver() { return inputs_[0]; }
559 LOperand* function() { return inputs_[1]; }
561 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
562 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
566 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
568 LApplyArguments(LOperand* function,
571 LOperand* elements) {
572 inputs_[0] = function;
573 inputs_[1] = receiver;
575 inputs_[3] = elements;
578 LOperand* function() { return inputs_[0]; }
579 LOperand* receiver() { return inputs_[1]; }
580 LOperand* length() { return inputs_[2]; }
581 LOperand* elements() { return inputs_[3]; }
583 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
587 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
589 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
590 inputs_[0] = arguments;
595 LOperand* arguments() { return inputs_[0]; }
596 LOperand* length() { return inputs_[1]; }
597 LOperand* index() { return inputs_[2]; }
599 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
601 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
605 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
607 explicit LArgumentsLength(LOperand* elements) {
608 inputs_[0] = elements;
611 LOperand* elements() { return inputs_[0]; }
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
617 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
620 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
624 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
626 LModI(LOperand* left, LOperand* right, LOperand* temp) {
632 LOperand* left() { return inputs_[0]; }
633 LOperand* right() { return inputs_[1]; }
634 LOperand* temp() { return temps_[0]; }
636 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
637 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
643 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
649 LOperand* left() { return inputs_[0]; }
650 LOperand* right() { return inputs_[1]; }
651 LOperand* temp() { return temps_[0]; }
653 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
655 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
656 DECLARE_HYDROGEN_ACCESSOR(Div)
660 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
662 LMathFloorOfDiv(LOperand* left,
664 LOperand* temp = NULL) {
670 LOperand* left() { return inputs_[0]; }
671 LOperand* right() { return inputs_[1]; }
672 LOperand* temp() { return temps_[0]; }
674 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
675 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
679 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
681 LMulI(LOperand* left, LOperand* right) {
686 LOperand* left() { return inputs_[0]; }
687 LOperand* right() { return inputs_[1]; }
689 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
690 DECLARE_HYDROGEN_ACCESSOR(Mul)
694 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
696 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
701 LOperand* left() { return inputs_[0]; }
702 LOperand* right() { return inputs_[1]; }
704 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
705 "compare-numeric-and-branch")
706 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
708 Token::Value op() const { return hydrogen()->token(); }
709 bool is_double() const {
710 return hydrogen()->representation().IsDouble();
713 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
717 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
719 explicit LMathFloor(LOperand* value) {
723 LOperand* value() { return inputs_[0]; }
725 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
726 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
730 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
732 explicit LMathRound(LOperand* value) {
736 LOperand* value() { return inputs_[0]; }
738 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
739 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
743 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
745 explicit LMathAbs(LOperand* context, LOperand* value) {
746 inputs_[1] = context;
750 LOperand* context() { return inputs_[1]; }
751 LOperand* value() { return inputs_[0]; }
753 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
754 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
758 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
760 explicit LMathLog(LOperand* value) {
764 LOperand* value() { return inputs_[0]; }
766 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
770 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
772 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
776 ExternalReference::InitializeMathExpData();
779 LOperand* value() { return inputs_[0]; }
780 LOperand* temp1() { return temps_[0]; }
781 LOperand* temp2() { return temps_[1]; }
783 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
787 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
789 explicit LMathSqrt(LOperand* value) {
793 LOperand* value() { return inputs_[0]; }
795 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
799 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
801 explicit LMathPowHalf(LOperand* value) {
805 LOperand* value() { return inputs_[0]; }
807 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
811 class LNullarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 0, 0> {
813 explicit LNullarySIMDOperation(BuiltinFunctionId op)
817 BuiltinFunctionId op() const { return op_; }
819 virtual Opcode opcode() const V8_OVERRIDE {
820 return LInstruction::kNullarySIMDOperation;
822 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
823 virtual const char* Mnemonic() const V8_OVERRIDE;
824 static LNullarySIMDOperation* cast(LInstruction* instr) {
825 ASSERT(instr->IsNullarySIMDOperation());
826 return reinterpret_cast<LNullarySIMDOperation*>(instr);
829 DECLARE_HYDROGEN_ACCESSOR(NullarySIMDOperation)
832 BuiltinFunctionId op_;
836 class LUnarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 1, 0> {
838 LUnarySIMDOperation(LOperand* value, BuiltinFunctionId op)
843 LOperand* value() { return inputs_[0]; }
844 BuiltinFunctionId op() const { return op_; }
846 virtual Opcode opcode() const V8_OVERRIDE {
847 return LInstruction::kUnarySIMDOperation;
849 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
850 virtual const char* Mnemonic() const V8_OVERRIDE;
851 static LUnarySIMDOperation* cast(LInstruction* instr) {
852 ASSERT(instr->IsUnarySIMDOperation());
853 return reinterpret_cast<LUnarySIMDOperation*>(instr);
856 DECLARE_HYDROGEN_ACCESSOR(UnarySIMDOperation)
859 BuiltinFunctionId op_;
863 class LBinarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 2, 0> {
865 LBinarySIMDOperation(LOperand* left, LOperand* right, BuiltinFunctionId op)
871 LOperand* left() { return inputs_[0]; }
872 LOperand* right() { return inputs_[1]; }
873 BuiltinFunctionId op() const { return op_; }
875 virtual Opcode opcode() const V8_OVERRIDE {
876 return LInstruction::kBinarySIMDOperation;
878 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
879 virtual const char* Mnemonic() const V8_OVERRIDE;
880 static LBinarySIMDOperation* cast(LInstruction* instr) {
881 ASSERT(instr->IsBinarySIMDOperation());
882 return reinterpret_cast<LBinarySIMDOperation*>(instr);
885 DECLARE_HYDROGEN_ACCESSOR(BinarySIMDOperation)
888 BuiltinFunctionId op_;
892 class LTernarySIMDOperation V8_FINAL : public LTemplateInstruction<1, 3, 0> {
894 LTernarySIMDOperation(LOperand* first, LOperand* second, LOperand* third,
895 BuiltinFunctionId op)
902 LOperand* first() { return inputs_[0]; }
903 LOperand* second() { return inputs_[1]; }
904 LOperand* third() { return inputs_[2]; }
905 BuiltinFunctionId op() const { return op_; }
907 virtual Opcode opcode() const V8_OVERRIDE {
908 return LInstruction::kTernarySIMDOperation;
910 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
911 virtual const char* Mnemonic() const V8_OVERRIDE;
912 static LTernarySIMDOperation* cast(LInstruction* instr) {
913 ASSERT(instr->IsTernarySIMDOperation());
914 return reinterpret_cast<LTernarySIMDOperation*>(instr);
917 DECLARE_HYDROGEN_ACCESSOR(TernarySIMDOperation)
920 BuiltinFunctionId op_;
924 class LQuarternarySIMDOperation V8_FINAL
925 : public LTemplateInstruction<1, 4, 0> {
927 LQuarternarySIMDOperation(LOperand* x, LOperand* y, LOperand* z,
928 LOperand* w, BuiltinFunctionId op)
936 LOperand* x() { return inputs_[0]; }
937 LOperand* y() { return inputs_[1]; }
938 LOperand* z() { return inputs_[2]; }
939 LOperand* w() { return inputs_[3]; }
940 BuiltinFunctionId op() const { return op_; }
942 virtual Opcode opcode() const V8_OVERRIDE {
943 return LInstruction::kQuarternarySIMDOperation;
945 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
946 virtual const char* Mnemonic() const V8_OVERRIDE;
947 static LQuarternarySIMDOperation* cast(LInstruction* instr) {
948 ASSERT(instr->IsQuarternarySIMDOperation());
949 return reinterpret_cast<LQuarternarySIMDOperation*>(instr);
952 DECLARE_HYDROGEN_ACCESSOR(QuarternarySIMDOperation)
955 BuiltinFunctionId op_;
959 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
961 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
966 LOperand* left() { return inputs_[0]; }
967 LOperand* right() { return inputs_[1]; }
969 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
973 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
975 explicit LCmpHoleAndBranch(LOperand* object) {
979 LOperand* object() { return inputs_[0]; }
981 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
982 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
986 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
988 explicit LCompareMinusZeroAndBranch(LOperand* value) {
992 LOperand* value() { return inputs_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
995 "cmp-minus-zero-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1001 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1003 explicit LIsObjectAndBranch(LOperand* value) {
1007 LOperand* value() { return inputs_[0]; }
1009 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1010 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1012 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1016 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1018 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1023 LOperand* value() { return inputs_[0]; }
1024 LOperand* temp() { return temps_[0]; }
1026 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1027 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1029 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1033 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1035 explicit LIsSmiAndBranch(LOperand* value) {
1039 LOperand* value() { return inputs_[0]; }
1041 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1042 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1044 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1048 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1050 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1055 LOperand* value() { return inputs_[0]; }
1056 LOperand* temp() { return temps_[0]; }
1058 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1059 "is-undetectable-and-branch")
1060 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1062 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1066 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1068 explicit LStringCompareAndBranch(LOperand* context,
1071 inputs_[0] = context;
1076 LOperand* context() { return inputs_[0]; }
1077 LOperand* left() { return inputs_[1]; }
1078 LOperand* right() { return inputs_[2]; }
1080 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1081 "string-compare-and-branch")
1082 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1084 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1086 Token::Value op() const { return hydrogen()->token(); }
1090 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1092 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1096 LOperand* value() { return inputs_[0]; }
1098 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1099 "has-instance-type-and-branch")
1100 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1102 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1106 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1108 explicit LGetCachedArrayIndex(LOperand* value) {
1112 LOperand* value() { return inputs_[0]; }
1114 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1115 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1119 class LHasCachedArrayIndexAndBranch V8_FINAL
1120 : public LControlInstruction<1, 0> {
1122 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1126 LOperand* value() { return inputs_[0]; }
1128 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1129 "has-cached-array-index-and-branch")
1130 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1132 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1136 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1138 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1144 LOperand* value() { return inputs_[0]; }
1145 LOperand* temp() { return temps_[0]; }
1146 LOperand* temp2() { return temps_[1]; }
1148 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1149 "class-of-test-and-branch")
1150 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1152 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1156 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1158 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1159 inputs_[0] = context;
1164 LOperand* context() { return inputs_[0]; }
1165 LOperand* left() { return inputs_[1]; }
1166 LOperand* right() { return inputs_[2]; }
1168 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1169 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1171 Token::Value op() const { return hydrogen()->token(); }
1175 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1177 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1178 inputs_[0] = context;
1183 LOperand* context() { return inputs_[0]; }
1184 LOperand* left() { return inputs_[1]; }
1185 LOperand* right() { return inputs_[2]; }
1187 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1191 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1193 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1194 inputs_[0] = context;
1199 LOperand* context() { return inputs_[0]; }
1200 LOperand* value() { return inputs_[1]; }
1201 LOperand* temp() { return temps_[0]; }
1203 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1204 "instance-of-known-global")
1205 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1207 Handle<JSFunction> function() const { return hydrogen()->function(); }
1208 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1209 return lazy_deopt_env_;
1211 virtual void SetDeferredLazyDeoptimizationEnvironment(
1212 LEnvironment* env) V8_OVERRIDE {
1213 lazy_deopt_env_ = env;
1217 LEnvironment* lazy_deopt_env_;
1221 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1223 LBoundsCheck(LOperand* index, LOperand* length) {
1225 inputs_[1] = length;
1228 LOperand* index() { return inputs_[0]; }
1229 LOperand* length() { return inputs_[1]; }
1231 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1232 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1236 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1238 LBitI(LOperand* left, LOperand* right) {
1243 LOperand* left() { return inputs_[0]; }
1244 LOperand* right() { return inputs_[1]; }
1246 Token::Value op() const { return hydrogen()->op(); }
1248 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1249 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1253 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1255 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1256 : op_(op), can_deopt_(can_deopt) {
1261 Token::Value op() const { return op_; }
1262 LOperand* left() { return inputs_[0]; }
1263 LOperand* right() { return inputs_[1]; }
1264 bool can_deopt() const { return can_deopt_; }
1266 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1274 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1276 LSubI(LOperand* left, LOperand* right) {
1281 LOperand* left() { return inputs_[0]; }
1282 LOperand* right() { return inputs_[1]; }
1284 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1285 DECLARE_HYDROGEN_ACCESSOR(Sub)
1289 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1291 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1292 DECLARE_HYDROGEN_ACCESSOR(Constant)
1294 int32_t value() const { return hydrogen()->Integer32Value(); }
1298 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1300 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1301 DECLARE_HYDROGEN_ACCESSOR(Constant)
1303 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1307 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1309 explicit LConstantD(LOperand* temp) {
1313 LOperand* temp() { return temps_[0]; }
1315 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1316 DECLARE_HYDROGEN_ACCESSOR(Constant)
1318 double value() const { return hydrogen()->DoubleValue(); }
1322 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1324 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1325 DECLARE_HYDROGEN_ACCESSOR(Constant)
1327 ExternalReference value() const {
1328 return hydrogen()->ExternalReferenceValue();
1333 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1335 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1336 DECLARE_HYDROGEN_ACCESSOR(Constant)
1338 Handle<Object> value(Isolate* isolate) const {
1339 return hydrogen()->handle(isolate);
1344 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1346 explicit LBranch(LOperand* value) {
1350 LOperand* value() { return inputs_[0]; }
1352 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1353 DECLARE_HYDROGEN_ACCESSOR(Branch)
1355 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1359 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1361 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1365 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1367 explicit LCmpMapAndBranch(LOperand* value) {
1371 LOperand* value() { return inputs_[0]; }
1373 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1374 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1376 Handle<Map> map() const { return hydrogen()->map().handle(); }
1380 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1382 explicit LMapEnumLength(LOperand* value) {
1386 LOperand* value() { return inputs_[0]; }
1388 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1392 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1394 LDateField(LOperand* date, Smi* index) : index_(index) {
1398 LOperand* date() { return inputs_[0]; }
1399 Smi* index() const { return index_; }
1401 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1402 DECLARE_HYDROGEN_ACCESSOR(DateField)
1409 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1411 LSeqStringGetChar(LOperand* string, LOperand* index) {
1412 inputs_[0] = string;
1416 LOperand* string() const { return inputs_[0]; }
1417 LOperand* index() const { return inputs_[1]; }
1419 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1420 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1424 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1426 LSeqStringSetChar(LOperand* context,
1430 inputs_[0] = context;
1431 inputs_[1] = string;
1436 LOperand* string() { return inputs_[1]; }
1437 LOperand* index() { return inputs_[2]; }
1438 LOperand* value() { return inputs_[3]; }
1440 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1441 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1445 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1447 LAddI(LOperand* left, LOperand* right) {
1452 LOperand* left() { return inputs_[0]; }
1453 LOperand* right() { return inputs_[1]; }
1455 static bool UseLea(HAdd* add) {
1456 return !add->CheckFlag(HValue::kCanOverflow) &&
1457 add->BetterLeftOperand()->UseCount() > 1;
1460 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1461 DECLARE_HYDROGEN_ACCESSOR(Add)
1465 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1467 LMathMinMax(LOperand* left, LOperand* right) {
1472 LOperand* left() { return inputs_[0]; }
1473 LOperand* right() { return inputs_[1]; }
1475 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1476 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1480 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1482 LPower(LOperand* left, LOperand* right) {
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1491 DECLARE_HYDROGEN_ACCESSOR(Power)
1495 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1497 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1503 Token::Value op() const { return op_; }
1504 LOperand* left() { return inputs_[0]; }
1505 LOperand* right() { return inputs_[1]; }
1507 virtual Opcode opcode() const V8_OVERRIDE {
1508 return LInstruction::kArithmeticD;
1510 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1511 virtual const char* Mnemonic() const V8_OVERRIDE;
1518 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1520 LArithmeticT(Token::Value op,
1525 inputs_[0] = context;
1530 Token::Value op() const { return op_; }
1531 LOperand* context() { return inputs_[0]; }
1532 LOperand* left() { return inputs_[1]; }
1533 LOperand* right() { return inputs_[2]; }
1535 virtual Opcode opcode() const V8_OVERRIDE {
1536 return LInstruction::kArithmeticT;
1538 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1539 virtual const char* Mnemonic() const V8_OVERRIDE;
1546 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1548 explicit LReturn(LOperand* value,
1550 LOperand* parameter_count) {
1552 inputs_[1] = context;
1553 inputs_[2] = parameter_count;
1556 LOperand* value() { return inputs_[0]; }
1557 LOperand* context() { return inputs_[1]; }
1559 bool has_constant_parameter_count() {
1560 return parameter_count()->IsConstantOperand();
1562 LConstantOperand* constant_parameter_count() {
1563 ASSERT(has_constant_parameter_count());
1564 return LConstantOperand::cast(parameter_count());
1566 LOperand* parameter_count() { return inputs_[2]; }
1568 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1569 DECLARE_HYDROGEN_ACCESSOR(Return)
1573 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1575 explicit LLoadNamedField(LOperand* object) {
1576 inputs_[0] = object;
1579 LOperand* object() { return inputs_[0]; }
1581 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1582 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1586 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1588 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1589 inputs_[0] = context;
1590 inputs_[1] = object;
1593 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1596 LOperand* context() { return inputs_[0]; }
1597 LOperand* object() { return inputs_[1]; }
1598 Handle<Object> name() const { return hydrogen()->name(); }
1602 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1604 explicit LLoadFunctionPrototype(LOperand* function) {
1605 inputs_[0] = function;
1608 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1609 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1611 LOperand* function() { return inputs_[0]; }
1615 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1617 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1620 Heap::RootListIndex index() const { return hydrogen()->index(); }
1624 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1626 LLoadKeyed(LOperand* elements, LOperand* key) {
1627 inputs_[0] = elements;
1631 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1632 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1634 bool is_external() const {
1635 return hydrogen()->is_external();
1637 bool is_fixed_typed_array() const {
1638 return hydrogen()->is_fixed_typed_array();
1640 bool is_typed_elements() const {
1641 return is_external() || is_fixed_typed_array();
1643 LOperand* elements() { return inputs_[0]; }
1644 LOperand* key() { return inputs_[1]; }
1645 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1646 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1647 ElementsKind elements_kind() const {
1648 return hydrogen()->elements_kind();
1653 inline static bool ExternalArrayOpRequiresPreScale(ElementsKind kind) {
1654 return ElementsKindToShiftSize(kind) > static_cast<int>(maximal_scale_factor);
1658 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1660 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1661 inputs_[0] = context;
1666 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1668 LOperand* context() { return inputs_[0]; }
1669 LOperand* object() { return inputs_[1]; }
1670 LOperand* key() { return inputs_[2]; }
1674 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1676 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1677 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1681 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1683 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1684 inputs_[0] = context;
1685 inputs_[1] = global_object;
1688 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1689 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1691 LOperand* context() { return inputs_[0]; }
1692 LOperand* global_object() { return inputs_[1]; }
1693 Handle<Object> name() const { return hydrogen()->name(); }
1694 bool for_typeof() const { return hydrogen()->for_typeof(); }
1698 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1700 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1705 LOperand* value() { return inputs_[0]; }
1706 LOperand* temp() { return temps_[0]; }
1708 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1709 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1713 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1715 explicit LLoadContextSlot(LOperand* context) {
1716 inputs_[0] = context;
1719 LOperand* context() { return inputs_[0]; }
1721 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1722 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1724 int slot_index() { return hydrogen()->slot_index(); }
1726 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1730 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1732 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1733 inputs_[0] = context;
1738 LOperand* context() { return inputs_[0]; }
1739 LOperand* value() { return inputs_[1]; }
1740 LOperand* temp() { return temps_[0]; }
1742 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1743 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1745 int slot_index() { return hydrogen()->slot_index(); }
1747 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1751 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1753 explicit LPushArgument(LOperand* value) {
1757 LOperand* value() { return inputs_[0]; }
1759 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1763 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1765 explicit LDrop(int count) : count_(count) { }
1767 int count() const { return count_; }
1769 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1776 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1778 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1779 inputs_[0] = function;
1780 temps_[0] = code_object;
1783 LOperand* function() { return inputs_[0]; }
1784 LOperand* code_object() { return temps_[0]; }
1786 virtual void PrintDataTo(StringStream* stream);
1788 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1789 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1793 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1795 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1796 inputs_[0] = base_object;
1797 inputs_[1] = offset;
1800 LOperand* base_object() const { return inputs_[0]; }
1801 LOperand* offset() const { return inputs_[1]; }
1803 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1805 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1809 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1811 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1812 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1816 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1818 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1819 DECLARE_HYDROGEN_ACCESSOR(Context)
1823 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1825 explicit LDeclareGlobals(LOperand* context) {
1826 inputs_[0] = context;
1829 LOperand* context() { return inputs_[0]; }
1831 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1832 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1836 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1838 explicit LCallJSFunction(LOperand* function) {
1839 inputs_[0] = function;
1842 LOperand* function() { return inputs_[0]; }
1844 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1845 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1847 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1849 int arity() const { return hydrogen()->argument_count() - 1; }
1853 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1855 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1856 ZoneList<LOperand*>& operands,
1858 : inputs_(descriptor->environment_length() + 1, zone) {
1859 ASSERT(descriptor->environment_length() + 1 == operands.length());
1860 inputs_.AddAll(operands, zone);
1863 LOperand* target() const { return inputs_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1867 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1869 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1871 int arity() const { return hydrogen()->argument_count() - 1; }
1873 ZoneList<LOperand*> inputs_;
1875 // Iterator support.
1876 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1877 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1879 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1880 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1884 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1886 LInvokeFunction(LOperand* context, LOperand* function) {
1887 inputs_[0] = context;
1888 inputs_[1] = function;
1891 LOperand* context() { return inputs_[0]; }
1892 LOperand* function() { return inputs_[1]; }
1894 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1895 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1897 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1899 int arity() const { return hydrogen()->argument_count() - 1; }
1903 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1905 LCallFunction(LOperand* context, LOperand* function) {
1906 inputs_[0] = context;
1907 inputs_[1] = function;
1910 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1911 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1913 LOperand* context() { return inputs_[0]; }
1914 LOperand* function() { return inputs_[1]; }
1915 int arity() const { return hydrogen()->argument_count() - 1; }
1919 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1921 LCallNew(LOperand* context, LOperand* constructor) {
1922 inputs_[0] = context;
1923 inputs_[1] = constructor;
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* constructor() { return inputs_[1]; }
1929 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1930 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1932 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1934 int arity() const { return hydrogen()->argument_count() - 1; }
1938 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1940 LCallNewArray(LOperand* context, LOperand* constructor) {
1941 inputs_[0] = context;
1942 inputs_[1] = constructor;
1945 LOperand* context() { return inputs_[0]; }
1946 LOperand* constructor() { return inputs_[1]; }
1948 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1949 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1951 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1953 int arity() const { return hydrogen()->argument_count() - 1; }
1957 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1959 explicit LCallRuntime(LOperand* context) {
1960 inputs_[0] = context;
1963 LOperand* context() { return inputs_[0]; }
1965 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1966 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1968 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1969 return save_doubles() == kDontSaveFPRegs;
1972 const Runtime::Function* function() const { return hydrogen()->function(); }
1973 int arity() const { return hydrogen()->argument_count(); }
1974 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1978 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1980 explicit LInteger32ToDouble(LOperand* value) {
1984 LOperand* value() { return inputs_[0]; }
1986 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1990 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1992 explicit LInteger32ToSmi(LOperand* value) {
1996 LOperand* value() { return inputs_[0]; }
1998 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1999 DECLARE_HYDROGEN_ACCESSOR(Change)
2003 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2005 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
2010 LOperand* value() { return inputs_[0]; }
2011 LOperand* temp() { return temps_[0]; }
2013 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2017 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2019 explicit LUint32ToSmi(LOperand* value) {
2023 LOperand* value() { return inputs_[0]; }
2025 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
2026 DECLARE_HYDROGEN_ACCESSOR(Change)
2030 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2032 explicit LNumberTagI(LOperand* value) {
2036 LOperand* value() { return inputs_[0]; }
2038 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2042 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2044 explicit LNumberTagU(LOperand* value, LOperand* temp) {
2049 LOperand* value() { return inputs_[0]; }
2050 LOperand* temp() { return temps_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2056 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2058 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2063 LOperand* value() { return inputs_[0]; }
2064 LOperand* temp() { return temps_[0]; }
2066 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2067 DECLARE_HYDROGEN_ACCESSOR(Change)
2071 class LSIMD128ToTagged V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2073 explicit LSIMD128ToTagged(LOperand* value, LOperand* temp) {
2078 LOperand* value() { return inputs_[0]; }
2079 LOperand* temp() { return temps_[0]; }
2081 DECLARE_CONCRETE_INSTRUCTION(SIMD128ToTagged, "simd128-tag")
2082 DECLARE_HYDROGEN_ACCESSOR(Change)
2086 // Sometimes truncating conversion from a tagged value to an int32.
2087 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2089 explicit LDoubleToI(LOperand* value) {
2093 LOperand* value() { return inputs_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2096 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2098 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2102 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2104 explicit LDoubleToSmi(LOperand* value) {
2108 LOperand* value() { return inputs_[0]; }
2110 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2111 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2115 // Truncating conversion from a tagged value to an int32.
2116 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2118 LTaggedToI(LOperand* value, LOperand* temp) {
2123 LOperand* value() { return inputs_[0]; }
2124 LOperand* temp() { return temps_[0]; }
2126 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2127 DECLARE_HYDROGEN_ACCESSOR(Change)
2129 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2133 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2135 explicit LSmiTag(LOperand* value) {
2139 LOperand* value() { return inputs_[0]; }
2141 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2145 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2147 explicit LNumberUntagD(LOperand* value) {
2151 LOperand* value() { return inputs_[0]; }
2153 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2154 DECLARE_HYDROGEN_ACCESSOR(Change);
2158 class LTaggedToSIMD128 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2160 explicit LTaggedToSIMD128(LOperand* value, Representation representation)
2161 : representation_(representation) {
2165 LOperand* value() { return inputs_[0]; }
2166 Representation representation() const { return representation_; }
2168 DECLARE_CONCRETE_INSTRUCTION(TaggedToSIMD128, "simd128-untag")
2169 DECLARE_HYDROGEN_ACCESSOR(Change);
2171 Representation representation_;
2175 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2177 LSmiUntag(LOperand* value, bool needs_check)
2178 : needs_check_(needs_check) {
2182 LOperand* value() { return inputs_[0]; }
2183 bool needs_check() const { return needs_check_; }
2185 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2192 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2194 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2195 inputs_[0] = object;
2200 LOperand* object() { return inputs_[0]; }
2201 LOperand* value() { return inputs_[1]; }
2202 LOperand* temp() { return temps_[0]; }
2204 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2205 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2207 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2209 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2210 Representation representation() const {
2211 return hydrogen()->field_representation();
2216 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2218 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2219 inputs_[0] = context;
2220 inputs_[1] = object;
2224 LOperand* context() { return inputs_[0]; }
2225 LOperand* object() { return inputs_[1]; }
2226 LOperand* value() { return inputs_[2]; }
2228 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2229 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2231 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2233 Handle<Object> name() const { return hydrogen()->name(); }
2234 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2238 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2240 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2241 inputs_[0] = object;
2246 bool is_external() const { return hydrogen()->is_external(); }
2247 bool is_fixed_typed_array() const {
2248 return hydrogen()->is_fixed_typed_array();
2250 bool is_typed_elements() const {
2251 return is_external() || is_fixed_typed_array();
2253 LOperand* elements() { return inputs_[0]; }
2254 LOperand* key() { return inputs_[1]; }
2255 LOperand* value() { return inputs_[2]; }
2256 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2258 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2259 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2261 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2262 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2263 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2267 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2269 LStoreKeyedGeneric(LOperand* context,
2273 inputs_[0] = context;
2274 inputs_[1] = object;
2279 LOperand* context() { return inputs_[0]; }
2280 LOperand* object() { return inputs_[1]; }
2281 LOperand* key() { return inputs_[2]; }
2282 LOperand* value() { return inputs_[3]; }
2284 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2285 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2287 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2289 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2293 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2295 LTransitionElementsKind(LOperand* object,
2297 LOperand* new_map_temp,
2299 inputs_[0] = object;
2300 inputs_[1] = context;
2301 temps_[0] = new_map_temp;
2305 LOperand* object() { return inputs_[0]; }
2306 LOperand* context() { return inputs_[1]; }
2307 LOperand* new_map_temp() { return temps_[0]; }
2308 LOperand* temp() { return temps_[1]; }
2310 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2311 "transition-elements-kind")
2312 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2314 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2316 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2317 Handle<Map> transitioned_map() {
2318 return hydrogen()->transitioned_map().handle();
2320 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2321 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2325 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2327 LTrapAllocationMemento(LOperand* object,
2329 inputs_[0] = object;
2333 LOperand* object() { return inputs_[0]; }
2334 LOperand* temp() { return temps_[0]; }
2336 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2337 "trap-allocation-memento")
2341 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2343 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2344 inputs_[0] = context;
2349 LOperand* context() { return inputs_[0]; }
2350 LOperand* left() { return inputs_[1]; }
2351 LOperand* right() { return inputs_[2]; }
2353 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2354 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2358 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2360 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2361 inputs_[0] = context;
2362 inputs_[1] = string;
2366 LOperand* context() { return inputs_[0]; }
2367 LOperand* string() { return inputs_[1]; }
2368 LOperand* index() { return inputs_[2]; }
2370 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2371 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2375 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2377 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2378 inputs_[0] = context;
2379 inputs_[1] = char_code;
2382 LOperand* context() { return inputs_[0]; }
2383 LOperand* char_code() { return inputs_[1]; }
2385 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2386 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2390 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2392 explicit LCheckValue(LOperand* value) {
2396 LOperand* value() { return inputs_[0]; }
2398 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2399 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2403 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2405 explicit LCheckInstanceType(LOperand* value) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2412 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2416 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2418 explicit LCheckMaps(LOperand* value) {
2422 LOperand* value() { return inputs_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2425 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2429 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2431 explicit LCheckSmi(LOperand* value) {
2435 LOperand* value() { return inputs_[0]; }
2437 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2441 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2443 explicit LClampDToUint8(LOperand* unclamped) {
2444 inputs_[0] = unclamped;
2447 LOperand* unclamped() { return inputs_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2453 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2455 explicit LClampIToUint8(LOperand* unclamped) {
2456 inputs_[0] = unclamped;
2459 LOperand* unclamped() { return inputs_[0]; }
2461 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2465 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2467 LClampTToUint8(LOperand* unclamped,
2468 LOperand* temp_xmm) {
2469 inputs_[0] = unclamped;
2470 temps_[0] = temp_xmm;
2473 LOperand* unclamped() { return inputs_[0]; }
2474 LOperand* temp_xmm() { return temps_[0]; }
2476 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2480 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2482 explicit LCheckNonSmi(LOperand* value) {
2486 LOperand* value() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2489 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2493 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2495 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2496 inputs_[0] = context;
2501 LOperand* context() { return inputs_[0]; }
2502 LOperand* size() { return inputs_[1]; }
2503 LOperand* temp() { return temps_[0]; }
2505 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2506 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2510 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2512 explicit LRegExpLiteral(LOperand* context) {
2513 inputs_[0] = context;
2516 LOperand* context() { return inputs_[0]; }
2518 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2519 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2523 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2525 explicit LFunctionLiteral(LOperand* context) {
2526 inputs_[0] = context;
2529 LOperand* context() { return inputs_[0]; }
2531 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2532 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2536 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2538 explicit LToFastProperties(LOperand* value) {
2542 LOperand* value() { return inputs_[0]; }
2544 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2545 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2549 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2551 LTypeof(LOperand* context, LOperand* value) {
2552 inputs_[0] = context;
2556 LOperand* context() { return inputs_[0]; }
2557 LOperand* value() { return inputs_[1]; }
2559 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2563 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2565 explicit LTypeofIsAndBranch(LOperand* value) {
2569 LOperand* value() { return inputs_[0]; }
2571 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2572 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2574 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2576 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2580 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2582 explicit LIsConstructCallAndBranch(LOperand* temp) {
2586 LOperand* temp() { return temps_[0]; }
2588 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2589 "is-construct-call-and-branch")
2590 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2594 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2598 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2601 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2605 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2607 explicit LStackCheck(LOperand* context) {
2608 inputs_[0] = context;
2611 LOperand* context() { return inputs_[0]; }
2613 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2614 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2616 Label* done_label() { return &done_label_; }
2623 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2625 LForInPrepareMap(LOperand* context, LOperand* object) {
2626 inputs_[0] = context;
2627 inputs_[1] = object;
2630 LOperand* context() { return inputs_[0]; }
2631 LOperand* object() { return inputs_[1]; }
2633 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2637 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2639 explicit LForInCacheArray(LOperand* map) {
2643 LOperand* map() { return inputs_[0]; }
2645 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2648 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2653 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2655 LCheckMapValue(LOperand* value, LOperand* map) {
2660 LOperand* value() { return inputs_[0]; }
2661 LOperand* map() { return inputs_[1]; }
2663 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2667 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2669 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2670 inputs_[0] = object;
2674 LOperand* object() { return inputs_[0]; }
2675 LOperand* index() { return inputs_[1]; }
2677 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2681 class LChunkBuilder;
2682 class LPlatformChunk V8_FINAL : public LChunk {
2684 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2685 : LChunk(info, graph) { }
2687 int GetNextSpillIndex(RegisterKind kind);
2688 LOperand* GetNextSpillSlot(RegisterKind kind);
2692 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2694 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2695 : LChunkBuilderBase(graph->zone()),
2700 current_instruction_(NULL),
2701 current_block_(NULL),
2703 allocator_(allocator),
2704 instruction_pending_deoptimization_environment_(NULL),
2705 pending_deoptimization_ast_id_(BailoutId::None()) { }
2707 // Build the sequence for the graph.
2708 LPlatformChunk* Build();
2710 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2712 // Declare methods that deal with the individual node types.
2713 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2714 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2717 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2718 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2719 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2720 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2721 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2722 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2723 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2733 LPlatformChunk* chunk() const { return chunk_; }
2734 CompilationInfo* info() const { return info_; }
2735 HGraph* graph() const { return graph_; }
2737 bool is_unused() const { return status_ == UNUSED; }
2738 bool is_building() const { return status_ == BUILDING; }
2739 bool is_done() const { return status_ == DONE; }
2740 bool is_aborted() const { return status_ == ABORTED; }
2742 void Abort(BailoutReason reason);
2744 // Methods for getting operands for Use / Define / Temp.
2745 LUnallocated* ToUnallocated(Register reg);
2746 LUnallocated* ToUnallocated(XMMRegister reg);
2748 // Methods for setting up define-use relationships.
2749 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2750 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2751 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2752 XMMRegister fixed_register);
2754 // A value that is guaranteed to be allocated to a register.
2755 // Operand created by UseRegister is guaranteed to be live until the end of
2756 // instruction. This means that register allocator will not reuse it's
2757 // register for any other operand inside instruction.
2758 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2759 // instruction start. Register allocator is free to assign the same register
2760 // to some other operand used inside instruction (i.e. temporary or
2762 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2763 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2765 // An input operand in a register that may be trashed.
2766 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2768 // An input operand in a register that may be trashed or a constant operand.
2769 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2771 // An input operand in a register or stack slot.
2772 MUST_USE_RESULT LOperand* Use(HValue* value);
2773 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2775 // An input operand in a register, stack slot or a constant operand.
2776 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2777 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2779 // An input operand in a register or a constant operand.
2780 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2781 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2783 // An input operand in a constant operand.
2784 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2786 // An input operand in register, stack slot or a constant operand.
2787 // Will not be moved to a register even if one is freely available.
2788 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2790 // Temporary operand that must be in a register.
2791 MUST_USE_RESULT LUnallocated* TempRegister();
2792 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2793 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2795 // Methods for setting up define-use relationships.
2796 // Return the same instruction that they are passed.
2797 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2798 LUnallocated* result);
2799 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2800 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2802 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2803 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2805 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2807 // Assigns an environment to an instruction. An instruction which can
2808 // deoptimize must have an environment.
2809 LInstruction* AssignEnvironment(LInstruction* instr);
2810 // Assigns a pointer map to an instruction. An instruction which can
2811 // trigger a GC or a lazy deoptimization must have a pointer map.
2812 LInstruction* AssignPointerMap(LInstruction* instr);
2814 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2816 // Marks a call for the register allocator. Assigns a pointer map to
2817 // support GC and lazy deoptimization. Assigns an environment to support
2818 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2819 LInstruction* MarkAsCall(
2820 LInstruction* instr,
2821 HInstruction* hinstr,
2822 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2824 void VisitInstruction(HInstruction* current);
2826 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2827 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2828 LInstruction* DoArithmeticD(Token::Value op,
2829 HArithmeticBinaryOperation* instr);
2830 LInstruction* DoArithmeticT(Token::Value op,
2831 HBinaryOperation* instr);
2833 LPlatformChunk* chunk_;
2834 CompilationInfo* info_;
2835 HGraph* const graph_;
2837 HInstruction* current_instruction_;
2838 HBasicBlock* current_block_;
2839 HBasicBlock* next_block_;
2840 LAllocator* allocator_;
2841 LInstruction* instruction_pending_deoptimization_environment_;
2842 BailoutId pending_deoptimization_ast_id_;
2844 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2847 #undef DECLARE_HYDROGEN_ACCESSOR
2848 #undef DECLARE_CONCRETE_INSTRUCTION
2850 } } // namespace v8::int
2852 #endif // V8_X64_LITHIUM_X64_H_