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) \
55 V(CallConstantFunction) \
65 V(CheckInstanceType) \
74 V(ClassOfTestAndBranch) \
75 V(CompareMinusZeroAndBranch) \
76 V(CompareNumericAndBranch) \
77 V(CmpObjectEqAndBranch) \
101 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
114 V(IsConstructCallAndBranch) \
115 V(IsObjectAndBranch) \
116 V(IsStringAndBranch) \
118 V(IsUndetectableAndBranch) \
122 V(LoadExternalArrayPointer) \
124 V(LoadFieldByIndex) \
125 V(LoadFunctionPrototype) \
127 V(LoadGlobalGeneric) \
129 V(LoadKeyedGeneric) \
131 V(LoadNamedGeneric) \
155 V(SeqStringGetChar) \
156 V(SeqStringSetChar) \
162 V(StoreContextSlot) \
164 V(StoreGlobalGeneric) \
166 V(StoreKeyedGeneric) \
168 V(StoreNamedGeneric) \
170 V(StringCharCodeAt) \
171 V(StringCharFromCode) \
172 V(StringCompareAndBranch) \
177 V(ToFastProperties) \
178 V(TransitionElementsKind) \
179 V(TrapAllocationMemento) \
181 V(TypeofIsAndBranch) \
189 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
190 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
191 return LInstruction::k##type; \
193 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
194 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
197 static L##type* cast(LInstruction* instr) { \
198 ASSERT(instr->Is##type()); \
199 return reinterpret_cast<L##type*>(instr); \
203 #define DECLARE_HYDROGEN_ACCESSOR(type) \
204 H##type* hydrogen() const { \
205 return H##type::cast(hydrogen_value()); \
209 class LInstruction : public ZoneObject {
212 : environment_(NULL),
213 hydrogen_value_(NULL),
214 bit_field_(IsCallBits::encode(false)) {
217 virtual ~LInstruction() {}
219 virtual void CompileToNative(LCodeGen* generator) = 0;
220 virtual const char* Mnemonic() const = 0;
221 virtual void PrintTo(StringStream* stream);
222 virtual void PrintDataTo(StringStream* stream);
223 virtual void PrintOutputOperandTo(StringStream* stream);
226 // Declare a unique enum value for each instruction.
227 #define DECLARE_OPCODE(type) k##type,
228 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
229 kNumberOfInstructions
230 #undef DECLARE_OPCODE
233 virtual Opcode opcode() const = 0;
235 // Declare non-virtual type testers for all leaf IR classes.
236 #define DECLARE_PREDICATE(type) \
237 bool Is##type() const { return opcode() == k##type; }
238 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
239 #undef DECLARE_PREDICATE
241 // Declare virtual predicates for instructions that don't have
243 virtual bool IsGap() const { return false; }
245 virtual bool IsControl() const { return false; }
247 void set_environment(LEnvironment* env) { environment_ = env; }
248 LEnvironment* environment() const { return environment_; }
249 bool HasEnvironment() const { return environment_ != NULL; }
251 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
252 LPointerMap* pointer_map() const { return pointer_map_.get(); }
253 bool HasPointerMap() const { return pointer_map_.is_set(); }
255 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
256 HValue* hydrogen_value() const { return hydrogen_value_; }
258 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
259 bool IsCall() const { return IsCallBits::decode(bit_field_); }
261 // Interface to the register allocator and iterators.
262 bool ClobbersTemps() const { return IsCall(); }
263 bool ClobbersRegisters() const { return IsCall(); }
264 virtual bool ClobbersDoubleRegisters() const { return IsCall(); }
266 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
268 // Interface to the register allocator and iterators.
269 bool IsMarkedAsCall() const { return IsCall(); }
271 virtual bool HasResult() const = 0;
272 virtual LOperand* result() const = 0;
274 LOperand* FirstInput() { return InputAt(0); }
275 LOperand* Output() { return HasResult() ? result() : NULL; }
277 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
285 friend class InputIterator;
286 virtual int InputCount() = 0;
287 virtual LOperand* InputAt(int i) = 0;
289 friend class TempIterator;
290 virtual int TempCount() = 0;
291 virtual LOperand* TempAt(int i) = 0;
293 class IsCallBits: public BitField<bool, 0, 1> {};
295 LEnvironment* environment_;
296 SetOncePointer<LPointerMap> pointer_map_;
297 HValue* hydrogen_value_;
302 // R = number of result operands (0 or 1).
303 // I = number of input operands.
304 // T = number of temporary operands.
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LInstruction {
308 // Allow 0 or 1 output operands.
309 STATIC_ASSERT(R == 0 || R == 1);
310 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
311 return R != 0 && result() != NULL;
313 void set_result(LOperand* operand) { results_[0] = operand; }
314 LOperand* result() const { return results_[0]; }
317 EmbeddedContainer<LOperand*, R> results_;
318 EmbeddedContainer<LOperand*, I> inputs_;
319 EmbeddedContainer<LOperand*, T> temps_;
323 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
324 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
326 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
327 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
331 class LGap : public LTemplateInstruction<0, 0, 0> {
333 explicit LGap(HBasicBlock* block)
335 parallel_moves_[BEFORE] = NULL;
336 parallel_moves_[START] = NULL;
337 parallel_moves_[END] = NULL;
338 parallel_moves_[AFTER] = NULL;
341 // Can't use the DECLARE-macro here because of sub-classes.
342 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
343 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
344 static LGap* cast(LInstruction* instr) {
345 ASSERT(instr->IsGap());
346 return reinterpret_cast<LGap*>(instr);
349 bool IsRedundant() const;
351 HBasicBlock* block() const { return block_; }
358 FIRST_INNER_POSITION = BEFORE,
359 LAST_INNER_POSITION = AFTER
362 LParallelMove* GetOrCreateParallelMove(InnerPosition pos,
364 if (parallel_moves_[pos] == NULL) {
365 parallel_moves_[pos] = new(zone) LParallelMove(zone);
367 return parallel_moves_[pos];
370 LParallelMove* GetParallelMove(InnerPosition pos) {
371 return parallel_moves_[pos];
375 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
380 class LInstructionGap V8_FINAL : public LGap {
382 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
384 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
385 return !IsRedundant();
388 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
392 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
394 explicit LGoto(HBasicBlock* block) : block_(block) { }
396 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
397 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
398 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
399 virtual bool IsControl() const V8_OVERRIDE { return true; }
401 int block_id() const { return block_->block_id(); }
408 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
410 LLazyBailout() : gap_instructions_size_(0) { }
412 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
414 void set_gap_instructions_size(int gap_instructions_size) {
415 gap_instructions_size_ = gap_instructions_size;
417 int gap_instructions_size() { return gap_instructions_size_; }
420 int gap_instructions_size_;
424 class LDummy V8_FINAL : public LTemplateInstruction<1, 0, 0> {
426 explicit LDummy() { }
427 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
431 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
433 explicit LDummyUse(LOperand* value) {
436 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
440 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
442 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
443 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
447 class LLabel V8_FINAL : public LGap {
449 explicit LLabel(HBasicBlock* block)
450 : LGap(block), replacement_(NULL) { }
452 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
455 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
457 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
459 int block_id() const { return block()->block_id(); }
460 bool is_loop_header() const { return block()->IsLoopHeader(); }
461 bool is_osr_entry() const { return block()->is_osr_entry(); }
462 Label* label() { return &label_; }
463 LLabel* replacement() const { return replacement_; }
464 void set_replacement(LLabel* label) { replacement_ = label; }
465 bool HasReplacement() const { return replacement_ != NULL; }
469 LLabel* replacement_;
473 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
475 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
478 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
482 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
484 explicit LCallStub(LOperand* context) {
485 inputs_[0] = context;
488 LOperand* context() { return inputs_[0]; }
490 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
491 DECLARE_HYDROGEN_ACCESSOR(CallStub)
495 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
497 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
500 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
504 template<int I, int T>
505 class LControlInstruction : public LTemplateInstruction<0, I, T> {
507 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
509 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
511 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
512 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
514 int TrueDestination(LChunk* chunk) {
515 return chunk->LookupDestination(true_block_id());
517 int FalseDestination(LChunk* chunk) {
518 return chunk->LookupDestination(false_block_id());
521 Label* TrueLabel(LChunk* chunk) {
522 if (true_label_ == NULL) {
523 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
527 Label* FalseLabel(LChunk* chunk) {
528 if (false_label_ == NULL) {
529 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
535 int true_block_id() { return SuccessorAt(0)->block_id(); }
536 int false_block_id() { return SuccessorAt(1)->block_id(); }
539 HControlInstruction* hydrogen() {
540 return HControlInstruction::cast(this->hydrogen_value());
548 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 0> {
550 LWrapReceiver(LOperand* receiver, LOperand* function) {
551 inputs_[0] = receiver;
552 inputs_[1] = function;
555 LOperand* receiver() { return inputs_[0]; }
556 LOperand* function() { return inputs_[1]; }
558 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
562 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
564 LApplyArguments(LOperand* function,
567 LOperand* elements) {
568 inputs_[0] = function;
569 inputs_[1] = receiver;
571 inputs_[3] = elements;
574 LOperand* function() { return inputs_[0]; }
575 LOperand* receiver() { return inputs_[1]; }
576 LOperand* length() { return inputs_[2]; }
577 LOperand* elements() { return inputs_[3]; }
579 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
583 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
585 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
586 inputs_[0] = arguments;
591 LOperand* arguments() { return inputs_[0]; }
592 LOperand* length() { return inputs_[1]; }
593 LOperand* index() { return inputs_[2]; }
595 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
597 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
601 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
603 explicit LArgumentsLength(LOperand* elements) {
604 inputs_[0] = elements;
607 LOperand* elements() { return inputs_[0]; }
609 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
613 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
615 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
616 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
620 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
622 LModI(LOperand* left, LOperand* right, LOperand* temp) {
628 LOperand* left() { return inputs_[0]; }
629 LOperand* right() { return inputs_[1]; }
630 LOperand* temp() { return temps_[0]; }
632 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
633 DECLARE_HYDROGEN_ACCESSOR(Mod)
637 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
639 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
645 LOperand* left() { return inputs_[0]; }
646 LOperand* right() { return inputs_[1]; }
647 LOperand* temp() { return temps_[0]; }
649 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
651 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
652 DECLARE_HYDROGEN_ACCESSOR(Div)
656 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
658 LMathFloorOfDiv(LOperand* left,
660 LOperand* temp = NULL) {
666 LOperand* left() { return inputs_[0]; }
667 LOperand* right() { return inputs_[1]; }
668 LOperand* temp() { return temps_[0]; }
670 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
671 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
675 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
677 LMulI(LOperand* left, LOperand* right) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
685 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
686 DECLARE_HYDROGEN_ACCESSOR(Mul)
690 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
692 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
697 LOperand* left() { return inputs_[0]; }
698 LOperand* right() { return inputs_[1]; }
700 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
701 "compare-numeric-and-branch")
702 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
704 Token::Value op() const { return hydrogen()->token(); }
705 bool is_double() const {
706 return hydrogen()->representation().IsDouble();
709 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
713 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
715 explicit LMathFloor(LOperand* value) {
719 LOperand* value() { return inputs_[0]; }
721 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
722 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
726 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
728 explicit LMathRound(LOperand* value) {
732 LOperand* value() { return inputs_[0]; }
734 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
735 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
739 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
741 explicit LMathAbs(LOperand* context, LOperand* value) {
742 inputs_[1] = context;
746 LOperand* context() { return inputs_[1]; }
747 LOperand* value() { return inputs_[0]; }
749 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
750 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
754 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
756 explicit LMathLog(LOperand* value) {
760 LOperand* value() { return inputs_[0]; }
762 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
766 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
768 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
772 ExternalReference::InitializeMathExpData();
775 LOperand* value() { return inputs_[0]; }
776 LOperand* temp1() { return temps_[0]; }
777 LOperand* temp2() { return temps_[1]; }
779 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
783 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
785 explicit LMathSqrt(LOperand* value) {
789 LOperand* value() { return inputs_[0]; }
791 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
795 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
797 explicit LMathPowHalf(LOperand* value) {
801 LOperand* value() { return inputs_[0]; }
803 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
807 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
809 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
814 LOperand* left() { return inputs_[0]; }
815 LOperand* right() { return inputs_[1]; }
817 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
821 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
823 explicit LCmpHoleAndBranch(LOperand* object) {
827 LOperand* object() { return inputs_[0]; }
829 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
830 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
834 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
836 explicit LCompareMinusZeroAndBranch(LOperand* value) {
840 LOperand* value() { return inputs_[0]; }
842 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
843 "cmp-minus-zero-and-branch")
844 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
849 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
851 explicit LIsObjectAndBranch(LOperand* value) {
855 LOperand* value() { return inputs_[0]; }
857 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
858 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
860 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
864 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
866 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
871 LOperand* value() { return inputs_[0]; }
872 LOperand* temp() { return temps_[0]; }
874 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
875 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
877 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
881 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
883 explicit LIsSmiAndBranch(LOperand* value) {
887 LOperand* value() { return inputs_[0]; }
889 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
890 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
892 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
896 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
898 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
903 LOperand* value() { return inputs_[0]; }
904 LOperand* temp() { return temps_[0]; }
906 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
907 "is-undetectable-and-branch")
908 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
910 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
914 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
916 explicit LStringCompareAndBranch(LOperand* context,
919 inputs_[0] = context;
924 LOperand* context() { return inputs_[0]; }
925 LOperand* left() { return inputs_[1]; }
926 LOperand* right() { return inputs_[2]; }
928 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
929 "string-compare-and-branch")
930 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
932 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
934 Token::Value op() const { return hydrogen()->token(); }
938 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
940 explicit LHasInstanceTypeAndBranch(LOperand* value) {
944 LOperand* value() { return inputs_[0]; }
946 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
947 "has-instance-type-and-branch")
948 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
950 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
954 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
956 explicit LGetCachedArrayIndex(LOperand* value) {
960 LOperand* value() { return inputs_[0]; }
962 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
963 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
967 class LHasCachedArrayIndexAndBranch V8_FINAL
968 : public LControlInstruction<1, 0> {
970 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
974 LOperand* value() { return inputs_[0]; }
976 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
977 "has-cached-array-index-and-branch")
978 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
980 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
984 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
986 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
992 LOperand* value() { return inputs_[0]; }
993 LOperand* temp() { return temps_[0]; }
994 LOperand* temp2() { return temps_[1]; }
996 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
997 "class-of-test-and-branch")
998 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1000 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1004 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1006 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1007 inputs_[0] = context;
1012 LOperand* context() { return inputs_[0]; }
1013 LOperand* left() { return inputs_[1]; }
1014 LOperand* right() { return inputs_[2]; }
1016 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1019 Token::Value op() const { return hydrogen()->token(); }
1023 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1025 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1026 inputs_[0] = context;
1031 LOperand* context() { return inputs_[0]; }
1032 LOperand* left() { return inputs_[1]; }
1033 LOperand* right() { return inputs_[2]; }
1035 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1039 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1041 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1042 inputs_[0] = context;
1047 LOperand* context() { return inputs_[0]; }
1048 LOperand* value() { return inputs_[1]; }
1049 LOperand* temp() { return temps_[0]; }
1051 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1052 "instance-of-known-global")
1053 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1055 Handle<JSFunction> function() const { return hydrogen()->function(); }
1056 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1057 return lazy_deopt_env_;
1059 virtual void SetDeferredLazyDeoptimizationEnvironment(
1060 LEnvironment* env) V8_OVERRIDE {
1061 lazy_deopt_env_ = env;
1065 LEnvironment* lazy_deopt_env_;
1069 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1071 LBoundsCheck(LOperand* index, LOperand* length) {
1073 inputs_[1] = length;
1076 LOperand* index() { return inputs_[0]; }
1077 LOperand* length() { return inputs_[1]; }
1079 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1080 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1084 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1086 LBitI(LOperand* left, LOperand* right) {
1091 LOperand* left() { return inputs_[0]; }
1092 LOperand* right() { return inputs_[1]; }
1094 Token::Value op() const { return hydrogen()->op(); }
1096 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1097 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1101 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1103 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1104 : op_(op), can_deopt_(can_deopt) {
1109 Token::Value op() const { return op_; }
1110 LOperand* left() { return inputs_[0]; }
1111 LOperand* right() { return inputs_[1]; }
1112 bool can_deopt() const { return can_deopt_; }
1114 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1122 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1124 LSubI(LOperand* left, LOperand* right) {
1129 LOperand* left() { return inputs_[0]; }
1130 LOperand* right() { return inputs_[1]; }
1132 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1133 DECLARE_HYDROGEN_ACCESSOR(Sub)
1137 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1139 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1140 DECLARE_HYDROGEN_ACCESSOR(Constant)
1142 int32_t value() const { return hydrogen()->Integer32Value(); }
1146 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1148 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1149 DECLARE_HYDROGEN_ACCESSOR(Constant)
1151 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1155 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1157 explicit LConstantD(LOperand* temp) {
1161 LOperand* temp() { return temps_[0]; }
1163 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1164 DECLARE_HYDROGEN_ACCESSOR(Constant)
1166 double value() const { return hydrogen()->DoubleValue(); }
1170 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1172 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1173 DECLARE_HYDROGEN_ACCESSOR(Constant)
1175 ExternalReference value() const {
1176 return hydrogen()->ExternalReferenceValue();
1181 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1183 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1184 DECLARE_HYDROGEN_ACCESSOR(Constant)
1186 Handle<Object> value(Isolate* isolate) const {
1187 return hydrogen()->handle(isolate);
1192 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1194 explicit LBranch(LOperand* value) {
1198 LOperand* value() { return inputs_[0]; }
1200 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1201 DECLARE_HYDROGEN_ACCESSOR(Branch)
1203 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1207 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1209 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1213 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1215 explicit LCmpMapAndBranch(LOperand* value) {
1219 LOperand* value() { return inputs_[0]; }
1221 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1222 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1224 Handle<Map> map() const { return hydrogen()->map().handle(); }
1228 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1230 explicit LMapEnumLength(LOperand* value) {
1234 LOperand* value() { return inputs_[0]; }
1236 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1240 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1242 explicit LElementsKind(LOperand* value) {
1246 LOperand* value() { return inputs_[0]; }
1248 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1249 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1253 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1255 explicit LValueOf(LOperand* value) {
1259 LOperand* value() { return inputs_[0]; }
1261 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1262 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1266 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1268 LDateField(LOperand* date, Smi* index) : index_(index) {
1272 LOperand* date() { return inputs_[0]; }
1273 Smi* index() const { return index_; }
1275 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1276 DECLARE_HYDROGEN_ACCESSOR(DateField)
1283 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1285 LSeqStringGetChar(LOperand* string, LOperand* index) {
1286 inputs_[0] = string;
1290 LOperand* string() const { return inputs_[0]; }
1291 LOperand* index() const { return inputs_[1]; }
1293 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1294 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1298 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1300 LSeqStringSetChar(LOperand* context,
1304 inputs_[0] = context;
1305 inputs_[1] = string;
1310 LOperand* string() { return inputs_[1]; }
1311 LOperand* index() { return inputs_[2]; }
1312 LOperand* value() { return inputs_[3]; }
1314 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1315 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1319 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1321 explicit LThrow(LOperand* context, LOperand* value) {
1322 inputs_[0] = context;
1326 LOperand* context() { return inputs_[0]; }
1327 LOperand* value() { return inputs_[1]; }
1329 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1333 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1335 LAddI(LOperand* left, LOperand* right) {
1340 LOperand* left() { return inputs_[0]; }
1341 LOperand* right() { return inputs_[1]; }
1343 static bool UseLea(HAdd* add) {
1344 return !add->CheckFlag(HValue::kCanOverflow) &&
1345 add->BetterLeftOperand()->UseCount() > 1;
1348 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1349 DECLARE_HYDROGEN_ACCESSOR(Add)
1353 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1355 LMathMinMax(LOperand* left, LOperand* right) {
1360 LOperand* left() { return inputs_[0]; }
1361 LOperand* right() { return inputs_[1]; }
1363 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1364 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1368 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1370 LPower(LOperand* left, LOperand* right) {
1375 LOperand* left() { return inputs_[0]; }
1376 LOperand* right() { return inputs_[1]; }
1378 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1379 DECLARE_HYDROGEN_ACCESSOR(Power)
1383 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1385 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1391 Token::Value op() const { return op_; }
1392 LOperand* left() { return inputs_[0]; }
1393 LOperand* right() { return inputs_[1]; }
1395 virtual Opcode opcode() const V8_OVERRIDE {
1396 return LInstruction::kArithmeticD;
1398 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1399 virtual const char* Mnemonic() const V8_OVERRIDE;
1406 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1408 LArithmeticT(Token::Value op,
1413 inputs_[0] = context;
1418 Token::Value op() const { return op_; }
1419 LOperand* context() { return inputs_[0]; }
1420 LOperand* left() { return inputs_[1]; }
1421 LOperand* right() { return inputs_[2]; }
1423 virtual Opcode opcode() const V8_OVERRIDE {
1424 return LInstruction::kArithmeticT;
1426 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1427 virtual const char* Mnemonic() const V8_OVERRIDE;
1434 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1436 explicit LReturn(LOperand* value,
1438 LOperand* parameter_count) {
1440 inputs_[1] = context;
1441 inputs_[2] = parameter_count;
1444 LOperand* value() { return inputs_[0]; }
1445 LOperand* context() { return inputs_[1]; }
1447 bool has_constant_parameter_count() {
1448 return parameter_count()->IsConstantOperand();
1450 LConstantOperand* constant_parameter_count() {
1451 ASSERT(has_constant_parameter_count());
1452 return LConstantOperand::cast(parameter_count());
1454 LOperand* parameter_count() { return inputs_[2]; }
1456 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1457 DECLARE_HYDROGEN_ACCESSOR(Return)
1461 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1463 explicit LLoadNamedField(LOperand* object) {
1464 inputs_[0] = object;
1467 LOperand* object() { return inputs_[0]; }
1469 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1470 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1474 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1476 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1477 inputs_[0] = context;
1478 inputs_[1] = object;
1481 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1482 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1484 LOperand* context() { return inputs_[0]; }
1485 LOperand* object() { return inputs_[1]; }
1486 Handle<Object> name() const { return hydrogen()->name(); }
1490 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1492 explicit LLoadFunctionPrototype(LOperand* function) {
1493 inputs_[0] = function;
1496 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1497 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1499 LOperand* function() { return inputs_[0]; }
1503 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1505 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1506 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1508 Heap::RootListIndex index() const { return hydrogen()->index(); }
1512 class LLoadExternalArrayPointer V8_FINAL
1513 : public LTemplateInstruction<1, 1, 0> {
1515 explicit LLoadExternalArrayPointer(LOperand* object) {
1516 inputs_[0] = object;
1519 LOperand* object() { return inputs_[0]; }
1521 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1522 "load-external-array-pointer")
1526 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1528 LLoadKeyed(LOperand* elements, LOperand* key) {
1529 inputs_[0] = elements;
1533 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1534 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1536 bool is_external() const {
1537 return hydrogen()->is_external();
1539 LOperand* elements() { return inputs_[0]; }
1540 LOperand* key() { return inputs_[1]; }
1541 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1542 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1543 ElementsKind elements_kind() const {
1544 return hydrogen()->elements_kind();
1549 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1551 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1552 inputs_[0] = context;
1557 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1559 LOperand* context() { return inputs_[0]; }
1560 LOperand* object() { return inputs_[1]; }
1561 LOperand* key() { return inputs_[2]; }
1565 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1567 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1568 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1572 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1574 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1575 inputs_[0] = context;
1576 inputs_[1] = global_object;
1579 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1580 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1582 LOperand* context() { return inputs_[0]; }
1583 LOperand* global_object() { return inputs_[1]; }
1584 Handle<Object> name() const { return hydrogen()->name(); }
1585 bool for_typeof() const { return hydrogen()->for_typeof(); }
1589 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1591 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1596 LOperand* value() { return inputs_[0]; }
1597 LOperand* temp() { return temps_[0]; }
1599 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1600 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1604 class LStoreGlobalGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1606 explicit LStoreGlobalGeneric(LOperand* context,
1607 LOperand* global_object,
1609 inputs_[0] = context;
1610 inputs_[1] = global_object;
1614 LOperand* context() { return inputs_[0]; }
1615 LOperand* global_object() { return inputs_[1]; }
1616 LOperand* value() { return inputs_[2]; }
1618 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1619 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1621 Handle<Object> name() const { return hydrogen()->name(); }
1622 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1626 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1628 explicit LLoadContextSlot(LOperand* context) {
1629 inputs_[0] = context;
1632 LOperand* context() { return inputs_[0]; }
1634 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1637 int slot_index() { return hydrogen()->slot_index(); }
1639 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1643 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1645 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1646 inputs_[0] = context;
1651 LOperand* context() { return inputs_[0]; }
1652 LOperand* value() { return inputs_[1]; }
1653 LOperand* temp() { return temps_[0]; }
1655 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1656 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1658 int slot_index() { return hydrogen()->slot_index(); }
1660 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1664 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1666 explicit LPushArgument(LOperand* value) {
1670 LOperand* value() { return inputs_[0]; }
1672 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1676 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1678 explicit LDrop(int count) : count_(count) { }
1680 int count() const { return count_; }
1682 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1689 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1691 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1692 inputs_[0] = function;
1693 temps_[0] = code_object;
1696 LOperand* function() { return inputs_[0]; }
1697 LOperand* code_object() { return temps_[0]; }
1699 virtual void PrintDataTo(StringStream* stream);
1701 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1702 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1706 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1708 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1709 inputs_[0] = base_object;
1710 inputs_[1] = offset;
1713 LOperand* base_object() const { return inputs_[0]; }
1714 LOperand* offset() const { return inputs_[1]; }
1716 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1718 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1722 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1724 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1725 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1729 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1731 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1732 DECLARE_HYDROGEN_ACCESSOR(Context)
1736 class LOuterContext V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1738 explicit LOuterContext(LOperand* context) {
1739 inputs_[0] = context;
1742 LOperand* context() { return inputs_[0]; }
1744 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1748 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1750 explicit LDeclareGlobals(LOperand* context) {
1751 inputs_[0] = context;
1754 LOperand* context() { return inputs_[0]; }
1756 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1757 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1761 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1763 explicit LGlobalObject(LOperand* context) {
1764 inputs_[0] = context;
1767 LOperand* context() { return inputs_[0]; }
1769 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1773 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1775 explicit LGlobalReceiver(LOperand* global_object) {
1776 inputs_[0] = global_object;
1779 LOperand* global() { return inputs_[0]; }
1781 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1785 class LCallConstantFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1787 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1788 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1790 virtual void PrintDataTo(StringStream* stream);
1792 Handle<JSFunction> function() { return hydrogen()->function(); }
1793 int arity() const { return hydrogen()->argument_count() - 1; }
1797 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1799 LInvokeFunction(LOperand* context, LOperand* function) {
1800 inputs_[0] = context;
1801 inputs_[1] = function;
1804 LOperand* context() { return inputs_[0]; }
1805 LOperand* function() { return inputs_[1]; }
1807 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1808 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1810 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1812 int arity() const { return hydrogen()->argument_count() - 1; }
1816 class LCallKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1818 LCallKeyed(LOperand* context, LOperand* key) {
1819 inputs_[0] = context;
1823 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1824 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1826 LOperand* context() { return inputs_[0]; }
1827 LOperand* key() { return inputs_[1]; }
1829 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1831 int arity() const { return hydrogen()->argument_count() - 1; }
1835 class LCallNamed V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1837 explicit LCallNamed(LOperand* context) {
1838 inputs_[0] = context;
1841 LOperand* context() { return inputs_[0]; }
1843 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1844 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1846 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1848 Handle<String> name() const { return hydrogen()->name(); }
1849 int arity() const { return hydrogen()->argument_count() - 1; }
1853 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1855 LCallFunction(LOperand* context, LOperand* function) {
1856 inputs_[0] = context;
1857 inputs_[1] = function;
1860 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1861 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1863 LOperand* context() { return inputs_[0]; }
1864 LOperand* function() { return inputs_[1]; }
1865 int arity() const { return hydrogen()->argument_count() - 1; }
1869 class LCallGlobal V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1871 explicit LCallGlobal(LOperand* context) {
1872 inputs_[0] = context;
1875 LOperand* context() { return inputs_[0]; }
1877 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1878 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1880 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1882 Handle<String> name() const {return hydrogen()->name(); }
1883 int arity() const { return hydrogen()->argument_count() - 1; }
1887 class LCallKnownGlobal V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1889 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1890 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1892 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1894 int arity() const { return hydrogen()->argument_count() - 1; }
1898 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1900 LCallNew(LOperand* context, LOperand* constructor) {
1901 inputs_[0] = context;
1902 inputs_[1] = constructor;
1905 LOperand* context() { return inputs_[0]; }
1906 LOperand* constructor() { return inputs_[1]; }
1908 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1909 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1911 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1913 int arity() const { return hydrogen()->argument_count() - 1; }
1917 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1919 LCallNewArray(LOperand* context, LOperand* constructor) {
1920 inputs_[0] = context;
1921 inputs_[1] = constructor;
1924 LOperand* context() { return inputs_[0]; }
1925 LOperand* constructor() { return inputs_[1]; }
1927 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1928 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1930 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1936 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1938 explicit LCallRuntime(LOperand* context) {
1939 inputs_[0] = context;
1942 LOperand* context() { return inputs_[0]; }
1944 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1945 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1947 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1948 return save_doubles() == kDontSaveFPRegs;
1951 const Runtime::Function* function() const { return hydrogen()->function(); }
1952 int arity() const { return hydrogen()->argument_count(); }
1953 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1957 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1959 explicit LInteger32ToDouble(LOperand* value) {
1963 LOperand* value() { return inputs_[0]; }
1965 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1969 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1971 explicit LInteger32ToSmi(LOperand* value) {
1975 LOperand* value() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1978 DECLARE_HYDROGEN_ACCESSOR(Change)
1982 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1984 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1989 LOperand* value() { return inputs_[0]; }
1990 LOperand* temp() { return temps_[0]; }
1992 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1996 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1998 explicit LUint32ToSmi(LOperand* value) {
2002 LOperand* value() { return inputs_[0]; }
2004 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
2005 DECLARE_HYDROGEN_ACCESSOR(Change)
2009 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2011 explicit LNumberTagI(LOperand* value) {
2015 LOperand* value() { return inputs_[0]; }
2017 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2021 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2023 explicit LNumberTagU(LOperand* value, LOperand* temp) {
2028 LOperand* value() { return inputs_[0]; }
2029 LOperand* temp() { return temps_[0]; }
2031 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2035 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2037 explicit LNumberTagD(LOperand* value, LOperand* temp) {
2042 LOperand* value() { return inputs_[0]; }
2043 LOperand* temp() { return temps_[0]; }
2045 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2046 DECLARE_HYDROGEN_ACCESSOR(Change)
2050 // Sometimes truncating conversion from a tagged value to an int32.
2051 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2053 explicit LDoubleToI(LOperand* value) {
2057 LOperand* value() { return inputs_[0]; }
2059 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2060 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2062 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2066 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2068 explicit LDoubleToSmi(LOperand* value) {
2072 LOperand* value() { return inputs_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2075 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2079 // Truncating conversion from a tagged value to an int32.
2080 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2082 LTaggedToI(LOperand* value, LOperand* temp) {
2087 LOperand* value() { return inputs_[0]; }
2088 LOperand* temp() { return temps_[0]; }
2090 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2091 DECLARE_HYDROGEN_ACCESSOR(Change)
2093 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2097 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2099 explicit LSmiTag(LOperand* value) {
2103 LOperand* value() { return inputs_[0]; }
2105 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2109 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2111 explicit LNumberUntagD(LOperand* value) {
2115 LOperand* value() { return inputs_[0]; }
2117 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2118 DECLARE_HYDROGEN_ACCESSOR(Change);
2122 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2124 LSmiUntag(LOperand* value, bool needs_check)
2125 : needs_check_(needs_check) {
2129 LOperand* value() { return inputs_[0]; }
2130 bool needs_check() const { return needs_check_; }
2132 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2139 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2141 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2142 inputs_[0] = object;
2147 LOperand* object() { return inputs_[0]; }
2148 LOperand* value() { return inputs_[1]; }
2149 LOperand* temp() { return temps_[0]; }
2151 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2152 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2154 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2156 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2157 Representation representation() const {
2158 return hydrogen()->field_representation();
2163 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2165 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2166 inputs_[0] = context;
2167 inputs_[1] = object;
2171 LOperand* context() { return inputs_[0]; }
2172 LOperand* object() { return inputs_[1]; }
2173 LOperand* value() { return inputs_[2]; }
2175 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2176 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2178 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2180 Handle<Object> name() const { return hydrogen()->name(); }
2181 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2185 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2187 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2188 inputs_[0] = object;
2193 bool is_external() const { return hydrogen()->is_external(); }
2194 LOperand* elements() { return inputs_[0]; }
2195 LOperand* key() { return inputs_[1]; }
2196 LOperand* value() { return inputs_[2]; }
2197 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2199 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2200 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2202 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2203 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2204 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2208 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2210 LStoreKeyedGeneric(LOperand* context,
2214 inputs_[0] = context;
2215 inputs_[1] = object;
2220 LOperand* context() { return inputs_[0]; }
2221 LOperand* object() { return inputs_[1]; }
2222 LOperand* key() { return inputs_[2]; }
2223 LOperand* value() { return inputs_[3]; }
2225 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2226 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2228 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2230 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2234 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2236 LTransitionElementsKind(LOperand* object,
2238 LOperand* new_map_temp,
2240 inputs_[0] = object;
2241 inputs_[1] = context;
2242 temps_[0] = new_map_temp;
2246 LOperand* object() { return inputs_[0]; }
2247 LOperand* context() { return inputs_[1]; }
2248 LOperand* new_map_temp() { return temps_[0]; }
2249 LOperand* temp() { return temps_[1]; }
2251 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2252 "transition-elements-kind")
2253 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2255 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2257 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2258 Handle<Map> transitioned_map() {
2259 return hydrogen()->transitioned_map().handle();
2261 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2262 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2266 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2268 LTrapAllocationMemento(LOperand* object,
2270 inputs_[0] = object;
2274 LOperand* object() { return inputs_[0]; }
2275 LOperand* temp() { return temps_[0]; }
2277 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2278 "trap-allocation-memento")
2282 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2284 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2285 inputs_[0] = context;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* left() { return inputs_[1]; }
2292 LOperand* right() { return inputs_[2]; }
2294 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2295 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2299 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2301 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2302 inputs_[0] = context;
2303 inputs_[1] = string;
2307 LOperand* context() { return inputs_[0]; }
2308 LOperand* string() { return inputs_[1]; }
2309 LOperand* index() { return inputs_[2]; }
2311 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2312 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2316 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2318 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2319 inputs_[0] = context;
2320 inputs_[1] = char_code;
2323 LOperand* context() { return inputs_[0]; }
2324 LOperand* char_code() { return inputs_[1]; }
2326 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2327 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2331 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2333 explicit LCheckValue(LOperand* value) {
2337 LOperand* value() { return inputs_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2340 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2344 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2346 explicit LCheckInstanceType(LOperand* value) {
2350 LOperand* value() { return inputs_[0]; }
2352 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2353 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2357 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2359 explicit LCheckMaps(LOperand* value) {
2363 LOperand* value() { return inputs_[0]; }
2365 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2366 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2370 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2372 explicit LCheckSmi(LOperand* value) {
2376 LOperand* value() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2382 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2384 explicit LClampDToUint8(LOperand* unclamped) {
2385 inputs_[0] = unclamped;
2388 LOperand* unclamped() { return inputs_[0]; }
2390 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2394 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2396 explicit LClampIToUint8(LOperand* unclamped) {
2397 inputs_[0] = unclamped;
2400 LOperand* unclamped() { return inputs_[0]; }
2402 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2406 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2408 LClampTToUint8(LOperand* unclamped,
2409 LOperand* temp_xmm) {
2410 inputs_[0] = unclamped;
2411 temps_[0] = temp_xmm;
2414 LOperand* unclamped() { return inputs_[0]; }
2415 LOperand* temp_xmm() { return temps_[0]; }
2417 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2421 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2423 explicit LCheckNonSmi(LOperand* value) {
2427 LOperand* value() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2430 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2434 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2436 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2437 inputs_[0] = context;
2442 LOperand* context() { return inputs_[0]; }
2443 LOperand* size() { return inputs_[1]; }
2444 LOperand* temp() { return temps_[0]; }
2446 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2447 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2451 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2453 explicit LRegExpLiteral(LOperand* context) {
2454 inputs_[0] = context;
2457 LOperand* context() { return inputs_[0]; }
2459 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2460 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2464 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2466 explicit LFunctionLiteral(LOperand* context) {
2467 inputs_[0] = context;
2470 LOperand* context() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2473 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2477 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2479 explicit LToFastProperties(LOperand* value) {
2483 LOperand* value() { return inputs_[0]; }
2485 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2486 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2490 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2492 LTypeof(LOperand* context, LOperand* value) {
2493 inputs_[0] = context;
2497 LOperand* context() { return inputs_[0]; }
2498 LOperand* value() { return inputs_[1]; }
2500 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2504 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2506 explicit LTypeofIsAndBranch(LOperand* value) {
2510 LOperand* value() { return inputs_[0]; }
2512 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2513 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2515 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2517 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2521 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2523 explicit LIsConstructCallAndBranch(LOperand* temp) {
2527 LOperand* temp() { return temps_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2530 "is-construct-call-and-branch")
2531 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2535 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2539 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2542 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2546 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2548 explicit LStackCheck(LOperand* context) {
2549 inputs_[0] = context;
2552 LOperand* context() { return inputs_[0]; }
2554 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2555 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2557 Label* done_label() { return &done_label_; }
2564 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2566 LForInPrepareMap(LOperand* context, LOperand* object) {
2567 inputs_[0] = context;
2568 inputs_[1] = object;
2571 LOperand* context() { return inputs_[0]; }
2572 LOperand* object() { return inputs_[1]; }
2574 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2578 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2580 explicit LForInCacheArray(LOperand* map) {
2584 LOperand* map() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2589 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2594 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2596 LCheckMapValue(LOperand* value, LOperand* map) {
2601 LOperand* value() { return inputs_[0]; }
2602 LOperand* map() { return inputs_[1]; }
2604 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2608 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2610 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2611 inputs_[0] = object;
2615 LOperand* object() { return inputs_[0]; }
2616 LOperand* index() { return inputs_[1]; }
2618 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2622 class LChunkBuilder;
2623 class LPlatformChunk V8_FINAL : public LChunk {
2625 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2626 : LChunk(info, graph) { }
2628 int GetNextSpillIndex(RegisterKind kind);
2629 LOperand* GetNextSpillSlot(RegisterKind kind);
2633 class LChunkBuilder V8_FINAL BASE_EMBEDDED {
2635 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2639 zone_(graph->zone()),
2641 current_instruction_(NULL),
2642 current_block_(NULL),
2645 allocator_(allocator),
2646 instruction_pending_deoptimization_environment_(NULL),
2647 pending_deoptimization_ast_id_(BailoutId::None()) { }
2649 // Build the sequence for the graph.
2650 LPlatformChunk* Build();
2652 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2654 // Declare methods that deal with the individual node types.
2655 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2656 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2659 static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
2661 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2662 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2663 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2664 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2665 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2666 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2667 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2677 LPlatformChunk* chunk() const { return chunk_; }
2678 CompilationInfo* info() const { return info_; }
2679 HGraph* graph() const { return graph_; }
2680 Zone* zone() const { return zone_; }
2682 bool is_unused() const { return status_ == UNUSED; }
2683 bool is_building() const { return status_ == BUILDING; }
2684 bool is_done() const { return status_ == DONE; }
2685 bool is_aborted() const { return status_ == ABORTED; }
2687 void Abort(BailoutReason reason);
2689 // Methods for getting operands for Use / Define / Temp.
2690 LUnallocated* ToUnallocated(Register reg);
2691 LUnallocated* ToUnallocated(XMMRegister reg);
2693 // Methods for setting up define-use relationships.
2694 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2695 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2696 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2697 XMMRegister fixed_register);
2699 // A value that is guaranteed to be allocated to a register.
2700 // Operand created by UseRegister is guaranteed to be live until the end of
2701 // instruction. This means that register allocator will not reuse it's
2702 // register for any other operand inside instruction.
2703 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2704 // instruction start. Register allocator is free to assign the same register
2705 // to some other operand used inside instruction (i.e. temporary or
2707 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2708 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2710 // An input operand in a register that may be trashed.
2711 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2713 // An input operand in a register or stack slot.
2714 MUST_USE_RESULT LOperand* Use(HValue* value);
2715 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2717 // An input operand in a register, stack slot or a constant operand.
2718 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2719 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2721 // An input operand in a register or a constant operand.
2722 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2723 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2725 // An input operand in a constant operand.
2726 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2728 // An input operand in register, stack slot or a constant operand.
2729 // Will not be moved to a register even if one is freely available.
2730 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2732 // Temporary operand that must be in a register.
2733 MUST_USE_RESULT LUnallocated* TempRegister();
2734 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2735 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2737 // Methods for setting up define-use relationships.
2738 // Return the same instruction that they are passed.
2739 template<int I, int T>
2740 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2741 LUnallocated* result);
2742 template<int I, int T>
2743 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2744 template<int I, int T>
2745 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2747 template<int I, int T>
2748 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2749 template<int I, int T>
2750 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2752 template<int I, int T>
2753 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2755 // Assigns an environment to an instruction. An instruction which can
2756 // deoptimize must have an environment.
2757 LInstruction* AssignEnvironment(LInstruction* instr);
2758 // Assigns a pointer map to an instruction. An instruction which can
2759 // trigger a GC or a lazy deoptimization must have a pointer map.
2760 LInstruction* AssignPointerMap(LInstruction* instr);
2762 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2764 // Marks a call for the register allocator. Assigns a pointer map to
2765 // support GC and lazy deoptimization. Assigns an environment to support
2766 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2767 LInstruction* MarkAsCall(
2768 LInstruction* instr,
2769 HInstruction* hinstr,
2770 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2772 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2773 int* argument_index_accumulator,
2774 ZoneList<HValue*>* objects_to_materialize);
2776 void VisitInstruction(HInstruction* current);
2778 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2779 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2780 LInstruction* DoArithmeticD(Token::Value op,
2781 HArithmeticBinaryOperation* instr);
2782 LInstruction* DoArithmeticT(Token::Value op,
2783 HBinaryOperation* instr);
2785 LPlatformChunk* chunk_;
2786 CompilationInfo* info_;
2787 HGraph* const graph_;
2790 HInstruction* current_instruction_;
2791 HBasicBlock* current_block_;
2792 HBasicBlock* next_block_;
2793 int argument_count_;
2794 LAllocator* allocator_;
2795 LInstruction* instruction_pending_deoptimization_environment_;
2796 BailoutId pending_deoptimization_ast_id_;
2798 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2801 #undef DECLARE_HYDROGEN_ACCESSOR
2802 #undef DECLARE_CONCRETE_INSTRUCTION
2804 } } // namespace v8::int
2806 #endif // V8_X64_LITHIUM_X64_H_