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")
558 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
560 LApplyArguments(LOperand* function,
563 LOperand* elements) {
564 inputs_[0] = function;
565 inputs_[1] = receiver;
567 inputs_[3] = elements;
570 LOperand* function() { return inputs_[0]; }
571 LOperand* receiver() { return inputs_[1]; }
572 LOperand* length() { return inputs_[2]; }
573 LOperand* elements() { return inputs_[3]; }
575 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
579 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
581 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
582 inputs_[0] = arguments;
587 LOperand* arguments() { return inputs_[0]; }
588 LOperand* length() { return inputs_[1]; }
589 LOperand* index() { return inputs_[2]; }
591 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
593 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
597 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
599 explicit LArgumentsLength(LOperand* elements) {
600 inputs_[0] = elements;
603 LOperand* elements() { return inputs_[0]; }
605 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
609 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
611 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
612 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
616 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
618 LModI(LOperand* left, LOperand* right, LOperand* temp) {
624 LOperand* left() { return inputs_[0]; }
625 LOperand* right() { return inputs_[1]; }
626 LOperand* temp() { return temps_[0]; }
628 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
629 DECLARE_HYDROGEN_ACCESSOR(Mod)
633 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
635 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
641 LOperand* left() { return inputs_[0]; }
642 LOperand* right() { return inputs_[1]; }
643 LOperand* temp() { return temps_[0]; }
645 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
647 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
648 DECLARE_HYDROGEN_ACCESSOR(Div)
652 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
654 LMathFloorOfDiv(LOperand* left,
656 LOperand* temp = NULL) {
662 LOperand* left() { return inputs_[0]; }
663 LOperand* right() { return inputs_[1]; }
664 LOperand* temp() { return temps_[0]; }
666 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
667 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
671 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
673 LMulI(LOperand* left, LOperand* right) {
678 LOperand* left() { return inputs_[0]; }
679 LOperand* right() { return inputs_[1]; }
681 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
682 DECLARE_HYDROGEN_ACCESSOR(Mul)
686 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
688 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
693 LOperand* left() { return inputs_[0]; }
694 LOperand* right() { return inputs_[1]; }
696 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
697 "compare-numeric-and-branch")
698 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
700 Token::Value op() const { return hydrogen()->token(); }
701 bool is_double() const {
702 return hydrogen()->representation().IsDouble();
705 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
709 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
711 explicit LMathFloor(LOperand* value) {
715 LOperand* value() { return inputs_[0]; }
717 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
718 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
722 class LMathRound V8_FINAL : public LTemplateInstruction<1, 1, 0> {
724 explicit LMathRound(LOperand* value) {
728 LOperand* value() { return inputs_[0]; }
730 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
731 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
735 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
737 explicit LMathAbs(LOperand* context, LOperand* value) {
738 inputs_[1] = context;
742 LOperand* context() { return inputs_[1]; }
743 LOperand* value() { return inputs_[0]; }
745 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
746 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
750 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
752 explicit LMathLog(LOperand* value) {
756 LOperand* value() { return inputs_[0]; }
758 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
762 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
764 LMathExp(LOperand* value, LOperand* temp1, LOperand* temp2) {
768 ExternalReference::InitializeMathExpData();
771 LOperand* value() { return inputs_[0]; }
772 LOperand* temp1() { return temps_[0]; }
773 LOperand* temp2() { return temps_[1]; }
775 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
779 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
781 explicit LMathSqrt(LOperand* value) {
785 LOperand* value() { return inputs_[0]; }
787 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
791 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 1, 0> {
793 explicit LMathPowHalf(LOperand* value) {
797 LOperand* value() { return inputs_[0]; }
799 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
803 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
805 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
810 LOperand* left() { return inputs_[0]; }
811 LOperand* right() { return inputs_[1]; }
813 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
817 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
819 explicit LCmpHoleAndBranch(LOperand* object) {
823 LOperand* object() { return inputs_[0]; }
825 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
826 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
830 class LCompareMinusZeroAndBranch V8_FINAL : public LControlInstruction<1, 0> {
832 explicit LCompareMinusZeroAndBranch(LOperand* value) {
836 LOperand* value() { return inputs_[0]; }
838 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
839 "cmp-minus-zero-and-branch")
840 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
845 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 0> {
847 explicit LIsObjectAndBranch(LOperand* value) {
851 LOperand* value() { return inputs_[0]; }
853 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
854 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
856 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
860 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
862 explicit LIsStringAndBranch(LOperand* value, LOperand* temp) {
867 LOperand* value() { return inputs_[0]; }
868 LOperand* temp() { return temps_[0]; }
870 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
871 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
873 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
877 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
879 explicit LIsSmiAndBranch(LOperand* value) {
883 LOperand* value() { return inputs_[0]; }
885 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
886 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
888 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
892 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
894 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
899 LOperand* value() { return inputs_[0]; }
900 LOperand* temp() { return temps_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
903 "is-undetectable-and-branch")
904 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
906 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
910 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
912 explicit LStringCompareAndBranch(LOperand* context,
915 inputs_[0] = context;
920 LOperand* context() { return inputs_[0]; }
921 LOperand* left() { return inputs_[1]; }
922 LOperand* right() { return inputs_[2]; }
924 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
925 "string-compare-and-branch")
926 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
928 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
930 Token::Value op() const { return hydrogen()->token(); }
934 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 0> {
936 explicit LHasInstanceTypeAndBranch(LOperand* value) {
940 LOperand* value() { return inputs_[0]; }
942 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
943 "has-instance-type-and-branch")
944 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
946 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
950 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
952 explicit LGetCachedArrayIndex(LOperand* value) {
956 LOperand* value() { return inputs_[0]; }
958 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
959 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
963 class LHasCachedArrayIndexAndBranch V8_FINAL
964 : public LControlInstruction<1, 0> {
966 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
970 LOperand* value() { return inputs_[0]; }
972 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
973 "has-cached-array-index-and-branch")
974 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
976 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
980 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
982 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
988 LOperand* value() { return inputs_[0]; }
989 LOperand* temp() { return temps_[0]; }
990 LOperand* temp2() { return temps_[1]; }
992 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
993 "class-of-test-and-branch")
994 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
996 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1000 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1002 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1003 inputs_[0] = context;
1008 LOperand* context() { return inputs_[0]; }
1009 LOperand* left() { return inputs_[1]; }
1010 LOperand* right() { return inputs_[2]; }
1012 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1013 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1015 Token::Value op() const { return hydrogen()->token(); }
1019 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1021 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1022 inputs_[0] = context;
1027 LOperand* context() { return inputs_[0]; }
1028 LOperand* left() { return inputs_[1]; }
1029 LOperand* right() { return inputs_[2]; }
1031 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1035 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1037 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1038 inputs_[0] = context;
1043 LOperand* context() { return inputs_[0]; }
1044 LOperand* value() { return inputs_[1]; }
1045 LOperand* temp() { return temps_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1048 "instance-of-known-global")
1049 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1051 Handle<JSFunction> function() const { return hydrogen()->function(); }
1052 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1053 return lazy_deopt_env_;
1055 virtual void SetDeferredLazyDeoptimizationEnvironment(
1056 LEnvironment* env) V8_OVERRIDE {
1057 lazy_deopt_env_ = env;
1061 LEnvironment* lazy_deopt_env_;
1065 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1067 LBoundsCheck(LOperand* index, LOperand* length) {
1069 inputs_[1] = length;
1072 LOperand* index() { return inputs_[0]; }
1073 LOperand* length() { return inputs_[1]; }
1075 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1076 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1080 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1082 LBitI(LOperand* left, LOperand* right) {
1087 LOperand* left() { return inputs_[0]; }
1088 LOperand* right() { return inputs_[1]; }
1090 Token::Value op() const { return hydrogen()->op(); }
1092 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1093 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1097 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1099 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1100 : op_(op), can_deopt_(can_deopt) {
1105 Token::Value op() const { return op_; }
1106 LOperand* left() { return inputs_[0]; }
1107 LOperand* right() { return inputs_[1]; }
1108 bool can_deopt() const { return can_deopt_; }
1110 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1118 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1120 LSubI(LOperand* left, LOperand* right) {
1125 LOperand* left() { return inputs_[0]; }
1126 LOperand* right() { return inputs_[1]; }
1128 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1129 DECLARE_HYDROGEN_ACCESSOR(Sub)
1133 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1135 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1136 DECLARE_HYDROGEN_ACCESSOR(Constant)
1138 int32_t value() const { return hydrogen()->Integer32Value(); }
1142 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1144 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1145 DECLARE_HYDROGEN_ACCESSOR(Constant)
1147 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1151 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1153 explicit LConstantD(LOperand* temp) {
1157 LOperand* temp() { return temps_[0]; }
1159 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1160 DECLARE_HYDROGEN_ACCESSOR(Constant)
1162 double value() const { return hydrogen()->DoubleValue(); }
1166 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1168 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1169 DECLARE_HYDROGEN_ACCESSOR(Constant)
1171 ExternalReference value() const {
1172 return hydrogen()->ExternalReferenceValue();
1177 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1179 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1180 DECLARE_HYDROGEN_ACCESSOR(Constant)
1182 Handle<Object> value(Isolate* isolate) const {
1183 return hydrogen()->handle(isolate);
1188 class LBranch V8_FINAL : public LControlInstruction<1, 0> {
1190 explicit LBranch(LOperand* value) {
1194 LOperand* value() { return inputs_[0]; }
1196 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1197 DECLARE_HYDROGEN_ACCESSOR(Branch)
1199 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1203 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1205 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1209 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1211 explicit LCmpMapAndBranch(LOperand* value) {
1215 LOperand* value() { return inputs_[0]; }
1217 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1218 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1220 Handle<Map> map() const { return hydrogen()->map().handle(); }
1224 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1226 explicit LMapEnumLength(LOperand* value) {
1230 LOperand* value() { return inputs_[0]; }
1232 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1236 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1238 LDateField(LOperand* date, Smi* index) : index_(index) {
1242 LOperand* date() { return inputs_[0]; }
1243 Smi* index() const { return index_; }
1245 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1246 DECLARE_HYDROGEN_ACCESSOR(DateField)
1253 class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1255 LSeqStringGetChar(LOperand* string, LOperand* index) {
1256 inputs_[0] = string;
1260 LOperand* string() const { return inputs_[0]; }
1261 LOperand* index() const { return inputs_[1]; }
1263 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1264 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1268 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 4, 0> {
1270 LSeqStringSetChar(LOperand* context,
1274 inputs_[0] = context;
1275 inputs_[1] = string;
1280 LOperand* string() { return inputs_[1]; }
1281 LOperand* index() { return inputs_[2]; }
1282 LOperand* value() { return inputs_[3]; }
1284 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1285 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1289 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1291 LAddI(LOperand* left, LOperand* right) {
1296 LOperand* left() { return inputs_[0]; }
1297 LOperand* right() { return inputs_[1]; }
1299 static bool UseLea(HAdd* add) {
1300 return !add->CheckFlag(HValue::kCanOverflow) &&
1301 add->BetterLeftOperand()->UseCount() > 1;
1304 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1305 DECLARE_HYDROGEN_ACCESSOR(Add)
1309 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1311 LMathMinMax(LOperand* left, LOperand* right) {
1316 LOperand* left() { return inputs_[0]; }
1317 LOperand* right() { return inputs_[1]; }
1319 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1320 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1324 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1326 LPower(LOperand* left, LOperand* right) {
1331 LOperand* left() { return inputs_[0]; }
1332 LOperand* right() { return inputs_[1]; }
1334 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1335 DECLARE_HYDROGEN_ACCESSOR(Power)
1339 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1341 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1347 Token::Value op() const { return op_; }
1348 LOperand* left() { return inputs_[0]; }
1349 LOperand* right() { return inputs_[1]; }
1351 virtual Opcode opcode() const V8_OVERRIDE {
1352 return LInstruction::kArithmeticD;
1354 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1355 virtual const char* Mnemonic() const V8_OVERRIDE;
1362 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1364 LArithmeticT(Token::Value op,
1369 inputs_[0] = context;
1374 Token::Value op() const { return op_; }
1375 LOperand* context() { return inputs_[0]; }
1376 LOperand* left() { return inputs_[1]; }
1377 LOperand* right() { return inputs_[2]; }
1379 virtual Opcode opcode() const V8_OVERRIDE {
1380 return LInstruction::kArithmeticT;
1382 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1383 virtual const char* Mnemonic() const V8_OVERRIDE;
1390 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1392 explicit LReturn(LOperand* value,
1394 LOperand* parameter_count) {
1396 inputs_[1] = context;
1397 inputs_[2] = parameter_count;
1400 LOperand* value() { return inputs_[0]; }
1401 LOperand* context() { return inputs_[1]; }
1403 bool has_constant_parameter_count() {
1404 return parameter_count()->IsConstantOperand();
1406 LConstantOperand* constant_parameter_count() {
1407 ASSERT(has_constant_parameter_count());
1408 return LConstantOperand::cast(parameter_count());
1410 LOperand* parameter_count() { return inputs_[2]; }
1412 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1413 DECLARE_HYDROGEN_ACCESSOR(Return)
1417 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1419 explicit LLoadNamedField(LOperand* object) {
1420 inputs_[0] = object;
1423 LOperand* object() { return inputs_[0]; }
1425 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1426 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1430 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1432 explicit LLoadNamedGeneric(LOperand* context, LOperand* object) {
1433 inputs_[0] = context;
1434 inputs_[1] = object;
1437 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1438 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1440 LOperand* context() { return inputs_[0]; }
1441 LOperand* object() { return inputs_[1]; }
1442 Handle<Object> name() const { return hydrogen()->name(); }
1446 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1448 explicit LLoadFunctionPrototype(LOperand* function) {
1449 inputs_[0] = function;
1452 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1453 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1455 LOperand* function() { return inputs_[0]; }
1459 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1461 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1462 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1464 Heap::RootListIndex index() const { return hydrogen()->index(); }
1468 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1470 LLoadKeyed(LOperand* elements, LOperand* key) {
1471 inputs_[0] = elements;
1475 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1476 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1478 bool is_external() const {
1479 return hydrogen()->is_external();
1481 bool is_fixed_typed_array() const {
1482 return hydrogen()->is_fixed_typed_array();
1484 bool is_typed_elements() const {
1485 return is_external() || is_fixed_typed_array();
1487 LOperand* elements() { return inputs_[0]; }
1488 LOperand* key() { return inputs_[1]; }
1489 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1490 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1491 ElementsKind elements_kind() const {
1492 return hydrogen()->elements_kind();
1497 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1499 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1500 inputs_[0] = context;
1505 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1507 LOperand* context() { return inputs_[0]; }
1508 LOperand* object() { return inputs_[1]; }
1509 LOperand* key() { return inputs_[2]; }
1513 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1515 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1516 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1520 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1522 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1523 inputs_[0] = context;
1524 inputs_[1] = global_object;
1527 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1528 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1530 LOperand* context() { return inputs_[0]; }
1531 LOperand* global_object() { return inputs_[1]; }
1532 Handle<Object> name() const { return hydrogen()->name(); }
1533 bool for_typeof() const { return hydrogen()->for_typeof(); }
1537 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 1> {
1539 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
1544 LOperand* value() { return inputs_[0]; }
1545 LOperand* temp() { return temps_[0]; }
1547 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1548 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1552 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1554 explicit LLoadContextSlot(LOperand* context) {
1555 inputs_[0] = context;
1558 LOperand* context() { return inputs_[0]; }
1560 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1561 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1563 int slot_index() { return hydrogen()->slot_index(); }
1565 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1569 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1571 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1572 inputs_[0] = context;
1577 LOperand* context() { return inputs_[0]; }
1578 LOperand* value() { return inputs_[1]; }
1579 LOperand* temp() { return temps_[0]; }
1581 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1582 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1584 int slot_index() { return hydrogen()->slot_index(); }
1586 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1590 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1592 explicit LPushArgument(LOperand* value) {
1596 LOperand* value() { return inputs_[0]; }
1598 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1602 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1604 explicit LDrop(int count) : count_(count) { }
1606 int count() const { return count_; }
1608 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1615 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1617 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1618 inputs_[0] = function;
1619 temps_[0] = code_object;
1622 LOperand* function() { return inputs_[0]; }
1623 LOperand* code_object() { return temps_[0]; }
1625 virtual void PrintDataTo(StringStream* stream);
1627 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1628 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1632 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> {
1634 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1635 inputs_[0] = base_object;
1636 inputs_[1] = offset;
1639 LOperand* base_object() const { return inputs_[0]; }
1640 LOperand* offset() const { return inputs_[1]; }
1642 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1644 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1648 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1650 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1651 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1655 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1657 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1658 DECLARE_HYDROGEN_ACCESSOR(Context)
1662 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1664 explicit LDeclareGlobals(LOperand* context) {
1665 inputs_[0] = context;
1668 LOperand* context() { return inputs_[0]; }
1670 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1671 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1675 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1677 explicit LCallJSFunction(LOperand* function) {
1678 inputs_[0] = function;
1681 LOperand* function() { return inputs_[0]; }
1683 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1684 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1686 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1688 int arity() const { return hydrogen()->argument_count() - 1; }
1692 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1694 LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
1695 ZoneList<LOperand*>& operands,
1697 : inputs_(descriptor->environment_length() + 1, zone) {
1698 ASSERT(descriptor->environment_length() + 1 == operands.length());
1699 inputs_.AddAll(operands, zone);
1702 LOperand* target() const { return inputs_[0]; }
1705 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1706 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1708 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1710 int arity() const { return hydrogen()->argument_count() - 1; }
1712 ZoneList<LOperand*> inputs_;
1714 // Iterator support.
1715 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1716 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1718 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1719 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1723 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1725 LInvokeFunction(LOperand* context, LOperand* function) {
1726 inputs_[0] = context;
1727 inputs_[1] = function;
1730 LOperand* context() { return inputs_[0]; }
1731 LOperand* function() { return inputs_[1]; }
1733 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1734 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1736 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1738 int arity() const { return hydrogen()->argument_count() - 1; }
1742 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1744 LCallFunction(LOperand* context, LOperand* function) {
1745 inputs_[0] = context;
1746 inputs_[1] = function;
1749 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1750 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1752 LOperand* context() { return inputs_[0]; }
1753 LOperand* function() { return inputs_[1]; }
1754 int arity() const { return hydrogen()->argument_count() - 1; }
1758 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1760 LCallNew(LOperand* context, LOperand* constructor) {
1761 inputs_[0] = context;
1762 inputs_[1] = constructor;
1765 LOperand* context() { return inputs_[0]; }
1766 LOperand* constructor() { return inputs_[1]; }
1768 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1769 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1771 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1773 int arity() const { return hydrogen()->argument_count() - 1; }
1777 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1779 LCallNewArray(LOperand* context, LOperand* constructor) {
1780 inputs_[0] = context;
1781 inputs_[1] = constructor;
1784 LOperand* context() { return inputs_[0]; }
1785 LOperand* constructor() { return inputs_[1]; }
1787 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1788 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1790 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1792 int arity() const { return hydrogen()->argument_count() - 1; }
1796 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1798 explicit LCallRuntime(LOperand* context) {
1799 inputs_[0] = context;
1802 LOperand* context() { return inputs_[0]; }
1804 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1805 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1807 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
1808 return save_doubles() == kDontSaveFPRegs;
1811 const Runtime::Function* function() const { return hydrogen()->function(); }
1812 int arity() const { return hydrogen()->argument_count(); }
1813 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1817 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1819 explicit LInteger32ToDouble(LOperand* value) {
1823 LOperand* value() { return inputs_[0]; }
1825 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1829 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1831 explicit LInteger32ToSmi(LOperand* value) {
1835 LOperand* value() { return inputs_[0]; }
1837 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1838 DECLARE_HYDROGEN_ACCESSOR(Change)
1842 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1844 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
1849 LOperand* value() { return inputs_[0]; }
1850 LOperand* temp() { return temps_[0]; }
1852 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1856 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1858 explicit LUint32ToSmi(LOperand* value) {
1862 LOperand* value() { return inputs_[0]; }
1864 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
1865 DECLARE_HYDROGEN_ACCESSOR(Change)
1869 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1871 explicit LNumberTagI(LOperand* value) {
1875 LOperand* value() { return inputs_[0]; }
1877 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1881 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1883 explicit LNumberTagU(LOperand* value, LOperand* temp) {
1888 LOperand* value() { return inputs_[0]; }
1889 LOperand* temp() { return temps_[0]; }
1891 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1895 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1897 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1902 LOperand* value() { return inputs_[0]; }
1903 LOperand* temp() { return temps_[0]; }
1905 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1906 DECLARE_HYDROGEN_ACCESSOR(Change)
1910 // Sometimes truncating conversion from a tagged value to an int32.
1911 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1913 explicit LDoubleToI(LOperand* value) {
1917 LOperand* value() { return inputs_[0]; }
1919 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1920 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1922 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1926 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1928 explicit LDoubleToSmi(LOperand* value) {
1932 LOperand* value() { return inputs_[0]; }
1934 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1935 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1939 // Truncating conversion from a tagged value to an int32.
1940 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1942 LTaggedToI(LOperand* value, LOperand* temp) {
1947 LOperand* value() { return inputs_[0]; }
1948 LOperand* temp() { return temps_[0]; }
1950 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1951 DECLARE_HYDROGEN_ACCESSOR(Change)
1953 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1957 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1959 explicit LSmiTag(LOperand* value) {
1963 LOperand* value() { return inputs_[0]; }
1965 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1969 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1971 explicit LNumberUntagD(LOperand* value) {
1975 LOperand* value() { return inputs_[0]; }
1977 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1978 DECLARE_HYDROGEN_ACCESSOR(Change);
1982 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1984 LSmiUntag(LOperand* value, bool needs_check)
1985 : needs_check_(needs_check) {
1989 LOperand* value() { return inputs_[0]; }
1990 bool needs_check() const { return needs_check_; }
1992 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1999 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 1> {
2001 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2002 inputs_[0] = object;
2007 LOperand* object() { return inputs_[0]; }
2008 LOperand* value() { return inputs_[1]; }
2009 LOperand* temp() { return temps_[0]; }
2011 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2012 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2014 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2016 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2017 Representation representation() const {
2018 return hydrogen()->field_representation();
2023 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2025 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2026 inputs_[0] = context;
2027 inputs_[1] = object;
2031 LOperand* context() { return inputs_[0]; }
2032 LOperand* object() { return inputs_[1]; }
2033 LOperand* value() { return inputs_[2]; }
2035 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2036 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2038 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2040 Handle<Object> name() const { return hydrogen()->name(); }
2041 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2045 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2047 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
2048 inputs_[0] = object;
2053 bool is_external() const { return hydrogen()->is_external(); }
2054 bool is_fixed_typed_array() const {
2055 return hydrogen()->is_fixed_typed_array();
2057 bool is_typed_elements() const {
2058 return is_external() || is_fixed_typed_array();
2060 LOperand* elements() { return inputs_[0]; }
2061 LOperand* key() { return inputs_[1]; }
2062 LOperand* value() { return inputs_[2]; }
2063 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2065 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2066 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2068 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2069 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2070 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2074 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2076 LStoreKeyedGeneric(LOperand* context,
2080 inputs_[0] = context;
2081 inputs_[1] = object;
2086 LOperand* context() { return inputs_[0]; }
2087 LOperand* object() { return inputs_[1]; }
2088 LOperand* key() { return inputs_[2]; }
2089 LOperand* value() { return inputs_[3]; }
2091 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2092 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2094 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2096 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2100 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2102 LTransitionElementsKind(LOperand* object,
2104 LOperand* new_map_temp,
2106 inputs_[0] = object;
2107 inputs_[1] = context;
2108 temps_[0] = new_map_temp;
2112 LOperand* object() { return inputs_[0]; }
2113 LOperand* context() { return inputs_[1]; }
2114 LOperand* new_map_temp() { return temps_[0]; }
2115 LOperand* temp() { return temps_[1]; }
2117 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2118 "transition-elements-kind")
2119 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2121 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2123 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2124 Handle<Map> transitioned_map() {
2125 return hydrogen()->transitioned_map().handle();
2127 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2128 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2132 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2134 LTrapAllocationMemento(LOperand* object,
2136 inputs_[0] = object;
2140 LOperand* object() { return inputs_[0]; }
2141 LOperand* temp() { return temps_[0]; }
2143 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2144 "trap-allocation-memento")
2148 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2150 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2151 inputs_[0] = context;
2156 LOperand* context() { return inputs_[0]; }
2157 LOperand* left() { return inputs_[1]; }
2158 LOperand* right() { return inputs_[2]; }
2160 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2161 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2165 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2167 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2168 inputs_[0] = context;
2169 inputs_[1] = string;
2173 LOperand* context() { return inputs_[0]; }
2174 LOperand* string() { return inputs_[1]; }
2175 LOperand* index() { return inputs_[2]; }
2177 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2178 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2182 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2184 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2185 inputs_[0] = context;
2186 inputs_[1] = char_code;
2189 LOperand* context() { return inputs_[0]; }
2190 LOperand* char_code() { return inputs_[1]; }
2192 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2193 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2197 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2199 explicit LCheckValue(LOperand* value) {
2203 LOperand* value() { return inputs_[0]; }
2205 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2206 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2210 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2212 explicit LCheckInstanceType(LOperand* value) {
2216 LOperand* value() { return inputs_[0]; }
2218 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2219 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2223 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2225 explicit LCheckMaps(LOperand* value) {
2229 LOperand* value() { return inputs_[0]; }
2231 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2232 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2236 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2238 explicit LCheckSmi(LOperand* value) {
2242 LOperand* value() { return inputs_[0]; }
2244 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2248 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2250 explicit LClampDToUint8(LOperand* unclamped) {
2251 inputs_[0] = unclamped;
2254 LOperand* unclamped() { return inputs_[0]; }
2256 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2260 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2262 explicit LClampIToUint8(LOperand* unclamped) {
2263 inputs_[0] = unclamped;
2266 LOperand* unclamped() { return inputs_[0]; }
2268 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2272 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2274 LClampTToUint8(LOperand* unclamped,
2275 LOperand* temp_xmm) {
2276 inputs_[0] = unclamped;
2277 temps_[0] = temp_xmm;
2280 LOperand* unclamped() { return inputs_[0]; }
2281 LOperand* temp_xmm() { return temps_[0]; }
2283 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2287 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2289 explicit LCheckNonSmi(LOperand* value) {
2293 LOperand* value() { return inputs_[0]; }
2295 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2296 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2300 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2302 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2303 inputs_[0] = context;
2308 LOperand* context() { return inputs_[0]; }
2309 LOperand* size() { return inputs_[1]; }
2310 LOperand* temp() { return temps_[0]; }
2312 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2313 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2317 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2319 explicit LRegExpLiteral(LOperand* context) {
2320 inputs_[0] = context;
2323 LOperand* context() { return inputs_[0]; }
2325 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2326 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2330 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2332 explicit LFunctionLiteral(LOperand* context) {
2333 inputs_[0] = context;
2336 LOperand* context() { return inputs_[0]; }
2338 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2339 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2343 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2345 explicit LToFastProperties(LOperand* value) {
2349 LOperand* value() { return inputs_[0]; }
2351 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2352 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2356 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2358 LTypeof(LOperand* context, LOperand* value) {
2359 inputs_[0] = context;
2363 LOperand* context() { return inputs_[0]; }
2364 LOperand* value() { return inputs_[1]; }
2366 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2370 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2372 explicit LTypeofIsAndBranch(LOperand* value) {
2376 LOperand* value() { return inputs_[0]; }
2378 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2379 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2381 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2383 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2387 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
2389 explicit LIsConstructCallAndBranch(LOperand* temp) {
2393 LOperand* temp() { return temps_[0]; }
2395 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2396 "is-construct-call-and-branch")
2397 DECLARE_HYDROGEN_ACCESSOR(IsConstructCallAndBranch)
2401 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2405 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2408 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2412 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2414 explicit LStackCheck(LOperand* context) {
2415 inputs_[0] = context;
2418 LOperand* context() { return inputs_[0]; }
2420 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2421 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2423 Label* done_label() { return &done_label_; }
2430 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2432 LForInPrepareMap(LOperand* context, LOperand* object) {
2433 inputs_[0] = context;
2434 inputs_[1] = object;
2437 LOperand* context() { return inputs_[0]; }
2438 LOperand* object() { return inputs_[1]; }
2440 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2444 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2446 explicit LForInCacheArray(LOperand* map) {
2450 LOperand* map() { return inputs_[0]; }
2452 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2455 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2460 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2462 LCheckMapValue(LOperand* value, LOperand* map) {
2467 LOperand* value() { return inputs_[0]; }
2468 LOperand* map() { return inputs_[1]; }
2470 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2474 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2476 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2477 inputs_[0] = object;
2481 LOperand* object() { return inputs_[0]; }
2482 LOperand* index() { return inputs_[1]; }
2484 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2488 class LChunkBuilder;
2489 class LPlatformChunk V8_FINAL : public LChunk {
2491 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2492 : LChunk(info, graph) { }
2494 int GetNextSpillIndex(RegisterKind kind);
2495 LOperand* GetNextSpillSlot(RegisterKind kind);
2499 class LChunkBuilder V8_FINAL : public LChunkBuilderBase {
2501 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2502 : LChunkBuilderBase(graph->zone()),
2507 current_instruction_(NULL),
2508 current_block_(NULL),
2510 allocator_(allocator),
2511 instruction_pending_deoptimization_environment_(NULL),
2512 pending_deoptimization_ast_id_(BailoutId::None()) { }
2514 // Build the sequence for the graph.
2515 LPlatformChunk* Build();
2517 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2519 // Declare methods that deal with the individual node types.
2520 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2521 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2524 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2525 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2526 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2527 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2528 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2529 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2530 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2540 LPlatformChunk* chunk() const { return chunk_; }
2541 CompilationInfo* info() const { return info_; }
2542 HGraph* graph() const { return graph_; }
2544 bool is_unused() const { return status_ == UNUSED; }
2545 bool is_building() const { return status_ == BUILDING; }
2546 bool is_done() const { return status_ == DONE; }
2547 bool is_aborted() const { return status_ == ABORTED; }
2549 void Abort(BailoutReason reason);
2551 // Methods for getting operands for Use / Define / Temp.
2552 LUnallocated* ToUnallocated(Register reg);
2553 LUnallocated* ToUnallocated(XMMRegister reg);
2555 // Methods for setting up define-use relationships.
2556 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2557 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2558 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2559 XMMRegister fixed_register);
2561 // A value that is guaranteed to be allocated to a register.
2562 // Operand created by UseRegister is guaranteed to be live until the end of
2563 // instruction. This means that register allocator will not reuse it's
2564 // register for any other operand inside instruction.
2565 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2566 // instruction start. Register allocator is free to assign the same register
2567 // to some other operand used inside instruction (i.e. temporary or
2569 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2570 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2572 // An input operand in a register that may be trashed.
2573 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2575 // An input operand in a register that may be trashed or a constant operand.
2576 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2578 // An input operand in a register or stack slot.
2579 MUST_USE_RESULT LOperand* Use(HValue* value);
2580 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2582 // An input operand in a register, stack slot or a constant operand.
2583 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2584 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2586 // An input operand in a register or a constant operand.
2587 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2588 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2590 // An input operand in a constant operand.
2591 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2593 // An input operand in register, stack slot or a constant operand.
2594 // Will not be moved to a register even if one is freely available.
2595 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) V8_OVERRIDE;
2597 // Temporary operand that must be in a register.
2598 MUST_USE_RESULT LUnallocated* TempRegister();
2599 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2600 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2602 // Methods for setting up define-use relationships.
2603 // Return the same instruction that they are passed.
2604 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2605 LUnallocated* result);
2606 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2607 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2609 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2610 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2612 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2614 // Assigns an environment to an instruction. An instruction which can
2615 // deoptimize must have an environment.
2616 LInstruction* AssignEnvironment(LInstruction* instr);
2617 // Assigns a pointer map to an instruction. An instruction which can
2618 // trigger a GC or a lazy deoptimization must have a pointer map.
2619 LInstruction* AssignPointerMap(LInstruction* instr);
2621 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2623 // Marks a call for the register allocator. Assigns a pointer map to
2624 // support GC and lazy deoptimization. Assigns an environment to support
2625 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2626 LInstruction* MarkAsCall(
2627 LInstruction* instr,
2628 HInstruction* hinstr,
2629 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2631 void VisitInstruction(HInstruction* current);
2633 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2634 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2635 LInstruction* DoArithmeticD(Token::Value op,
2636 HArithmeticBinaryOperation* instr);
2637 LInstruction* DoArithmeticT(Token::Value op,
2638 HBinaryOperation* instr);
2640 LPlatformChunk* chunk_;
2641 CompilationInfo* info_;
2642 HGraph* const graph_;
2644 HInstruction* current_instruction_;
2645 HBasicBlock* current_block_;
2646 HBasicBlock* next_block_;
2647 LAllocator* allocator_;
2648 LInstruction* instruction_pending_deoptimization_environment_;
2649 BailoutId pending_deoptimization_ast_id_;
2651 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2654 #undef DECLARE_HYDROGEN_ACCESSOR
2655 #undef DECLARE_CONCRETE_INSTRUCTION
2657 } } // namespace v8::int
2659 #endif // V8_X64_LITHIUM_X64_H_