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) \
100 V(HasCachedArrayIndexAndBranch) \
101 V(HasInstanceTypeAndBranch) \
102 V(InnerAllocatedObject) \
104 V(InstanceOfKnownGlobal) \
106 V(Integer32ToDouble) \
109 V(IsConstructCallAndBranch) \
110 V(IsObjectAndBranch) \
111 V(IsStringAndBranch) \
113 V(IsUndetectableAndBranch) \
118 V(LoadFieldByIndex) \
119 V(LoadFunctionPrototype) \
121 V(LoadGlobalGeneric) \
123 V(LoadKeyedGeneric) \
125 V(LoadNamedGeneric) \
148 V(SeqStringGetChar) \
149 V(SeqStringSetChar) \
155 V(StoreContextSlot) \
158 V(StoreKeyedGeneric) \
160 V(StoreNamedGeneric) \
162 V(StringCharCodeAt) \
163 V(StringCharFromCode) \
164 V(StringCompareAndBranch) \
169 V(ToFastProperties) \
170 V(TransitionElementsKind) \
171 V(TrapAllocationMemento) \
173 V(TypeofIsAndBranch) \
180 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
181 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
182 return LInstruction::k##type; \
184 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
185 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
188 static L##type* cast(LInstruction* instr) { \
189 ASSERT(instr->Is##type()); \
190 return reinterpret_cast<L##type*>(instr); \
194 #define DECLARE_HYDROGEN_ACCESSOR(type) \
195 H##type* hydrogen() const { \
196 return H##type::cast(hydrogen_value()); \
200 class LInstruction : public ZoneObject {
203 : environment_(NULL),
204 hydrogen_value_(NULL),
205 bit_field_(IsCallBits::encode(false)) {
208 virtual ~LInstruction() {}
210 virtual void CompileToNative(LCodeGen* generator) = 0;
211 virtual const char* Mnemonic() const = 0;
212 virtual void PrintTo(StringStream* stream);
213 virtual void PrintDataTo(StringStream* stream);
214 virtual void PrintOutputOperandTo(StringStream* stream);
217 // Declare a unique enum value for each instruction.
218 #define DECLARE_OPCODE(type) k##type,
219 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
220 kNumberOfInstructions
221 #undef DECLARE_OPCODE
224 virtual Opcode opcode() const = 0;
226 // Declare non-virtual type testers for all leaf IR classes.
227 #define DECLARE_PREDICATE(type) \
228 bool Is##type() const { return opcode() == k##type; }
229 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
230 #undef DECLARE_PREDICATE
232 // Declare virtual predicates for instructions that don't have
234 virtual bool IsGap() const { return false; }
236 virtual bool IsControl() const { return false; }
238 void set_environment(LEnvironment* env) { environment_ = env; }
239 LEnvironment* environment() const { return environment_; }
240 bool HasEnvironment() const { return environment_ != NULL; }
242 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
243 LPointerMap* pointer_map() const { return pointer_map_.get(); }
244 bool HasPointerMap() const { return pointer_map_.is_set(); }
246 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
247 HValue* hydrogen_value() const { return hydrogen_value_; }
249 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
250 bool IsCall() const { return IsCallBits::decode(bit_field_); }
252 // Interface to the register allocator and iterators.
253 bool ClobbersTemps() const { return IsCall(); }
254 bool ClobbersRegisters() const { return IsCall(); }
255 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
257 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
259 // Interface to the register allocator and iterators.
260 bool IsMarkedAsCall() const { return IsCall(); }
262 virtual bool HasResult() const = 0;
263 virtual LOperand* result() const = 0;
265 LOperand* FirstInput() { return InputAt(0); }
266 LOperand* Output() { return HasResult() ? result() : NULL; }
268 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
276 friend class InputIterator;
277 virtual int InputCount() = 0;
278 virtual LOperand* InputAt(int i) = 0;
280 friend class TempIterator;
281 virtual int TempCount() = 0;
282 virtual LOperand* TempAt(int i) = 0;
284 class IsCallBits: public BitField<bool, 0, 1> {};
286 LEnvironment* environment_;
287 SetOncePointer<LPointerMap> pointer_map_;
288 HValue* hydrogen_value_;
293 // R = number of result operands (0 or 1).
295 class LTemplateResultInstruction : public LInstruction {
297 // Allow 0 or 1 output operands.
298 STATIC_ASSERT(R == 0 || R == 1);
299 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
300 return R != 0 && result() != NULL;
302 void set_result(LOperand* operand) { results_[0] = operand; }
303 LOperand* result() const { return results_[0]; }
306 EmbeddedContainer<LOperand*, R> results_;
310 // R = number of result operands (0 or 1).
311 // I = number of input operands.
312 // T = number of temporary operands.
313 template<int R, int I, int T>
314 class LTemplateInstruction : public LTemplateResultInstruction<R> {
316 EmbeddedContainer<LOperand*, I> inputs_;
317 EmbeddedContainer<LOperand*, T> temps_;
321 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
322 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
324 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
325 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
329 class LGap : public LTemplateInstruction<0, 0, 0> {
331 explicit LGap(HBasicBlock* block)
333 parallel_moves_[BEFORE] = NULL;
334 parallel_moves_[START] = NULL;
335 parallel_moves_[END] = NULL;
336 parallel_moves_[AFTER] = NULL;
339 // Can't use the DECLARE-macro here because of sub-classes.
340 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
341 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
342 static LGap* cast(LInstruction* instr) {
343 ASSERT(instr->IsGap());
344 return reinterpret_cast<LGap*>(instr);
347 bool IsRedundant() const;
349 HBasicBlock* block() const { return block_; }
356 FIRST_INNER_POSITION = BEFORE,
357 LAST_INNER_POSITION = AFTER
360 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
362 if (parallel_moves_[pos] == NULL) {
363 parallel_moves_[pos] = new(zone) LParallelMove(zone);
365 return parallel_moves_[pos];
368 LParallelMove* GetParallelMove(InnerPosition pos) {
369 return parallel_moves_[pos];
373 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
378 class LInstructionGap V8_FINAL : public LGap {
380 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
382 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
383 return !IsRedundant();
386 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
390 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
392 explicit LGoto(HBasicBlock* block) : block_(block) { }
394 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
395 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
396 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
397 virtual bool IsControl() const V8_OVERRIDE { return true; }
399 int block_id() const { return block_->block_id(); }
406 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
408 LLazyBailout() : gap_instructions_size_(0) { }
410 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
412 void set_gap_instructions_size(int gap_instructions_size) {
413 gap_instructions_size_ = gap_instructions_size;
415 int gap_instructions_size() { return gap_instructions_size_; }
418 int gap_instructions_size_;
422 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
424 explicit LDummy() { }
425 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
429 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
431 explicit LDummyUse(LOperand* value) {
434 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
438 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
440 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
441 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
445 class LLabel V8_FINAL : public LGap {
447 explicit LLabel(HBasicBlock* block)
448 : LGap(block), replacement_(NULL) { }
450 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
453 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
455 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
457 int block_id() const { return block()->block_id(); }
458 bool is_loop_header() const { return block()->IsLoopHeader(); }
459 bool is_osr_entry() const { return block()->is_osr_entry(); }
460 Label* label() { return &label_; }
461 LLabel* replacement() const { return replacement_; }
462 void set_replacement(LLabel* label) { replacement_ = label; }
463 bool HasReplacement() const { return replacement_ != NULL; }
467 LLabel* replacement_;
471 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
473 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
476 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
480 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
482 explicit LCallStub(LOperand* context) {
483 inputs_[0] = context;
486 LOperand* context() { return inputs_[0]; }
488 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
489 DECLARE_HYDROGEN_ACCESSOR(CallStub)
493 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
495 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
498 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
502 template<int I, int T>
503 class LControlInstruction : public LTemplateInstruction<0, I, T> {
505 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
507 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
509 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
510 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
512 int TrueDestination(LChunk* chunk) {
513 return chunk->LookupDestination(true_block_id());
515 int FalseDestination(LChunk* chunk) {
516 return chunk->LookupDestination(false_block_id());
519 Label* TrueLabel(LChunk* chunk) {
520 if (true_label_ == NULL) {
521 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
525 Label* FalseLabel(LChunk* chunk) {
526 if (false_label_ == NULL) {
527 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
533 int true_block_id() { return SuccessorAt(0)->block_id(); }
534 int false_block_id() { return SuccessorAt(1)->block_id(); }
537 HControlInstruction* hydrogen() {
538 return HControlInstruction::cast(this->hydrogen_value());
546 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
548 LWrapReceiver(LOperand* receiver, LOperand* function) {
549 inputs_[0] = receiver;
550 inputs_[1] = function;
553 LOperand* receiver() { return inputs_[0]; }
554 LOperand* function() { return inputs_[1]; }
556 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
560 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
562 LApplyArguments(LOperand* function,
565 LOperand* elements) {
566 inputs_[0] = function;
567 inputs_[1] = receiver;
569 inputs_[3] = elements;
572 LOperand* function() { return inputs_[0]; }
573 LOperand* receiver() { return inputs_[1]; }
574 LOperand* length() { return inputs_[2]; }
575 LOperand* elements() { return inputs_[3]; }
577 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
581 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
583 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
584 inputs_[0] = arguments;
589 LOperand* arguments() { return inputs_[0]; }
590 LOperand* length() { return inputs_[1]; }
591 LOperand* index() { return inputs_[2]; }
593 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
595 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
599 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
601 explicit LArgumentsLength(LOperand* elements) {
602 inputs_[0] = elements;
605 LOperand* elements() { return inputs_[0]; }
607 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
611 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
613 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
614 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
618 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
620 LModI(LOperand* left, LOperand* right, LOperand* temp) {
626 LOperand* left() { return inputs_[0]; }
627 LOperand* right() { return inputs_[1]; }
628 LOperand* temp() { return temps_[0]; }
630 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
631 DECLARE_HYDROGEN_ACCESSOR(Mod)
635 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
637 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
643 LOperand* left() { return inputs_[0]; }
644 LOperand* right() { return inputs_[1]; }
645 LOperand* temp() { return temps_[0]; }
647 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
649 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
650 DECLARE_HYDROGEN_ACCESSOR(Div)
654 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
656 LMathFloorOfDiv(LOperand* left,
658 LOperand* temp = NULL) {
664 LOperand* left() { return inputs_[0]; }
665 LOperand* right() { return inputs_[1]; }
666 LOperand* temp() { return temps_[0]; }
668 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
669 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
673 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
675 LMulI(LOperand* left, LOperand* right) {
680 LOperand* left() { return inputs_[0]; }
681 LOperand* right() { return inputs_[1]; }
683 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
684 DECLARE_HYDROGEN_ACCESSOR(Mul)
688 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
690 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
695 LOperand* left() { return inputs_[0]; }
696 LOperand* right() { return inputs_[1]; }
698 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
699 "compare-numeric-and-branch")
700 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
702 Token::Value op() const { return hydrogen()->token(); }
703 bool is_double() const {
704 return hydrogen()->representation().IsDouble();
707 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
711 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
713 explicit LMathFloor(LOperand* value) {
717 LOperand* value() { return inputs_[0]; }
719 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
720 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
724 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
726 explicit LMathRound(LOperand* value) {
730 LOperand* value() { return inputs_[0]; }
732 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
733 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
737 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
739 explicit LMathAbs(LOperand* context, LOperand* value) {
740 inputs_[1] = context;
744 LOperand* context() { return inputs_[1]; }
745 LOperand* value() { return inputs_[0]; }
747 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
748 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
752 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
754 explicit LMathLog(LOperand* value) {
758 LOperand* value() { return inputs_[0]; }
760 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
764 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
766 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
770 ExternalReference::InitializeMathExpData();
773 LOperand* value() { return inputs_[0]; }
774 LOperand* temp1() { return temps_[0]; }
775 LOperand* temp2() { return temps_[1]; }
777 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
781 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
783 explicit LMathSqrt(LOperand* value) {
787 LOperand* value() { return inputs_[0]; }
789 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
793 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
795 explicit LMathPowHalf(LOperand* value) {
799 LOperand* value() { return inputs_[0]; }
801 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
805 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
807 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
812 LOperand* left() { return inputs_[0]; }
813 LOperand* right() { return inputs_[1]; }
815 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
819 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
821 explicit LCmpHoleAndBranch(LOperand* object) {
825 LOperand* object() { return inputs_[0]; }
827 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
828 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
832 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
834 explicit LCompareMinusZeroAndBranch(LOperand* value) {
838 LOperand* value() { return inputs_[0]; }
840 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
841 "cmp-minus-zero-and-branch")
842 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
847 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
849 explicit LIsObjectAndBranch(LOperand* value) {
853 LOperand* value() { return inputs_[0]; }
855 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
856 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
858 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
862 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
864 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
869 LOperand* value() { return inputs_[0]; }
870 LOperand* temp() { return temps_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
873 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
875 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
879 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
881 explicit LIsSmiAndBranch(LOperand* value) {
885 LOperand* value() { return inputs_[0]; }
887 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
888 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
890 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
894 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
896 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
901 LOperand* value() { return inputs_[0]; }
902 LOperand* temp() { return temps_[0]; }
904 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
905 "is-undetectable-and-branch")
906 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
908 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
912 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
914 explicit LStringCompareAndBranch(LOperand* context,
917 inputs_[0] = context;
922 LOperand* context() { return inputs_[0]; }
923 LOperand* left() { return inputs_[1]; }
924 LOperand* right() { return inputs_[2]; }
926 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
927 "string-compare-and-branch")
928 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
930 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
932 Token::Value op() const { return hydrogen()->token(); }
936 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
938 explicit LHasInstanceTypeAndBranch(LOperand* value) {
942 LOperand* value() { return inputs_[0]; }
944 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
945 "has-instance-type-and-branch")
946 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
948 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
952 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
954 explicit LGetCachedArrayIndex(LOperand* value) {
958 LOperand* value() { return inputs_[0]; }
960 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
961 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
965 class LHasCachedArrayIndexAndBranch V8_FINAL
966 : public LControlInstruction<1, 0> {
968 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
972 LOperand* value() { return inputs_[0]; }
974 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
975 "has-cached-array-index-and-branch")
976 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
978 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
982 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
984 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
990 LOperand* value() { return inputs_[0]; }
991 LOperand* temp() { return temps_[0]; }
992 LOperand* temp2() { return temps_[1]; }
994 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
995 "class-of-test-and-branch")
996 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
998 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1002 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1004 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1005 inputs_[0] = context;
1010 LOperand* context() { return inputs_[0]; }
1011 LOperand* left() { return inputs_[1]; }
1012 LOperand* right() { return inputs_[2]; }
1014 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1015 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1017 Token::Value op() const { return hydrogen()->token(); }
1021 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1023 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1024 inputs_[0] = context;
1029 LOperand* context() { return inputs_[0]; }
1030 LOperand* left() { return inputs_[1]; }
1031 LOperand* right() { return inputs_[2]; }
1033 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1037 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1039 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1040 inputs_[0] = context;
1045 LOperand* context() { return inputs_[0]; }
1046 LOperand* value() { return inputs_[1]; }
1047 LOperand* temp() { return temps_[0]; }
1049 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1050 "instance-of-known-global")
1051 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1053 Handle<JSFunction> function() const { return hydrogen()->function(); }
1054 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1055 return lazy_deopt_env_;
1057 virtual void SetDeferredLazyDeoptimizationEnvironment(
1058 LEnvironment* env) V8_OVERRIDE {
1059 lazy_deopt_env_ = env;
1063 LEnvironment* lazy_deopt_env_;
1067 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1069 LBoundsCheck(LOperand* index, LOperand* length) {
1071 inputs_[1] = length;
1074 LOperand* index() { return inputs_[0]; }
1075 LOperand* length() { return inputs_[1]; }
1077 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1078 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1082 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1084 LBitI(LOperand* left, LOperand* right) {
1089 LOperand* left() { return inputs_[0]; }
1090 LOperand* right() { return inputs_[1]; }
1092 Token::Value op() const { return hydrogen()->op(); }
1094 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1095 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1099 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1101 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1102 : op_(op), can_deopt_(can_deopt) {
1107 Token::Value op() const { return op_; }
1108 LOperand* left() { return inputs_[0]; }
1109 LOperand* right() { return inputs_[1]; }
1110 bool can_deopt() const { return can_deopt_; }
1112 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1120 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1122 LSubI(LOperand* left, LOperand* right) {
1127 LOperand* left() { return inputs_[0]; }
1128 LOperand* right() { return inputs_[1]; }
1130 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1131 DECLARE_HYDROGEN_ACCESSOR(Sub)
1135 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1137 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1138 DECLARE_HYDROGEN_ACCESSOR(Constant)
1140 int32_t value() const { return hydrogen()->Integer32Value(); }
1144 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1146 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1147 DECLARE_HYDROGEN_ACCESSOR(Constant)
1149 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1153 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1155 explicit LConstantD(LOperand* temp) {
1159 LOperand* temp() { return temps_[0]; }
1161 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1162 DECLARE_HYDROGEN_ACCESSOR(Constant)
1164 double value() const { return hydrogen()->DoubleValue(); }
1168 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1170 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1171 DECLARE_HYDROGEN_ACCESSOR(Constant)
1173 ExternalReference value() const {
1174 return hydrogen()->ExternalReferenceValue();
1179 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1181 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1182 DECLARE_HYDROGEN_ACCESSOR(Constant)
1184 Handle<Object> value(Isolate* isolate) const {
1185 return hydrogen()->handle(isolate);
1190 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1192 explicit LBranch(LOperand* value) {
1196 LOperand* value() { return inputs_[0]; }
1198 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1199 DECLARE_HYDROGEN_ACCESSOR(Branch)
1201 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1205 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1207 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1211 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1213 explicit LCmpMapAndBranch(LOperand* value) {
1217 LOperand* value() { return inputs_[0]; }
1219 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1220 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1222 Handle<Map> map() const { return hydrogen()->map().handle(); }
1226 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1228 explicit LMapEnumLength(LOperand* value) {
1232 LOperand* value() { return inputs_[0]; }
1234 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1238 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1240 explicit LElementsKind(LOperand* value) {
1244 LOperand* value() { return inputs_[0]; }
1246 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1247 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1251 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1253 LDateField(LOperand* date, Smi* index) : index_(index) {
1257 LOperand* date() { return inputs_[0]; }
1258 Smi* index() const { return index_; }
1260 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1261 DECLARE_HYDROGEN_ACCESSOR(DateField)
1268 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1270 LSeqStringGetChar(LOperand* string, LOperand* index) {
1271 inputs_[0] = string;
1275 LOperand* string() const { return inputs_[0]; }
1276 LOperand* index() const { return inputs_[1]; }
1278 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1279 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1283 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1285 LSeqStringSetChar(LOperand* context,
1289 inputs_[0] = context;
1290 inputs_[1] = string;
1295 LOperand* string() { return inputs_[1]; }
1296 LOperand* index() { return inputs_[2]; }
1297 LOperand* value() { return inputs_[3]; }
1299 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1300 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1304 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1306 explicit LThrow(LOperand* context, LOperand* value) {
1307 inputs_[0] = context;
1311 LOperand* context() { return inputs_[0]; }
1312 LOperand* value() { return inputs_[1]; }
1314 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1318 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1320 LAddI(LOperand* left, LOperand* right) {
1325 LOperand* left() { return inputs_[0]; }
1326 LOperand* right() { return inputs_[1]; }
1328 static bool UseLea(HAdd* add) {
1329 return !add->CheckFlag(HValue::kCanOverflow) &&
1330 add->BetterLeftOperand()->UseCount() > 1;
1333 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1334 DECLARE_HYDROGEN_ACCESSOR(Add)
1338 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1340 LMathMinMax(LOperand* left, LOperand* right) {
1345 LOperand* left() { return inputs_[0]; }
1346 LOperand* right() { return inputs_[1]; }
1348 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1349 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1353 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1355 LPower(LOperand* left, LOperand* right) {
1360 LOperand* left() { return inputs_[0]; }
1361 LOperand* right() { return inputs_[1]; }
1363 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1364 DECLARE_HYDROGEN_ACCESSOR(Power)
1368 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1370 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1376 Token::Value op() const { return op_; }
1377 LOperand* left() { return inputs_[0]; }
1378 LOperand* right() { return inputs_[1]; }
1380 virtual Opcode opcode() const V8_OVERRIDE {
1381 return LInstruction::kArithmeticD;
1383 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1384 virtual const char* Mnemonic() const V8_OVERRIDE;
1391 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1393 LArithmeticT(Token::Value op,
1398 inputs_[0] = context;
1403 Token::Value op() const { return op_; }
1404 LOperand* context() { return inputs_[0]; }
1405 LOperand* left() { return inputs_[1]; }
1406 LOperand* right() { return inputs_[2]; }
1408 virtual Opcode opcode() const V8_OVERRIDE {
1409 return LInstruction::kArithmeticT;
1411 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1412 virtual const char* Mnemonic() const V8_OVERRIDE;
1419 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1421 explicit LReturn(LOperand* value,
1423 LOperand* parameter_count) {
1425 inputs_[1] = context;
1426 inputs_[2] = parameter_count;
1429 LOperand* value() { return inputs_[0]; }
1430 LOperand* context() { return inputs_[1]; }
1432 bool has_constant_parameter_count() {
1433 return parameter_count()->IsConstantOperand();
1435 LConstantOperand* constant_parameter_count() {
1436 ASSERT(has_constant_parameter_count());
1437 return LConstantOperand::cast(parameter_count());
1439 LOperand* parameter_count() { return inputs_[2]; }
1441 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1442 DECLARE_HYDROGEN_ACCESSOR(Return)
1446 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1448 explicit LLoadNamedField(LOperand* object) {
1449 inputs_[0] = object;
1452 LOperand* object() { return inputs_[0]; }
1454 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1455 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1459 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1461 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1462 inputs_[0] = context;
1463 inputs_[1] = object;
1466 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1467 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1469 LOperand* context() { return inputs_[0]; }
1470 LOperand* object() { return inputs_[1]; }
1471 Handle<Object> name() const { return hydrogen()->name(); }
1475 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1477 explicit LLoadFunctionPrototype(LOperand* function) {
1478 inputs_[0] = function;
1481 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1482 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1484 LOperand* function() { return inputs_[0]; }
1488 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1490 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1491 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1493 Heap::RootListIndex index() const { return hydrogen()->index(); }
1497 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1499 LLoadKeyed(LOperand* elements, LOperand* key) {
1500 inputs_[0] = elements;
1504 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1505 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1507 bool is_external() const {
1508 return hydrogen()->is_external();
1510 bool is_fixed_typed_array() const {
1511 return hydrogen()->is_fixed_typed_array();
1513 bool is_typed_elements() const {
1514 return is_external() || is_fixed_typed_array();
1516 LOperand* elements() { return inputs_[0]; }
1517 LOperand* key() { return inputs_[1]; }
1518 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1519 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1520 ElementsKind elements_kind() const {
1521 return hydrogen()->elements_kind();
1526 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1528 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1529 inputs_[0] = context;
1534 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1536 LOperand* context() { return inputs_[0]; }
1537 LOperand* object() { return inputs_[1]; }
1538 LOperand* key() { return inputs_[2]; }
1542 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1544 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1545 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1549 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1551 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1552 inputs_[0] = context;
1553 inputs_[1] = global_object;
1556 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1557 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1559 LOperand* context() { return inputs_[0]; }
1560 LOperand* global_object() { return inputs_[1]; }
1561 Handle<Object> name() const { return hydrogen()->name(); }
1562 bool for_typeof() const { return hydrogen()->for_typeof(); }
1566 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1568 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1573 LOperand* value() { return inputs_[0]; }
1574 LOperand* temp() { return temps_[0]; }
1576 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1577 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1581 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1583 explicit LLoadContextSlot(LOperand* context) {
1584 inputs_[0] = context;
1587 LOperand* context() { return inputs_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1590 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1592 int slot_index() { return hydrogen()->slot_index(); }
1594 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1598 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1600 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1601 inputs_[0] = context;
1606 LOperand* context() { return inputs_[0]; }
1607 LOperand* value() { return inputs_[1]; }
1608 LOperand* temp() { return temps_[0]; }
1610 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1611 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1613 int slot_index() { return hydrogen()->slot_index(); }
1615 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1619 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1621 explicit LPushArgument(LOperand* value) {
1625 LOperand* value() { return inputs_[0]; }
1627 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1631 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1633 explicit LDrop(int count) : count_(count) { }
1635 int count() const { return count_; }
1637 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1644 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1646 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1647 inputs_[0] = function;
1648 temps_[0] = code_object;
1651 LOperand* function() { return inputs_[0]; }
1652 LOperand* code_object() { return temps_[0]; }
1654 virtual void PrintDataTo(StringStream* stream);
1656 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1657 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1661 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1663 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1664 inputs_[0] = base_object;
1665 inputs_[1] = offset;
1668 LOperand* base_object() const { return inputs_[0]; }
1669 LOperand* offset() const { return inputs_[1]; }
1671 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1673 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1677 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1679 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1680 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1684 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1686 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1687 DECLARE_HYDROGEN_ACCESSOR(Context)
1691 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1693 explicit LDeclareGlobals(LOperand* context) {
1694 inputs_[0] = context;
1697 LOperand* context() { return inputs_[0]; }
1699 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1700 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1704 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1706 explicit LCallJSFunction(LOperand* function) {
1707 inputs_[0] = function;
1710 LOperand* function() { return inputs_[0]; }
1712 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1713 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1715 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1717 int arity() const { return hydrogen()->argument_count() - 1; }
1721 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1723 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1724 ZoneList<LOperand*>& operands,
1726 : inputs_(descriptor->environment_length() + 1, zone) {
1727 ASSERT(descriptor->environment_length() + 1 == operands.length());
1728 inputs_.AddAll(operands, zone);
1731 LOperand* target() const { return inputs_[0]; }
1734 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1735 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1737 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1739 int arity() const { return hydrogen()->argument_count() - 1; }
1741 ZoneList<LOperand*> inputs_;
1743 // Iterator support.
1744 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1745 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1747 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1748 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1752 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1754 LInvokeFunction(LOperand* context, LOperand* function) {
1755 inputs_[0] = context;
1756 inputs_[1] = function;
1759 LOperand* context() { return inputs_[0]; }
1760 LOperand* function() { return inputs_[1]; }
1762 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1763 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1765 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1767 int arity() const { return hydrogen()->argument_count() - 1; }
1771 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1773 LCallFunction(LOperand* context, LOperand* function) {
1774 inputs_[0] = context;
1775 inputs_[1] = function;
1778 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1779 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1781 LOperand* context() { return inputs_[0]; }
1782 LOperand* function() { return inputs_[1]; }
1783 int arity() const { return hydrogen()->argument_count() - 1; }
1787 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1789 LCallNew(LOperand* context, LOperand* constructor) {
1790 inputs_[0] = context;
1791 inputs_[1] = constructor;
1794 LOperand* context() { return inputs_[0]; }
1795 LOperand* constructor() { return inputs_[1]; }
1797 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1798 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1800 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1802 int arity() const { return hydrogen()->argument_count() - 1; }
1806 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1808 LCallNewArray(LOperand* context, LOperand* constructor) {
1809 inputs_[0] = context;
1810 inputs_[1] = constructor;
1813 LOperand* context() { return inputs_[0]; }
1814 LOperand* constructor() { return inputs_[1]; }
1816 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1817 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1819 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1821 int arity() const { return hydrogen()->argument_count() - 1; }
1825 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1827 explicit LCallRuntime(LOperand* context) {
1828 inputs_[0] = context;
1831 LOperand* context() { return inputs_[0]; }
1833 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1834 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1836 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1837 return save_doubles() == kDontSaveFPRegs;
1840 const Runtime::Function* function() const { return hydrogen()->function(); }
1841 int arity() const { return hydrogen()->argument_count(); }
1842 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1846 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1848 explicit LInteger32ToDouble(LOperand* value) {
1852 LOperand* value() { return inputs_[0]; }
1854 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1858 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1860 explicit LInteger32ToSmi(LOperand* value) {
1864 LOperand* value() { return inputs_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1867 DECLARE_HYDROGEN_ACCESSOR(Change)
1871 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1873 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1878 LOperand* value() { return inputs_[0]; }
1879 LOperand* temp() { return temps_[0]; }
1881 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1885 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1887 explicit LUint32ToSmi(LOperand* value) {
1891 LOperand* value() { return inputs_[0]; }
1893 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1894 DECLARE_HYDROGEN_ACCESSOR(Change)
1898 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1900 explicit LNumberTagI(LOperand* value) {
1904 LOperand* value() { return inputs_[0]; }
1906 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1910 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1912 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1917 LOperand* value() { return inputs_[0]; }
1918 LOperand* temp() { return temps_[0]; }
1920 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1924 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1926 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1931 LOperand* value() { return inputs_[0]; }
1932 LOperand* temp() { return temps_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1935 DECLARE_HYDROGEN_ACCESSOR(Change)
1939 // Sometimes truncating conversion from a tagged value to an int32.
1940 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1942 explicit LDoubleToI(LOperand* value) {
1946 LOperand* value() { return inputs_[0]; }
1948 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1949 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1951 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1955 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1957 explicit LDoubleToSmi(LOperand* value) {
1961 LOperand* value() { return inputs_[0]; }
1963 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1964 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1968 // Truncating conversion from a tagged value to an int32.
1969 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1971 LTaggedToI(LOperand* value, LOperand* temp) {
1976 LOperand* value() { return inputs_[0]; }
1977 LOperand* temp() { return temps_[0]; }
1979 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1980 DECLARE_HYDROGEN_ACCESSOR(Change)
1982 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1986 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1988 explicit LSmiTag(LOperand* value) {
1992 LOperand* value() { return inputs_[0]; }
1994 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1998 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2000 explicit LNumberUntagD(LOperand* value) {
2004 LOperand* value() { return inputs_[0]; }
2006 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2007 DECLARE_HYDROGEN_ACCESSOR(Change);
2011 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2013 LSmiUntag(LOperand* value, bool needs_check)
2014 : needs_check_(needs_check) {
2018 LOperand* value() { return inputs_[0]; }
2019 bool needs_check() const { return needs_check_; }
2021 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2028 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2030 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2031 inputs_[0] = object;
2036 LOperand* object() { return inputs_[0]; }
2037 LOperand* value() { return inputs_[1]; }
2038 LOperand* temp() { return temps_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2041 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2043 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2045 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2046 Representation representation() const {
2047 return hydrogen()->field_representation();
2052 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2054 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2055 inputs_[0] = context;
2056 inputs_[1] = object;
2060 LOperand* context() { return inputs_[0]; }
2061 LOperand* object() { return inputs_[1]; }
2062 LOperand* value() { return inputs_[2]; }
2064 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2065 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2067 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2069 Handle<Object> name() const { return hydrogen()->name(); }
2070 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2074 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2076 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2077 inputs_[0] = object;
2082 bool is_external() const { return hydrogen()->is_external(); }
2083 bool is_fixed_typed_array() const {
2084 return hydrogen()->is_fixed_typed_array();
2086 bool is_typed_elements() const {
2087 return is_external() || is_fixed_typed_array();
2089 LOperand* elements() { return inputs_[0]; }
2090 LOperand* key() { return inputs_[1]; }
2091 LOperand* value() { return inputs_[2]; }
2092 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2094 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2095 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2097 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2098 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2099 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2103 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2105 LStoreKeyedGeneric(LOperand* context,
2109 inputs_[0] = context;
2110 inputs_[1] = object;
2115 LOperand* context() { return inputs_[0]; }
2116 LOperand* object() { return inputs_[1]; }
2117 LOperand* key() { return inputs_[2]; }
2118 LOperand* value() { return inputs_[3]; }
2120 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2121 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2123 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2125 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2129 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2131 LTransitionElementsKind(LOperand* object,
2133 LOperand* new_map_temp,
2135 inputs_[0] = object;
2136 inputs_[1] = context;
2137 temps_[0] = new_map_temp;
2141 LOperand* object() { return inputs_[0]; }
2142 LOperand* context() { return inputs_[1]; }
2143 LOperand* new_map_temp() { return temps_[0]; }
2144 LOperand* temp() { return temps_[1]; }
2146 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2147 "transition-elements-kind")
2148 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2150 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2152 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2153 Handle<Map> transitioned_map() {
2154 return hydrogen()->transitioned_map().handle();
2156 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2157 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2161 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2163 LTrapAllocationMemento(LOperand* object,
2165 inputs_[0] = object;
2169 LOperand* object() { return inputs_[0]; }
2170 LOperand* temp() { return temps_[0]; }
2172 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2173 "trap-allocation-memento")
2177 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2179 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2180 inputs_[0] = context;
2185 LOperand* context() { return inputs_[0]; }
2186 LOperand* left() { return inputs_[1]; }
2187 LOperand* right() { return inputs_[2]; }
2189 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2190 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2194 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2196 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2197 inputs_[0] = context;
2198 inputs_[1] = string;
2202 LOperand* context() { return inputs_[0]; }
2203 LOperand* string() { return inputs_[1]; }
2204 LOperand* index() { return inputs_[2]; }
2206 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2207 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2211 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2213 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2214 inputs_[0] = context;
2215 inputs_[1] = char_code;
2218 LOperand* context() { return inputs_[0]; }
2219 LOperand* char_code() { return inputs_[1]; }
2221 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2222 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2226 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2228 explicit LCheckValue(LOperand* value) {
2232 LOperand* value() { return inputs_[0]; }
2234 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2235 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2239 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2241 explicit LCheckInstanceType(LOperand* value) {
2245 LOperand* value() { return inputs_[0]; }
2247 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2248 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2252 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2254 explicit LCheckMaps(LOperand* value) {
2258 LOperand* value() { return inputs_[0]; }
2260 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2261 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2265 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2267 explicit LCheckSmi(LOperand* value) {
2271 LOperand* value() { return inputs_[0]; }
2273 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2277 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2279 explicit LClampDToUint8(LOperand* unclamped) {
2280 inputs_[0] = unclamped;
2283 LOperand* unclamped() { return inputs_[0]; }
2285 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2289 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2291 explicit LClampIToUint8(LOperand* unclamped) {
2292 inputs_[0] = unclamped;
2295 LOperand* unclamped() { return inputs_[0]; }
2297 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2301 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2303 LClampTToUint8(LOperand* unclamped,
2304 LOperand* temp_xmm) {
2305 inputs_[0] = unclamped;
2306 temps_[0] = temp_xmm;
2309 LOperand* unclamped() { return inputs_[0]; }
2310 LOperand* temp_xmm() { return temps_[0]; }
2312 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2316 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2318 explicit LCheckNonSmi(LOperand* value) {
2322 LOperand* value() { return inputs_[0]; }
2324 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2325 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2329 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2331 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2332 inputs_[0] = context;
2337 LOperand* context() { return inputs_[0]; }
2338 LOperand* size() { return inputs_[1]; }
2339 LOperand* temp() { return temps_[0]; }
2341 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2342 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2346 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2348 explicit LRegExpLiteral(LOperand* context) {
2349 inputs_[0] = context;
2352 LOperand* context() { return inputs_[0]; }
2354 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2355 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2359 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2361 explicit LFunctionLiteral(LOperand* context) {
2362 inputs_[0] = context;
2365 LOperand* context() { return inputs_[0]; }
2367 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2368 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2372 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2374 explicit LToFastProperties(LOperand* value) {
2378 LOperand* value() { return inputs_[0]; }
2380 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2381 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2385 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2387 LTypeof(LOperand* context, LOperand* value) {
2388 inputs_[0] = context;
2392 LOperand* context() { return inputs_[0]; }
2393 LOperand* value() { return inputs_[1]; }
2395 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2399 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2401 explicit LTypeofIsAndBranch(LOperand* value) {
2405 LOperand* value() { return inputs_[0]; }
2407 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2408 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2410 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2412 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2416 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2418 explicit LIsConstructCallAndBranch(LOperand* temp) {
2422 LOperand* temp() { return temps_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2425 "is-construct-call-and-branch")
2426 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2430 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2434 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2437 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2441 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2443 explicit LStackCheck(LOperand* context) {
2444 inputs_[0] = context;
2447 LOperand* context() { return inputs_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2450 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2452 Label* done_label() { return &done_label_; }
2459 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2461 LForInPrepareMap(LOperand* context, LOperand* object) {
2462 inputs_[0] = context;
2463 inputs_[1] = object;
2466 LOperand* context() { return inputs_[0]; }
2467 LOperand* object() { return inputs_[1]; }
2469 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2473 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2475 explicit LForInCacheArray(LOperand* map) {
2479 LOperand* map() { return inputs_[0]; }
2481 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2484 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2489 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2491 LCheckMapValue(LOperand* value, LOperand* map) {
2496 LOperand* value() { return inputs_[0]; }
2497 LOperand* map() { return inputs_[1]; }
2499 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2503 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2505 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2506 inputs_[0] = object;
2510 LOperand* object() { return inputs_[0]; }
2511 LOperand* index() { return inputs_[1]; }
2513 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2517 class LChunkBuilder;
2518 class LPlatformChunk V8_FINAL : public LChunk {
2520 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2521 : LChunk(info, graph) { }
2523 int GetNextSpillIndex(RegisterKind kind);
2524 LOperand* GetNextSpillSlot(RegisterKind kind);
2528 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2530 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2531 : LChunkBuilderBase(graph->zone()),
2536 current_instruction_(NULL),
2537 current_block_(NULL),
2539 allocator_(allocator),
2540 instruction_pending_deoptimization_environment_(NULL),
2541 pending_deoptimization_ast_id_(BailoutId::None()) { }
2543 // Build the sequence for the graph.
2544 LPlatformChunk* Build();
2546 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2548 // Declare methods that deal with the individual node types.
2549 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2550 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2553 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2554 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2555 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2556 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2557 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2558 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2559 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2569 LPlatformChunk* chunk() const { return chunk_; }
2570 CompilationInfo* info() const { return info_; }
2571 HGraph* graph() const { return graph_; }
2573 bool is_unused() const { return status_ == UNUSED; }
2574 bool is_building() const { return status_ == BUILDING; }
2575 bool is_done() const { return status_ == DONE; }
2576 bool is_aborted() const { return status_ == ABORTED; }
2578 void Abort(BailoutReason reason);
2580 // Methods for getting operands for Use / Define / Temp.
2581 LUnallocated* ToUnallocated(Register reg);
2582 LUnallocated* ToUnallocated(XMMRegister reg);
2584 // Methods for setting up define-use relationships.
2585 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2586 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2587 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2588 XMMRegister fixed_register);
2590 // A value that is guaranteed to be allocated to a register.
2591 // Operand created by UseRegister is guaranteed to be live until the end of
2592 // instruction. This means that register allocator will not reuse it's
2593 // register for any other operand inside instruction.
2594 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2595 // instruction start. Register allocator is free to assign the same register
2596 // to some other operand used inside instruction (i.e. temporary or
2598 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2599 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2601 // An input operand in a register that may be trashed.
2602 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2604 // An input operand in a register that may be trashed or a constant operand.
2605 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2607 // An input operand in a register or stack slot.
2608 MUST_USE_RESULT LOperand* Use(HValue* value);
2609 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2611 // An input operand in a register, stack slot or a constant operand.
2612 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2613 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2615 // An input operand in a register or a constant operand.
2616 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2617 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2619 // An input operand in a constant operand.
2620 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2622 // An input operand in register, stack slot or a constant operand.
2623 // Will not be moved to a register even if one is freely available.
2624 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2626 // Temporary operand that must be in a register.
2627 MUST_USE_RESULT LUnallocated* TempRegister();
2628 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2629 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2631 // Methods for setting up define-use relationships.
2632 // Return the same instruction that they are passed.
2633 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2634 LUnallocated* result);
2635 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2636 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2638 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2639 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2641 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2643 // Assigns an environment to an instruction. An instruction which can
2644 // deoptimize must have an environment.
2645 LInstruction* AssignEnvironment(LInstruction* instr);
2646 // Assigns a pointer map to an instruction. An instruction which can
2647 // trigger a GC or a lazy deoptimization must have a pointer map.
2648 LInstruction* AssignPointerMap(LInstruction* instr);
2650 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2652 // Marks a call for the register allocator. Assigns a pointer map to
2653 // support GC and lazy deoptimization. Assigns an environment to support
2654 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2655 LInstruction* MarkAsCall(
2656 LInstruction* instr,
2657 HInstruction* hinstr,
2658 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2660 void VisitInstruction(HInstruction* current);
2662 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2663 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2664 LInstruction* DoArithmeticD(Token::Value op,
2665 HArithmeticBinaryOperation* instr);
2666 LInstruction* DoArithmeticT(Token::Value op,
2667 HBinaryOperation* instr);
2669 LPlatformChunk* chunk_;
2670 CompilationInfo* info_;
2671 HGraph* const graph_;
2673 HInstruction* current_instruction_;
2674 HBasicBlock* current_block_;
2675 HBasicBlock* next_block_;
2676 LAllocator* allocator_;
2677 LInstruction* instruction_pending_deoptimization_environment_;
2678 BailoutId pending_deoptimization_ast_id_;
2680 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2683 #undef DECLARE_HYDROGEN_ACCESSOR
2684 #undef DECLARE_CONCRETE_INSTRUCTION
2686 } } // namespace v8::int
2688 #endif // V8_X64_LITHIUM_X64_H_