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) \
104 V(GetCachedArrayIndex) \
106 V(HasCachedArrayIndexAndBranch) \
107 V(HasInstanceTypeAndBranch) \
108 V(InnerAllocatedObject) \
110 V(InstanceOfKnownGlobal) \
112 V(Integer32ToDouble) \
114 V(IsConstructCallAndBranch) \
115 V(IsObjectAndBranch) \
116 V(IsStringAndBranch) \
118 V(IsUndetectableAndBranch) \
123 V(LoadFieldByIndex) \
124 V(LoadFunctionPrototype) \
126 V(LoadGlobalGeneric) \
128 V(LoadKeyedGeneric) \
130 V(LoadNamedGeneric) \
155 V(SeqStringGetChar) \
156 V(SeqStringSetChar) \
162 V(StoreContextSlot) \
165 V(StoreKeyedGeneric) \
167 V(StoreNamedGeneric) \
169 V(StringCharCodeAt) \
170 V(StringCharFromCode) \
171 V(StringCompareAndBranch) \
175 V(ToFastProperties) \
176 V(TransitionElementsKind) \
177 V(TrapAllocationMemento) \
179 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; }
275 virtual bool MustSignExtendResult(LPlatformChunk* chunk) const {
285 friend class InputIterator;
286 virtual int InputCount() = 0;
287 virtual LOperand* InputAt(int i) = 0;
289 friend class TempIterator;
290 virtual int TempCount() = 0;
291 virtual LOperand* TempAt(int i) = 0;
293 class IsCallBits: public BitField<bool, 0, 1> {};
295 LEnvironment* environment_;
296 SetOncePointer<LPointerMap> pointer_map_;
297 HValue* hydrogen_value_;
302 // R = number of result operands (0 or 1).
304 class LTemplateResultInstruction : public LInstruction {
306 // Allow 0 or 1 output operands.
307 STATIC_ASSERT(R == 0 || R == 1);
308 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
309 return R != 0 && result() != NULL;
311 void set_result(LOperand* operand) { results_[0] = operand; }
312 LOperand* result() const { return results_[0]; }
314 virtual bool MustSignExtendResult(
315 LPlatformChunk* chunk) const V8_FINAL V8_OVERRIDE;
318 EmbeddedContainer<LOperand*, R> results_;
322 // R = number of result operands (0 or 1).
323 // I = number of input operands.
324 // T = number of temporary operands.
325 template<int R, int I, int T>
326 class LTemplateInstruction : public LTemplateResultInstruction<R> {
328 EmbeddedContainer<LOperand*, I> inputs_;
329 EmbeddedContainer<LOperand*, T> temps_;
333 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
334 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
336 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
337 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
341 class LGap : public LTemplateInstruction<0, 0, 0> {
343 explicit LGap(HBasicBlock* block)
345 parallel_moves_[BEFORE] = NULL;
346 parallel_moves_[START] = NULL;
347 parallel_moves_[END] = NULL;
348 parallel_moves_[AFTER] = NULL;
351 // Can't use the DECLARE-macro here because of sub-classes.
352 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
353 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
354 static LGap* cast(LInstruction* instr) {
355 ASSERT(instr->IsGap());
356 return reinterpret_cast<LGap*>(instr);
359 bool IsRedundant() const;
361 HBasicBlock* block() const { return block_; }
368 FIRST_INNER_POSITION = BEFORE,
369 LAST_INNER_POSITION = AFTER
372 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
374 if (parallel_moves_[pos] == NULL) {
375 parallel_moves_[pos] = new(zone) LParallelMove(zone);
377 return parallel_moves_[pos];
380 LParallelMove* GetParallelMove(InnerPosition pos) {
381 return parallel_moves_[pos];
385 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
390 class LInstructionGap V8_FINAL : public LGap {
392 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
394 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
395 return !IsRedundant();
398 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
402 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
404 explicit LGoto(HBasicBlock* block) : block_(block) { }
406 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
407 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
408 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
409 virtual bool IsControl() const V8_OVERRIDE { return true; }
411 int block_id() const { return block_->block_id(); }
418 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
420 LLazyBailout() : gap_instructions_size_(0) { }
422 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
424 void set_gap_instructions_size(int gap_instructions_size) {
425 gap_instructions_size_ = gap_instructions_size;
427 int gap_instructions_size() { return gap_instructions_size_; }
430 int gap_instructions_size_;
434 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
436 explicit LDummy() { }
437 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
441 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
443 explicit LDummyUse(LOperand* value) {
446 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
450 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
452 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
453 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
457 class LLabel V8_FINAL : public LGap {
459 explicit LLabel(HBasicBlock* block)
460 : LGap(block), replacement_(NULL) { }
462 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
465 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
467 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
469 int block_id() const { return block()->block_id(); }
470 bool is_loop_header() const { return block()->IsLoopHeader(); }
471 bool is_osr_entry() const { return block()->is_osr_entry(); }
472 Label* label() { return &label_; }
473 LLabel* replacement() const { return replacement_; }
474 void set_replacement(LLabel* label) { replacement_ = label; }
475 bool HasReplacement() const { return replacement_ != NULL; }
479 LLabel* replacement_;
483 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
485 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
488 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
492 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
494 explicit LCallStub(LOperand* context) {
495 inputs_[0] = context;
498 LOperand* context() { return inputs_[0]; }
500 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
501 DECLARE_HYDROGEN_ACCESSOR(CallStub)
505 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
507 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
510 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
514 template<int I, int T>
515 class LControlInstruction : public LTemplateInstruction<0, I, T> {
517 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
519 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
521 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
522 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
524 int TrueDestination(LChunk* chunk) {
525 return chunk->LookupDestination(true_block_id());
527 int FalseDestination(LChunk* chunk) {
528 return chunk->LookupDestination(false_block_id());
531 Label* TrueLabel(LChunk* chunk) {
532 if (true_label_ == NULL) {
533 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
537 Label* FalseLabel(LChunk* chunk) {
538 if (false_label_ == NULL) {
539 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
545 int true_block_id() { return SuccessorAt(0)->block_id(); }
546 int false_block_id() { return SuccessorAt(1)->block_id(); }
549 HControlInstruction* hydrogen() {
550 return HControlInstruction::cast(this->hydrogen_value());
558 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
560 LWrapReceiver(LOperand* receiver, LOperand* function) {
561 inputs_[0] = receiver;
562 inputs_[1] = function;
565 LOperand* receiver() { return inputs_[0]; }
566 LOperand* function() { return inputs_[1]; }
568 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
569 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
573 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
575 LApplyArguments(LOperand* function,
578 LOperand* elements) {
579 inputs_[0] = function;
580 inputs_[1] = receiver;
582 inputs_[3] = elements;
585 LOperand* function() { return inputs_[0]; }
586 LOperand* receiver() { return inputs_[1]; }
587 LOperand* length() { return inputs_[2]; }
588 LOperand* elements() { return inputs_[3]; }
590 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
594 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
596 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
597 inputs_[0] = arguments;
602 LOperand* arguments() { return inputs_[0]; }
603 LOperand* length() { return inputs_[1]; }
604 LOperand* index() { return inputs_[2]; }
606 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
608 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
612 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
614 explicit LArgumentsLength(LOperand* elements) {
615 inputs_[0] = elements;
618 LOperand* elements() { return inputs_[0]; }
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
624 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
626 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
627 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
631 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
633 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
634 inputs_[0] = dividend;
638 LOperand* dividend() { return inputs_[0]; }
639 int32_t divisor() const { return divisor_; }
641 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
642 DECLARE_HYDROGEN_ACCESSOR(Mod)
649 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
651 LModByConstI(LOperand* dividend,
655 inputs_[0] = dividend;
661 LOperand* dividend() { return inputs_[0]; }
662 int32_t divisor() const { return divisor_; }
663 LOperand* temp1() { return temps_[0]; }
664 LOperand* temp2() { return temps_[1]; }
666 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
667 DECLARE_HYDROGEN_ACCESSOR(Mod)
674 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
676 LModI(LOperand* left, LOperand* right, LOperand* temp) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
684 LOperand* temp() { return temps_[0]; }
686 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
687 DECLARE_HYDROGEN_ACCESSOR(Mod)
691 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
693 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
694 inputs_[0] = dividend;
698 LOperand* dividend() { return inputs_[0]; }
699 int32_t divisor() const { return divisor_; }
701 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
702 DECLARE_HYDROGEN_ACCESSOR(Div)
709 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
711 LDivByConstI(LOperand* dividend,
715 inputs_[0] = dividend;
721 LOperand* dividend() { return inputs_[0]; }
722 int32_t divisor() const { return divisor_; }
723 LOperand* temp1() { return temps_[0]; }
724 LOperand* temp2() { return temps_[1]; }
726 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
727 DECLARE_HYDROGEN_ACCESSOR(Div)
734 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
736 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
737 inputs_[0] = dividend;
738 inputs_[1] = divisor;
742 LOperand* dividend() { return inputs_[0]; }
743 LOperand* divisor() { return inputs_[1]; }
744 LOperand* temp() { return temps_[0]; }
746 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
747 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
751 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
753 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
754 inputs_[0] = dividend;
758 LOperand* dividend() { return inputs_[0]; }
759 int32_t divisor() const { return divisor_; }
761 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
762 "flooring-div-by-power-of-2-i")
763 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
770 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
772 LFlooringDivByConstI(LOperand* dividend,
777 inputs_[0] = dividend;
784 LOperand* dividend() { return inputs_[0]; }
785 int32_t divisor() const { return divisor_; }
786 LOperand* temp1() { return temps_[0]; }
787 LOperand* temp2() { return temps_[1]; }
788 LOperand* temp3() { return temps_[2]; }
790 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
791 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
798 class LFlooringDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
800 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
801 inputs_[0] = dividend;
802 inputs_[1] = divisor;
806 LOperand* dividend() { return inputs_[0]; }
807 LOperand* divisor() { return inputs_[1]; }
808 LOperand* temp() { return temps_[0]; }
810 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
811 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
815 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
817 LMulI(LOperand* left, LOperand* right) {
822 LOperand* left() { return inputs_[0]; }
823 LOperand* right() { return inputs_[1]; }
825 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
826 DECLARE_HYDROGEN_ACCESSOR(Mul)
830 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
832 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
837 LOperand* left() { return inputs_[0]; }
838 LOperand* right() { return inputs_[1]; }
840 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
841 "compare-numeric-and-branch")
842 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
844 Token::Value op() const { return hydrogen()->token(); }
845 bool is_double() const {
846 return hydrogen()->representation().IsDouble();
849 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
853 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
855 explicit LMathFloor(LOperand* value) {
859 LOperand* value() { return inputs_[0]; }
861 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
862 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
866 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
868 explicit LMathRound(LOperand* value, LOperand* temp) {
873 LOperand* value() { return inputs_[0]; }
874 LOperand* temp() { return temps_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
877 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
881 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
883 explicit LMathAbs(LOperand* context, LOperand* value) {
884 inputs_[1] = context;
888 LOperand* context() { return inputs_[1]; }
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
892 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
896 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
898 explicit LMathLog(LOperand* value) {
902 LOperand* value() { return inputs_[0]; }
904 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
908 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
910 explicit LMathClz32(LOperand* value) {
914 LOperand* value() { return inputs_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
920 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
922 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
926 ExternalReference::InitializeMathExpData();
929 LOperand* value() { return inputs_[0]; }
930 LOperand* temp1() { return temps_[0]; }
931 LOperand* temp2() { return temps_[1]; }
933 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
937 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
939 explicit LMathSqrt(LOperand* value) {
943 LOperand* value() { return inputs_[0]; }
945 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
949 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
951 explicit LMathPowHalf(LOperand* value) {
955 LOperand* value() { return inputs_[0]; }
957 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
961 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
963 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
968 LOperand* left() { return inputs_[0]; }
969 LOperand* right() { return inputs_[1]; }
971 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
975 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
977 explicit LCmpHoleAndBranch(LOperand* object) {
981 LOperand* object() { return inputs_[0]; }
983 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
984 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
988 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
990 explicit LCompareMinusZeroAndBranch(LOperand* value) {
994 LOperand* value() { return inputs_[0]; }
996 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
997 "cmp-minus-zero-and-branch")
998 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1003 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1005 explicit LIsObjectAndBranch(LOperand* value) {
1009 LOperand* value() { return inputs_[0]; }
1011 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1012 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
1014 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1018 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1020 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1025 LOperand* value() { return inputs_[0]; }
1026 LOperand* temp() { return temps_[0]; }
1028 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1029 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1031 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1035 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1037 explicit LIsSmiAndBranch(LOperand* value) {
1041 LOperand* value() { return inputs_[0]; }
1043 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1044 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1046 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1050 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1052 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1057 LOperand* value() { return inputs_[0]; }
1058 LOperand* temp() { return temps_[0]; }
1060 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1061 "is-undetectable-and-branch")
1062 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1064 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1068 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1070 explicit LStringCompareAndBranch(LOperand* context,
1073 inputs_[0] = context;
1078 LOperand* context() { return inputs_[0]; }
1079 LOperand* left() { return inputs_[1]; }
1080 LOperand* right() { return inputs_[2]; }
1082 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1083 "string-compare-and-branch")
1084 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1086 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1088 Token::Value op() const { return hydrogen()->token(); }
1092 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1094 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1098 LOperand* value() { return inputs_[0]; }
1100 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1101 "has-instance-type-and-branch")
1102 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1104 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1108 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1110 explicit LGetCachedArrayIndex(LOperand* value) {
1114 LOperand* value() { return inputs_[0]; }
1116 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1117 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1121 class LHasCachedArrayIndexAndBranch V8_FINAL
1122 : public LControlInstruction<1, 0> {
1124 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1128 LOperand* value() { return inputs_[0]; }
1130 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1131 "has-cached-array-index-and-branch")
1132 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1134 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1138 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1140 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1146 LOperand* value() { return inputs_[0]; }
1147 LOperand* temp() { return temps_[0]; }
1148 LOperand* temp2() { return temps_[1]; }
1150 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1151 "class-of-test-and-branch")
1152 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1154 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1158 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1160 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1161 inputs_[0] = context;
1166 LOperand* context() { return inputs_[0]; }
1167 LOperand* left() { return inputs_[1]; }
1168 LOperand* right() { return inputs_[2]; }
1170 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1171 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1173 Token::Value op() const { return hydrogen()->token(); }
1177 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1179 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1180 inputs_[0] = context;
1185 LOperand* context() { return inputs_[0]; }
1186 LOperand* left() { return inputs_[1]; }
1187 LOperand* right() { return inputs_[2]; }
1189 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1193 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1195 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1196 inputs_[0] = context;
1201 LOperand* context() { return inputs_[0]; }
1202 LOperand* value() { return inputs_[1]; }
1203 LOperand* temp() { return temps_[0]; }
1205 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1206 "instance-of-known-global")
1207 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1209 Handle<JSFunction> function() const { return hydrogen()->function(); }
1210 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1211 return lazy_deopt_env_;
1213 virtual void SetDeferredLazyDeoptimizationEnvironment(
1214 LEnvironment* env) V8_OVERRIDE {
1215 lazy_deopt_env_ = env;
1219 LEnvironment* lazy_deopt_env_;
1223 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1225 LBoundsCheck(LOperand* index, LOperand* length) {
1227 inputs_[1] = length;
1230 LOperand* index() { return inputs_[0]; }
1231 LOperand* length() { return inputs_[1]; }
1233 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1234 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1238 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1240 LBitI(LOperand* left, LOperand* right) {
1245 LOperand* left() { return inputs_[0]; }
1246 LOperand* right() { return inputs_[1]; }
1248 Token::Value op() const { return hydrogen()->op(); }
1250 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1251 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1255 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1257 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1258 : op_(op), can_deopt_(can_deopt) {
1263 Token::Value op() const { return op_; }
1264 LOperand* left() { return inputs_[0]; }
1265 LOperand* right() { return inputs_[1]; }
1266 bool can_deopt() const { return can_deopt_; }
1268 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1276 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LSubI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Sub)
1291 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1293 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1294 DECLARE_HYDROGEN_ACCESSOR(Constant)
1296 int32_t value() const { return hydrogen()->Integer32Value(); }
1300 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1302 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1303 DECLARE_HYDROGEN_ACCESSOR(Constant)
1305 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1309 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1311 explicit LConstantD(LOperand* temp) {
1315 LOperand* temp() { return temps_[0]; }
1317 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1318 DECLARE_HYDROGEN_ACCESSOR(Constant)
1320 double value() const { return hydrogen()->DoubleValue(); }
1324 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1326 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1327 DECLARE_HYDROGEN_ACCESSOR(Constant)
1329 ExternalReference value() const {
1330 return hydrogen()->ExternalReferenceValue();
1335 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 Handle<Object> value(Isolate* isolate) const {
1341 return hydrogen()->handle(isolate);
1346 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1348 explicit LBranch(LOperand* value) {
1352 LOperand* value() { return inputs_[0]; }
1354 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1355 DECLARE_HYDROGEN_ACCESSOR(Branch)
1357 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1361 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1367 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1369 explicit LCmpMapAndBranch(LOperand* value) {
1373 LOperand* value() { return inputs_[0]; }
1375 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1376 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1378 Handle<Map> map() const { return hydrogen()->map().handle(); }
1382 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1384 explicit LMapEnumLength(LOperand* value) {
1388 LOperand* value() { return inputs_[0]; }
1390 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1394 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1396 LDateField(LOperand* date, Smi* index) : index_(index) {
1400 LOperand* date() { return inputs_[0]; }
1401 Smi* index() const { return index_; }
1403 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1404 DECLARE_HYDROGEN_ACCESSOR(DateField)
1411 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1413 LSeqStringGetChar(LOperand* string, LOperand* index) {
1414 inputs_[0] = string;
1418 LOperand* string() const { return inputs_[0]; }
1419 LOperand* index() const { return inputs_[1]; }
1421 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1422 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1426 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1428 LSeqStringSetChar(LOperand* context,
1432 inputs_[0] = context;
1433 inputs_[1] = string;
1438 LOperand* string() { return inputs_[1]; }
1439 LOperand* index() { return inputs_[2]; }
1440 LOperand* value() { return inputs_[3]; }
1442 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1443 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1447 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1449 LAddI(LOperand* left, LOperand* right) {
1454 LOperand* left() { return inputs_[0]; }
1455 LOperand* right() { return inputs_[1]; }
1457 static bool UseLea(HAdd* add) {
1458 return !add->CheckFlag(HValue::kCanOverflow) &&
1459 add->BetterLeftOperand()->UseCount() > 1;
1462 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1463 DECLARE_HYDROGEN_ACCESSOR(Add)
1467 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1469 LMathMinMax(LOperand* left, LOperand* right) {
1474 LOperand* left() { return inputs_[0]; }
1475 LOperand* right() { return inputs_[1]; }
1477 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1478 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1482 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LPower(LOperand* left, LOperand* right) {
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1493 DECLARE_HYDROGEN_ACCESSOR(Power)
1497 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1499 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1505 Token::Value op() const { return op_; }
1506 LOperand* left() { return inputs_[0]; }
1507 LOperand* right() { return inputs_[1]; }
1509 virtual Opcode opcode() const V8_OVERRIDE {
1510 return LInstruction::kArithmeticD;
1512 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1513 virtual const char* Mnemonic() const V8_OVERRIDE;
1520 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1522 LArithmeticT(Token::Value op,
1527 inputs_[0] = context;
1532 Token::Value op() const { return op_; }
1533 LOperand* context() { return inputs_[0]; }
1534 LOperand* left() { return inputs_[1]; }
1535 LOperand* right() { return inputs_[2]; }
1537 virtual Opcode opcode() const V8_OVERRIDE {
1538 return LInstruction::kArithmeticT;
1540 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1541 virtual const char* Mnemonic() const V8_OVERRIDE;
1548 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1550 explicit LReturn(LOperand* value,
1552 LOperand* parameter_count) {
1554 inputs_[1] = context;
1555 inputs_[2] = parameter_count;
1558 LOperand* value() { return inputs_[0]; }
1559 LOperand* context() { return inputs_[1]; }
1561 bool has_constant_parameter_count() {
1562 return parameter_count()->IsConstantOperand();
1564 LConstantOperand* constant_parameter_count() {
1565 ASSERT(has_constant_parameter_count());
1566 return LConstantOperand::cast(parameter_count());
1568 LOperand* parameter_count() { return inputs_[2]; }
1570 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1571 DECLARE_HYDROGEN_ACCESSOR(Return)
1575 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1577 explicit LLoadNamedField(LOperand* object) {
1578 inputs_[0] = object;
1581 LOperand* object() { return inputs_[0]; }
1583 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1588 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1590 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1591 inputs_[0] = context;
1592 inputs_[1] = object;
1595 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1596 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1598 LOperand* context() { return inputs_[0]; }
1599 LOperand* object() { return inputs_[1]; }
1600 Handle<Object> name() const { return hydrogen()->name(); }
1604 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1606 explicit LLoadFunctionPrototype(LOperand* function) {
1607 inputs_[0] = function;
1610 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1611 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1613 LOperand* function() { return inputs_[0]; }
1617 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1619 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1620 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1622 Heap::RootListIndex index() const { return hydrogen()->index(); }
1626 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1628 LLoadKeyed(LOperand* elements, LOperand* key) {
1629 inputs_[0] = elements;
1633 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1634 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1636 bool is_external() const {
1637 return hydrogen()->is_external();
1639 bool is_fixed_typed_array() const {
1640 return hydrogen()->is_fixed_typed_array();
1642 bool is_typed_elements() const {
1643 return is_external() || is_fixed_typed_array();
1645 LOperand* elements() { return inputs_[0]; }
1646 LOperand* key() { return inputs_[1]; }
1647 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1648 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1649 ElementsKind elements_kind() const {
1650 return hydrogen()->elements_kind();
1655 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1657 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1658 inputs_[0] = context;
1663 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1665 LOperand* context() { return inputs_[0]; }
1666 LOperand* object() { return inputs_[1]; }
1667 LOperand* key() { return inputs_[2]; }
1671 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1673 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1674 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1678 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1680 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1681 inputs_[0] = context;
1682 inputs_[1] = global_object;
1685 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1686 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1688 LOperand* context() { return inputs_[0]; }
1689 LOperand* global_object() { return inputs_[1]; }
1690 Handle<Object> name() const { return hydrogen()->name(); }
1691 bool for_typeof() const { return hydrogen()->for_typeof(); }
1695 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1697 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1702 LOperand* value() { return inputs_[0]; }
1703 LOperand* temp() { return temps_[0]; }
1705 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1706 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1710 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1712 explicit LLoadContextSlot(LOperand* context) {
1713 inputs_[0] = context;
1716 LOperand* context() { return inputs_[0]; }
1718 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1719 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1721 int slot_index() { return hydrogen()->slot_index(); }
1723 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1727 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1729 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1730 inputs_[0] = context;
1735 LOperand* context() { return inputs_[0]; }
1736 LOperand* value() { return inputs_[1]; }
1737 LOperand* temp() { return temps_[0]; }
1739 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1740 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1742 int slot_index() { return hydrogen()->slot_index(); }
1744 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1748 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1750 explicit LPushArgument(LOperand* value) {
1754 LOperand* value() { return inputs_[0]; }
1756 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1760 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1762 explicit LDrop(int count) : count_(count) { }
1764 int count() const { return count_; }
1766 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1773 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1775 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1776 inputs_[0] = function;
1777 temps_[0] = code_object;
1780 LOperand* function() { return inputs_[0]; }
1781 LOperand* code_object() { return temps_[0]; }
1783 virtual void PrintDataTo(StringStream* stream);
1785 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1786 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1790 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1792 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1793 inputs_[0] = base_object;
1794 inputs_[1] = offset;
1797 LOperand* base_object() const { return inputs_[0]; }
1798 LOperand* offset() const { return inputs_[1]; }
1800 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1802 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1806 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1808 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1809 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1813 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1815 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1816 DECLARE_HYDROGEN_ACCESSOR(Context)
1820 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1822 explicit LDeclareGlobals(LOperand* context) {
1823 inputs_[0] = context;
1826 LOperand* context() { return inputs_[0]; }
1828 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1829 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1833 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1835 explicit LCallJSFunction(LOperand* function) {
1836 inputs_[0] = function;
1839 LOperand* function() { return inputs_[0]; }
1841 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1842 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1844 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1846 int arity() const { return hydrogen()->argument_count() - 1; }
1850 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1852 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1853 ZoneList<LOperand*>& operands,
1855 : inputs_(descriptor->environment_length() + 1, zone) {
1856 ASSERT(descriptor->environment_length() + 1 == operands.length());
1857 inputs_.AddAll(operands, zone);
1860 LOperand* target() const { return inputs_[0]; }
1863 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1864 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1866 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1868 int arity() const { return hydrogen()->argument_count() - 1; }
1870 ZoneList<LOperand*> inputs_;
1872 // Iterator support.
1873 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1874 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1876 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1877 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1881 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1883 LInvokeFunction(LOperand* context, LOperand* function) {
1884 inputs_[0] = context;
1885 inputs_[1] = function;
1888 LOperand* context() { return inputs_[0]; }
1889 LOperand* function() { return inputs_[1]; }
1891 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1892 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1894 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1896 int arity() const { return hydrogen()->argument_count() - 1; }
1900 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1902 LCallFunction(LOperand* context, LOperand* function) {
1903 inputs_[0] = context;
1904 inputs_[1] = function;
1907 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1908 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1910 LOperand* context() { return inputs_[0]; }
1911 LOperand* function() { return inputs_[1]; }
1912 int arity() const { return hydrogen()->argument_count() - 1; }
1916 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1918 LCallNew(LOperand* context, LOperand* constructor) {
1919 inputs_[0] = context;
1920 inputs_[1] = constructor;
1923 LOperand* context() { return inputs_[0]; }
1924 LOperand* constructor() { return inputs_[1]; }
1926 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1927 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1929 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1931 int arity() const { return hydrogen()->argument_count() - 1; }
1935 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1937 LCallNewArray(LOperand* context, LOperand* constructor) {
1938 inputs_[0] = context;
1939 inputs_[1] = constructor;
1942 LOperand* context() { return inputs_[0]; }
1943 LOperand* constructor() { return inputs_[1]; }
1945 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1946 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1948 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1950 int arity() const { return hydrogen()->argument_count() - 1; }
1954 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1956 explicit LCallRuntime(LOperand* context) {
1957 inputs_[0] = context;
1960 LOperand* context() { return inputs_[0]; }
1962 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1963 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1965 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1966 return save_doubles() == kDontSaveFPRegs;
1969 const Runtime::Function* function() const { return hydrogen()->function(); }
1970 int arity() const { return hydrogen()->argument_count(); }
1971 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1975 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1977 explicit LInteger32ToDouble(LOperand* value) {
1981 LOperand* value() { return inputs_[0]; }
1983 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1987 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1989 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1994 LOperand* value() { return inputs_[0]; }
1995 LOperand* temp() { return temps_[0]; }
1997 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2001 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2003 explicit LNumberTagI(LOperand* value) {
2007 LOperand* value() { return inputs_[0]; }
2009 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2013 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
2015 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
2021 LOperand* value() { return inputs_[0]; }
2022 LOperand* temp1() { return temps_[0]; }
2023 LOperand* temp2() { return temps_[1]; }
2025 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2029 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2031 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2036 LOperand* value() { return inputs_[0]; }
2037 LOperand* temp() { return temps_[0]; }
2039 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2040 DECLARE_HYDROGEN_ACCESSOR(Change)
2044 // Sometimes truncating conversion from a tagged value to an int32.
2045 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2047 explicit LDoubleToI(LOperand* value) {
2051 LOperand* value() { return inputs_[0]; }
2053 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2054 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2056 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2060 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2062 explicit LDoubleToSmi(LOperand* value) {
2066 LOperand* value() { return inputs_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2069 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2073 // Truncating conversion from a tagged value to an int32.
2074 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2076 LTaggedToI(LOperand* value, LOperand* temp) {
2081 LOperand* value() { return inputs_[0]; }
2082 LOperand* temp() { return temps_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2085 DECLARE_HYDROGEN_ACCESSOR(Change)
2087 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2091 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2093 explicit LSmiTag(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2100 DECLARE_HYDROGEN_ACCESSOR(Change)
2104 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2106 explicit LNumberUntagD(LOperand* value) {
2110 LOperand* value() { return inputs_[0]; }
2112 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2113 DECLARE_HYDROGEN_ACCESSOR(Change);
2117 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2119 LSmiUntag(LOperand* value, bool needs_check)
2120 : needs_check_(needs_check) {
2124 LOperand* value() { return inputs_[0]; }
2125 bool needs_check() const { return needs_check_; }
2127 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2134 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2136 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2137 inputs_[0] = object;
2142 LOperand* object() { return inputs_[0]; }
2143 LOperand* value() { return inputs_[1]; }
2144 LOperand* temp() { return temps_[0]; }
2146 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2147 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2149 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2151 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2152 Representation representation() const {
2153 return hydrogen()->field_representation();
2158 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2160 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2161 inputs_[0] = context;
2162 inputs_[1] = object;
2166 LOperand* context() { return inputs_[0]; }
2167 LOperand* object() { return inputs_[1]; }
2168 LOperand* value() { return inputs_[2]; }
2170 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2171 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2173 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2175 Handle<Object> name() const { return hydrogen()->name(); }
2176 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2180 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2182 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2183 inputs_[0] = object;
2188 bool is_external() const { return hydrogen()->is_external(); }
2189 bool is_fixed_typed_array() const {
2190 return hydrogen()->is_fixed_typed_array();
2192 bool is_typed_elements() const {
2193 return is_external() || is_fixed_typed_array();
2195 LOperand* elements() { return inputs_[0]; }
2196 LOperand* key() { return inputs_[1]; }
2197 LOperand* value() { return inputs_[2]; }
2198 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2200 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2201 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2203 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2204 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2205 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2209 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2211 LStoreKeyedGeneric(LOperand* context,
2215 inputs_[0] = context;
2216 inputs_[1] = object;
2221 LOperand* context() { return inputs_[0]; }
2222 LOperand* object() { return inputs_[1]; }
2223 LOperand* key() { return inputs_[2]; }
2224 LOperand* value() { return inputs_[3]; }
2226 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2227 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2229 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2231 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2235 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2237 LTransitionElementsKind(LOperand* object,
2239 LOperand* new_map_temp,
2241 inputs_[0] = object;
2242 inputs_[1] = context;
2243 temps_[0] = new_map_temp;
2247 LOperand* object() { return inputs_[0]; }
2248 LOperand* context() { return inputs_[1]; }
2249 LOperand* new_map_temp() { return temps_[0]; }
2250 LOperand* temp() { return temps_[1]; }
2252 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2253 "transition-elements-kind")
2254 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2256 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2258 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2259 Handle<Map> transitioned_map() {
2260 return hydrogen()->transitioned_map().handle();
2262 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2263 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2267 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2269 LTrapAllocationMemento(LOperand* object,
2271 inputs_[0] = object;
2275 LOperand* object() { return inputs_[0]; }
2276 LOperand* temp() { return temps_[0]; }
2278 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2279 "trap-allocation-memento")
2283 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2285 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2286 inputs_[0] = context;
2291 LOperand* context() { return inputs_[0]; }
2292 LOperand* left() { return inputs_[1]; }
2293 LOperand* right() { return inputs_[2]; }
2295 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2296 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2300 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2302 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2303 inputs_[0] = context;
2304 inputs_[1] = string;
2308 LOperand* context() { return inputs_[0]; }
2309 LOperand* string() { return inputs_[1]; }
2310 LOperand* index() { return inputs_[2]; }
2312 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2313 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2317 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2319 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2320 inputs_[0] = context;
2321 inputs_[1] = char_code;
2324 LOperand* context() { return inputs_[0]; }
2325 LOperand* char_code() { return inputs_[1]; }
2327 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2328 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2332 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2334 explicit LCheckValue(LOperand* value) {
2338 LOperand* value() { return inputs_[0]; }
2340 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2341 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2345 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2347 explicit LCheckInstanceType(LOperand* value) {
2351 LOperand* value() { return inputs_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2354 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2358 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2360 explicit LCheckMaps(LOperand* value) {
2364 LOperand* value() { return inputs_[0]; }
2366 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2367 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2371 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2373 explicit LCheckSmi(LOperand* value) {
2377 LOperand* value() { return inputs_[0]; }
2379 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2383 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2385 explicit LClampDToUint8(LOperand* unclamped) {
2386 inputs_[0] = unclamped;
2389 LOperand* unclamped() { return inputs_[0]; }
2391 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2395 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2397 explicit LClampIToUint8(LOperand* unclamped) {
2398 inputs_[0] = unclamped;
2401 LOperand* unclamped() { return inputs_[0]; }
2403 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2407 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2409 LClampTToUint8(LOperand* unclamped,
2410 LOperand* temp_xmm) {
2411 inputs_[0] = unclamped;
2412 temps_[0] = temp_xmm;
2415 LOperand* unclamped() { return inputs_[0]; }
2416 LOperand* temp_xmm() { return temps_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2422 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2424 explicit LCheckNonSmi(LOperand* value) {
2428 LOperand* value() { return inputs_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2431 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2435 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2437 explicit LDoubleBits(LOperand* value) {
2441 LOperand* value() { return inputs_[0]; }
2443 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2444 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2448 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2450 LConstructDouble(LOperand* hi, LOperand* lo) {
2455 LOperand* hi() { return inputs_[0]; }
2456 LOperand* lo() { return inputs_[1]; }
2458 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2462 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2464 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2465 inputs_[0] = context;
2470 LOperand* context() { return inputs_[0]; }
2471 LOperand* size() { return inputs_[1]; }
2472 LOperand* temp() { return temps_[0]; }
2474 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2475 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2479 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2481 explicit LRegExpLiteral(LOperand* context) {
2482 inputs_[0] = context;
2485 LOperand* context() { return inputs_[0]; }
2487 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2488 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2492 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2494 explicit LFunctionLiteral(LOperand* context) {
2495 inputs_[0] = context;
2498 LOperand* context() { return inputs_[0]; }
2500 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2501 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2505 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2507 explicit LToFastProperties(LOperand* value) {
2511 LOperand* value() { return inputs_[0]; }
2513 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2514 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2518 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2520 LTypeof(LOperand* context, LOperand* value) {
2521 inputs_[0] = context;
2525 LOperand* context() { return inputs_[0]; }
2526 LOperand* value() { return inputs_[1]; }
2528 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2532 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2534 explicit LTypeofIsAndBranch(LOperand* value) {
2538 LOperand* value() { return inputs_[0]; }
2540 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2541 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2543 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2545 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2549 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2551 explicit LIsConstructCallAndBranch(LOperand* temp) {
2555 LOperand* temp() { return temps_[0]; }
2557 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2558 "is-construct-call-and-branch")
2559 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2563 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2567 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2570 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2574 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2576 explicit LStackCheck(LOperand* context) {
2577 inputs_[0] = context;
2580 LOperand* context() { return inputs_[0]; }
2582 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2583 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2585 Label* done_label() { return &done_label_; }
2592 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2594 LForInPrepareMap(LOperand* context, LOperand* object) {
2595 inputs_[0] = context;
2596 inputs_[1] = object;
2599 LOperand* context() { return inputs_[0]; }
2600 LOperand* object() { return inputs_[1]; }
2602 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2606 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2608 explicit LForInCacheArray(LOperand* map) {
2612 LOperand* map() { return inputs_[0]; }
2614 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2617 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2622 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2624 LCheckMapValue(LOperand* value, LOperand* map) {
2629 LOperand* value() { return inputs_[0]; }
2630 LOperand* map() { return inputs_[1]; }
2632 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2636 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2638 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2639 inputs_[0] = object;
2643 LOperand* object() { return inputs_[0]; }
2644 LOperand* index() { return inputs_[1]; }
2646 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2650 class LChunkBuilder;
2651 class LPlatformChunk V8_FINAL : public LChunk {
2653 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2654 : LChunk(info, graph),
2655 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2657 int GetNextSpillIndex(RegisterKind kind);
2658 LOperand* GetNextSpillSlot(RegisterKind kind);
2659 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2660 bool IsDehoistedKey(HValue* value) {
2661 return dehoisted_key_ids_.Contains(value->id());
2665 BitVector dehoisted_key_ids_;
2669 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2671 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2672 : LChunkBuilderBase(graph->zone()),
2677 current_instruction_(NULL),
2678 current_block_(NULL),
2680 allocator_(allocator) { }
2682 // Build the sequence for the graph.
2683 LPlatformChunk* Build();
2685 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2687 // Declare methods that deal with the individual node types.
2688 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2689 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2692 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2693 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2694 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2695 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2696 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2697 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2698 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2699 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2700 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2701 LInstruction* DoDivByConstI(HDiv* instr);
2702 LInstruction* DoDivI(HDiv* instr);
2703 LInstruction* DoModByPowerOf2I(HMod* instr);
2704 LInstruction* DoModByConstI(HMod* instr);
2705 LInstruction* DoModI(HMod* instr);
2706 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2707 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2708 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2718 LPlatformChunk* chunk() const { return chunk_; }
2719 CompilationInfo* info() const { return info_; }
2720 HGraph* graph() const { return graph_; }
2722 bool is_unused() const { return status_ == UNUSED; }
2723 bool is_building() const { return status_ == BUILDING; }
2724 bool is_done() const { return status_ == DONE; }
2725 bool is_aborted() const { return status_ == ABORTED; }
2727 void Abort(BailoutReason reason);
2729 // Methods for getting operands for Use / Define / Temp.
2730 LUnallocated* ToUnallocated(Register reg);
2731 LUnallocated* ToUnallocated(XMMRegister reg);
2733 // Methods for setting up define-use relationships.
2734 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2735 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2736 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2737 XMMRegister fixed_register);
2739 // A value that is guaranteed to be allocated to a register.
2740 // Operand created by UseRegister is guaranteed to be live until the end of
2741 // instruction. This means that register allocator will not reuse it's
2742 // register for any other operand inside instruction.
2743 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2744 // instruction start. Register allocator is free to assign the same register
2745 // to some other operand used inside instruction (i.e. temporary or
2747 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2748 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2750 // An input operand in a register that may be trashed.
2751 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2753 // An input operand in a register that may be trashed or a constant operand.
2754 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2756 // An input operand in a register or stack slot.
2757 MUST_USE_RESULT LOperand* Use(HValue* value);
2758 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2760 // An input operand in a register, stack slot or a constant operand.
2761 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2762 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2764 // An input operand in a register or a constant operand.
2765 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2766 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2768 // An input operand in a constant operand.
2769 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2771 // An input operand in register, stack slot or a constant operand.
2772 // Will not be moved to a register even if one is freely available.
2773 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2775 // Temporary operand that must be in a register.
2776 MUST_USE_RESULT LUnallocated* TempRegister();
2777 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2778 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2780 // Methods for setting up define-use relationships.
2781 // Return the same instruction that they are passed.
2782 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2783 LUnallocated* result);
2784 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2785 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2787 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2788 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2790 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2792 // Assigns an environment to an instruction. An instruction which can
2793 // deoptimize must have an environment.
2794 LInstruction* AssignEnvironment(LInstruction* instr);
2795 // Assigns a pointer map to an instruction. An instruction which can
2796 // trigger a GC or a lazy deoptimization must have a pointer map.
2797 LInstruction* AssignPointerMap(LInstruction* instr);
2799 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2801 // Marks a call for the register allocator. Assigns a pointer map to
2802 // support GC and lazy deoptimization. Assigns an environment to support
2803 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2804 LInstruction* MarkAsCall(
2805 LInstruction* instr,
2806 HInstruction* hinstr,
2807 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2809 void VisitInstruction(HInstruction* current);
2811 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2812 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2813 LInstruction* DoArithmeticD(Token::Value op,
2814 HArithmeticBinaryOperation* instr);
2815 LInstruction* DoArithmeticT(Token::Value op,
2816 HBinaryOperation* instr);
2817 void FindDehoistedKeyDefinitions(HValue* candidate);
2819 LPlatformChunk* chunk_;
2820 CompilationInfo* info_;
2821 HGraph* const graph_;
2823 HInstruction* current_instruction_;
2824 HBasicBlock* current_block_;
2825 HBasicBlock* next_block_;
2826 LAllocator* allocator_;
2828 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2831 #undef DECLARE_HYDROGEN_ACCESSOR
2832 #undef DECLARE_CONCRETE_INSTRUCTION
2834 } } // namespace v8::int
2836 #endif // V8_X64_LITHIUM_X64_H_