1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_X64_LITHIUM_X64_H_
29 #define V8_X64_LITHIUM_X64_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
56 V(CallWithDescriptor) \
62 V(CheckInstanceType) \
71 V(ClassOfTestAndBranch) \
72 V(CompareMinusZeroAndBranch) \
73 V(CompareNumericAndBranch) \
74 V(CmpObjectEqAndBranch) \
98 V(FlooringDivByConstI) \
99 V(FlooringDivByPowerOf2I) \
103 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
113 V(IsConstructCallAndBranch) \
114 V(IsObjectAndBranch) \
115 V(IsStringAndBranch) \
117 V(IsUndetectableAndBranch) \
122 V(LoadFieldByIndex) \
123 V(LoadFunctionPrototype) \
125 V(LoadGlobalGeneric) \
127 V(LoadKeyedGeneric) \
129 V(LoadNamedGeneric) \
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) \
184 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
185 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
186 return LInstruction::k##type; \
188 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
189 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
192 static L##type* cast(LInstruction* instr) { \
193 ASSERT(instr->Is##type()); \
194 return reinterpret_cast<L##type*>(instr); \
198 #define DECLARE_HYDROGEN_ACCESSOR(type) \
199 H##type* hydrogen() const { \
200 return H##type::cast(hydrogen_value()); \
204 class LInstruction : public ZoneObject {
207 : environment_(NULL),
208 hydrogen_value_(NULL),
209 bit_field_(IsCallBits::encode(false)) {
212 virtual ~LInstruction() {}
214 virtual void CompileToNative(LCodeGen* generator) = 0;
215 virtual const char* Mnemonic() const = 0;
216 virtual void PrintTo(StringStream* stream);
217 virtual void PrintDataTo(StringStream* stream);
218 virtual void PrintOutputOperandTo(StringStream* stream);
221 // Declare a unique enum value for each instruction.
222 #define DECLARE_OPCODE(type) k##type,
223 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
224 kNumberOfInstructions
225 #undef DECLARE_OPCODE
228 virtual Opcode opcode() const = 0;
230 // Declare non-virtual type testers for all leaf IR classes.
231 #define DECLARE_PREDICATE(type) \
232 bool Is##type() const { return opcode() == k##type; }
233 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
234 #undef DECLARE_PREDICATE
236 // Declare virtual predicates for instructions that don't have
238 virtual bool IsGap() const { return false; }
240 virtual bool IsControl() const { return false; }
242 void set_environment(LEnvironment* env) { environment_ = env; }
243 LEnvironment* environment() const { return environment_; }
244 bool HasEnvironment() const { return environment_ != NULL; }
246 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
247 LPointerMap* pointer_map() const { return pointer_map_.get(); }
248 bool HasPointerMap() const { return pointer_map_.is_set(); }
250 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
251 HValue* hydrogen_value() const { return hydrogen_value_; }
253 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
254 bool IsCall() const { return IsCallBits::decode(bit_field_); }
256 // Interface to the register allocator and iterators.
257 bool ClobbersTemps() const { return IsCall(); }
258 bool ClobbersRegisters() const { return IsCall(); }
259 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
261 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
263 // Interface to the register allocator and iterators.
264 bool IsMarkedAsCall() const { return IsCall(); }
266 virtual bool HasResult() const = 0;
267 virtual LOperand* result() const = 0;
269 LOperand* FirstInput() { return InputAt(0); }
270 LOperand* Output() { return HasResult() ? result() : NULL; }
272 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
280 friend class InputIterator;
281 virtual int InputCount() = 0;
282 virtual LOperand* InputAt(int i) = 0;
284 friend class TempIterator;
285 virtual int TempCount() = 0;
286 virtual LOperand* TempAt(int i) = 0;
288 class IsCallBits: public BitField<bool, 0, 1> {};
290 LEnvironment* environment_;
291 SetOncePointer<LPointerMap> pointer_map_;
292 HValue* hydrogen_value_;
297 // R = number of result operands (0 or 1).
299 class LTemplateResultInstruction : public LInstruction {
301 // Allow 0 or 1 output operands.
302 STATIC_ASSERT(R == 0 || R == 1);
303 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
304 return R != 0 && result() != NULL;
306 void set_result(LOperand* operand) { results_[0] = operand; }
307 LOperand* result() const { return results_[0]; }
310 EmbeddedContainer<LOperand*, R> results_;
314 // R = number of result operands (0 or 1).
315 // I = number of input operands.
316 // T = number of temporary operands.
317 template<int R, int I, int T>
318 class LTemplateInstruction : public LTemplateResultInstruction<R> {
320 EmbeddedContainer<LOperand*, I> inputs_;
321 EmbeddedContainer<LOperand*, T> temps_;
325 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
326 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
328 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
329 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
333 class LGap : public LTemplateInstruction<0, 0, 0> {
335 explicit LGap(HBasicBlock* block)
337 parallel_moves_[BEFORE] = NULL;
338 parallel_moves_[START] = NULL;
339 parallel_moves_[END] = NULL;
340 parallel_moves_[AFTER] = NULL;
343 // Can't use the DECLARE-macro here because of sub-classes.
344 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
345 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
346 static LGap* cast(LInstruction* instr) {
347 ASSERT(instr->IsGap());
348 return reinterpret_cast<LGap*>(instr);
351 bool IsRedundant() const;
353 HBasicBlock* block() const { return block_; }
360 FIRST_INNER_POSITION = BEFORE,
361 LAST_INNER_POSITION = AFTER
364 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
366 if (parallel_moves_[pos] == NULL) {
367 parallel_moves_[pos] = new(zone) LParallelMove(zone);
369 return parallel_moves_[pos];
372 LParallelMove* GetParallelMove(InnerPosition pos) {
373 return parallel_moves_[pos];
377 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
382 class LInstructionGap V8_FINAL : public LGap {
384 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
386 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
387 return !IsRedundant();
390 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
394 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
396 explicit LGoto(HBasicBlock* block) : block_(block) { }
398 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
399 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
400 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
401 virtual bool IsControl() const V8_OVERRIDE { return true; }
403 int block_id() const { return block_->block_id(); }
410 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
412 LLazyBailout() : gap_instructions_size_(0) { }
414 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
416 void set_gap_instructions_size(int gap_instructions_size) {
417 gap_instructions_size_ = gap_instructions_size;
419 int gap_instructions_size() { return gap_instructions_size_; }
422 int gap_instructions_size_;
426 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
428 explicit LDummy() { }
429 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
433 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
435 explicit LDummyUse(LOperand* value) {
438 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
442 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
444 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
445 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
449 class LLabel V8_FINAL : public LGap {
451 explicit LLabel(HBasicBlock* block)
452 : LGap(block), replacement_(NULL) { }
454 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
457 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
459 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
461 int block_id() const { return block()->block_id(); }
462 bool is_loop_header() const { return block()->IsLoopHeader(); }
463 bool is_osr_entry() const { return block()->is_osr_entry(); }
464 Label* label() { return &label_; }
465 LLabel* replacement() const { return replacement_; }
466 void set_replacement(LLabel* label) { replacement_ = label; }
467 bool HasReplacement() const { return replacement_ != NULL; }
471 LLabel* replacement_;
475 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
477 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
480 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
484 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
486 explicit LCallStub(LOperand* context) {
487 inputs_[0] = context;
490 LOperand* context() { return inputs_[0]; }
492 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
493 DECLARE_HYDROGEN_ACCESSOR(CallStub)
497 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
499 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
502 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
506 template<int I, int T>
507 class LControlInstruction : public LTemplateInstruction<0, I, T> {
509 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
511 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
513 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
514 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
516 int TrueDestination(LChunk* chunk) {
517 return chunk->LookupDestination(true_block_id());
519 int FalseDestination(LChunk* chunk) {
520 return chunk->LookupDestination(false_block_id());
523 Label* TrueLabel(LChunk* chunk) {
524 if (true_label_ == NULL) {
525 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
529 Label* FalseLabel(LChunk* chunk) {
530 if (false_label_ == NULL) {
531 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
537 int true_block_id() { return SuccessorAt(0)->block_id(); }
538 int false_block_id() { return SuccessorAt(1)->block_id(); }
541 HControlInstruction* hydrogen() {
542 return HControlInstruction::cast(this->hydrogen_value());
550 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
552 LWrapReceiver(LOperand* receiver, LOperand* function) {
553 inputs_[0] = receiver;
554 inputs_[1] = function;
557 LOperand* receiver() { return inputs_[0]; }
558 LOperand* function() { return inputs_[1]; }
560 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
561 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
565 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
567 LApplyArguments(LOperand* function,
570 LOperand* elements) {
571 inputs_[0] = function;
572 inputs_[1] = receiver;
574 inputs_[3] = elements;
577 LOperand* function() { return inputs_[0]; }
578 LOperand* receiver() { return inputs_[1]; }
579 LOperand* length() { return inputs_[2]; }
580 LOperand* elements() { return inputs_[3]; }
582 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
586 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
588 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
589 inputs_[0] = arguments;
594 LOperand* arguments() { return inputs_[0]; }
595 LOperand* length() { return inputs_[1]; }
596 LOperand* index() { return inputs_[2]; }
598 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
600 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
604 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
606 explicit LArgumentsLength(LOperand* elements) {
607 inputs_[0] = elements;
610 LOperand* elements() { return inputs_[0]; }
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
616 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
618 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
619 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
623 class LModByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
625 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
626 inputs_[0] = dividend;
630 LOperand* dividend() { return inputs_[0]; }
631 int32_t divisor() const { return divisor_; }
633 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
634 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LModByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
643 LModByConstI(LOperand* dividend,
647 inputs_[0] = dividend;
653 LOperand* dividend() { return inputs_[0]; }
654 int32_t divisor() const { return divisor_; }
655 LOperand* temp1() { return temps_[0]; }
656 LOperand* temp2() { return temps_[1]; }
658 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
659 DECLARE_HYDROGEN_ACCESSOR(Mod)
666 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
668 LModI(LOperand* left, LOperand* right, LOperand* temp) {
674 LOperand* left() { return inputs_[0]; }
675 LOperand* right() { return inputs_[1]; }
676 LOperand* temp() { return temps_[0]; }
678 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
679 DECLARE_HYDROGEN_ACCESSOR(Mod)
683 class LDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
685 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
686 inputs_[0] = dividend;
690 LOperand* dividend() { return inputs_[0]; }
691 int32_t divisor() const { return divisor_; }
693 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
694 DECLARE_HYDROGEN_ACCESSOR(Div)
701 class LDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 2> {
703 LDivByConstI(LOperand* dividend,
707 inputs_[0] = dividend;
713 LOperand* dividend() { return inputs_[0]; }
714 int32_t divisor() const { return divisor_; }
715 LOperand* temp1() { return temps_[0]; }
716 LOperand* temp2() { return temps_[1]; }
718 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
719 DECLARE_HYDROGEN_ACCESSOR(Div)
726 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
728 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
734 LOperand* left() { return inputs_[0]; }
735 LOperand* right() { return inputs_[1]; }
736 LOperand* temp() { return temps_[0]; }
738 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
739 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
743 class LFlooringDivByPowerOf2I V8_FINAL : public LTemplateInstruction<1, 1, 0> {
745 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
746 inputs_[0] = dividend;
750 LOperand* dividend() { return inputs_[0]; }
751 int32_t divisor() const { return divisor_; }
753 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
754 "flooring-div-by-power-of-2-i")
755 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
762 class LFlooringDivByConstI V8_FINAL : public LTemplateInstruction<1, 1, 3> {
764 LFlooringDivByConstI(LOperand* dividend,
769 inputs_[0] = dividend;
776 LOperand* dividend() { return inputs_[0]; }
777 int32_t divisor() const { return divisor_; }
778 LOperand* temp1() { return temps_[0]; }
779 LOperand* temp2() { return temps_[1]; }
780 LOperand* temp3() { return temps_[2]; }
782 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
783 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
790 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
792 LMulI(LOperand* left, LOperand* right) {
797 LOperand* left() { return inputs_[0]; }
798 LOperand* right() { return inputs_[1]; }
800 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
801 DECLARE_HYDROGEN_ACCESSOR(Mul)
805 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
807 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
812 LOperand* left() { return inputs_[0]; }
813 LOperand* right() { return inputs_[1]; }
815 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
816 "compare-numeric-and-branch")
817 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
819 Token::Value op() const { return hydrogen()->token(); }
820 bool is_double() const {
821 return hydrogen()->representation().IsDouble();
824 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
828 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
830 explicit LMathFloor(LOperand* value) {
834 LOperand* value() { return inputs_[0]; }
836 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
837 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
841 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 1> {
843 explicit LMathRound(LOperand* value, LOperand* temp) {
848 LOperand* value() { return inputs_[0]; }
849 LOperand* temp() { return temps_[0]; }
851 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
852 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
856 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
858 explicit LMathAbs(LOperand* context, LOperand* value) {
859 inputs_[1] = context;
863 LOperand* context() { return inputs_[1]; }
864 LOperand* value() { return inputs_[0]; }
866 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
867 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
871 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
873 explicit LMathLog(LOperand* value) {
877 LOperand* value() { return inputs_[0]; }
879 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
883 class LMathClz32 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathClz32(LOperand* value) {
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
895 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
897 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
901 ExternalReference::InitializeMathExpData();
904 LOperand* value() { return inputs_[0]; }
905 LOperand* temp1() { return temps_[0]; }
906 LOperand* temp2() { return temps_[1]; }
908 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
912 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
914 explicit LMathSqrt(LOperand* value) {
918 LOperand* value() { return inputs_[0]; }
920 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
924 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
926 explicit LMathPowHalf(LOperand* value) {
930 LOperand* value() { return inputs_[0]; }
932 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
936 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
938 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
943 LOperand* left() { return inputs_[0]; }
944 LOperand* right() { return inputs_[1]; }
946 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
950 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
952 explicit LCmpHoleAndBranch(LOperand* object) {
956 LOperand* object() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
959 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
963 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
965 explicit LCompareMinusZeroAndBranch(LOperand* value) {
969 LOperand* value() { return inputs_[0]; }
971 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
972 "cmp-minus-zero-and-branch")
973 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
978 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
980 explicit LIsObjectAndBranch(LOperand* value) {
984 LOperand* value() { return inputs_[0]; }
986 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
987 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
989 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
993 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
995 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
1000 LOperand* value() { return inputs_[0]; }
1001 LOperand* temp() { return temps_[0]; }
1003 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1004 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1006 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1010 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1012 explicit LIsSmiAndBranch(LOperand* value) {
1016 LOperand* value() { return inputs_[0]; }
1018 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1019 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1021 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1025 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
1027 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1032 LOperand* value() { return inputs_[0]; }
1033 LOperand* temp() { return temps_[0]; }
1035 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1036 "is-undetectable-and-branch")
1037 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1039 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1043 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
1045 explicit LStringCompareAndBranch(LOperand* context,
1048 inputs_[0] = context;
1053 LOperand* context() { return inputs_[0]; }
1054 LOperand* left() { return inputs_[1]; }
1055 LOperand* right() { return inputs_[2]; }
1057 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1058 "string-compare-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1061 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1063 Token::Value op() const { return hydrogen()->token(); }
1067 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1069 explicit LHasInstanceTypeAndBranch(LOperand* value) {
1073 LOperand* value() { return inputs_[0]; }
1075 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1076 "has-instance-type-and-branch")
1077 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1079 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1083 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1085 explicit LGetCachedArrayIndex(LOperand* value) {
1089 LOperand* value() { return inputs_[0]; }
1091 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1092 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1096 class LHasCachedArrayIndexAndBranch V8_FINAL
1097 : public LControlInstruction<1, 0> {
1099 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1103 LOperand* value() { return inputs_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1106 "has-cached-array-index-and-branch")
1107 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1109 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1113 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1115 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1121 LOperand* value() { return inputs_[0]; }
1122 LOperand* temp() { return temps_[0]; }
1123 LOperand* temp2() { return temps_[1]; }
1125 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1126 "class-of-test-and-branch")
1127 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1129 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1133 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1135 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1136 inputs_[0] = context;
1141 LOperand* context() { return inputs_[0]; }
1142 LOperand* left() { return inputs_[1]; }
1143 LOperand* right() { return inputs_[2]; }
1145 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1146 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1148 Token::Value op() const { return hydrogen()->token(); }
1152 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1154 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1155 inputs_[0] = context;
1160 LOperand* context() { return inputs_[0]; }
1161 LOperand* left() { return inputs_[1]; }
1162 LOperand* right() { return inputs_[2]; }
1164 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1168 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1170 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1171 inputs_[0] = context;
1176 LOperand* context() { return inputs_[0]; }
1177 LOperand* value() { return inputs_[1]; }
1178 LOperand* temp() { return temps_[0]; }
1180 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1181 "instance-of-known-global")
1182 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1184 Handle<JSFunction> function() const { return hydrogen()->function(); }
1185 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1186 return lazy_deopt_env_;
1188 virtual void SetDeferredLazyDeoptimizationEnvironment(
1189 LEnvironment* env) V8_OVERRIDE {
1190 lazy_deopt_env_ = env;
1194 LEnvironment* lazy_deopt_env_;
1198 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1200 LBoundsCheck(LOperand* index, LOperand* length) {
1202 inputs_[1] = length;
1205 LOperand* index() { return inputs_[0]; }
1206 LOperand* length() { return inputs_[1]; }
1208 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1209 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1213 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1215 LBitI(LOperand* left, LOperand* right) {
1220 LOperand* left() { return inputs_[0]; }
1221 LOperand* right() { return inputs_[1]; }
1223 Token::Value op() const { return hydrogen()->op(); }
1225 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1226 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1230 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1232 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1233 : op_(op), can_deopt_(can_deopt) {
1238 Token::Value op() const { return op_; }
1239 LOperand* left() { return inputs_[0]; }
1240 LOperand* right() { return inputs_[1]; }
1241 bool can_deopt() const { return can_deopt_; }
1243 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1251 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1253 LSubI(LOperand* left, LOperand* right) {
1258 LOperand* left() { return inputs_[0]; }
1259 LOperand* right() { return inputs_[1]; }
1261 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1262 DECLARE_HYDROGEN_ACCESSOR(Sub)
1266 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1268 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1269 DECLARE_HYDROGEN_ACCESSOR(Constant)
1271 int32_t value() const { return hydrogen()->Integer32Value(); }
1275 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1277 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1278 DECLARE_HYDROGEN_ACCESSOR(Constant)
1280 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1284 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1286 explicit LConstantD(LOperand* temp) {
1290 LOperand* temp() { return temps_[0]; }
1292 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1293 DECLARE_HYDROGEN_ACCESSOR(Constant)
1295 double value() const { return hydrogen()->DoubleValue(); }
1299 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1301 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1302 DECLARE_HYDROGEN_ACCESSOR(Constant)
1304 ExternalReference value() const {
1305 return hydrogen()->ExternalReferenceValue();
1310 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1312 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1313 DECLARE_HYDROGEN_ACCESSOR(Constant)
1315 Handle<Object> value(Isolate* isolate) const {
1316 return hydrogen()->handle(isolate);
1321 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1323 explicit LBranch(LOperand* value) {
1327 LOperand* value() { return inputs_[0]; }
1329 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1330 DECLARE_HYDROGEN_ACCESSOR(Branch)
1332 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1336 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1338 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1342 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1344 explicit LCmpMapAndBranch(LOperand* value) {
1348 LOperand* value() { return inputs_[0]; }
1350 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1351 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1353 Handle<Map> map() const { return hydrogen()->map().handle(); }
1357 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1359 explicit LMapEnumLength(LOperand* value) {
1363 LOperand* value() { return inputs_[0]; }
1365 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1369 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1371 LDateField(LOperand* date, Smi* index) : index_(index) {
1375 LOperand* date() { return inputs_[0]; }
1376 Smi* index() const { return index_; }
1378 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1379 DECLARE_HYDROGEN_ACCESSOR(DateField)
1386 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1388 LSeqStringGetChar(LOperand* string, LOperand* index) {
1389 inputs_[0] = string;
1393 LOperand* string() const { return inputs_[0]; }
1394 LOperand* index() const { return inputs_[1]; }
1396 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1397 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1401 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1403 LSeqStringSetChar(LOperand* context,
1407 inputs_[0] = context;
1408 inputs_[1] = string;
1413 LOperand* string() { return inputs_[1]; }
1414 LOperand* index() { return inputs_[2]; }
1415 LOperand* value() { return inputs_[3]; }
1417 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1418 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1422 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1424 LAddI(LOperand* left, LOperand* right) {
1429 LOperand* left() { return inputs_[0]; }
1430 LOperand* right() { return inputs_[1]; }
1432 static bool UseLea(HAdd* add) {
1433 return !add->CheckFlag(HValue::kCanOverflow) &&
1434 add->BetterLeftOperand()->UseCount() > 1;
1437 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1438 DECLARE_HYDROGEN_ACCESSOR(Add)
1442 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1444 LMathMinMax(LOperand* left, LOperand* right) {
1449 LOperand* left() { return inputs_[0]; }
1450 LOperand* right() { return inputs_[1]; }
1452 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1453 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1457 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1459 LPower(LOperand* left, LOperand* right) {
1464 LOperand* left() { return inputs_[0]; }
1465 LOperand* right() { return inputs_[1]; }
1467 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1468 DECLARE_HYDROGEN_ACCESSOR(Power)
1472 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1474 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1480 Token::Value op() const { return op_; }
1481 LOperand* left() { return inputs_[0]; }
1482 LOperand* right() { return inputs_[1]; }
1484 virtual Opcode opcode() const V8_OVERRIDE {
1485 return LInstruction::kArithmeticD;
1487 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1488 virtual const char* Mnemonic() const V8_OVERRIDE;
1495 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1497 LArithmeticT(Token::Value op,
1502 inputs_[0] = context;
1507 Token::Value op() const { return op_; }
1508 LOperand* context() { return inputs_[0]; }
1509 LOperand* left() { return inputs_[1]; }
1510 LOperand* right() { return inputs_[2]; }
1512 virtual Opcode opcode() const V8_OVERRIDE {
1513 return LInstruction::kArithmeticT;
1515 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1516 virtual const char* Mnemonic() const V8_OVERRIDE;
1523 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1525 explicit LReturn(LOperand* value,
1527 LOperand* parameter_count) {
1529 inputs_[1] = context;
1530 inputs_[2] = parameter_count;
1533 LOperand* value() { return inputs_[0]; }
1534 LOperand* context() { return inputs_[1]; }
1536 bool has_constant_parameter_count() {
1537 return parameter_count()->IsConstantOperand();
1539 LConstantOperand* constant_parameter_count() {
1540 ASSERT(has_constant_parameter_count());
1541 return LConstantOperand::cast(parameter_count());
1543 LOperand* parameter_count() { return inputs_[2]; }
1545 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1546 DECLARE_HYDROGEN_ACCESSOR(Return)
1550 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1552 explicit LLoadNamedField(LOperand* object) {
1553 inputs_[0] = object;
1556 LOperand* object() { return inputs_[0]; }
1558 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1559 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1563 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1565 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1566 inputs_[0] = context;
1567 inputs_[1] = object;
1570 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1571 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1573 LOperand* context() { return inputs_[0]; }
1574 LOperand* object() { return inputs_[1]; }
1575 Handle<Object> name() const { return hydrogen()->name(); }
1579 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1581 explicit LLoadFunctionPrototype(LOperand* function) {
1582 inputs_[0] = function;
1585 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1586 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1588 LOperand* function() { return inputs_[0]; }
1592 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1594 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1597 Heap::RootListIndex index() const { return hydrogen()->index(); }
1601 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1603 LLoadKeyed(LOperand* elements, LOperand* key) {
1604 inputs_[0] = elements;
1608 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1609 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1611 bool is_external() const {
1612 return hydrogen()->is_external();
1614 bool is_fixed_typed_array() const {
1615 return hydrogen()->is_fixed_typed_array();
1617 bool is_typed_elements() const {
1618 return is_external() || is_fixed_typed_array();
1620 LOperand* elements() { return inputs_[0]; }
1621 LOperand* key() { return inputs_[1]; }
1622 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1623 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1624 ElementsKind elements_kind() const {
1625 return hydrogen()->elements_kind();
1630 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1632 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1633 inputs_[0] = context;
1638 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1640 LOperand* context() { return inputs_[0]; }
1641 LOperand* object() { return inputs_[1]; }
1642 LOperand* key() { return inputs_[2]; }
1646 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1648 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1649 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1653 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1655 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1656 inputs_[0] = context;
1657 inputs_[1] = global_object;
1660 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1661 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1663 LOperand* context() { return inputs_[0]; }
1664 LOperand* global_object() { return inputs_[1]; }
1665 Handle<Object> name() const { return hydrogen()->name(); }
1666 bool for_typeof() const { return hydrogen()->for_typeof(); }
1670 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1672 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1677 LOperand* value() { return inputs_[0]; }
1678 LOperand* temp() { return temps_[0]; }
1680 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1681 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1685 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1687 explicit LLoadContextSlot(LOperand* context) {
1688 inputs_[0] = context;
1691 LOperand* context() { return inputs_[0]; }
1693 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1694 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1696 int slot_index() { return hydrogen()->slot_index(); }
1698 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1702 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1704 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1705 inputs_[0] = context;
1710 LOperand* context() { return inputs_[0]; }
1711 LOperand* value() { return inputs_[1]; }
1712 LOperand* temp() { return temps_[0]; }
1714 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1715 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1717 int slot_index() { return hydrogen()->slot_index(); }
1719 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1723 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1725 explicit LPushArgument(LOperand* value) {
1729 LOperand* value() { return inputs_[0]; }
1731 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1735 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1737 explicit LDrop(int count) : count_(count) { }
1739 int count() const { return count_; }
1741 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1748 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1750 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1751 inputs_[0] = function;
1752 temps_[0] = code_object;
1755 LOperand* function() { return inputs_[0]; }
1756 LOperand* code_object() { return temps_[0]; }
1758 virtual void PrintDataTo(StringStream* stream);
1760 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1761 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1765 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1767 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1768 inputs_[0] = base_object;
1769 inputs_[1] = offset;
1772 LOperand* base_object() const { return inputs_[0]; }
1773 LOperand* offset() const { return inputs_[1]; }
1775 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1777 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1781 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1783 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1784 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1788 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1790 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1791 DECLARE_HYDROGEN_ACCESSOR(Context)
1795 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1797 explicit LDeclareGlobals(LOperand* context) {
1798 inputs_[0] = context;
1801 LOperand* context() { return inputs_[0]; }
1803 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1804 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1808 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1810 explicit LCallJSFunction(LOperand* function) {
1811 inputs_[0] = function;
1814 LOperand* function() { return inputs_[0]; }
1816 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1817 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1819 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1821 int arity() const { return hydrogen()->argument_count() - 1; }
1825 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1827 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1828 ZoneList<LOperand*>& operands,
1830 : inputs_(descriptor->environment_length() + 1, zone) {
1831 ASSERT(descriptor->environment_length() + 1 == operands.length());
1832 inputs_.AddAll(operands, zone);
1835 LOperand* target() const { return inputs_[0]; }
1838 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1839 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1841 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1843 int arity() const { return hydrogen()->argument_count() - 1; }
1845 ZoneList<LOperand*> inputs_;
1847 // Iterator support.
1848 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1849 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1851 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1852 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1856 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1858 LInvokeFunction(LOperand* context, LOperand* function) {
1859 inputs_[0] = context;
1860 inputs_[1] = function;
1863 LOperand* context() { return inputs_[0]; }
1864 LOperand* function() { return inputs_[1]; }
1866 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1867 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1869 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1871 int arity() const { return hydrogen()->argument_count() - 1; }
1875 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1877 LCallFunction(LOperand* context, LOperand* function) {
1878 inputs_[0] = context;
1879 inputs_[1] = function;
1882 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1883 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1885 LOperand* context() { return inputs_[0]; }
1886 LOperand* function() { return inputs_[1]; }
1887 int arity() const { return hydrogen()->argument_count() - 1; }
1891 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1893 LCallNew(LOperand* context, LOperand* constructor) {
1894 inputs_[0] = context;
1895 inputs_[1] = constructor;
1898 LOperand* context() { return inputs_[0]; }
1899 LOperand* constructor() { return inputs_[1]; }
1901 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1902 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1904 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1910 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1912 LCallNewArray(LOperand* context, LOperand* constructor) {
1913 inputs_[0] = context;
1914 inputs_[1] = constructor;
1917 LOperand* context() { return inputs_[0]; }
1918 LOperand* constructor() { return inputs_[1]; }
1920 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1921 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1923 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1925 int arity() const { return hydrogen()->argument_count() - 1; }
1929 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1931 explicit LCallRuntime(LOperand* context) {
1932 inputs_[0] = context;
1935 LOperand* context() { return inputs_[0]; }
1937 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1938 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1940 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1941 return save_doubles() == kDontSaveFPRegs;
1944 const Runtime::Function* function() const { return hydrogen()->function(); }
1945 int arity() const { return hydrogen()->argument_count(); }
1946 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1950 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1952 explicit LInteger32ToDouble(LOperand* value) {
1956 LOperand* value() { return inputs_[0]; }
1958 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1962 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1964 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1969 LOperand* value() { return inputs_[0]; }
1970 LOperand* temp() { return temps_[0]; }
1972 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1976 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1978 explicit LNumberTagI(LOperand* value) {
1982 LOperand* value() { return inputs_[0]; }
1984 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1988 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 2> {
1990 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1996 LOperand* value() { return inputs_[0]; }
1997 LOperand* temp1() { return temps_[0]; }
1998 LOperand* temp2() { return temps_[1]; }
2000 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2004 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2006 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2011 LOperand* value() { return inputs_[0]; }
2012 LOperand* temp() { return temps_[0]; }
2014 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2015 DECLARE_HYDROGEN_ACCESSOR(Change)
2019 // Sometimes truncating conversion from a tagged value to an int32.
2020 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2022 explicit LDoubleToI(LOperand* value) {
2026 LOperand* value() { return inputs_[0]; }
2028 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2029 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2031 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2035 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2037 explicit LDoubleToSmi(LOperand* value) {
2041 LOperand* value() { return inputs_[0]; }
2043 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2044 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2048 // Truncating conversion from a tagged value to an int32.
2049 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2051 LTaggedToI(LOperand* value, LOperand* temp) {
2056 LOperand* value() { return inputs_[0]; }
2057 LOperand* temp() { return temps_[0]; }
2059 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2060 DECLARE_HYDROGEN_ACCESSOR(Change)
2062 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2066 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2068 explicit LSmiTag(LOperand* value) {
2072 LOperand* value() { return inputs_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2075 DECLARE_HYDROGEN_ACCESSOR(Change)
2079 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2081 explicit LNumberUntagD(LOperand* value) {
2085 LOperand* value() { return inputs_[0]; }
2087 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2088 DECLARE_HYDROGEN_ACCESSOR(Change);
2092 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2094 LSmiUntag(LOperand* value, bool needs_check)
2095 : needs_check_(needs_check) {
2099 LOperand* value() { return inputs_[0]; }
2100 bool needs_check() const { return needs_check_; }
2102 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2109 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2111 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2112 inputs_[0] = object;
2117 LOperand* object() { return inputs_[0]; }
2118 LOperand* value() { return inputs_[1]; }
2119 LOperand* temp() { return temps_[0]; }
2121 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2122 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2124 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2126 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2127 Representation representation() const {
2128 return hydrogen()->field_representation();
2133 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2135 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2136 inputs_[0] = context;
2137 inputs_[1] = object;
2141 LOperand* context() { return inputs_[0]; }
2142 LOperand* object() { return inputs_[1]; }
2143 LOperand* value() { return inputs_[2]; }
2145 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2146 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2148 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2150 Handle<Object> name() const { return hydrogen()->name(); }
2151 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2155 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2157 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2158 inputs_[0] = object;
2163 bool is_external() const { return hydrogen()->is_external(); }
2164 bool is_fixed_typed_array() const {
2165 return hydrogen()->is_fixed_typed_array();
2167 bool is_typed_elements() const {
2168 return is_external() || is_fixed_typed_array();
2170 LOperand* elements() { return inputs_[0]; }
2171 LOperand* key() { return inputs_[1]; }
2172 LOperand* value() { return inputs_[2]; }
2173 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2175 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2176 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2178 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2179 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2180 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2184 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2186 LStoreKeyedGeneric(LOperand* context,
2190 inputs_[0] = context;
2191 inputs_[1] = object;
2196 LOperand* context() { return inputs_[0]; }
2197 LOperand* object() { return inputs_[1]; }
2198 LOperand* key() { return inputs_[2]; }
2199 LOperand* value() { return inputs_[3]; }
2201 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2202 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2204 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2206 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2210 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2212 LTransitionElementsKind(LOperand* object,
2214 LOperand* new_map_temp,
2216 inputs_[0] = object;
2217 inputs_[1] = context;
2218 temps_[0] = new_map_temp;
2222 LOperand* object() { return inputs_[0]; }
2223 LOperand* context() { return inputs_[1]; }
2224 LOperand* new_map_temp() { return temps_[0]; }
2225 LOperand* temp() { return temps_[1]; }
2227 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2228 "transition-elements-kind")
2229 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2231 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2233 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2234 Handle<Map> transitioned_map() {
2235 return hydrogen()->transitioned_map().handle();
2237 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2238 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2242 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2244 LTrapAllocationMemento(LOperand* object,
2246 inputs_[0] = object;
2250 LOperand* object() { return inputs_[0]; }
2251 LOperand* temp() { return temps_[0]; }
2253 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2254 "trap-allocation-memento")
2258 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2260 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2261 inputs_[0] = context;
2266 LOperand* context() { return inputs_[0]; }
2267 LOperand* left() { return inputs_[1]; }
2268 LOperand* right() { return inputs_[2]; }
2270 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2271 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2275 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2277 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2278 inputs_[0] = context;
2279 inputs_[1] = string;
2283 LOperand* context() { return inputs_[0]; }
2284 LOperand* string() { return inputs_[1]; }
2285 LOperand* index() { return inputs_[2]; }
2287 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2288 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2292 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2294 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2295 inputs_[0] = context;
2296 inputs_[1] = char_code;
2299 LOperand* context() { return inputs_[0]; }
2300 LOperand* char_code() { return inputs_[1]; }
2302 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2303 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2307 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2309 explicit LCheckValue(LOperand* value) {
2313 LOperand* value() { return inputs_[0]; }
2315 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2316 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2320 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2322 explicit LCheckInstanceType(LOperand* value) {
2326 LOperand* value() { return inputs_[0]; }
2328 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2329 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2333 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2335 explicit LCheckMaps(LOperand* value) {
2339 LOperand* value() { return inputs_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2342 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2346 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2348 explicit LCheckSmi(LOperand* value) {
2352 LOperand* value() { return inputs_[0]; }
2354 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2358 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2360 explicit LClampDToUint8(LOperand* unclamped) {
2361 inputs_[0] = unclamped;
2364 LOperand* unclamped() { return inputs_[0]; }
2366 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2370 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2372 explicit LClampIToUint8(LOperand* unclamped) {
2373 inputs_[0] = unclamped;
2376 LOperand* unclamped() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2382 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2384 LClampTToUint8(LOperand* unclamped,
2385 LOperand* temp_xmm) {
2386 inputs_[0] = unclamped;
2387 temps_[0] = temp_xmm;
2390 LOperand* unclamped() { return inputs_[0]; }
2391 LOperand* temp_xmm() { return temps_[0]; }
2393 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2397 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2399 explicit LCheckNonSmi(LOperand* value) {
2403 LOperand* value() { return inputs_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2406 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2410 class LDoubleBits V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2412 explicit LDoubleBits(LOperand* value) {
2416 LOperand* value() { return inputs_[0]; }
2418 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2419 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2423 class LConstructDouble V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2425 LConstructDouble(LOperand* hi, LOperand* lo) {
2430 LOperand* hi() { return inputs_[0]; }
2431 LOperand* lo() { return inputs_[1]; }
2433 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2437 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2439 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2440 inputs_[0] = context;
2445 LOperand* context() { return inputs_[0]; }
2446 LOperand* size() { return inputs_[1]; }
2447 LOperand* temp() { return temps_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2450 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2454 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2456 explicit LRegExpLiteral(LOperand* context) {
2457 inputs_[0] = context;
2460 LOperand* context() { return inputs_[0]; }
2462 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2463 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2467 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2469 explicit LFunctionLiteral(LOperand* context) {
2470 inputs_[0] = context;
2473 LOperand* context() { return inputs_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2476 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2480 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2482 explicit LToFastProperties(LOperand* value) {
2486 LOperand* value() { return inputs_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2489 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2493 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2495 LTypeof(LOperand* context, LOperand* value) {
2496 inputs_[0] = context;
2500 LOperand* context() { return inputs_[0]; }
2501 LOperand* value() { return inputs_[1]; }
2503 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2507 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2509 explicit LTypeofIsAndBranch(LOperand* value) {
2513 LOperand* value() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2516 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2518 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2520 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2524 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2526 explicit LIsConstructCallAndBranch(LOperand* temp) {
2530 LOperand* temp() { return temps_[0]; }
2532 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2533 "is-construct-call-and-branch")
2534 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2538 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2542 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2545 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2549 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2551 explicit LStackCheck(LOperand* context) {
2552 inputs_[0] = context;
2555 LOperand* context() { return inputs_[0]; }
2557 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2558 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2560 Label* done_label() { return &done_label_; }
2567 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2569 LForInPrepareMap(LOperand* context, LOperand* object) {
2570 inputs_[0] = context;
2571 inputs_[1] = object;
2574 LOperand* context() { return inputs_[0]; }
2575 LOperand* object() { return inputs_[1]; }
2577 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2581 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2583 explicit LForInCacheArray(LOperand* map) {
2587 LOperand* map() { return inputs_[0]; }
2589 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2592 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2597 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2599 LCheckMapValue(LOperand* value, LOperand* map) {
2604 LOperand* value() { return inputs_[0]; }
2605 LOperand* map() { return inputs_[1]; }
2607 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2611 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2613 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2614 inputs_[0] = object;
2618 LOperand* object() { return inputs_[0]; }
2619 LOperand* index() { return inputs_[1]; }
2621 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2625 class LChunkBuilder;
2626 class LPlatformChunk V8_FINAL : public LChunk {
2628 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2629 : LChunk(info, graph) { }
2631 int GetNextSpillIndex(RegisterKind kind);
2632 LOperand* GetNextSpillSlot(RegisterKind kind);
2636 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2638 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2639 : LChunkBuilderBase(graph->zone()),
2644 current_instruction_(NULL),
2645 current_block_(NULL),
2647 allocator_(allocator) { }
2649 // Build the sequence for the graph.
2650 LPlatformChunk* Build();
2652 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2654 // Declare methods that deal with the individual node types.
2655 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2656 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2659 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2660 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2661 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2662 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2663 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2664 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2665 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2666 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2667 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2668 LInstruction* DoDivByConstI(HDiv* instr);
2669 LInstruction* DoDivI(HBinaryOperation* instr);
2670 LInstruction* DoModByPowerOf2I(HMod* instr);
2671 LInstruction* DoModByConstI(HMod* instr);
2672 LInstruction* DoModI(HMod* instr);
2673 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2674 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2684 LPlatformChunk* chunk() const { return chunk_; }
2685 CompilationInfo* info() const { return info_; }
2686 HGraph* graph() const { return graph_; }
2688 bool is_unused() const { return status_ == UNUSED; }
2689 bool is_building() const { return status_ == BUILDING; }
2690 bool is_done() const { return status_ == DONE; }
2691 bool is_aborted() const { return status_ == ABORTED; }
2693 void Abort(BailoutReason reason);
2695 // Methods for getting operands for Use / Define / Temp.
2696 LUnallocated* ToUnallocated(Register reg);
2697 LUnallocated* ToUnallocated(XMMRegister reg);
2699 // Methods for setting up define-use relationships.
2700 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2701 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2702 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2703 XMMRegister fixed_register);
2705 // A value that is guaranteed to be allocated to a register.
2706 // Operand created by UseRegister is guaranteed to be live until the end of
2707 // instruction. This means that register allocator will not reuse it's
2708 // register for any other operand inside instruction.
2709 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2710 // instruction start. Register allocator is free to assign the same register
2711 // to some other operand used inside instruction (i.e. temporary or
2713 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2714 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2716 // An input operand in a register that may be trashed.
2717 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2719 // An input operand in a register that may be trashed or a constant operand.
2720 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2722 // An input operand in a register or stack slot.
2723 MUST_USE_RESULT LOperand* Use(HValue* value);
2724 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2726 // An input operand in a register, stack slot or a constant operand.
2727 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2728 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2730 // An input operand in a register or a constant operand.
2731 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2732 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2734 // An input operand in a constant operand.
2735 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2737 // An input operand in register, stack slot or a constant operand.
2738 // Will not be moved to a register even if one is freely available.
2739 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2741 // Temporary operand that must be in a register.
2742 MUST_USE_RESULT LUnallocated* TempRegister();
2743 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2744 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2746 // Methods for setting up define-use relationships.
2747 // Return the same instruction that they are passed.
2748 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2749 LUnallocated* result);
2750 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2751 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2753 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2754 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2756 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2758 // Assigns an environment to an instruction. An instruction which can
2759 // deoptimize must have an environment.
2760 LInstruction* AssignEnvironment(LInstruction* instr);
2761 // Assigns a pointer map to an instruction. An instruction which can
2762 // trigger a GC or a lazy deoptimization must have a pointer map.
2763 LInstruction* AssignPointerMap(LInstruction* instr);
2765 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2767 // Marks a call for the register allocator. Assigns a pointer map to
2768 // support GC and lazy deoptimization. Assigns an environment to support
2769 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2770 LInstruction* MarkAsCall(
2771 LInstruction* instr,
2772 HInstruction* hinstr,
2773 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2775 void VisitInstruction(HInstruction* current);
2777 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2778 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2779 LInstruction* DoArithmeticD(Token::Value op,
2780 HArithmeticBinaryOperation* instr);
2781 LInstruction* DoArithmeticT(Token::Value op,
2782 HBinaryOperation* instr);
2784 LPlatformChunk* chunk_;
2785 CompilationInfo* info_;
2786 HGraph* const graph_;
2788 HInstruction* current_instruction_;
2789 HBasicBlock* current_block_;
2790 HBasicBlock* next_block_;
2791 LAllocator* allocator_;
2793 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2796 #undef DECLARE_HYDROGEN_ACCESSOR
2797 #undef DECLARE_CONCRETE_INSTRUCTION
2799 } } // namespace v8::int
2801 #endif // V8_X64_LITHIUM_X64_H_