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) \
97 V(GetCachedArrayIndex) \
99 V(HasCachedArrayIndexAndBranch) \
100 V(HasInstanceTypeAndBranch) \
101 V(InnerAllocatedObject) \
103 V(InstanceOfKnownGlobal) \
105 V(Integer32ToDouble) \
108 V(IsConstructCallAndBranch) \
109 V(IsObjectAndBranch) \
110 V(IsStringAndBranch) \
112 V(IsUndetectableAndBranch) \
117 V(LoadFieldByIndex) \
118 V(LoadFunctionPrototype) \
120 V(LoadGlobalGeneric) \
122 V(LoadKeyedGeneric) \
124 V(LoadNamedGeneric) \
147 V(SeqStringGetChar) \
148 V(SeqStringSetChar) \
154 V(StoreContextSlot) \
157 V(StoreKeyedGeneric) \
159 V(StoreNamedGeneric) \
161 V(StringCharCodeAt) \
162 V(StringCharFromCode) \
163 V(StringCompareAndBranch) \
167 V(ToFastProperties) \
168 V(TransitionElementsKind) \
169 V(TrapAllocationMemento) \
171 V(TypeofIsAndBranch) \
178 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
179 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
180 return LInstruction::k##type; \
182 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
183 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
186 static L##type* cast(LInstruction* instr) { \
187 ASSERT(instr->Is##type()); \
188 return reinterpret_cast<L##type*>(instr); \
192 #define DECLARE_HYDROGEN_ACCESSOR(type) \
193 H##type* hydrogen() const { \
194 return H##type::cast(hydrogen_value()); \
198 class LInstruction : public ZoneObject {
201 : environment_(NULL),
202 hydrogen_value_(NULL),
203 bit_field_(IsCallBits::encode(false)) {
206 virtual ~LInstruction() {}
208 virtual void CompileToNative(LCodeGen* generator) = 0;
209 virtual const char* Mnemonic() const = 0;
210 virtual void PrintTo(StringStream* stream);
211 virtual void PrintDataTo(StringStream* stream);
212 virtual void PrintOutputOperandTo(StringStream* stream);
215 // Declare a unique enum value for each instruction.
216 #define DECLARE_OPCODE(type) k##type,
217 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
218 kNumberOfInstructions
219 #undef DECLARE_OPCODE
222 virtual Opcode opcode() const = 0;
224 // Declare non-virtual type testers for all leaf IR classes.
225 #define DECLARE_PREDICATE(type) \
226 bool Is##type() const { return opcode() == k##type; }
227 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
228 #undef DECLARE_PREDICATE
230 // Declare virtual predicates for instructions that don't have
232 virtual bool IsGap() const { return false; }
234 virtual bool IsControl() const { return false; }
236 void set_environment(LEnvironment* env) { environment_ = env; }
237 LEnvironment* environment() const { return environment_; }
238 bool HasEnvironment() const { return environment_ != NULL; }
240 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
241 LPointerMap* pointer_map() const { return pointer_map_.get(); }
242 bool HasPointerMap() const { return pointer_map_.is_set(); }
244 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
245 HValue* hydrogen_value() const { return hydrogen_value_; }
247 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
248 bool IsCall() const { return IsCallBits::decode(bit_field_); }
250 // Interface to the register allocator and iterators.
251 bool ClobbersTemps() const { return IsCall(); }
252 bool ClobbersRegisters() const { return IsCall(); }
253 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
255 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
257 // Interface to the register allocator and iterators.
258 bool IsMarkedAsCall() const { return IsCall(); }
260 virtual bool HasResult() const = 0;
261 virtual LOperand* result() const = 0;
263 LOperand* FirstInput() { return InputAt(0); }
264 LOperand* Output() { return HasResult() ? result() : NULL; }
266 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
274 friend class InputIterator;
275 virtual int InputCount() = 0;
276 virtual LOperand* InputAt(int i) = 0;
278 friend class TempIterator;
279 virtual int TempCount() = 0;
280 virtual LOperand* TempAt(int i) = 0;
282 class IsCallBits: public BitField<bool, 0, 1> {};
284 LEnvironment* environment_;
285 SetOncePointer<LPointerMap> pointer_map_;
286 HValue* hydrogen_value_;
291 // R = number of result operands (0 or 1).
293 class LTemplateResultInstruction : public LInstruction {
295 // Allow 0 or 1 output operands.
296 STATIC_ASSERT(R == 0 || R == 1);
297 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
298 return R != 0 && result() != NULL;
300 void set_result(LOperand* operand) { results_[0] = operand; }
301 LOperand* result() const { return results_[0]; }
304 EmbeddedContainer<LOperand*, R> results_;
308 // R = number of result operands (0 or 1).
309 // I = number of input operands.
310 // T = number of temporary operands.
311 template<int R, int I, int T>
312 class LTemplateInstruction : public LTemplateResultInstruction<R> {
314 EmbeddedContainer<LOperand*, I> inputs_;
315 EmbeddedContainer<LOperand*, T> temps_;
319 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
320 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
322 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
323 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
327 class LGap : public LTemplateInstruction<0, 0, 0> {
329 explicit LGap(HBasicBlock* block)
331 parallel_moves_[BEFORE] = NULL;
332 parallel_moves_[START] = NULL;
333 parallel_moves_[END] = NULL;
334 parallel_moves_[AFTER] = NULL;
337 // Can't use the DECLARE-macro here because of sub-classes.
338 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
339 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
340 static LGap* cast(LInstruction* instr) {
341 ASSERT(instr->IsGap());
342 return reinterpret_cast<LGap*>(instr);
345 bool IsRedundant() const;
347 HBasicBlock* block() const { return block_; }
354 FIRST_INNER_POSITION = BEFORE,
355 LAST_INNER_POSITION = AFTER
358 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
360 if (parallel_moves_[pos] == NULL) {
361 parallel_moves_[pos] = new(zone) LParallelMove(zone);
363 return parallel_moves_[pos];
366 LParallelMove* GetParallelMove(InnerPosition pos) {
367 return parallel_moves_[pos];
371 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
376 class LInstructionGap V8_FINAL : public LGap {
378 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
380 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
381 return !IsRedundant();
384 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
388 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
390 explicit LGoto(HBasicBlock* block) : block_(block) { }
392 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
393 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
394 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
395 virtual bool IsControl() const V8_OVERRIDE { return true; }
397 int block_id() const { return block_->block_id(); }
404 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
406 LLazyBailout() : gap_instructions_size_(0) { }
408 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
410 void set_gap_instructions_size(int gap_instructions_size) {
411 gap_instructions_size_ = gap_instructions_size;
413 int gap_instructions_size() { return gap_instructions_size_; }
416 int gap_instructions_size_;
420 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
422 explicit LDummy() { }
423 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
427 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
429 explicit LDummyUse(LOperand* value) {
432 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
436 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
438 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
439 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
443 class LLabel V8_FINAL : public LGap {
445 explicit LLabel(HBasicBlock* block)
446 : LGap(block), replacement_(NULL) { }
448 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
451 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
453 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
455 int block_id() const { return block()->block_id(); }
456 bool is_loop_header() const { return block()->IsLoopHeader(); }
457 bool is_osr_entry() const { return block()->is_osr_entry(); }
458 Label* label() { return &label_; }
459 LLabel* replacement() const { return replacement_; }
460 void set_replacement(LLabel* label) { replacement_ = label; }
461 bool HasReplacement() const { return replacement_ != NULL; }
465 LLabel* replacement_;
469 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
471 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
474 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
478 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
480 explicit LCallStub(LOperand* context) {
481 inputs_[0] = context;
484 LOperand* context() { return inputs_[0]; }
486 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
487 DECLARE_HYDROGEN_ACCESSOR(CallStub)
491 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
493 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
496 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
500 template<int I, int T>
501 class LControlInstruction : public LTemplateInstruction<0, I, T> {
503 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
505 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
507 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
508 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
510 int TrueDestination(LChunk* chunk) {
511 return chunk->LookupDestination(true_block_id());
513 int FalseDestination(LChunk* chunk) {
514 return chunk->LookupDestination(false_block_id());
517 Label* TrueLabel(LChunk* chunk) {
518 if (true_label_ == NULL) {
519 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
523 Label* FalseLabel(LChunk* chunk) {
524 if (false_label_ == NULL) {
525 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
531 int true_block_id() { return SuccessorAt(0)->block_id(); }
532 int false_block_id() { return SuccessorAt(1)->block_id(); }
535 HControlInstruction* hydrogen() {
536 return HControlInstruction::cast(this->hydrogen_value());
544 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
546 LWrapReceiver(LOperand* receiver, LOperand* function) {
547 inputs_[0] = receiver;
548 inputs_[1] = function;
551 LOperand* receiver() { return inputs_[0]; }
552 LOperand* function() { return inputs_[1]; }
554 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
555 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
559 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
561 LApplyArguments(LOperand* function,
564 LOperand* elements) {
565 inputs_[0] = function;
566 inputs_[1] = receiver;
568 inputs_[3] = elements;
571 LOperand* function() { return inputs_[0]; }
572 LOperand* receiver() { return inputs_[1]; }
573 LOperand* length() { return inputs_[2]; }
574 LOperand* elements() { return inputs_[3]; }
576 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
580 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
582 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
583 inputs_[0] = arguments;
588 LOperand* arguments() { return inputs_[0]; }
589 LOperand* length() { return inputs_[1]; }
590 LOperand* index() { return inputs_[2]; }
592 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
594 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
598 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
600 explicit LArgumentsLength(LOperand* elements) {
601 inputs_[0] = elements;
604 LOperand* elements() { return inputs_[0]; }
606 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
610 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
612 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
613 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
617 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
619 LModI(LOperand* left, LOperand* right, LOperand* temp) {
625 LOperand* left() { return inputs_[0]; }
626 LOperand* right() { return inputs_[1]; }
627 LOperand* temp() { return temps_[0]; }
629 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
630 DECLARE_HYDROGEN_ACCESSOR(Mod)
634 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
636 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
642 LOperand* left() { return inputs_[0]; }
643 LOperand* right() { return inputs_[1]; }
644 LOperand* temp() { return temps_[0]; }
646 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
648 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
649 DECLARE_HYDROGEN_ACCESSOR(Div)
653 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
655 LMathFloorOfDiv(LOperand* left,
657 LOperand* temp = NULL) {
663 LOperand* left() { return inputs_[0]; }
664 LOperand* right() { return inputs_[1]; }
665 LOperand* temp() { return temps_[0]; }
667 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
668 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
672 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
674 LMulI(LOperand* left, LOperand* right) {
679 LOperand* left() { return inputs_[0]; }
680 LOperand* right() { return inputs_[1]; }
682 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
683 DECLARE_HYDROGEN_ACCESSOR(Mul)
687 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
689 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
694 LOperand* left() { return inputs_[0]; }
695 LOperand* right() { return inputs_[1]; }
697 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
698 "compare-numeric-and-branch")
699 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
701 Token::Value op() const { return hydrogen()->token(); }
702 bool is_double() const {
703 return hydrogen()->representation().IsDouble();
706 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
710 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
712 explicit LMathFloor(LOperand* value) {
716 LOperand* value() { return inputs_[0]; }
718 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
719 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
723 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
725 explicit LMathRound(LOperand* value) {
729 LOperand* value() { return inputs_[0]; }
731 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
732 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
736 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
738 explicit LMathAbs(LOperand* context, LOperand* value) {
739 inputs_[1] = context;
743 LOperand* context() { return inputs_[1]; }
744 LOperand* value() { return inputs_[0]; }
746 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
747 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
751 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
753 explicit LMathLog(LOperand* value) {
757 LOperand* value() { return inputs_[0]; }
759 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
763 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
765 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
769 ExternalReference::InitializeMathExpData();
772 LOperand* value() { return inputs_[0]; }
773 LOperand* temp1() { return temps_[0]; }
774 LOperand* temp2() { return temps_[1]; }
776 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
780 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
782 explicit LMathSqrt(LOperand* value) {
786 LOperand* value() { return inputs_[0]; }
788 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
792 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
794 explicit LMathPowHalf(LOperand* value) {
798 LOperand* value() { return inputs_[0]; }
800 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
804 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
806 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
811 LOperand* left() { return inputs_[0]; }
812 LOperand* right() { return inputs_[1]; }
814 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
818 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
820 explicit LCmpHoleAndBranch(LOperand* object) {
824 LOperand* object() { return inputs_[0]; }
826 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
827 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
831 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
833 explicit LCompareMinusZeroAndBranch(LOperand* value) {
837 LOperand* value() { return inputs_[0]; }
839 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
840 "cmp-minus-zero-and-branch")
841 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
846 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
848 explicit LIsObjectAndBranch(LOperand* value) {
852 LOperand* value() { return inputs_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
855 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
857 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
861 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
863 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
868 LOperand* value() { return inputs_[0]; }
869 LOperand* temp() { return temps_[0]; }
871 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
872 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
874 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
878 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
880 explicit LIsSmiAndBranch(LOperand* value) {
884 LOperand* value() { return inputs_[0]; }
886 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
887 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
889 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
893 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
895 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
900 LOperand* value() { return inputs_[0]; }
901 LOperand* temp() { return temps_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
904 "is-undetectable-and-branch")
905 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
907 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
911 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
913 explicit LStringCompareAndBranch(LOperand* context,
916 inputs_[0] = context;
921 LOperand* context() { return inputs_[0]; }
922 LOperand* left() { return inputs_[1]; }
923 LOperand* right() { return inputs_[2]; }
925 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
926 "string-compare-and-branch")
927 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
929 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
931 Token::Value op() const { return hydrogen()->token(); }
935 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
937 explicit LHasInstanceTypeAndBranch(LOperand* value) {
941 LOperand* value() { return inputs_[0]; }
943 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
944 "has-instance-type-and-branch")
945 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
947 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
951 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
953 explicit LGetCachedArrayIndex(LOperand* value) {
957 LOperand* value() { return inputs_[0]; }
959 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
960 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
964 class LHasCachedArrayIndexAndBranch V8_FINAL
965 : public LControlInstruction<1, 0> {
967 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
971 LOperand* value() { return inputs_[0]; }
973 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
974 "has-cached-array-index-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
977 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
981 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
983 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
989 LOperand* value() { return inputs_[0]; }
990 LOperand* temp() { return temps_[0]; }
991 LOperand* temp2() { return temps_[1]; }
993 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
994 "class-of-test-and-branch")
995 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
997 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1001 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1003 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1004 inputs_[0] = context;
1009 LOperand* context() { return inputs_[0]; }
1010 LOperand* left() { return inputs_[1]; }
1011 LOperand* right() { return inputs_[2]; }
1013 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1014 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1016 Token::Value op() const { return hydrogen()->token(); }
1020 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1022 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1023 inputs_[0] = context;
1028 LOperand* context() { return inputs_[0]; }
1029 LOperand* left() { return inputs_[1]; }
1030 LOperand* right() { return inputs_[2]; }
1032 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1036 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1038 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1039 inputs_[0] = context;
1044 LOperand* context() { return inputs_[0]; }
1045 LOperand* value() { return inputs_[1]; }
1046 LOperand* temp() { return temps_[0]; }
1048 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1049 "instance-of-known-global")
1050 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1052 Handle<JSFunction> function() const { return hydrogen()->function(); }
1053 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1054 return lazy_deopt_env_;
1056 virtual void SetDeferredLazyDeoptimizationEnvironment(
1057 LEnvironment* env) V8_OVERRIDE {
1058 lazy_deopt_env_ = env;
1062 LEnvironment* lazy_deopt_env_;
1066 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1068 LBoundsCheck(LOperand* index, LOperand* length) {
1070 inputs_[1] = length;
1073 LOperand* index() { return inputs_[0]; }
1074 LOperand* length() { return inputs_[1]; }
1076 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1077 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1081 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1083 LBitI(LOperand* left, LOperand* right) {
1088 LOperand* left() { return inputs_[0]; }
1089 LOperand* right() { return inputs_[1]; }
1091 Token::Value op() const { return hydrogen()->op(); }
1093 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1094 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1098 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1100 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1101 : op_(op), can_deopt_(can_deopt) {
1106 Token::Value op() const { return op_; }
1107 LOperand* left() { return inputs_[0]; }
1108 LOperand* right() { return inputs_[1]; }
1109 bool can_deopt() const { return can_deopt_; }
1111 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1119 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1121 LSubI(LOperand* left, LOperand* right) {
1126 LOperand* left() { return inputs_[0]; }
1127 LOperand* right() { return inputs_[1]; }
1129 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1130 DECLARE_HYDROGEN_ACCESSOR(Sub)
1134 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1136 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1137 DECLARE_HYDROGEN_ACCESSOR(Constant)
1139 int32_t value() const { return hydrogen()->Integer32Value(); }
1143 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1145 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1146 DECLARE_HYDROGEN_ACCESSOR(Constant)
1148 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1152 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1154 explicit LConstantD(LOperand* temp) {
1158 LOperand* temp() { return temps_[0]; }
1160 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1161 DECLARE_HYDROGEN_ACCESSOR(Constant)
1163 double value() const { return hydrogen()->DoubleValue(); }
1167 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1169 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1170 DECLARE_HYDROGEN_ACCESSOR(Constant)
1172 ExternalReference value() const {
1173 return hydrogen()->ExternalReferenceValue();
1178 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1180 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1181 DECLARE_HYDROGEN_ACCESSOR(Constant)
1183 Handle<Object> value(Isolate* isolate) const {
1184 return hydrogen()->handle(isolate);
1189 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1191 explicit LBranch(LOperand* value) {
1195 LOperand* value() { return inputs_[0]; }
1197 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1198 DECLARE_HYDROGEN_ACCESSOR(Branch)
1200 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1204 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1206 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1210 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1212 explicit LCmpMapAndBranch(LOperand* value) {
1216 LOperand* value() { return inputs_[0]; }
1218 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1219 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1221 Handle<Map> map() const { return hydrogen()->map().handle(); }
1225 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1227 explicit LMapEnumLength(LOperand* value) {
1231 LOperand* value() { return inputs_[0]; }
1233 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1237 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1239 LDateField(LOperand* date, Smi* index) : index_(index) {
1243 LOperand* date() { return inputs_[0]; }
1244 Smi* index() const { return index_; }
1246 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1247 DECLARE_HYDROGEN_ACCESSOR(DateField)
1254 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1256 LSeqStringGetChar(LOperand* string, LOperand* index) {
1257 inputs_[0] = string;
1261 LOperand* string() const { return inputs_[0]; }
1262 LOperand* index() const { return inputs_[1]; }
1264 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1265 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1269 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1271 LSeqStringSetChar(LOperand* context,
1275 inputs_[0] = context;
1276 inputs_[1] = string;
1281 LOperand* string() { return inputs_[1]; }
1282 LOperand* index() { return inputs_[2]; }
1283 LOperand* value() { return inputs_[3]; }
1285 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1286 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1290 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1292 LAddI(LOperand* left, LOperand* right) {
1297 LOperand* left() { return inputs_[0]; }
1298 LOperand* right() { return inputs_[1]; }
1300 static bool UseLea(HAdd* add) {
1301 return !add->CheckFlag(HValue::kCanOverflow) &&
1302 add->BetterLeftOperand()->UseCount() > 1;
1305 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1306 DECLARE_HYDROGEN_ACCESSOR(Add)
1310 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1312 LMathMinMax(LOperand* left, LOperand* right) {
1317 LOperand* left() { return inputs_[0]; }
1318 LOperand* right() { return inputs_[1]; }
1320 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1321 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1325 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1327 LPower(LOperand* left, LOperand* right) {
1332 LOperand* left() { return inputs_[0]; }
1333 LOperand* right() { return inputs_[1]; }
1335 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1336 DECLARE_HYDROGEN_ACCESSOR(Power)
1340 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1342 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1348 Token::Value op() const { return op_; }
1349 LOperand* left() { return inputs_[0]; }
1350 LOperand* right() { return inputs_[1]; }
1352 virtual Opcode opcode() const V8_OVERRIDE {
1353 return LInstruction::kArithmeticD;
1355 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1356 virtual const char* Mnemonic() const V8_OVERRIDE;
1363 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1365 LArithmeticT(Token::Value op,
1370 inputs_[0] = context;
1375 Token::Value op() const { return op_; }
1376 LOperand* context() { return inputs_[0]; }
1377 LOperand* left() { return inputs_[1]; }
1378 LOperand* right() { return inputs_[2]; }
1380 virtual Opcode opcode() const V8_OVERRIDE {
1381 return LInstruction::kArithmeticT;
1383 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1384 virtual const char* Mnemonic() const V8_OVERRIDE;
1391 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1393 explicit LReturn(LOperand* value,
1395 LOperand* parameter_count) {
1397 inputs_[1] = context;
1398 inputs_[2] = parameter_count;
1401 LOperand* value() { return inputs_[0]; }
1402 LOperand* context() { return inputs_[1]; }
1404 bool has_constant_parameter_count() {
1405 return parameter_count()->IsConstantOperand();
1407 LConstantOperand* constant_parameter_count() {
1408 ASSERT(has_constant_parameter_count());
1409 return LConstantOperand::cast(parameter_count());
1411 LOperand* parameter_count() { return inputs_[2]; }
1413 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1414 DECLARE_HYDROGEN_ACCESSOR(Return)
1418 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1420 explicit LLoadNamedField(LOperand* object) {
1421 inputs_[0] = object;
1424 LOperand* object() { return inputs_[0]; }
1426 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1427 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1431 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1433 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1434 inputs_[0] = context;
1435 inputs_[1] = object;
1438 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1439 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1441 LOperand* context() { return inputs_[0]; }
1442 LOperand* object() { return inputs_[1]; }
1443 Handle<Object> name() const { return hydrogen()->name(); }
1447 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1449 explicit LLoadFunctionPrototype(LOperand* function) {
1450 inputs_[0] = function;
1453 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1454 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1456 LOperand* function() { return inputs_[0]; }
1460 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1462 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1463 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1465 Heap::RootListIndex index() const { return hydrogen()->index(); }
1469 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1471 LLoadKeyed(LOperand* elements, LOperand* key) {
1472 inputs_[0] = elements;
1476 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1477 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1479 bool is_external() const {
1480 return hydrogen()->is_external();
1482 bool is_fixed_typed_array() const {
1483 return hydrogen()->is_fixed_typed_array();
1485 bool is_typed_elements() const {
1486 return is_external() || is_fixed_typed_array();
1488 LOperand* elements() { return inputs_[0]; }
1489 LOperand* key() { return inputs_[1]; }
1490 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1491 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1492 ElementsKind elements_kind() const {
1493 return hydrogen()->elements_kind();
1498 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1500 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1501 inputs_[0] = context;
1506 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1508 LOperand* context() { return inputs_[0]; }
1509 LOperand* object() { return inputs_[1]; }
1510 LOperand* key() { return inputs_[2]; }
1514 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1516 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1517 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1521 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1523 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1524 inputs_[0] = context;
1525 inputs_[1] = global_object;
1528 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1529 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1531 LOperand* context() { return inputs_[0]; }
1532 LOperand* global_object() { return inputs_[1]; }
1533 Handle<Object> name() const { return hydrogen()->name(); }
1534 bool for_typeof() const { return hydrogen()->for_typeof(); }
1538 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1540 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1545 LOperand* value() { return inputs_[0]; }
1546 LOperand* temp() { return temps_[0]; }
1548 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1549 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1553 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1555 explicit LLoadContextSlot(LOperand* context) {
1556 inputs_[0] = context;
1559 LOperand* context() { return inputs_[0]; }
1561 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1562 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1564 int slot_index() { return hydrogen()->slot_index(); }
1566 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1570 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1572 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1573 inputs_[0] = context;
1578 LOperand* context() { return inputs_[0]; }
1579 LOperand* value() { return inputs_[1]; }
1580 LOperand* temp() { return temps_[0]; }
1582 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1583 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1585 int slot_index() { return hydrogen()->slot_index(); }
1587 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1591 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1593 explicit LPushArgument(LOperand* value) {
1597 LOperand* value() { return inputs_[0]; }
1599 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1603 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1605 explicit LDrop(int count) : count_(count) { }
1607 int count() const { return count_; }
1609 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1616 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1618 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1619 inputs_[0] = function;
1620 temps_[0] = code_object;
1623 LOperand* function() { return inputs_[0]; }
1624 LOperand* code_object() { return temps_[0]; }
1626 virtual void PrintDataTo(StringStream* stream);
1628 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1629 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1633 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1635 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1636 inputs_[0] = base_object;
1637 inputs_[1] = offset;
1640 LOperand* base_object() const { return inputs_[0]; }
1641 LOperand* offset() const { return inputs_[1]; }
1643 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1645 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1649 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1651 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1652 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1656 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1658 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1659 DECLARE_HYDROGEN_ACCESSOR(Context)
1663 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1665 explicit LDeclareGlobals(LOperand* context) {
1666 inputs_[0] = context;
1669 LOperand* context() { return inputs_[0]; }
1671 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1672 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1676 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1678 explicit LCallJSFunction(LOperand* function) {
1679 inputs_[0] = function;
1682 LOperand* function() { return inputs_[0]; }
1684 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1685 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1687 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1689 int arity() const { return hydrogen()->argument_count() - 1; }
1693 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1695 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1696 ZoneList<LOperand*>& operands,
1698 : inputs_(descriptor->environment_length() + 1, zone) {
1699 ASSERT(descriptor->environment_length() + 1 == operands.length());
1700 inputs_.AddAll(operands, zone);
1703 LOperand* target() const { return inputs_[0]; }
1706 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1707 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1709 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1711 int arity() const { return hydrogen()->argument_count() - 1; }
1713 ZoneList<LOperand*> inputs_;
1715 // Iterator support.
1716 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1717 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1719 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1720 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1724 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1726 LInvokeFunction(LOperand* context, LOperand* function) {
1727 inputs_[0] = context;
1728 inputs_[1] = function;
1731 LOperand* context() { return inputs_[0]; }
1732 LOperand* function() { return inputs_[1]; }
1734 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1735 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1737 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1739 int arity() const { return hydrogen()->argument_count() - 1; }
1743 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1745 LCallFunction(LOperand* context, LOperand* function) {
1746 inputs_[0] = context;
1747 inputs_[1] = function;
1750 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1751 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1753 LOperand* context() { return inputs_[0]; }
1754 LOperand* function() { return inputs_[1]; }
1755 int arity() const { return hydrogen()->argument_count() - 1; }
1759 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1761 LCallNew(LOperand* context, LOperand* constructor) {
1762 inputs_[0] = context;
1763 inputs_[1] = constructor;
1766 LOperand* context() { return inputs_[0]; }
1767 LOperand* constructor() { return inputs_[1]; }
1769 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1770 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1772 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1774 int arity() const { return hydrogen()->argument_count() - 1; }
1778 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1780 LCallNewArray(LOperand* context, LOperand* constructor) {
1781 inputs_[0] = context;
1782 inputs_[1] = constructor;
1785 LOperand* context() { return inputs_[0]; }
1786 LOperand* constructor() { return inputs_[1]; }
1788 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1789 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1791 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1793 int arity() const { return hydrogen()->argument_count() - 1; }
1797 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1799 explicit LCallRuntime(LOperand* context) {
1800 inputs_[0] = context;
1803 LOperand* context() { return inputs_[0]; }
1805 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1806 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1808 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1809 return save_doubles() == kDontSaveFPRegs;
1812 const Runtime::Function* function() const { return hydrogen()->function(); }
1813 int arity() const { return hydrogen()->argument_count(); }
1814 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1818 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1820 explicit LInteger32ToDouble(LOperand* value) {
1824 LOperand* value() { return inputs_[0]; }
1826 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1830 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1832 explicit LInteger32ToSmi(LOperand* value) {
1836 LOperand* value() { return inputs_[0]; }
1838 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1839 DECLARE_HYDROGEN_ACCESSOR(Change)
1843 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1845 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1850 LOperand* value() { return inputs_[0]; }
1851 LOperand* temp() { return temps_[0]; }
1853 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1857 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1859 explicit LUint32ToSmi(LOperand* value) {
1863 LOperand* value() { return inputs_[0]; }
1865 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1866 DECLARE_HYDROGEN_ACCESSOR(Change)
1870 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1872 explicit LNumberTagI(LOperand* value) {
1876 LOperand* value() { return inputs_[0]; }
1878 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1882 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1884 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1889 LOperand* value() { return inputs_[0]; }
1890 LOperand* temp() { return temps_[0]; }
1892 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1896 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1898 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1903 LOperand* value() { return inputs_[0]; }
1904 LOperand* temp() { return temps_[0]; }
1906 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1907 DECLARE_HYDROGEN_ACCESSOR(Change)
1911 // Sometimes truncating conversion from a tagged value to an int32.
1912 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1914 explicit LDoubleToI(LOperand* value) {
1918 LOperand* value() { return inputs_[0]; }
1920 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1921 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1923 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1927 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1929 explicit LDoubleToSmi(LOperand* value) {
1933 LOperand* value() { return inputs_[0]; }
1935 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1936 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1940 // Truncating conversion from a tagged value to an int32.
1941 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1943 LTaggedToI(LOperand* value, LOperand* temp) {
1948 LOperand* value() { return inputs_[0]; }
1949 LOperand* temp() { return temps_[0]; }
1951 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1952 DECLARE_HYDROGEN_ACCESSOR(Change)
1954 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1958 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1960 explicit LSmiTag(LOperand* value) {
1964 LOperand* value() { return inputs_[0]; }
1966 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1970 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1972 explicit LNumberUntagD(LOperand* value) {
1976 LOperand* value() { return inputs_[0]; }
1978 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1979 DECLARE_HYDROGEN_ACCESSOR(Change);
1983 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1985 LSmiUntag(LOperand* value, bool needs_check)
1986 : needs_check_(needs_check) {
1990 LOperand* value() { return inputs_[0]; }
1991 bool needs_check() const { return needs_check_; }
1993 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2000 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2002 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2003 inputs_[0] = object;
2008 LOperand* object() { return inputs_[0]; }
2009 LOperand* value() { return inputs_[1]; }
2010 LOperand* temp() { return temps_[0]; }
2012 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2013 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2015 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2017 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2018 Representation representation() const {
2019 return hydrogen()->field_representation();
2024 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2026 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2027 inputs_[0] = context;
2028 inputs_[1] = object;
2032 LOperand* context() { return inputs_[0]; }
2033 LOperand* object() { return inputs_[1]; }
2034 LOperand* value() { return inputs_[2]; }
2036 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2037 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2039 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2041 Handle<Object> name() const { return hydrogen()->name(); }
2042 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2046 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2048 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2049 inputs_[0] = object;
2054 bool is_external() const { return hydrogen()->is_external(); }
2055 bool is_fixed_typed_array() const {
2056 return hydrogen()->is_fixed_typed_array();
2058 bool is_typed_elements() const {
2059 return is_external() || is_fixed_typed_array();
2061 LOperand* elements() { return inputs_[0]; }
2062 LOperand* key() { return inputs_[1]; }
2063 LOperand* value() { return inputs_[2]; }
2064 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2066 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2067 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2069 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2070 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2071 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2075 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2077 LStoreKeyedGeneric(LOperand* context,
2081 inputs_[0] = context;
2082 inputs_[1] = object;
2087 LOperand* context() { return inputs_[0]; }
2088 LOperand* object() { return inputs_[1]; }
2089 LOperand* key() { return inputs_[2]; }
2090 LOperand* value() { return inputs_[3]; }
2092 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2093 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2095 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2097 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2101 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2103 LTransitionElementsKind(LOperand* object,
2105 LOperand* new_map_temp,
2107 inputs_[0] = object;
2108 inputs_[1] = context;
2109 temps_[0] = new_map_temp;
2113 LOperand* object() { return inputs_[0]; }
2114 LOperand* context() { return inputs_[1]; }
2115 LOperand* new_map_temp() { return temps_[0]; }
2116 LOperand* temp() { return temps_[1]; }
2118 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2119 "transition-elements-kind")
2120 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2122 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2124 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2125 Handle<Map> transitioned_map() {
2126 return hydrogen()->transitioned_map().handle();
2128 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2129 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2133 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2135 LTrapAllocationMemento(LOperand* object,
2137 inputs_[0] = object;
2141 LOperand* object() { return inputs_[0]; }
2142 LOperand* temp() { return temps_[0]; }
2144 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2145 "trap-allocation-memento")
2149 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2151 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2152 inputs_[0] = context;
2157 LOperand* context() { return inputs_[0]; }
2158 LOperand* left() { return inputs_[1]; }
2159 LOperand* right() { return inputs_[2]; }
2161 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2162 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2166 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2168 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2169 inputs_[0] = context;
2170 inputs_[1] = string;
2174 LOperand* context() { return inputs_[0]; }
2175 LOperand* string() { return inputs_[1]; }
2176 LOperand* index() { return inputs_[2]; }
2178 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2179 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2183 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2185 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2186 inputs_[0] = context;
2187 inputs_[1] = char_code;
2190 LOperand* context() { return inputs_[0]; }
2191 LOperand* char_code() { return inputs_[1]; }
2193 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2194 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2198 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2200 explicit LCheckValue(LOperand* value) {
2204 LOperand* value() { return inputs_[0]; }
2206 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2207 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2211 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2213 explicit LCheckInstanceType(LOperand* value) {
2217 LOperand* value() { return inputs_[0]; }
2219 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2220 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2224 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2226 explicit LCheckMaps(LOperand* value) {
2230 LOperand* value() { return inputs_[0]; }
2232 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2233 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2237 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2239 explicit LCheckSmi(LOperand* value) {
2243 LOperand* value() { return inputs_[0]; }
2245 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2249 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2251 explicit LClampDToUint8(LOperand* unclamped) {
2252 inputs_[0] = unclamped;
2255 LOperand* unclamped() { return inputs_[0]; }
2257 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2261 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2263 explicit LClampIToUint8(LOperand* unclamped) {
2264 inputs_[0] = unclamped;
2267 LOperand* unclamped() { return inputs_[0]; }
2269 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2273 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2275 LClampTToUint8(LOperand* unclamped,
2276 LOperand* temp_xmm) {
2277 inputs_[0] = unclamped;
2278 temps_[0] = temp_xmm;
2281 LOperand* unclamped() { return inputs_[0]; }
2282 LOperand* temp_xmm() { return temps_[0]; }
2284 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2288 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2290 explicit LCheckNonSmi(LOperand* value) {
2294 LOperand* value() { return inputs_[0]; }
2296 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2297 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2301 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2303 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2304 inputs_[0] = context;
2309 LOperand* context() { return inputs_[0]; }
2310 LOperand* size() { return inputs_[1]; }
2311 LOperand* temp() { return temps_[0]; }
2313 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2314 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2318 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2320 explicit LRegExpLiteral(LOperand* context) {
2321 inputs_[0] = context;
2324 LOperand* context() { return inputs_[0]; }
2326 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2327 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2331 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2333 explicit LFunctionLiteral(LOperand* context) {
2334 inputs_[0] = context;
2337 LOperand* context() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2340 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2344 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2346 explicit LToFastProperties(LOperand* value) {
2350 LOperand* value() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2353 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2357 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2359 LTypeof(LOperand* context, LOperand* value) {
2360 inputs_[0] = context;
2364 LOperand* context() { return inputs_[0]; }
2365 LOperand* value() { return inputs_[1]; }
2367 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2371 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2373 explicit LTypeofIsAndBranch(LOperand* value) {
2377 LOperand* value() { return inputs_[0]; }
2379 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2380 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2382 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2384 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2388 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2390 explicit LIsConstructCallAndBranch(LOperand* temp) {
2394 LOperand* temp() { return temps_[0]; }
2396 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2397 "is-construct-call-and-branch")
2398 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2402 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2406 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2409 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2413 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2415 explicit LStackCheck(LOperand* context) {
2416 inputs_[0] = context;
2419 LOperand* context() { return inputs_[0]; }
2421 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2422 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2424 Label* done_label() { return &done_label_; }
2431 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2433 LForInPrepareMap(LOperand* context, LOperand* object) {
2434 inputs_[0] = context;
2435 inputs_[1] = object;
2438 LOperand* context() { return inputs_[0]; }
2439 LOperand* object() { return inputs_[1]; }
2441 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2445 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2447 explicit LForInCacheArray(LOperand* map) {
2451 LOperand* map() { return inputs_[0]; }
2453 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2456 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2461 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2463 LCheckMapValue(LOperand* value, LOperand* map) {
2468 LOperand* value() { return inputs_[0]; }
2469 LOperand* map() { return inputs_[1]; }
2471 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2475 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2477 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2478 inputs_[0] = object;
2482 LOperand* object() { return inputs_[0]; }
2483 LOperand* index() { return inputs_[1]; }
2485 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2489 class LChunkBuilder;
2490 class LPlatformChunk V8_FINAL : public LChunk {
2492 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2493 : LChunk(info, graph) { }
2495 int GetNextSpillIndex(RegisterKind kind);
2496 LOperand* GetNextSpillSlot(RegisterKind kind);
2500 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2502 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2503 : LChunkBuilderBase(graph->zone()),
2508 current_instruction_(NULL),
2509 current_block_(NULL),
2511 allocator_(allocator),
2512 instruction_pending_deoptimization_environment_(NULL),
2513 pending_deoptimization_ast_id_(BailoutId::None()) { }
2515 // Build the sequence for the graph.
2516 LPlatformChunk* Build();
2518 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2520 // Declare methods that deal with the individual node types.
2521 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2522 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2525 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2526 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2527 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2528 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2529 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2530 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2531 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2541 LPlatformChunk* chunk() const { return chunk_; }
2542 CompilationInfo* info() const { return info_; }
2543 HGraph* graph() const { return graph_; }
2545 bool is_unused() const { return status_ == UNUSED; }
2546 bool is_building() const { return status_ == BUILDING; }
2547 bool is_done() const { return status_ == DONE; }
2548 bool is_aborted() const { return status_ == ABORTED; }
2550 void Abort(BailoutReason reason);
2552 // Methods for getting operands for Use / Define / Temp.
2553 LUnallocated* ToUnallocated(Register reg);
2554 LUnallocated* ToUnallocated(XMMRegister reg);
2556 // Methods for setting up define-use relationships.
2557 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2558 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2559 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2560 XMMRegister fixed_register);
2562 // A value that is guaranteed to be allocated to a register.
2563 // Operand created by UseRegister is guaranteed to be live until the end of
2564 // instruction. This means that register allocator will not reuse it's
2565 // register for any other operand inside instruction.
2566 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2567 // instruction start. Register allocator is free to assign the same register
2568 // to some other operand used inside instruction (i.e. temporary or
2570 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2571 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2573 // An input operand in a register that may be trashed.
2574 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2576 // An input operand in a register that may be trashed or a constant operand.
2577 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2579 // An input operand in a register or stack slot.
2580 MUST_USE_RESULT LOperand* Use(HValue* value);
2581 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2583 // An input operand in a register, stack slot or a constant operand.
2584 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2585 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2587 // An input operand in a register or a constant operand.
2588 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2589 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2591 // An input operand in a constant operand.
2592 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2594 // An input operand in register, stack slot or a constant operand.
2595 // Will not be moved to a register even if one is freely available.
2596 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2598 // Temporary operand that must be in a register.
2599 MUST_USE_RESULT LUnallocated* TempRegister();
2600 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2601 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2603 // Methods for setting up define-use relationships.
2604 // Return the same instruction that they are passed.
2605 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2606 LUnallocated* result);
2607 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2608 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2610 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2611 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2613 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2615 // Assigns an environment to an instruction. An instruction which can
2616 // deoptimize must have an environment.
2617 LInstruction* AssignEnvironment(LInstruction* instr);
2618 // Assigns a pointer map to an instruction. An instruction which can
2619 // trigger a GC or a lazy deoptimization must have a pointer map.
2620 LInstruction* AssignPointerMap(LInstruction* instr);
2622 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2624 // Marks a call for the register allocator. Assigns a pointer map to
2625 // support GC and lazy deoptimization. Assigns an environment to support
2626 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2627 LInstruction* MarkAsCall(
2628 LInstruction* instr,
2629 HInstruction* hinstr,
2630 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2632 void VisitInstruction(HInstruction* current);
2634 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2635 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2636 LInstruction* DoArithmeticD(Token::Value op,
2637 HArithmeticBinaryOperation* instr);
2638 LInstruction* DoArithmeticT(Token::Value op,
2639 HBinaryOperation* instr);
2641 LPlatformChunk* chunk_;
2642 CompilationInfo* info_;
2643 HGraph* const graph_;
2645 HInstruction* current_instruction_;
2646 HBasicBlock* current_block_;
2647 HBasicBlock* next_block_;
2648 LAllocator* allocator_;
2649 LInstruction* instruction_pending_deoptimization_environment_;
2650 BailoutId pending_deoptimization_ast_id_;
2652 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2655 #undef DECLARE_HYDROGEN_ACCESSOR
2656 #undef DECLARE_CONCRETE_INSTRUCTION
2658 } } // namespace v8::int
2660 #endif // V8_X64_LITHIUM_X64_H_