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 bool is_fixed_typed_array() const {
1544 return hydrogen()->is_fixed_typed_array();
1546 bool is_typed_elements() const {
1547 return is_external() || is_fixed_typed_array();
1549 LOperand* elements() { return inputs_[0]; }
1550 LOperand* key() { return inputs_[1]; }
1551 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1552 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1553 ElementsKind elements_kind() const {
1554 return hydrogen()->elements_kind();
1559 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1561 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1562 inputs_[0] = context;
1567 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1569 LOperand* context() { return inputs_[0]; }
1570 LOperand* object() { return inputs_[1]; }
1571 LOperand* key() { return inputs_[2]; }
1575 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1577 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1578 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1582 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1584 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1585 inputs_[0] = context;
1586 inputs_[1] = global_object;
1589 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1592 LOperand* context() { return inputs_[0]; }
1593 LOperand* global_object() { return inputs_[1]; }
1594 Handle<Object> name() const { return hydrogen()->name(); }
1595 bool for_typeof() const { return hydrogen()->for_typeof(); }
1599 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1601 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1606 LOperand* value() { return inputs_[0]; }
1607 LOperand* temp() { return temps_[0]; }
1609 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1610 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1614 class LStoreGlobalGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1616 explicit LStoreGlobalGeneric(LOperand* context,
1617 LOperand* global_object,
1619 inputs_[0] = context;
1620 inputs_[1] = global_object;
1624 LOperand* context() { return inputs_[0]; }
1625 LOperand* global_object() { return inputs_[1]; }
1626 LOperand* value() { return inputs_[2]; }
1628 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1629 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1631 Handle<Object> name() const { return hydrogen()->name(); }
1632 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1636 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1638 explicit LLoadContextSlot(LOperand* context) {
1639 inputs_[0] = context;
1642 LOperand* context() { return inputs_[0]; }
1644 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1645 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1647 int slot_index() { return hydrogen()->slot_index(); }
1649 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1653 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1655 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1656 inputs_[0] = context;
1661 LOperand* context() { return inputs_[0]; }
1662 LOperand* value() { return inputs_[1]; }
1663 LOperand* temp() { return temps_[0]; }
1665 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1666 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1668 int slot_index() { return hydrogen()->slot_index(); }
1670 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1674 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1676 explicit LPushArgument(LOperand* value) {
1680 LOperand* value() { return inputs_[0]; }
1682 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1686 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1688 explicit LDrop(int count) : count_(count) { }
1690 int count() const { return count_; }
1692 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1699 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1701 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1702 inputs_[0] = function;
1703 temps_[0] = code_object;
1706 LOperand* function() { return inputs_[0]; }
1707 LOperand* code_object() { return temps_[0]; }
1709 virtual void PrintDataTo(StringStream* stream);
1711 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1712 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1716 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1718 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1719 inputs_[0] = base_object;
1720 inputs_[1] = offset;
1723 LOperand* base_object() const { return inputs_[0]; }
1724 LOperand* offset() const { return inputs_[1]; }
1726 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1728 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1732 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1734 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1735 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1739 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1741 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1742 DECLARE_HYDROGEN_ACCESSOR(Context)
1746 class LOuterContext V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1748 explicit LOuterContext(LOperand* context) {
1749 inputs_[0] = context;
1752 LOperand* context() { return inputs_[0]; }
1754 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1758 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1760 explicit LDeclareGlobals(LOperand* context) {
1761 inputs_[0] = context;
1764 LOperand* context() { return inputs_[0]; }
1766 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1767 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1771 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1773 explicit LGlobalObject(LOperand* context) {
1774 inputs_[0] = context;
1777 LOperand* context() { return inputs_[0]; }
1779 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1783 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1785 explicit LGlobalReceiver(LOperand* global_object) {
1786 inputs_[0] = global_object;
1789 LOperand* global() { return inputs_[0]; }
1791 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1795 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1797 explicit LCallJSFunction(LOperand* function) {
1798 inputs_[0] = function;
1801 LOperand* function() { return inputs_[0]; }
1803 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1804 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1806 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1808 int arity() const { return hydrogen()->argument_count() - 1; }
1812 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1814 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1815 ZoneList<LOperand*>& operands,
1817 : descriptor_(descriptor),
1818 inputs_(descriptor->environment_length() + 1, zone) {
1819 ASSERT(descriptor->environment_length() + 1 == operands.length());
1820 inputs_.AddAll(operands, zone);
1823 LOperand* target() const { return inputs_[0]; }
1826 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1827 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1831 int arity() const { return hydrogen()->argument_count() - 1; }
1833 const CallInterfaceDescriptor* descriptor_;
1834 ZoneList<LOperand*> inputs_;
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 bool is_fixed_typed_array() const {
2177 return hydrogen()->is_fixed_typed_array();
2179 bool is_typed_elements() const {
2180 return is_external() || is_fixed_typed_array();
2182 LOperand* elements() { return inputs_[0]; }
2183 LOperand* key() { return inputs_[1]; }
2184 LOperand* value() { return inputs_[2]; }
2185 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2187 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2188 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2190 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2191 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2192 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2196 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2198 LStoreKeyedGeneric(LOperand* context,
2202 inputs_[0] = context;
2203 inputs_[1] = object;
2208 LOperand* context() { return inputs_[0]; }
2209 LOperand* object() { return inputs_[1]; }
2210 LOperand* key() { return inputs_[2]; }
2211 LOperand* value() { return inputs_[3]; }
2213 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2214 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2216 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2218 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2222 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2224 LTransitionElementsKind(LOperand* object,
2226 LOperand* new_map_temp,
2228 inputs_[0] = object;
2229 inputs_[1] = context;
2230 temps_[0] = new_map_temp;
2234 LOperand* object() { return inputs_[0]; }
2235 LOperand* context() { return inputs_[1]; }
2236 LOperand* new_map_temp() { return temps_[0]; }
2237 LOperand* temp() { return temps_[1]; }
2239 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2240 "transition-elements-kind")
2241 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2243 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2245 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2246 Handle<Map> transitioned_map() {
2247 return hydrogen()->transitioned_map().handle();
2249 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2250 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2254 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2256 LTrapAllocationMemento(LOperand* object,
2258 inputs_[0] = object;
2262 LOperand* object() { return inputs_[0]; }
2263 LOperand* temp() { return temps_[0]; }
2265 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2266 "trap-allocation-memento")
2270 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2272 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2273 inputs_[0] = context;
2278 LOperand* context() { return inputs_[0]; }
2279 LOperand* left() { return inputs_[1]; }
2280 LOperand* right() { return inputs_[2]; }
2282 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2283 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2287 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2289 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2290 inputs_[0] = context;
2291 inputs_[1] = string;
2295 LOperand* context() { return inputs_[0]; }
2296 LOperand* string() { return inputs_[1]; }
2297 LOperand* index() { return inputs_[2]; }
2299 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2300 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2304 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2306 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2307 inputs_[0] = context;
2308 inputs_[1] = char_code;
2311 LOperand* context() { return inputs_[0]; }
2312 LOperand* char_code() { return inputs_[1]; }
2314 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2315 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2319 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2321 explicit LCheckValue(LOperand* value) {
2325 LOperand* value() { return inputs_[0]; }
2327 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2328 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2332 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2334 explicit LCheckInstanceType(LOperand* value) {
2338 LOperand* value() { return inputs_[0]; }
2340 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2341 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2345 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2347 explicit LCheckMaps(LOperand* value) {
2351 LOperand* value() { return inputs_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2354 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2358 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2360 explicit LCheckSmi(LOperand* value) {
2364 LOperand* value() { return inputs_[0]; }
2366 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2370 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2372 explicit LClampDToUint8(LOperand* unclamped) {
2373 inputs_[0] = unclamped;
2376 LOperand* unclamped() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2382 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2384 explicit LClampIToUint8(LOperand* unclamped) {
2385 inputs_[0] = unclamped;
2388 LOperand* unclamped() { return inputs_[0]; }
2390 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2394 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2396 LClampTToUint8(LOperand* unclamped,
2397 LOperand* temp_xmm) {
2398 inputs_[0] = unclamped;
2399 temps_[0] = temp_xmm;
2402 LOperand* unclamped() { return inputs_[0]; }
2403 LOperand* temp_xmm() { return temps_[0]; }
2405 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2409 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2411 explicit LCheckNonSmi(LOperand* value) {
2415 LOperand* value() { return inputs_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2418 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2422 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2424 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2425 inputs_[0] = context;
2430 LOperand* context() { return inputs_[0]; }
2431 LOperand* size() { return inputs_[1]; }
2432 LOperand* temp() { return temps_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2435 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2439 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2441 explicit LRegExpLiteral(LOperand* context) {
2442 inputs_[0] = context;
2445 LOperand* context() { return inputs_[0]; }
2447 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2448 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2452 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2454 explicit LFunctionLiteral(LOperand* context) {
2455 inputs_[0] = context;
2458 LOperand* context() { return inputs_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2461 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2465 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2467 explicit LToFastProperties(LOperand* value) {
2471 LOperand* value() { return inputs_[0]; }
2473 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2474 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2478 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2480 LTypeof(LOperand* context, LOperand* value) {
2481 inputs_[0] = context;
2485 LOperand* context() { return inputs_[0]; }
2486 LOperand* value() { return inputs_[1]; }
2488 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2492 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2494 explicit LTypeofIsAndBranch(LOperand* value) {
2498 LOperand* value() { return inputs_[0]; }
2500 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2501 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2503 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2505 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2509 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2511 explicit LIsConstructCallAndBranch(LOperand* temp) {
2515 LOperand* temp() { return temps_[0]; }
2517 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2518 "is-construct-call-and-branch")
2519 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2523 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2527 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2530 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2534 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2536 explicit LStackCheck(LOperand* context) {
2537 inputs_[0] = context;
2540 LOperand* context() { return inputs_[0]; }
2542 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2543 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2545 Label* done_label() { return &done_label_; }
2552 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2554 LForInPrepareMap(LOperand* context, LOperand* object) {
2555 inputs_[0] = context;
2556 inputs_[1] = object;
2559 LOperand* context() { return inputs_[0]; }
2560 LOperand* object() { return inputs_[1]; }
2562 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2566 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2568 explicit LForInCacheArray(LOperand* map) {
2572 LOperand* map() { return inputs_[0]; }
2574 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2577 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2582 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2584 LCheckMapValue(LOperand* value, LOperand* map) {
2589 LOperand* value() { return inputs_[0]; }
2590 LOperand* map() { return inputs_[1]; }
2592 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2596 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2598 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2599 inputs_[0] = object;
2603 LOperand* object() { return inputs_[0]; }
2604 LOperand* index() { return inputs_[1]; }
2606 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2610 class LChunkBuilder;
2611 class LPlatformChunk V8_FINAL : public LChunk {
2613 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2614 : LChunk(info, graph) { }
2616 int GetNextSpillIndex(RegisterKind kind);
2617 LOperand* GetNextSpillSlot(RegisterKind kind);
2621 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2623 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2624 : LChunkBuilderBase(graph->zone()),
2629 current_instruction_(NULL),
2630 current_block_(NULL),
2632 allocator_(allocator),
2633 instruction_pending_deoptimization_environment_(NULL),
2634 pending_deoptimization_ast_id_(BailoutId::None()) { }
2636 // Build the sequence for the graph.
2637 LPlatformChunk* Build();
2639 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2641 // Declare methods that deal with the individual node types.
2642 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2643 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2646 static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
2648 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2649 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2650 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2651 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2652 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2653 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2654 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2664 LPlatformChunk* chunk() const { return chunk_; }
2665 CompilationInfo* info() const { return info_; }
2666 HGraph* graph() const { return graph_; }
2668 bool is_unused() const { return status_ == UNUSED; }
2669 bool is_building() const { return status_ == BUILDING; }
2670 bool is_done() const { return status_ == DONE; }
2671 bool is_aborted() const { return status_ == ABORTED; }
2673 void Abort(BailoutReason reason);
2675 // Methods for getting operands for Use / Define / Temp.
2676 LUnallocated* ToUnallocated(Register reg);
2677 LUnallocated* ToUnallocated(XMMRegister reg);
2679 // Methods for setting up define-use relationships.
2680 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2681 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2682 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2683 XMMRegister fixed_register);
2685 // A value that is guaranteed to be allocated to a register.
2686 // Operand created by UseRegister is guaranteed to be live until the end of
2687 // instruction. This means that register allocator will not reuse it's
2688 // register for any other operand inside instruction.
2689 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2690 // instruction start. Register allocator is free to assign the same register
2691 // to some other operand used inside instruction (i.e. temporary or
2693 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2694 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2696 // An input operand in a register that may be trashed.
2697 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2699 // An input operand in a register that may be trashed or a constant operand.
2700 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2702 // An input operand in a register or stack slot.
2703 MUST_USE_RESULT LOperand* Use(HValue* value);
2704 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2706 // An input operand in a register, stack slot or a constant operand.
2707 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2708 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2710 // An input operand in a register or a constant operand.
2711 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2712 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2714 // An input operand in a constant operand.
2715 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2717 // An input operand in register, stack slot or a constant operand.
2718 // Will not be moved to a register even if one is freely available.
2719 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2721 // Temporary operand that must be in a register.
2722 MUST_USE_RESULT LUnallocated* TempRegister();
2723 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2724 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2726 // Methods for setting up define-use relationships.
2727 // Return the same instruction that they are passed.
2728 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2729 LUnallocated* result);
2730 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2731 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2733 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2734 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2736 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2738 // Assigns an environment to an instruction. An instruction which can
2739 // deoptimize must have an environment.
2740 LInstruction* AssignEnvironment(LInstruction* instr);
2741 // Assigns a pointer map to an instruction. An instruction which can
2742 // trigger a GC or a lazy deoptimization must have a pointer map.
2743 LInstruction* AssignPointerMap(LInstruction* instr);
2745 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2747 // Marks a call for the register allocator. Assigns a pointer map to
2748 // support GC and lazy deoptimization. Assigns an environment to support
2749 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2750 LInstruction* MarkAsCall(
2751 LInstruction* instr,
2752 HInstruction* hinstr,
2753 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2755 void VisitInstruction(HInstruction* current);
2757 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2758 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2759 LInstruction* DoArithmeticD(Token::Value op,
2760 HArithmeticBinaryOperation* instr);
2761 LInstruction* DoArithmeticT(Token::Value op,
2762 HBinaryOperation* instr);
2764 LPlatformChunk* chunk_;
2765 CompilationInfo* info_;
2766 HGraph* const graph_;
2768 HInstruction* current_instruction_;
2769 HBasicBlock* current_block_;
2770 HBasicBlock* next_block_;
2771 LAllocator* allocator_;
2772 LInstruction* instruction_pending_deoptimization_environment_;
2773 BailoutId pending_deoptimization_ast_id_;
2775 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2778 #undef DECLARE_HYDROGEN_ACCESSOR
2779 #undef DECLARE_CONCRETE_INSTRUCTION
2781 } } // namespace v8::int
2783 #endif // V8_X64_LITHIUM_X64_H_