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) \
152 V(SeqStringGetChar) \
153 V(SeqStringSetChar) \
159 V(StoreContextSlot) \
161 V(StoreGlobalGeneric) \
163 V(StoreKeyedGeneric) \
165 V(StoreNamedGeneric) \
167 V(StringCharCodeAt) \
168 V(StringCharFromCode) \
169 V(StringCompareAndBranch) \
174 V(ToFastProperties) \
175 V(TransitionElementsKind) \
176 V(TrapAllocationMemento) \
178 V(TypeofIsAndBranch) \
186 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
187 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
188 return LInstruction::k##type; \
190 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
191 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
194 static L##type* cast(LInstruction* instr) { \
195 ASSERT(instr->Is##type()); \
196 return reinterpret_cast<L##type*>(instr); \
200 #define DECLARE_HYDROGEN_ACCESSOR(type) \
201 H##type* hydrogen() const { \
202 return H##type::cast(hydrogen_value()); \
206 class LInstruction : public ZoneObject {
209 : environment_(NULL),
210 hydrogen_value_(NULL),
211 bit_field_(IsCallBits::encode(false)) {
214 virtual ~LInstruction() {}
216 virtual void CompileToNative(LCodeGen* generator) = 0;
217 virtual const char* Mnemonic() const = 0;
218 virtual void PrintTo(StringStream* stream);
219 virtual void PrintDataTo(StringStream* stream);
220 virtual void PrintOutputOperandTo(StringStream* stream);
223 // Declare a unique enum value for each instruction.
224 #define DECLARE_OPCODE(type) k##type,
225 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
226 kNumberOfInstructions
227 #undef DECLARE_OPCODE
230 virtual Opcode opcode() const = 0;
232 // Declare non-virtual type testers for all leaf IR classes.
233 #define DECLARE_PREDICATE(type) \
234 bool Is##type() const { return opcode() == k##type; }
235 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
236 #undef DECLARE_PREDICATE
238 // Declare virtual predicates for instructions that don't have
240 virtual bool IsGap() const { return false; }
242 virtual bool IsControl() const { return false; }
244 void set_environment(LEnvironment* env) { environment_ = env; }
245 LEnvironment* environment() const { return environment_; }
246 bool HasEnvironment() const { return environment_ != NULL; }
248 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
249 LPointerMap* pointer_map() const { return pointer_map_.get(); }
250 bool HasPointerMap() const { return pointer_map_.is_set(); }
252 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
253 HValue* hydrogen_value() const { return hydrogen_value_; }
255 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
256 bool IsCall() const { return IsCallBits::decode(bit_field_); }
258 // Interface to the register allocator and iterators.
259 bool ClobbersTemps() const { return IsCall(); }
260 bool ClobbersRegisters() const { return IsCall(); }
261 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
263 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
265 // Interface to the register allocator and iterators.
266 bool IsMarkedAsCall() const { return IsCall(); }
268 virtual bool HasResult() const = 0;
269 virtual LOperand* result() const = 0;
271 LOperand* FirstInput() { return InputAt(0); }
272 LOperand* Output() { return HasResult() ? result() : NULL; }
274 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
282 friend class InputIterator;
283 virtual int InputCount() = 0;
284 virtual LOperand* InputAt(int i) = 0;
286 friend class TempIterator;
287 virtual int TempCount() = 0;
288 virtual LOperand* TempAt(int i) = 0;
290 class IsCallBits: public BitField<bool, 0, 1> {};
292 LEnvironment* environment_;
293 SetOncePointer<LPointerMap> pointer_map_;
294 HValue* hydrogen_value_;
299 // R = number of result operands (0 or 1).
301 class LTemplateResultInstruction : public LInstruction {
303 // Allow 0 or 1 output operands.
304 STATIC_ASSERT(R == 0 || R == 1);
305 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
306 return R != 0 && result() != NULL;
308 void set_result(LOperand* operand) { results_[0] = operand; }
309 LOperand* result() const { return results_[0]; }
312 EmbeddedContainer<LOperand*, R> results_;
316 // R = number of result operands (0 or 1).
317 // I = number of input operands.
318 // T = number of temporary operands.
319 template<int R, int I, int T>
320 class LTemplateInstruction : public LTemplateResultInstruction<R> {
322 EmbeddedContainer<LOperand*, I> inputs_;
323 EmbeddedContainer<LOperand*, T> temps_;
327 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
328 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
330 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
331 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
335 class LGap : public LTemplateInstruction<0, 0, 0> {
337 explicit LGap(HBasicBlock* block)
339 parallel_moves_[BEFORE] = NULL;
340 parallel_moves_[START] = NULL;
341 parallel_moves_[END] = NULL;
342 parallel_moves_[AFTER] = NULL;
345 // Can't use the DECLARE-macro here because of sub-classes.
346 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
347 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
348 static LGap* cast(LInstruction* instr) {
349 ASSERT(instr->IsGap());
350 return reinterpret_cast<LGap*>(instr);
353 bool IsRedundant() const;
355 HBasicBlock* block() const { return block_; }
362 FIRST_INNER_POSITION = BEFORE,
363 LAST_INNER_POSITION = AFTER
366 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
368 if (parallel_moves_[pos] == NULL) {
369 parallel_moves_[pos] = new(zone) LParallelMove(zone);
371 return parallel_moves_[pos];
374 LParallelMove* GetParallelMove(InnerPosition pos) {
375 return parallel_moves_[pos];
379 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
384 class LInstructionGap V8_FINAL : public LGap {
386 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
389 return !IsRedundant();
392 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
396 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
398 explicit LGoto(HBasicBlock* block) : block_(block) { }
400 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
401 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
402 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
403 virtual bool IsControl() const V8_OVERRIDE { return true; }
405 int block_id() const { return block_->block_id(); }
412 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
414 LLazyBailout() : gap_instructions_size_(0) { }
416 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418 void set_gap_instructions_size(int gap_instructions_size) {
419 gap_instructions_size_ = gap_instructions_size;
421 int gap_instructions_size() { return gap_instructions_size_; }
424 int gap_instructions_size_;
428 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
430 explicit LDummy() { }
431 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
435 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
437 explicit LDummyUse(LOperand* value) {
440 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
444 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
446 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
447 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
451 class LLabel V8_FINAL : public LGap {
453 explicit LLabel(HBasicBlock* block)
454 : LGap(block), replacement_(NULL) { }
456 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
459 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
461 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
463 int block_id() const { return block()->block_id(); }
464 bool is_loop_header() const { return block()->IsLoopHeader(); }
465 bool is_osr_entry() const { return block()->is_osr_entry(); }
466 Label* label() { return &label_; }
467 LLabel* replacement() const { return replacement_; }
468 void set_replacement(LLabel* label) { replacement_ = label; }
469 bool HasReplacement() const { return replacement_ != NULL; }
473 LLabel* replacement_;
477 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
479 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
482 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
486 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
488 explicit LCallStub(LOperand* context) {
489 inputs_[0] = context;
492 LOperand* context() { return inputs_[0]; }
494 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
495 DECLARE_HYDROGEN_ACCESSOR(CallStub)
499 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
501 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
504 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
508 template<int I, int T>
509 class LControlInstruction : public LTemplateInstruction<0, I, T> {
511 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
513 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
515 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
516 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
518 int TrueDestination(LChunk* chunk) {
519 return chunk->LookupDestination(true_block_id());
521 int FalseDestination(LChunk* chunk) {
522 return chunk->LookupDestination(false_block_id());
525 Label* TrueLabel(LChunk* chunk) {
526 if (true_label_ == NULL) {
527 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
531 Label* FalseLabel(LChunk* chunk) {
532 if (false_label_ == NULL) {
533 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
539 int true_block_id() { return SuccessorAt(0)->block_id(); }
540 int false_block_id() { return SuccessorAt(1)->block_id(); }
543 HControlInstruction* hydrogen() {
544 return HControlInstruction::cast(this->hydrogen_value());
552 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
554 LWrapReceiver(LOperand* receiver, LOperand* function) {
555 inputs_[0] = receiver;
556 inputs_[1] = function;
559 LOperand* receiver() { return inputs_[0]; }
560 LOperand* function() { return inputs_[1]; }
562 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
566 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
568 LApplyArguments(LOperand* function,
571 LOperand* elements) {
572 inputs_[0] = function;
573 inputs_[1] = receiver;
575 inputs_[3] = elements;
578 LOperand* function() { return inputs_[0]; }
579 LOperand* receiver() { return inputs_[1]; }
580 LOperand* length() { return inputs_[2]; }
581 LOperand* elements() { return inputs_[3]; }
583 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
587 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
589 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
590 inputs_[0] = arguments;
595 LOperand* arguments() { return inputs_[0]; }
596 LOperand* length() { return inputs_[1]; }
597 LOperand* index() { return inputs_[2]; }
599 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
601 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
605 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
607 explicit LArgumentsLength(LOperand* elements) {
608 inputs_[0] = elements;
611 LOperand* elements() { return inputs_[0]; }
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
617 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
619 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
620 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
624 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
626 LModI(LOperand* left, LOperand* right, LOperand* temp) {
632 LOperand* left() { return inputs_[0]; }
633 LOperand* right() { return inputs_[1]; }
634 LOperand* temp() { return temps_[0]; }
636 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
637 DECLARE_HYDROGEN_ACCESSOR(Mod)
641 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
643 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
649 LOperand* left() { return inputs_[0]; }
650 LOperand* right() { return inputs_[1]; }
651 LOperand* temp() { return temps_[0]; }
653 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
655 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
656 DECLARE_HYDROGEN_ACCESSOR(Div)
660 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
662 LMathFloorOfDiv(LOperand* left,
664 LOperand* temp = NULL) {
670 LOperand* left() { return inputs_[0]; }
671 LOperand* right() { return inputs_[1]; }
672 LOperand* temp() { return temps_[0]; }
674 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
675 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
679 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
681 LMulI(LOperand* left, LOperand* right) {
686 LOperand* left() { return inputs_[0]; }
687 LOperand* right() { return inputs_[1]; }
689 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
690 DECLARE_HYDROGEN_ACCESSOR(Mul)
694 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
696 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
701 LOperand* left() { return inputs_[0]; }
702 LOperand* right() { return inputs_[1]; }
704 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
705 "compare-numeric-and-branch")
706 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
708 Token::Value op() const { return hydrogen()->token(); }
709 bool is_double() const {
710 return hydrogen()->representation().IsDouble();
713 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
717 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
719 explicit LMathFloor(LOperand* value) {
723 LOperand* value() { return inputs_[0]; }
725 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
726 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
730 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
732 explicit LMathRound(LOperand* value) {
736 LOperand* value() { return inputs_[0]; }
738 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
739 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
743 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
745 explicit LMathAbs(LOperand* context, LOperand* value) {
746 inputs_[1] = context;
750 LOperand* context() { return inputs_[1]; }
751 LOperand* value() { return inputs_[0]; }
753 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
754 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
758 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
760 explicit LMathLog(LOperand* value) {
764 LOperand* value() { return inputs_[0]; }
766 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
770 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
772 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
776 ExternalReference::InitializeMathExpData();
779 LOperand* value() { return inputs_[0]; }
780 LOperand* temp1() { return temps_[0]; }
781 LOperand* temp2() { return temps_[1]; }
783 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
787 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
789 explicit LMathSqrt(LOperand* value) {
793 LOperand* value() { return inputs_[0]; }
795 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
799 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
801 explicit LMathPowHalf(LOperand* value) {
805 LOperand* value() { return inputs_[0]; }
807 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
811 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
813 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
818 LOperand* left() { return inputs_[0]; }
819 LOperand* right() { return inputs_[1]; }
821 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
825 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
827 explicit LCmpHoleAndBranch(LOperand* object) {
831 LOperand* object() { return inputs_[0]; }
833 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
834 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
838 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
840 explicit LCompareMinusZeroAndBranch(LOperand* value) {
844 LOperand* value() { return inputs_[0]; }
846 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
847 "cmp-minus-zero-and-branch")
848 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
853 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
855 explicit LIsObjectAndBranch(LOperand* value) {
859 LOperand* value() { return inputs_[0]; }
861 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
862 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
864 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
868 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
870 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
875 LOperand* value() { return inputs_[0]; }
876 LOperand* temp() { return temps_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
879 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
881 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
885 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
887 explicit LIsSmiAndBranch(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
894 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
896 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
900 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
902 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
907 LOperand* value() { return inputs_[0]; }
908 LOperand* temp() { return temps_[0]; }
910 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
911 "is-undetectable-and-branch")
912 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
914 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
918 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
920 explicit LStringCompareAndBranch(LOperand* context,
923 inputs_[0] = context;
928 LOperand* context() { return inputs_[0]; }
929 LOperand* left() { return inputs_[1]; }
930 LOperand* right() { return inputs_[2]; }
932 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
933 "string-compare-and-branch")
934 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
936 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
938 Token::Value op() const { return hydrogen()->token(); }
942 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
944 explicit LHasInstanceTypeAndBranch(LOperand* value) {
948 LOperand* value() { return inputs_[0]; }
950 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
951 "has-instance-type-and-branch")
952 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
954 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
958 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
960 explicit LGetCachedArrayIndex(LOperand* value) {
964 LOperand* value() { return inputs_[0]; }
966 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
967 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
971 class LHasCachedArrayIndexAndBranch V8_FINAL
972 : public LControlInstruction<1, 0> {
974 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
978 LOperand* value() { return inputs_[0]; }
980 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
981 "has-cached-array-index-and-branch")
982 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
984 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
988 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
990 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
996 LOperand* value() { return inputs_[0]; }
997 LOperand* temp() { return temps_[0]; }
998 LOperand* temp2() { return temps_[1]; }
1000 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1001 "class-of-test-and-branch")
1002 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1004 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1008 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1010 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1011 inputs_[0] = context;
1016 LOperand* context() { return inputs_[0]; }
1017 LOperand* left() { return inputs_[1]; }
1018 LOperand* right() { return inputs_[2]; }
1020 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1021 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1023 Token::Value op() const { return hydrogen()->token(); }
1027 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1029 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1030 inputs_[0] = context;
1035 LOperand* context() { return inputs_[0]; }
1036 LOperand* left() { return inputs_[1]; }
1037 LOperand* right() { return inputs_[2]; }
1039 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1043 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1045 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1046 inputs_[0] = context;
1051 LOperand* context() { return inputs_[0]; }
1052 LOperand* value() { return inputs_[1]; }
1053 LOperand* temp() { return temps_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1056 "instance-of-known-global")
1057 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1059 Handle<JSFunction> function() const { return hydrogen()->function(); }
1060 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1061 return lazy_deopt_env_;
1063 virtual void SetDeferredLazyDeoptimizationEnvironment(
1064 LEnvironment* env) V8_OVERRIDE {
1065 lazy_deopt_env_ = env;
1069 LEnvironment* lazy_deopt_env_;
1073 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1075 LBoundsCheck(LOperand* index, LOperand* length) {
1077 inputs_[1] = length;
1080 LOperand* index() { return inputs_[0]; }
1081 LOperand* length() { return inputs_[1]; }
1083 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1084 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1088 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1090 LBitI(LOperand* left, LOperand* right) {
1095 LOperand* left() { return inputs_[0]; }
1096 LOperand* right() { return inputs_[1]; }
1098 Token::Value op() const { return hydrogen()->op(); }
1100 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1101 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1105 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1107 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1108 : op_(op), can_deopt_(can_deopt) {
1113 Token::Value op() const { return op_; }
1114 LOperand* left() { return inputs_[0]; }
1115 LOperand* right() { return inputs_[1]; }
1116 bool can_deopt() const { return can_deopt_; }
1118 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1126 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1128 LSubI(LOperand* left, LOperand* right) {
1133 LOperand* left() { return inputs_[0]; }
1134 LOperand* right() { return inputs_[1]; }
1136 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1137 DECLARE_HYDROGEN_ACCESSOR(Sub)
1141 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1143 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1144 DECLARE_HYDROGEN_ACCESSOR(Constant)
1146 int32_t value() const { return hydrogen()->Integer32Value(); }
1150 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1152 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1153 DECLARE_HYDROGEN_ACCESSOR(Constant)
1155 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1159 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1161 explicit LConstantD(LOperand* temp) {
1165 LOperand* temp() { return temps_[0]; }
1167 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1168 DECLARE_HYDROGEN_ACCESSOR(Constant)
1170 double value() const { return hydrogen()->DoubleValue(); }
1174 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1176 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1177 DECLARE_HYDROGEN_ACCESSOR(Constant)
1179 ExternalReference value() const {
1180 return hydrogen()->ExternalReferenceValue();
1185 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1187 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1188 DECLARE_HYDROGEN_ACCESSOR(Constant)
1190 Handle<Object> value(Isolate* isolate) const {
1191 return hydrogen()->handle(isolate);
1196 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1198 explicit LBranch(LOperand* value) {
1202 LOperand* value() { return inputs_[0]; }
1204 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1205 DECLARE_HYDROGEN_ACCESSOR(Branch)
1207 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1211 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1213 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1217 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1219 explicit LCmpMapAndBranch(LOperand* value) {
1223 LOperand* value() { return inputs_[0]; }
1225 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1226 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1228 Handle<Map> map() const { return hydrogen()->map().handle(); }
1232 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1234 explicit LMapEnumLength(LOperand* value) {
1238 LOperand* value() { return inputs_[0]; }
1240 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1244 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1246 explicit LElementsKind(LOperand* value) {
1250 LOperand* value() { return inputs_[0]; }
1252 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1253 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1257 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1259 explicit LValueOf(LOperand* value) {
1263 LOperand* value() { return inputs_[0]; }
1265 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1266 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1270 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1272 LDateField(LOperand* date, Smi* index) : index_(index) {
1276 LOperand* date() { return inputs_[0]; }
1277 Smi* index() const { return index_; }
1279 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1280 DECLARE_HYDROGEN_ACCESSOR(DateField)
1287 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1289 LSeqStringGetChar(LOperand* string, LOperand* index) {
1290 inputs_[0] = string;
1294 LOperand* string() const { return inputs_[0]; }
1295 LOperand* index() const { return inputs_[1]; }
1297 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1298 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1302 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1304 LSeqStringSetChar(LOperand* context,
1308 inputs_[0] = context;
1309 inputs_[1] = string;
1314 LOperand* string() { return inputs_[1]; }
1315 LOperand* index() { return inputs_[2]; }
1316 LOperand* value() { return inputs_[3]; }
1318 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1319 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1323 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1325 explicit LThrow(LOperand* context, LOperand* value) {
1326 inputs_[0] = context;
1330 LOperand* context() { return inputs_[0]; }
1331 LOperand* value() { return inputs_[1]; }
1333 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1337 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1339 LAddI(LOperand* left, LOperand* right) {
1344 LOperand* left() { return inputs_[0]; }
1345 LOperand* right() { return inputs_[1]; }
1347 static bool UseLea(HAdd* add) {
1348 return !add->CheckFlag(HValue::kCanOverflow) &&
1349 add->BetterLeftOperand()->UseCount() > 1;
1352 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1353 DECLARE_HYDROGEN_ACCESSOR(Add)
1357 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1359 LMathMinMax(LOperand* left, LOperand* right) {
1364 LOperand* left() { return inputs_[0]; }
1365 LOperand* right() { return inputs_[1]; }
1367 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1368 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1372 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1374 LPower(LOperand* left, LOperand* right) {
1379 LOperand* left() { return inputs_[0]; }
1380 LOperand* right() { return inputs_[1]; }
1382 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1383 DECLARE_HYDROGEN_ACCESSOR(Power)
1387 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1389 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1395 Token::Value op() const { return op_; }
1396 LOperand* left() { return inputs_[0]; }
1397 LOperand* right() { return inputs_[1]; }
1399 virtual Opcode opcode() const V8_OVERRIDE {
1400 return LInstruction::kArithmeticD;
1402 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1403 virtual const char* Mnemonic() const V8_OVERRIDE;
1410 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1412 LArithmeticT(Token::Value op,
1417 inputs_[0] = context;
1422 Token::Value op() const { return op_; }
1423 LOperand* context() { return inputs_[0]; }
1424 LOperand* left() { return inputs_[1]; }
1425 LOperand* right() { return inputs_[2]; }
1427 virtual Opcode opcode() const V8_OVERRIDE {
1428 return LInstruction::kArithmeticT;
1430 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1431 virtual const char* Mnemonic() const V8_OVERRIDE;
1438 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1440 explicit LReturn(LOperand* value,
1442 LOperand* parameter_count) {
1444 inputs_[1] = context;
1445 inputs_[2] = parameter_count;
1448 LOperand* value() { return inputs_[0]; }
1449 LOperand* context() { return inputs_[1]; }
1451 bool has_constant_parameter_count() {
1452 return parameter_count()->IsConstantOperand();
1454 LConstantOperand* constant_parameter_count() {
1455 ASSERT(has_constant_parameter_count());
1456 return LConstantOperand::cast(parameter_count());
1458 LOperand* parameter_count() { return inputs_[2]; }
1460 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1461 DECLARE_HYDROGEN_ACCESSOR(Return)
1465 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1467 explicit LLoadNamedField(LOperand* object) {
1468 inputs_[0] = object;
1471 LOperand* object() { return inputs_[0]; }
1473 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1474 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1478 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1480 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1481 inputs_[0] = context;
1482 inputs_[1] = object;
1485 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1486 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1488 LOperand* context() { return inputs_[0]; }
1489 LOperand* object() { return inputs_[1]; }
1490 Handle<Object> name() const { return hydrogen()->name(); }
1494 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1496 explicit LLoadFunctionPrototype(LOperand* function) {
1497 inputs_[0] = function;
1500 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1501 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1503 LOperand* function() { return inputs_[0]; }
1507 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1509 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1510 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1512 Heap::RootListIndex index() const { return hydrogen()->index(); }
1516 class LLoadExternalArrayPointer V8_FINAL
1517 : public LTemplateInstruction<1, 1, 0> {
1519 explicit LLoadExternalArrayPointer(LOperand* object) {
1520 inputs_[0] = object;
1523 LOperand* object() { return inputs_[0]; }
1525 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1526 "load-external-array-pointer")
1530 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1532 LLoadKeyed(LOperand* elements, LOperand* key) {
1533 inputs_[0] = elements;
1537 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1538 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1540 bool is_external() const {
1541 return hydrogen()->is_external();
1543 LOperand* elements() { return inputs_[0]; }
1544 LOperand* key() { return inputs_[1]; }
1545 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1546 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1547 ElementsKind elements_kind() const {
1548 return hydrogen()->elements_kind();
1553 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1555 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1556 inputs_[0] = context;
1561 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1563 LOperand* context() { return inputs_[0]; }
1564 LOperand* object() { return inputs_[1]; }
1565 LOperand* key() { return inputs_[2]; }
1569 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1571 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1572 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1576 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1578 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1579 inputs_[0] = context;
1580 inputs_[1] = global_object;
1583 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1584 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1586 LOperand* context() { return inputs_[0]; }
1587 LOperand* global_object() { return inputs_[1]; }
1588 Handle<Object> name() const { return hydrogen()->name(); }
1589 bool for_typeof() const { return hydrogen()->for_typeof(); }
1593 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1595 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1600 LOperand* value() { return inputs_[0]; }
1601 LOperand* temp() { return temps_[0]; }
1603 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1604 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1608 class LStoreGlobalGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1610 explicit LStoreGlobalGeneric(LOperand* context,
1611 LOperand* global_object,
1613 inputs_[0] = context;
1614 inputs_[1] = global_object;
1618 LOperand* context() { return inputs_[0]; }
1619 LOperand* global_object() { return inputs_[1]; }
1620 LOperand* value() { return inputs_[2]; }
1622 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1623 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1625 Handle<Object> name() const { return hydrogen()->name(); }
1626 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1630 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1632 explicit LLoadContextSlot(LOperand* context) {
1633 inputs_[0] = context;
1636 LOperand* context() { return inputs_[0]; }
1638 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1639 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1641 int slot_index() { return hydrogen()->slot_index(); }
1643 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1647 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1649 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1650 inputs_[0] = context;
1655 LOperand* context() { return inputs_[0]; }
1656 LOperand* value() { return inputs_[1]; }
1657 LOperand* temp() { return temps_[0]; }
1659 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1660 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1662 int slot_index() { return hydrogen()->slot_index(); }
1664 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1668 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1670 explicit LPushArgument(LOperand* value) {
1674 LOperand* value() { return inputs_[0]; }
1676 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1680 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1682 explicit LDrop(int count) : count_(count) { }
1684 int count() const { return count_; }
1686 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1693 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1695 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1696 inputs_[0] = function;
1697 temps_[0] = code_object;
1700 LOperand* function() { return inputs_[0]; }
1701 LOperand* code_object() { return temps_[0]; }
1703 virtual void PrintDataTo(StringStream* stream);
1705 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1706 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1710 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1712 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1713 inputs_[0] = base_object;
1714 inputs_[1] = offset;
1717 LOperand* base_object() const { return inputs_[0]; }
1718 LOperand* offset() const { return inputs_[1]; }
1720 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1722 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1726 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1728 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1729 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1733 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1735 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1736 DECLARE_HYDROGEN_ACCESSOR(Context)
1740 class LOuterContext V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1742 explicit LOuterContext(LOperand* context) {
1743 inputs_[0] = context;
1746 LOperand* context() { return inputs_[0]; }
1748 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1752 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1754 explicit LDeclareGlobals(LOperand* context) {
1755 inputs_[0] = context;
1758 LOperand* context() { return inputs_[0]; }
1760 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1761 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1765 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1767 explicit LGlobalObject(LOperand* context) {
1768 inputs_[0] = context;
1771 LOperand* context() { return inputs_[0]; }
1773 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1777 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1779 explicit LGlobalReceiver(LOperand* global_object) {
1780 inputs_[0] = global_object;
1783 LOperand* global() { return inputs_[0]; }
1785 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1789 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1791 explicit LCallJSFunction(LOperand* function) {
1792 inputs_[0] = function;
1795 LOperand* function() { return inputs_[0]; }
1797 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1798 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1800 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1802 int arity() const { return hydrogen()->argument_count() - 1; }
1806 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1808 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1809 ZoneList<LOperand*>& operands,
1811 : descriptor_(descriptor),
1812 inputs_(descriptor->environment_length() + 1, zone) {
1813 ASSERT(descriptor->environment_length() + 1 == operands.length());
1814 inputs_.AddAll(operands, zone);
1817 LOperand* target() const { return inputs_[0]; }
1821 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1822 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1824 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1826 int arity() const { return hydrogen()->argument_count() - 1; }
1828 const CallInterfaceDescriptor* descriptor_;
1829 ZoneList<LOperand*> inputs_;
1831 virtual void InternalSetOperandAt(int index,
1832 LOperand* value) V8_FINAL V8_OVERRIDE {
1833 inputs_[index] = value;
1836 // Iterator support.
1837 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1838 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1840 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1841 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1845 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1847 LInvokeFunction(LOperand* context, LOperand* function) {
1848 inputs_[0] = context;
1849 inputs_[1] = function;
1852 LOperand* context() { return inputs_[0]; }
1853 LOperand* function() { return inputs_[1]; }
1855 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1856 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1858 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1860 int arity() const { return hydrogen()->argument_count() - 1; }
1864 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1866 LCallFunction(LOperand* context, LOperand* function) {
1867 inputs_[0] = context;
1868 inputs_[1] = function;
1871 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1872 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1874 LOperand* context() { return inputs_[0]; }
1875 LOperand* function() { return inputs_[1]; }
1876 int arity() const { return hydrogen()->argument_count() - 1; }
1880 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1882 LCallNew(LOperand* context, LOperand* constructor) {
1883 inputs_[0] = context;
1884 inputs_[1] = constructor;
1887 LOperand* context() { return inputs_[0]; }
1888 LOperand* constructor() { return inputs_[1]; }
1890 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1891 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1893 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1899 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1901 LCallNewArray(LOperand* context, LOperand* constructor) {
1902 inputs_[0] = context;
1903 inputs_[1] = constructor;
1906 LOperand* context() { return inputs_[0]; }
1907 LOperand* constructor() { return inputs_[1]; }
1909 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1910 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1912 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1914 int arity() const { return hydrogen()->argument_count() - 1; }
1918 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1920 explicit LCallRuntime(LOperand* context) {
1921 inputs_[0] = context;
1924 LOperand* context() { return inputs_[0]; }
1926 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1927 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1929 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1930 return save_doubles() == kDontSaveFPRegs;
1933 const Runtime::Function* function() const { return hydrogen()->function(); }
1934 int arity() const { return hydrogen()->argument_count(); }
1935 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1939 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1941 explicit LInteger32ToDouble(LOperand* value) {
1945 LOperand* value() { return inputs_[0]; }
1947 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1951 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1953 explicit LInteger32ToSmi(LOperand* value) {
1957 LOperand* value() { return inputs_[0]; }
1959 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1960 DECLARE_HYDROGEN_ACCESSOR(Change)
1964 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1966 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1971 LOperand* value() { return inputs_[0]; }
1972 LOperand* temp() { return temps_[0]; }
1974 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1978 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1980 explicit LUint32ToSmi(LOperand* value) {
1984 LOperand* value() { return inputs_[0]; }
1986 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1987 DECLARE_HYDROGEN_ACCESSOR(Change)
1991 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1993 explicit LNumberTagI(LOperand* value) {
1997 LOperand* value() { return inputs_[0]; }
1999 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2003 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2005 explicit LNumberTagU(LOperand* value, LOperand* temp) {
2010 LOperand* value() { return inputs_[0]; }
2011 LOperand* temp() { return temps_[0]; }
2013 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2017 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2019 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2024 LOperand* value() { return inputs_[0]; }
2025 LOperand* temp() { return temps_[0]; }
2027 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2028 DECLARE_HYDROGEN_ACCESSOR(Change)
2032 // Sometimes truncating conversion from a tagged value to an int32.
2033 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2035 explicit LDoubleToI(LOperand* value) {
2039 LOperand* value() { return inputs_[0]; }
2041 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2042 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2044 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2048 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2050 explicit LDoubleToSmi(LOperand* value) {
2054 LOperand* value() { return inputs_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2057 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2061 // Truncating conversion from a tagged value to an int32.
2062 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2064 LTaggedToI(LOperand* value, LOperand* temp) {
2069 LOperand* value() { return inputs_[0]; }
2070 LOperand* temp() { return temps_[0]; }
2072 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2073 DECLARE_HYDROGEN_ACCESSOR(Change)
2075 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2079 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2081 explicit LSmiTag(LOperand* value) {
2085 LOperand* value() { return inputs_[0]; }
2087 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2091 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2093 explicit LNumberUntagD(LOperand* value) {
2097 LOperand* value() { return inputs_[0]; }
2099 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2100 DECLARE_HYDROGEN_ACCESSOR(Change);
2104 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2106 LSmiUntag(LOperand* value, bool needs_check)
2107 : needs_check_(needs_check) {
2111 LOperand* value() { return inputs_[0]; }
2112 bool needs_check() const { return needs_check_; }
2114 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2121 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2123 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2124 inputs_[0] = object;
2129 LOperand* object() { return inputs_[0]; }
2130 LOperand* value() { return inputs_[1]; }
2131 LOperand* temp() { return temps_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2134 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2136 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2138 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2139 Representation representation() const {
2140 return hydrogen()->field_representation();
2145 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2147 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2148 inputs_[0] = context;
2149 inputs_[1] = object;
2153 LOperand* context() { return inputs_[0]; }
2154 LOperand* object() { return inputs_[1]; }
2155 LOperand* value() { return inputs_[2]; }
2157 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2158 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2160 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2162 Handle<Object> name() const { return hydrogen()->name(); }
2163 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2167 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2169 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2170 inputs_[0] = object;
2175 bool is_external() const { return hydrogen()->is_external(); }
2176 LOperand* elements() { return inputs_[0]; }
2177 LOperand* key() { return inputs_[1]; }
2178 LOperand* value() { return inputs_[2]; }
2179 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2181 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2182 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2184 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2185 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2186 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2190 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2192 LStoreKeyedGeneric(LOperand* context,
2196 inputs_[0] = context;
2197 inputs_[1] = object;
2202 LOperand* context() { return inputs_[0]; }
2203 LOperand* object() { return inputs_[1]; }
2204 LOperand* key() { return inputs_[2]; }
2205 LOperand* value() { return inputs_[3]; }
2207 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2208 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2210 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2212 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2216 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2218 LTransitionElementsKind(LOperand* object,
2220 LOperand* new_map_temp,
2222 inputs_[0] = object;
2223 inputs_[1] = context;
2224 temps_[0] = new_map_temp;
2228 LOperand* object() { return inputs_[0]; }
2229 LOperand* context() { return inputs_[1]; }
2230 LOperand* new_map_temp() { return temps_[0]; }
2231 LOperand* temp() { return temps_[1]; }
2233 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2234 "transition-elements-kind")
2235 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2237 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2239 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2240 Handle<Map> transitioned_map() {
2241 return hydrogen()->transitioned_map().handle();
2243 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2244 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2248 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2250 LTrapAllocationMemento(LOperand* object,
2252 inputs_[0] = object;
2256 LOperand* object() { return inputs_[0]; }
2257 LOperand* temp() { return temps_[0]; }
2259 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2260 "trap-allocation-memento")
2264 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2266 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2267 inputs_[0] = context;
2272 LOperand* context() { return inputs_[0]; }
2273 LOperand* left() { return inputs_[1]; }
2274 LOperand* right() { return inputs_[2]; }
2276 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2277 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2281 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2283 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2284 inputs_[0] = context;
2285 inputs_[1] = string;
2289 LOperand* context() { return inputs_[0]; }
2290 LOperand* string() { return inputs_[1]; }
2291 LOperand* index() { return inputs_[2]; }
2293 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2294 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2298 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2300 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2301 inputs_[0] = context;
2302 inputs_[1] = char_code;
2305 LOperand* context() { return inputs_[0]; }
2306 LOperand* char_code() { return inputs_[1]; }
2308 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2309 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2313 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2315 explicit LCheckValue(LOperand* value) {
2319 LOperand* value() { return inputs_[0]; }
2321 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2322 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2326 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2328 explicit LCheckInstanceType(LOperand* value) {
2332 LOperand* value() { return inputs_[0]; }
2334 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2335 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2339 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2341 explicit LCheckMaps(LOperand* value) {
2345 LOperand* value() { return inputs_[0]; }
2347 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2348 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2352 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2354 explicit LCheckSmi(LOperand* value) {
2358 LOperand* value() { return inputs_[0]; }
2360 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2364 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2366 explicit LClampDToUint8(LOperand* unclamped) {
2367 inputs_[0] = unclamped;
2370 LOperand* unclamped() { return inputs_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2376 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2378 explicit LClampIToUint8(LOperand* unclamped) {
2379 inputs_[0] = unclamped;
2382 LOperand* unclamped() { return inputs_[0]; }
2384 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2388 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2390 LClampTToUint8(LOperand* unclamped,
2391 LOperand* temp_xmm) {
2392 inputs_[0] = unclamped;
2393 temps_[0] = temp_xmm;
2396 LOperand* unclamped() { return inputs_[0]; }
2397 LOperand* temp_xmm() { return temps_[0]; }
2399 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2403 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2405 explicit LCheckNonSmi(LOperand* value) {
2409 LOperand* value() { return inputs_[0]; }
2411 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2412 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2416 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2418 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2419 inputs_[0] = context;
2424 LOperand* context() { return inputs_[0]; }
2425 LOperand* size() { return inputs_[1]; }
2426 LOperand* temp() { return temps_[0]; }
2428 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2429 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2433 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2435 explicit LRegExpLiteral(LOperand* context) {
2436 inputs_[0] = context;
2439 LOperand* context() { return inputs_[0]; }
2441 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2442 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2446 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2448 explicit LFunctionLiteral(LOperand* context) {
2449 inputs_[0] = context;
2452 LOperand* context() { return inputs_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2455 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2459 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2461 explicit LToFastProperties(LOperand* value) {
2465 LOperand* value() { return inputs_[0]; }
2467 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2468 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2472 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2474 LTypeof(LOperand* context, LOperand* value) {
2475 inputs_[0] = context;
2479 LOperand* context() { return inputs_[0]; }
2480 LOperand* value() { return inputs_[1]; }
2482 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2486 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2488 explicit LTypeofIsAndBranch(LOperand* value) {
2492 LOperand* value() { return inputs_[0]; }
2494 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2495 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2497 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2499 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2503 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2505 explicit LIsConstructCallAndBranch(LOperand* temp) {
2509 LOperand* temp() { return temps_[0]; }
2511 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2512 "is-construct-call-and-branch")
2513 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2517 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2521 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2524 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2528 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2530 explicit LStackCheck(LOperand* context) {
2531 inputs_[0] = context;
2534 LOperand* context() { return inputs_[0]; }
2536 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2537 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2539 Label* done_label() { return &done_label_; }
2546 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2548 LForInPrepareMap(LOperand* context, LOperand* object) {
2549 inputs_[0] = context;
2550 inputs_[1] = object;
2553 LOperand* context() { return inputs_[0]; }
2554 LOperand* object() { return inputs_[1]; }
2556 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2560 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2562 explicit LForInCacheArray(LOperand* map) {
2566 LOperand* map() { return inputs_[0]; }
2568 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2571 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2576 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2578 LCheckMapValue(LOperand* value, LOperand* map) {
2583 LOperand* value() { return inputs_[0]; }
2584 LOperand* map() { return inputs_[1]; }
2586 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2590 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2592 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2593 inputs_[0] = object;
2597 LOperand* object() { return inputs_[0]; }
2598 LOperand* index() { return inputs_[1]; }
2600 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2604 class LChunkBuilder;
2605 class LPlatformChunk V8_FINAL : public LChunk {
2607 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2608 : LChunk(info, graph) { }
2610 int GetNextSpillIndex(RegisterKind kind);
2611 LOperand* GetNextSpillSlot(RegisterKind kind);
2615 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2617 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2618 : LChunkBuilderBase(graph->zone()),
2623 current_instruction_(NULL),
2624 current_block_(NULL),
2626 allocator_(allocator),
2627 instruction_pending_deoptimization_environment_(NULL),
2628 pending_deoptimization_ast_id_(BailoutId::None()) { }
2630 // Build the sequence for the graph.
2631 LPlatformChunk* Build();
2633 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2635 // Declare methods that deal with the individual node types.
2636 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2637 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2640 static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
2642 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2643 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2644 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2645 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2646 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2647 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2648 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2658 LPlatformChunk* chunk() const { return chunk_; }
2659 CompilationInfo* info() const { return info_; }
2660 HGraph* graph() const { return graph_; }
2662 bool is_unused() const { return status_ == UNUSED; }
2663 bool is_building() const { return status_ == BUILDING; }
2664 bool is_done() const { return status_ == DONE; }
2665 bool is_aborted() const { return status_ == ABORTED; }
2667 void Abort(BailoutReason reason);
2669 // Methods for getting operands for Use / Define / Temp.
2670 LUnallocated* ToUnallocated(Register reg);
2671 LUnallocated* ToUnallocated(XMMRegister reg);
2673 // Methods for setting up define-use relationships.
2674 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2675 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2676 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2677 XMMRegister fixed_register);
2679 // A value that is guaranteed to be allocated to a register.
2680 // Operand created by UseRegister is guaranteed to be live until the end of
2681 // instruction. This means that register allocator will not reuse it's
2682 // register for any other operand inside instruction.
2683 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2684 // instruction start. Register allocator is free to assign the same register
2685 // to some other operand used inside instruction (i.e. temporary or
2687 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2688 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2690 // An input operand in a register that may be trashed.
2691 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2693 // An input operand in a register that may be trashed or a constant operand.
2694 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2696 // An input operand in a register or stack slot.
2697 MUST_USE_RESULT LOperand* Use(HValue* value);
2698 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2700 // An input operand in a register, stack slot or a constant operand.
2701 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2702 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2704 // An input operand in a register or a constant operand.
2705 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2706 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2708 // An input operand in a constant operand.
2709 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2711 // An input operand in register, stack slot or a constant operand.
2712 // Will not be moved to a register even if one is freely available.
2713 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2715 // Temporary operand that must be in a register.
2716 MUST_USE_RESULT LUnallocated* TempRegister();
2717 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2718 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2720 // Methods for setting up define-use relationships.
2721 // Return the same instruction that they are passed.
2722 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2723 LUnallocated* result);
2724 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2725 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2727 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2728 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2730 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2732 // Assigns an environment to an instruction. An instruction which can
2733 // deoptimize must have an environment.
2734 LInstruction* AssignEnvironment(LInstruction* instr);
2735 // Assigns a pointer map to an instruction. An instruction which can
2736 // trigger a GC or a lazy deoptimization must have a pointer map.
2737 LInstruction* AssignPointerMap(LInstruction* instr);
2739 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2741 // Marks a call for the register allocator. Assigns a pointer map to
2742 // support GC and lazy deoptimization. Assigns an environment to support
2743 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2744 LInstruction* MarkAsCall(
2745 LInstruction* instr,
2746 HInstruction* hinstr,
2747 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2749 void VisitInstruction(HInstruction* current);
2751 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2752 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2753 LInstruction* DoArithmeticD(Token::Value op,
2754 HArithmeticBinaryOperation* instr);
2755 LInstruction* DoArithmeticT(Token::Value op,
2756 HBinaryOperation* instr);
2758 LPlatformChunk* chunk_;
2759 CompilationInfo* info_;
2760 HGraph* const graph_;
2762 HInstruction* current_instruction_;
2763 HBasicBlock* current_block_;
2764 HBasicBlock* next_block_;
2765 LAllocator* allocator_;
2766 LInstruction* instruction_pending_deoptimization_environment_;
2767 BailoutId pending_deoptimization_ast_id_;
2769 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2772 #undef DECLARE_HYDROGEN_ACCESSOR
2773 #undef DECLARE_CONCRETE_INSTRUCTION
2775 } } // namespace v8::int
2777 #endif // V8_X64_LITHIUM_X64_H_