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(GetCachedArrayIndex) \
102 V(HasCachedArrayIndexAndBranch) \
103 V(HasInstanceTypeAndBranch) \
104 V(InnerAllocatedObject) \
106 V(InstanceOfKnownGlobal) \
108 V(Integer32ToDouble) \
111 V(IsConstructCallAndBranch) \
112 V(IsObjectAndBranch) \
113 V(IsStringAndBranch) \
115 V(IsUndetectableAndBranch) \
119 V(LoadExternalArrayPointer) \
121 V(LoadFieldByIndex) \
122 V(LoadFunctionPrototype) \
124 V(LoadGlobalGeneric) \
126 V(LoadKeyedGeneric) \
128 V(LoadNamedGeneric) \
151 V(SeqStringGetChar) \
152 V(SeqStringSetChar) \
158 V(StoreContextSlot) \
161 V(StoreKeyedGeneric) \
163 V(StoreNamedGeneric) \
165 V(StringCharCodeAt) \
166 V(StringCharFromCode) \
167 V(StringCompareAndBranch) \
172 V(ToFastProperties) \
173 V(TransitionElementsKind) \
174 V(TrapAllocationMemento) \
176 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")
564 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
566 LApplyArguments(LOperand* function,
569 LOperand* elements) {
570 inputs_[0] = function;
571 inputs_[1] = receiver;
573 inputs_[3] = elements;
576 LOperand* function() { return inputs_[0]; }
577 LOperand* receiver() { return inputs_[1]; }
578 LOperand* length() { return inputs_[2]; }
579 LOperand* elements() { return inputs_[3]; }
581 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
585 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
587 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
588 inputs_[0] = arguments;
593 LOperand* arguments() { return inputs_[0]; }
594 LOperand* length() { return inputs_[1]; }
595 LOperand* index() { return inputs_[2]; }
597 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
599 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
603 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
605 explicit LArgumentsLength(LOperand* elements) {
606 inputs_[0] = elements;
609 LOperand* elements() { return inputs_[0]; }
611 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
615 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
617 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
618 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
622 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
624 LModI(LOperand* left, LOperand* right, LOperand* temp) {
630 LOperand* left() { return inputs_[0]; }
631 LOperand* right() { return inputs_[1]; }
632 LOperand* temp() { return temps_[0]; }
634 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
635 DECLARE_HYDROGEN_ACCESSOR(Mod)
639 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
641 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
647 LOperand* left() { return inputs_[0]; }
648 LOperand* right() { return inputs_[1]; }
649 LOperand* temp() { return temps_[0]; }
651 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
653 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
654 DECLARE_HYDROGEN_ACCESSOR(Div)
658 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
660 LMathFloorOfDiv(LOperand* left,
662 LOperand* temp = NULL) {
668 LOperand* left() { return inputs_[0]; }
669 LOperand* right() { return inputs_[1]; }
670 LOperand* temp() { return temps_[0]; }
672 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
673 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
677 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
679 LMulI(LOperand* left, LOperand* right) {
684 LOperand* left() { return inputs_[0]; }
685 LOperand* right() { return inputs_[1]; }
687 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
688 DECLARE_HYDROGEN_ACCESSOR(Mul)
692 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
694 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
699 LOperand* left() { return inputs_[0]; }
700 LOperand* right() { return inputs_[1]; }
702 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
703 "compare-numeric-and-branch")
704 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
706 Token::Value op() const { return hydrogen()->token(); }
707 bool is_double() const {
708 return hydrogen()->representation().IsDouble();
711 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
715 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
717 explicit LMathFloor(LOperand* value) {
721 LOperand* value() { return inputs_[0]; }
723 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
724 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
728 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
730 explicit LMathRound(LOperand* value) {
734 LOperand* value() { return inputs_[0]; }
736 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
737 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
741 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
743 explicit LMathAbs(LOperand* context, LOperand* value) {
744 inputs_[1] = context;
748 LOperand* context() { return inputs_[1]; }
749 LOperand* value() { return inputs_[0]; }
751 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
752 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
756 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
758 explicit LMathLog(LOperand* value) {
762 LOperand* value() { return inputs_[0]; }
764 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
768 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
770 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
774 ExternalReference::InitializeMathExpData();
777 LOperand* value() { return inputs_[0]; }
778 LOperand* temp1() { return temps_[0]; }
779 LOperand* temp2() { return temps_[1]; }
781 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
785 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
787 explicit LMathSqrt(LOperand* value) {
791 LOperand* value() { return inputs_[0]; }
793 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
797 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
799 explicit LMathPowHalf(LOperand* value) {
803 LOperand* value() { return inputs_[0]; }
805 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
809 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
811 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
819 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
823 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
825 explicit LCmpHoleAndBranch(LOperand* object) {
829 LOperand* object() { return inputs_[0]; }
831 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
832 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
836 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
838 explicit LCompareMinusZeroAndBranch(LOperand* value) {
842 LOperand* value() { return inputs_[0]; }
844 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
845 "cmp-minus-zero-and-branch")
846 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
851 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
853 explicit LIsObjectAndBranch(LOperand* value) {
857 LOperand* value() { return inputs_[0]; }
859 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
860 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
862 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
866 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
868 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
873 LOperand* value() { return inputs_[0]; }
874 LOperand* temp() { return temps_[0]; }
876 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
877 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
879 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
883 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
885 explicit LIsSmiAndBranch(LOperand* value) {
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
892 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
894 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
898 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
900 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
905 LOperand* value() { return inputs_[0]; }
906 LOperand* temp() { return temps_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
909 "is-undetectable-and-branch")
910 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
912 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
916 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
918 explicit LStringCompareAndBranch(LOperand* context,
921 inputs_[0] = context;
926 LOperand* context() { return inputs_[0]; }
927 LOperand* left() { return inputs_[1]; }
928 LOperand* right() { return inputs_[2]; }
930 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
931 "string-compare-and-branch")
932 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
934 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
936 Token::Value op() const { return hydrogen()->token(); }
940 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
942 explicit LHasInstanceTypeAndBranch(LOperand* value) {
946 LOperand* value() { return inputs_[0]; }
948 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
949 "has-instance-type-and-branch")
950 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
952 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
956 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
958 explicit LGetCachedArrayIndex(LOperand* value) {
962 LOperand* value() { return inputs_[0]; }
964 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
965 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
969 class LHasCachedArrayIndexAndBranch V8_FINAL
970 : public LControlInstruction<1, 0> {
972 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
976 LOperand* value() { return inputs_[0]; }
978 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
979 "has-cached-array-index-and-branch")
980 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
982 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
986 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
988 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
994 LOperand* value() { return inputs_[0]; }
995 LOperand* temp() { return temps_[0]; }
996 LOperand* temp2() { return temps_[1]; }
998 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
999 "class-of-test-and-branch")
1000 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1002 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1006 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1008 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1009 inputs_[0] = context;
1014 LOperand* context() { return inputs_[0]; }
1015 LOperand* left() { return inputs_[1]; }
1016 LOperand* right() { return inputs_[2]; }
1018 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1019 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1021 Token::Value op() const { return hydrogen()->token(); }
1025 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1027 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1028 inputs_[0] = context;
1033 LOperand* context() { return inputs_[0]; }
1034 LOperand* left() { return inputs_[1]; }
1035 LOperand* right() { return inputs_[2]; }
1037 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1041 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1043 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1044 inputs_[0] = context;
1049 LOperand* context() { return inputs_[0]; }
1050 LOperand* value() { return inputs_[1]; }
1051 LOperand* temp() { return temps_[0]; }
1053 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1054 "instance-of-known-global")
1055 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1057 Handle<JSFunction> function() const { return hydrogen()->function(); }
1058 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1059 return lazy_deopt_env_;
1061 virtual void SetDeferredLazyDeoptimizationEnvironment(
1062 LEnvironment* env) V8_OVERRIDE {
1063 lazy_deopt_env_ = env;
1067 LEnvironment* lazy_deopt_env_;
1071 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1073 LBoundsCheck(LOperand* index, LOperand* length) {
1075 inputs_[1] = length;
1078 LOperand* index() { return inputs_[0]; }
1079 LOperand* length() { return inputs_[1]; }
1081 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1082 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1086 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1088 LBitI(LOperand* left, LOperand* right) {
1093 LOperand* left() { return inputs_[0]; }
1094 LOperand* right() { return inputs_[1]; }
1096 Token::Value op() const { return hydrogen()->op(); }
1098 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1099 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1103 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1105 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1106 : op_(op), can_deopt_(can_deopt) {
1111 Token::Value op() const { return op_; }
1112 LOperand* left() { return inputs_[0]; }
1113 LOperand* right() { return inputs_[1]; }
1114 bool can_deopt() const { return can_deopt_; }
1116 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1124 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1126 LSubI(LOperand* left, LOperand* right) {
1131 LOperand* left() { return inputs_[0]; }
1132 LOperand* right() { return inputs_[1]; }
1134 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1135 DECLARE_HYDROGEN_ACCESSOR(Sub)
1139 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1141 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1142 DECLARE_HYDROGEN_ACCESSOR(Constant)
1144 int32_t value() const { return hydrogen()->Integer32Value(); }
1148 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1150 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1151 DECLARE_HYDROGEN_ACCESSOR(Constant)
1153 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1157 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1159 explicit LConstantD(LOperand* temp) {
1163 LOperand* temp() { return temps_[0]; }
1165 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1166 DECLARE_HYDROGEN_ACCESSOR(Constant)
1168 double value() const { return hydrogen()->DoubleValue(); }
1172 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1174 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1175 DECLARE_HYDROGEN_ACCESSOR(Constant)
1177 ExternalReference value() const {
1178 return hydrogen()->ExternalReferenceValue();
1183 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1185 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1186 DECLARE_HYDROGEN_ACCESSOR(Constant)
1188 Handle<Object> value(Isolate* isolate) const {
1189 return hydrogen()->handle(isolate);
1194 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1196 explicit LBranch(LOperand* value) {
1200 LOperand* value() { return inputs_[0]; }
1202 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1203 DECLARE_HYDROGEN_ACCESSOR(Branch)
1205 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1209 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1211 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1215 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1217 explicit LCmpMapAndBranch(LOperand* value) {
1221 LOperand* value() { return inputs_[0]; }
1223 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1224 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1226 Handle<Map> map() const { return hydrogen()->map().handle(); }
1230 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1232 explicit LMapEnumLength(LOperand* value) {
1236 LOperand* value() { return inputs_[0]; }
1238 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1242 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1244 explicit LElementsKind(LOperand* value) {
1248 LOperand* value() { return inputs_[0]; }
1250 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1251 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1255 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1257 explicit LValueOf(LOperand* value) {
1261 LOperand* value() { return inputs_[0]; }
1263 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1264 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1268 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1270 LDateField(LOperand* date, Smi* index) : index_(index) {
1274 LOperand* date() { return inputs_[0]; }
1275 Smi* index() const { return index_; }
1277 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1278 DECLARE_HYDROGEN_ACCESSOR(DateField)
1285 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1287 LSeqStringGetChar(LOperand* string, LOperand* index) {
1288 inputs_[0] = string;
1292 LOperand* string() const { return inputs_[0]; }
1293 LOperand* index() const { return inputs_[1]; }
1295 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1296 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1300 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1302 LSeqStringSetChar(LOperand* context,
1306 inputs_[0] = context;
1307 inputs_[1] = string;
1312 LOperand* string() { return inputs_[1]; }
1313 LOperand* index() { return inputs_[2]; }
1314 LOperand* value() { return inputs_[3]; }
1316 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1317 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1321 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1323 explicit LThrow(LOperand* context, LOperand* value) {
1324 inputs_[0] = context;
1328 LOperand* context() { return inputs_[0]; }
1329 LOperand* value() { return inputs_[1]; }
1331 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1335 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1337 LAddI(LOperand* left, LOperand* right) {
1342 LOperand* left() { return inputs_[0]; }
1343 LOperand* right() { return inputs_[1]; }
1345 static bool UseLea(HAdd* add) {
1346 return !add->CheckFlag(HValue::kCanOverflow) &&
1347 add->BetterLeftOperand()->UseCount() > 1;
1350 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1351 DECLARE_HYDROGEN_ACCESSOR(Add)
1355 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1357 LMathMinMax(LOperand* left, LOperand* right) {
1362 LOperand* left() { return inputs_[0]; }
1363 LOperand* right() { return inputs_[1]; }
1365 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1366 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1370 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1372 LPower(LOperand* left, LOperand* right) {
1377 LOperand* left() { return inputs_[0]; }
1378 LOperand* right() { return inputs_[1]; }
1380 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1381 DECLARE_HYDROGEN_ACCESSOR(Power)
1385 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1387 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1393 Token::Value op() const { return op_; }
1394 LOperand* left() { return inputs_[0]; }
1395 LOperand* right() { return inputs_[1]; }
1397 virtual Opcode opcode() const V8_OVERRIDE {
1398 return LInstruction::kArithmeticD;
1400 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1401 virtual const char* Mnemonic() const V8_OVERRIDE;
1408 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1410 LArithmeticT(Token::Value op,
1415 inputs_[0] = context;
1420 Token::Value op() const { return op_; }
1421 LOperand* context() { return inputs_[0]; }
1422 LOperand* left() { return inputs_[1]; }
1423 LOperand* right() { return inputs_[2]; }
1425 virtual Opcode opcode() const V8_OVERRIDE {
1426 return LInstruction::kArithmeticT;
1428 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1429 virtual const char* Mnemonic() const V8_OVERRIDE;
1436 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1438 explicit LReturn(LOperand* value,
1440 LOperand* parameter_count) {
1442 inputs_[1] = context;
1443 inputs_[2] = parameter_count;
1446 LOperand* value() { return inputs_[0]; }
1447 LOperand* context() { return inputs_[1]; }
1449 bool has_constant_parameter_count() {
1450 return parameter_count()->IsConstantOperand();
1452 LConstantOperand* constant_parameter_count() {
1453 ASSERT(has_constant_parameter_count());
1454 return LConstantOperand::cast(parameter_count());
1456 LOperand* parameter_count() { return inputs_[2]; }
1458 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1459 DECLARE_HYDROGEN_ACCESSOR(Return)
1463 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1465 explicit LLoadNamedField(LOperand* object) {
1466 inputs_[0] = object;
1469 LOperand* object() { return inputs_[0]; }
1471 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1472 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1476 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1478 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1479 inputs_[0] = context;
1480 inputs_[1] = object;
1483 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1484 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1486 LOperand* context() { return inputs_[0]; }
1487 LOperand* object() { return inputs_[1]; }
1488 Handle<Object> name() const { return hydrogen()->name(); }
1492 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1494 explicit LLoadFunctionPrototype(LOperand* function) {
1495 inputs_[0] = function;
1498 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1499 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1501 LOperand* function() { return inputs_[0]; }
1505 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1507 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1508 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1510 Heap::RootListIndex index() const { return hydrogen()->index(); }
1514 class LLoadExternalArrayPointer V8_FINAL
1515 : public LTemplateInstruction<1, 1, 0> {
1517 explicit LLoadExternalArrayPointer(LOperand* object) {
1518 inputs_[0] = object;
1521 LOperand* object() { return inputs_[0]; }
1523 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1524 "load-external-array-pointer")
1528 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1530 LLoadKeyed(LOperand* elements, LOperand* key) {
1531 inputs_[0] = elements;
1535 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1536 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1538 bool is_external() const {
1539 return hydrogen()->is_external();
1541 bool is_fixed_typed_array() const {
1542 return hydrogen()->is_fixed_typed_array();
1544 bool is_typed_elements() const {
1545 return is_external() || is_fixed_typed_array();
1547 LOperand* elements() { return inputs_[0]; }
1548 LOperand* key() { return inputs_[1]; }
1549 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1550 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1551 ElementsKind elements_kind() const {
1552 return hydrogen()->elements_kind();
1557 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1559 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1560 inputs_[0] = context;
1565 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1567 LOperand* context() { return inputs_[0]; }
1568 LOperand* object() { return inputs_[1]; }
1569 LOperand* key() { return inputs_[2]; }
1573 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1575 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1576 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1580 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1582 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1583 inputs_[0] = context;
1584 inputs_[1] = global_object;
1587 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1588 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1590 LOperand* context() { return inputs_[0]; }
1591 LOperand* global_object() { return inputs_[1]; }
1592 Handle<Object> name() const { return hydrogen()->name(); }
1593 bool for_typeof() const { return hydrogen()->for_typeof(); }
1597 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1599 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1604 LOperand* value() { return inputs_[0]; }
1605 LOperand* temp() { return temps_[0]; }
1607 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1608 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1612 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1614 explicit LLoadContextSlot(LOperand* context) {
1615 inputs_[0] = context;
1618 LOperand* context() { return inputs_[0]; }
1620 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1621 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1623 int slot_index() { return hydrogen()->slot_index(); }
1625 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1629 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1631 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1632 inputs_[0] = context;
1637 LOperand* context() { return inputs_[0]; }
1638 LOperand* value() { return inputs_[1]; }
1639 LOperand* temp() { return temps_[0]; }
1641 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1642 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1644 int slot_index() { return hydrogen()->slot_index(); }
1646 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1650 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1652 explicit LPushArgument(LOperand* value) {
1656 LOperand* value() { return inputs_[0]; }
1658 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1662 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1664 explicit LDrop(int count) : count_(count) { }
1666 int count() const { return count_; }
1668 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1675 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1677 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1678 inputs_[0] = function;
1679 temps_[0] = code_object;
1682 LOperand* function() { return inputs_[0]; }
1683 LOperand* code_object() { return temps_[0]; }
1685 virtual void PrintDataTo(StringStream* stream);
1687 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1688 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1692 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1694 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1695 inputs_[0] = base_object;
1696 inputs_[1] = offset;
1699 LOperand* base_object() const { return inputs_[0]; }
1700 LOperand* offset() const { return inputs_[1]; }
1702 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1704 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1708 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1710 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1711 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1715 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1717 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1718 DECLARE_HYDROGEN_ACCESSOR(Context)
1722 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1724 explicit LDeclareGlobals(LOperand* context) {
1725 inputs_[0] = context;
1728 LOperand* context() { return inputs_[0]; }
1730 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1731 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1735 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1737 explicit LGlobalObject(LOperand* context) {
1738 inputs_[0] = context;
1741 LOperand* context() { return inputs_[0]; }
1743 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1747 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1749 explicit LGlobalReceiver(LOperand* global_object) {
1750 inputs_[0] = global_object;
1753 LOperand* global() { return inputs_[0]; }
1755 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1759 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1761 explicit LCallJSFunction(LOperand* function) {
1762 inputs_[0] = function;
1765 LOperand* function() { return inputs_[0]; }
1767 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1768 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1770 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1772 int arity() const { return hydrogen()->argument_count() - 1; }
1776 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1778 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1779 ZoneList<LOperand*>& operands,
1781 : inputs_(descriptor->environment_length() + 1, zone) {
1782 ASSERT(descriptor->environment_length() + 1 == operands.length());
1783 inputs_.AddAll(operands, zone);
1786 LOperand* target() const { return inputs_[0]; }
1789 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1790 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1792 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1794 int arity() const { return hydrogen()->argument_count() - 1; }
1796 ZoneList<LOperand*> inputs_;
1798 // Iterator support.
1799 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1800 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1802 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1803 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1807 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1809 LInvokeFunction(LOperand* context, LOperand* function) {
1810 inputs_[0] = context;
1811 inputs_[1] = function;
1814 LOperand* context() { return inputs_[0]; }
1815 LOperand* function() { return inputs_[1]; }
1817 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1818 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1820 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1822 int arity() const { return hydrogen()->argument_count() - 1; }
1826 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1828 LCallFunction(LOperand* context, LOperand* function) {
1829 inputs_[0] = context;
1830 inputs_[1] = function;
1833 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1834 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1836 LOperand* context() { return inputs_[0]; }
1837 LOperand* function() { return inputs_[1]; }
1838 int arity() const { return hydrogen()->argument_count() - 1; }
1842 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1844 LCallNew(LOperand* context, LOperand* constructor) {
1845 inputs_[0] = context;
1846 inputs_[1] = constructor;
1849 LOperand* context() { return inputs_[0]; }
1850 LOperand* constructor() { return inputs_[1]; }
1852 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1853 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1855 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1857 int arity() const { return hydrogen()->argument_count() - 1; }
1861 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1863 LCallNewArray(LOperand* context, LOperand* constructor) {
1864 inputs_[0] = context;
1865 inputs_[1] = constructor;
1868 LOperand* context() { return inputs_[0]; }
1869 LOperand* constructor() { return inputs_[1]; }
1871 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1872 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1874 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1876 int arity() const { return hydrogen()->argument_count() - 1; }
1880 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1882 explicit LCallRuntime(LOperand* context) {
1883 inputs_[0] = context;
1886 LOperand* context() { return inputs_[0]; }
1888 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1889 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1891 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1892 return save_doubles() == kDontSaveFPRegs;
1895 const Runtime::Function* function() const { return hydrogen()->function(); }
1896 int arity() const { return hydrogen()->argument_count(); }
1897 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1901 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1903 explicit LInteger32ToDouble(LOperand* value) {
1907 LOperand* value() { return inputs_[0]; }
1909 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1913 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1915 explicit LInteger32ToSmi(LOperand* value) {
1919 LOperand* value() { return inputs_[0]; }
1921 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1922 DECLARE_HYDROGEN_ACCESSOR(Change)
1926 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1928 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1933 LOperand* value() { return inputs_[0]; }
1934 LOperand* temp() { return temps_[0]; }
1936 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1940 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1942 explicit LUint32ToSmi(LOperand* value) {
1946 LOperand* value() { return inputs_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1949 DECLARE_HYDROGEN_ACCESSOR(Change)
1953 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1955 explicit LNumberTagI(LOperand* value) {
1959 LOperand* value() { return inputs_[0]; }
1961 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1965 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1967 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1972 LOperand* value() { return inputs_[0]; }
1973 LOperand* temp() { return temps_[0]; }
1975 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1979 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1981 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1986 LOperand* value() { return inputs_[0]; }
1987 LOperand* temp() { return temps_[0]; }
1989 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1990 DECLARE_HYDROGEN_ACCESSOR(Change)
1994 // Sometimes truncating conversion from a tagged value to an int32.
1995 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1997 explicit LDoubleToI(LOperand* value) {
2001 LOperand* value() { return inputs_[0]; }
2003 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2004 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2006 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2010 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2012 explicit LDoubleToSmi(LOperand* value) {
2016 LOperand* value() { return inputs_[0]; }
2018 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2019 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2023 // Truncating conversion from a tagged value to an int32.
2024 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2026 LTaggedToI(LOperand* value, LOperand* temp) {
2031 LOperand* value() { return inputs_[0]; }
2032 LOperand* temp() { return temps_[0]; }
2034 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2035 DECLARE_HYDROGEN_ACCESSOR(Change)
2037 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2041 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2043 explicit LSmiTag(LOperand* value) {
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2053 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2055 explicit LNumberUntagD(LOperand* value) {
2059 LOperand* value() { return inputs_[0]; }
2061 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2062 DECLARE_HYDROGEN_ACCESSOR(Change);
2066 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2068 LSmiUntag(LOperand* value, bool needs_check)
2069 : needs_check_(needs_check) {
2073 LOperand* value() { return inputs_[0]; }
2074 bool needs_check() const { return needs_check_; }
2076 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2083 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2085 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2086 inputs_[0] = object;
2091 LOperand* object() { return inputs_[0]; }
2092 LOperand* value() { return inputs_[1]; }
2093 LOperand* temp() { return temps_[0]; }
2095 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2096 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2098 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2100 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2101 Representation representation() const {
2102 return hydrogen()->field_representation();
2107 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2109 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2110 inputs_[0] = context;
2111 inputs_[1] = object;
2115 LOperand* context() { return inputs_[0]; }
2116 LOperand* object() { return inputs_[1]; }
2117 LOperand* value() { return inputs_[2]; }
2119 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2120 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2122 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2124 Handle<Object> name() const { return hydrogen()->name(); }
2125 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2129 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2131 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2132 inputs_[0] = object;
2137 bool is_external() const { return hydrogen()->is_external(); }
2138 bool is_fixed_typed_array() const {
2139 return hydrogen()->is_fixed_typed_array();
2141 bool is_typed_elements() const {
2142 return is_external() || is_fixed_typed_array();
2144 LOperand* elements() { return inputs_[0]; }
2145 LOperand* key() { return inputs_[1]; }
2146 LOperand* value() { return inputs_[2]; }
2147 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2149 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2150 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2152 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2153 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2154 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2158 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2160 LStoreKeyedGeneric(LOperand* context,
2164 inputs_[0] = context;
2165 inputs_[1] = object;
2170 LOperand* context() { return inputs_[0]; }
2171 LOperand* object() { return inputs_[1]; }
2172 LOperand* key() { return inputs_[2]; }
2173 LOperand* value() { return inputs_[3]; }
2175 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2176 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2178 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2180 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2184 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2186 LTransitionElementsKind(LOperand* object,
2188 LOperand* new_map_temp,
2190 inputs_[0] = object;
2191 inputs_[1] = context;
2192 temps_[0] = new_map_temp;
2196 LOperand* object() { return inputs_[0]; }
2197 LOperand* context() { return inputs_[1]; }
2198 LOperand* new_map_temp() { return temps_[0]; }
2199 LOperand* temp() { return temps_[1]; }
2201 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2202 "transition-elements-kind")
2203 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2205 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2207 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2208 Handle<Map> transitioned_map() {
2209 return hydrogen()->transitioned_map().handle();
2211 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2212 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2216 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2218 LTrapAllocationMemento(LOperand* object,
2220 inputs_[0] = object;
2224 LOperand* object() { return inputs_[0]; }
2225 LOperand* temp() { return temps_[0]; }
2227 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2228 "trap-allocation-memento")
2232 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2234 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2235 inputs_[0] = context;
2240 LOperand* context() { return inputs_[0]; }
2241 LOperand* left() { return inputs_[1]; }
2242 LOperand* right() { return inputs_[2]; }
2244 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2245 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2249 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2251 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2252 inputs_[0] = context;
2253 inputs_[1] = string;
2257 LOperand* context() { return inputs_[0]; }
2258 LOperand* string() { return inputs_[1]; }
2259 LOperand* index() { return inputs_[2]; }
2261 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2262 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2266 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2268 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2269 inputs_[0] = context;
2270 inputs_[1] = char_code;
2273 LOperand* context() { return inputs_[0]; }
2274 LOperand* char_code() { return inputs_[1]; }
2276 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2277 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2281 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2283 explicit LCheckValue(LOperand* value) {
2287 LOperand* value() { return inputs_[0]; }
2289 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2290 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2294 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2296 explicit LCheckInstanceType(LOperand* value) {
2300 LOperand* value() { return inputs_[0]; }
2302 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2303 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2307 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2309 explicit LCheckMaps(LOperand* value) {
2313 LOperand* value() { return inputs_[0]; }
2315 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2316 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2320 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2322 explicit LCheckSmi(LOperand* value) {
2326 LOperand* value() { return inputs_[0]; }
2328 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2332 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2334 explicit LClampDToUint8(LOperand* unclamped) {
2335 inputs_[0] = unclamped;
2338 LOperand* unclamped() { return inputs_[0]; }
2340 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2344 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2346 explicit LClampIToUint8(LOperand* unclamped) {
2347 inputs_[0] = unclamped;
2350 LOperand* unclamped() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2356 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2358 LClampTToUint8(LOperand* unclamped,
2359 LOperand* temp_xmm) {
2360 inputs_[0] = unclamped;
2361 temps_[0] = temp_xmm;
2364 LOperand* unclamped() { return inputs_[0]; }
2365 LOperand* temp_xmm() { return temps_[0]; }
2367 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2371 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2373 explicit LCheckNonSmi(LOperand* value) {
2377 LOperand* value() { return inputs_[0]; }
2379 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2380 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2384 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2386 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2387 inputs_[0] = context;
2392 LOperand* context() { return inputs_[0]; }
2393 LOperand* size() { return inputs_[1]; }
2394 LOperand* temp() { return temps_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2397 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2401 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2403 explicit LRegExpLiteral(LOperand* context) {
2404 inputs_[0] = context;
2407 LOperand* context() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2410 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2414 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2416 explicit LFunctionLiteral(LOperand* context) {
2417 inputs_[0] = context;
2420 LOperand* context() { return inputs_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2423 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2427 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2429 explicit LToFastProperties(LOperand* value) {
2433 LOperand* value() { return inputs_[0]; }
2435 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2436 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2440 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2442 LTypeof(LOperand* context, LOperand* value) {
2443 inputs_[0] = context;
2447 LOperand* context() { return inputs_[0]; }
2448 LOperand* value() { return inputs_[1]; }
2450 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2454 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2456 explicit LTypeofIsAndBranch(LOperand* value) {
2460 LOperand* value() { return inputs_[0]; }
2462 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2463 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2465 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2467 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2471 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2473 explicit LIsConstructCallAndBranch(LOperand* temp) {
2477 LOperand* temp() { return temps_[0]; }
2479 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2480 "is-construct-call-and-branch")
2481 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2485 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2489 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2492 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2496 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2498 explicit LStackCheck(LOperand* context) {
2499 inputs_[0] = context;
2502 LOperand* context() { return inputs_[0]; }
2504 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2505 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2507 Label* done_label() { return &done_label_; }
2514 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2516 LForInPrepareMap(LOperand* context, LOperand* object) {
2517 inputs_[0] = context;
2518 inputs_[1] = object;
2521 LOperand* context() { return inputs_[0]; }
2522 LOperand* object() { return inputs_[1]; }
2524 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2528 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2530 explicit LForInCacheArray(LOperand* map) {
2534 LOperand* map() { return inputs_[0]; }
2536 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2539 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2544 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2546 LCheckMapValue(LOperand* value, LOperand* map) {
2551 LOperand* value() { return inputs_[0]; }
2552 LOperand* map() { return inputs_[1]; }
2554 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2558 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2560 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2561 inputs_[0] = object;
2565 LOperand* object() { return inputs_[0]; }
2566 LOperand* index() { return inputs_[1]; }
2568 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2572 class LChunkBuilder;
2573 class LPlatformChunk V8_FINAL : public LChunk {
2575 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2576 : LChunk(info, graph) { }
2578 int GetNextSpillIndex(RegisterKind kind);
2579 LOperand* GetNextSpillSlot(RegisterKind kind);
2583 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2585 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2586 : LChunkBuilderBase(graph->zone()),
2591 current_instruction_(NULL),
2592 current_block_(NULL),
2594 allocator_(allocator),
2595 instruction_pending_deoptimization_environment_(NULL),
2596 pending_deoptimization_ast_id_(BailoutId::None()) { }
2598 // Build the sequence for the graph.
2599 LPlatformChunk* Build();
2601 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2603 // Declare methods that deal with the individual node types.
2604 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2605 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2608 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2609 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2610 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2611 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2612 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2613 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2614 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2624 LPlatformChunk* chunk() const { return chunk_; }
2625 CompilationInfo* info() const { return info_; }
2626 HGraph* graph() const { return graph_; }
2628 bool is_unused() const { return status_ == UNUSED; }
2629 bool is_building() const { return status_ == BUILDING; }
2630 bool is_done() const { return status_ == DONE; }
2631 bool is_aborted() const { return status_ == ABORTED; }
2633 void Abort(BailoutReason reason);
2635 // Methods for getting operands for Use / Define / Temp.
2636 LUnallocated* ToUnallocated(Register reg);
2637 LUnallocated* ToUnallocated(XMMRegister reg);
2639 // Methods for setting up define-use relationships.
2640 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2641 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2642 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2643 XMMRegister fixed_register);
2645 // A value that is guaranteed to be allocated to a register.
2646 // Operand created by UseRegister is guaranteed to be live until the end of
2647 // instruction. This means that register allocator will not reuse it's
2648 // register for any other operand inside instruction.
2649 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2650 // instruction start. Register allocator is free to assign the same register
2651 // to some other operand used inside instruction (i.e. temporary or
2653 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2654 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2656 // An input operand in a register that may be trashed.
2657 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2659 // An input operand in a register that may be trashed or a constant operand.
2660 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2662 // An input operand in a register or stack slot.
2663 MUST_USE_RESULT LOperand* Use(HValue* value);
2664 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2666 // An input operand in a register, stack slot or a constant operand.
2667 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2668 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2670 // An input operand in a register or a constant operand.
2671 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2672 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2674 // An input operand in a constant operand.
2675 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2677 // An input operand in register, stack slot or a constant operand.
2678 // Will not be moved to a register even if one is freely available.
2679 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2681 // Temporary operand that must be in a register.
2682 MUST_USE_RESULT LUnallocated* TempRegister();
2683 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2684 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2686 // Methods for setting up define-use relationships.
2687 // Return the same instruction that they are passed.
2688 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2689 LUnallocated* result);
2690 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2691 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2693 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2694 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2696 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2698 // Assigns an environment to an instruction. An instruction which can
2699 // deoptimize must have an environment.
2700 LInstruction* AssignEnvironment(LInstruction* instr);
2701 // Assigns a pointer map to an instruction. An instruction which can
2702 // trigger a GC or a lazy deoptimization must have a pointer map.
2703 LInstruction* AssignPointerMap(LInstruction* instr);
2705 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2707 // Marks a call for the register allocator. Assigns a pointer map to
2708 // support GC and lazy deoptimization. Assigns an environment to support
2709 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2710 LInstruction* MarkAsCall(
2711 LInstruction* instr,
2712 HInstruction* hinstr,
2713 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2715 void VisitInstruction(HInstruction* current);
2717 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2718 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2719 LInstruction* DoArithmeticD(Token::Value op,
2720 HArithmeticBinaryOperation* instr);
2721 LInstruction* DoArithmeticT(Token::Value op,
2722 HBinaryOperation* instr);
2724 LPlatformChunk* chunk_;
2725 CompilationInfo* info_;
2726 HGraph* const graph_;
2728 HInstruction* current_instruction_;
2729 HBasicBlock* current_block_;
2730 HBasicBlock* next_block_;
2731 LAllocator* allocator_;
2732 LInstruction* instruction_pending_deoptimization_environment_;
2733 BailoutId pending_deoptimization_ast_id_;
2735 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2738 #undef DECLARE_HYDROGEN_ACCESSOR
2739 #undef DECLARE_CONCRETE_INSTRUCTION
2741 } } // namespace v8::int
2743 #endif // V8_X64_LITHIUM_X64_H_