1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef V8_X87_LITHIUM_X87_H_
6 #define V8_X87_LITHIUM_X87_H_
8 #include "src/hydrogen.h"
9 #include "src/lithium.h"
10 #include "src/lithium-allocator.h"
11 #include "src/safepoint-table.h"
12 #include "src/utils.h"
18 class RCodeVisualizer;
21 // Forward declarations.
24 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
27 V(AllocateBlockContext) \
30 V(ArgumentsElements) \
38 V(CallWithDescriptor) \
44 V(CheckInstanceType) \
52 V(ClampTToUint8NoSSE2) \
53 V(ClassOfTestAndBranch) \
55 V(CompareMinusZeroAndBranch) \
56 V(CompareNumericAndBranch) \
57 V(CmpObjectEqAndBranch) \
81 V(FlooringDivByConstI) \
82 V(FlooringDivByPowerOf2I) \
87 V(GetCachedArrayIndex) \
89 V(HasCachedArrayIndexAndBranch) \
90 V(HasInstanceTypeAndBranch) \
91 V(InnerAllocatedObject) \
93 V(InstanceOfKnownGlobal) \
95 V(Integer32ToDouble) \
97 V(IsConstructCallAndBranch) \
98 V(IsObjectAndBranch) \
99 V(IsStringAndBranch) \
101 V(IsUndetectableAndBranch) \
105 V(LoadFieldByIndex) \
106 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
148 V(StoreKeyedGeneric) \
150 V(StoreNamedGeneric) \
152 V(StringCharCodeAt) \
153 V(StringCharFromCode) \
154 V(StringCompareAndBranch) \
157 V(TailCallThroughMegamorphicCache) \
159 V(ToFastProperties) \
160 V(TransitionElementsKind) \
161 V(TrapAllocationMemento) \
163 V(TypeofIsAndBranch) \
169 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
170 Opcode opcode() const FINAL { return LInstruction::k##type; } \
171 void CompileToNative(LCodeGen* generator) FINAL; \
172 const char* Mnemonic() const FINAL { return mnemonic; } \
173 static L##type* cast(LInstruction* instr) { \
174 DCHECK(instr->Is##type()); \
175 return reinterpret_cast<L##type*>(instr); \
179 #define DECLARE_HYDROGEN_ACCESSOR(type) \
180 H##type* hydrogen() const { \
181 return H##type::cast(hydrogen_value()); \
185 class LInstruction : public ZoneObject {
188 : environment_(NULL),
189 hydrogen_value_(NULL),
190 bit_field_(IsCallBits::encode(false)) {
193 virtual ~LInstruction() {}
195 virtual void CompileToNative(LCodeGen* generator) = 0;
196 virtual const char* Mnemonic() const = 0;
197 virtual void PrintTo(StringStream* stream);
198 virtual void PrintDataTo(StringStream* stream);
199 virtual void PrintOutputOperandTo(StringStream* stream);
202 // Declare a unique enum value for each instruction.
203 #define DECLARE_OPCODE(type) k##type,
204 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
205 kNumberOfInstructions
206 #undef DECLARE_OPCODE
209 virtual Opcode opcode() const = 0;
211 // Declare non-virtual type testers for all leaf IR classes.
212 #define DECLARE_PREDICATE(type) \
213 bool Is##type() const { return opcode() == k##type; }
214 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
215 #undef DECLARE_PREDICATE
217 // Declare virtual predicates for instructions that don't have
219 virtual bool IsGap() const { return false; }
221 virtual bool IsControl() const { return false; }
223 // Try deleting this instruction if possible.
224 virtual bool TryDelete() { return false; }
226 void set_environment(LEnvironment* env) { environment_ = env; }
227 LEnvironment* environment() const { return environment_; }
228 bool HasEnvironment() const { return environment_ != NULL; }
230 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
231 LPointerMap* pointer_map() const { return pointer_map_.get(); }
232 bool HasPointerMap() const { return pointer_map_.is_set(); }
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
237 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
239 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
240 bool IsCall() const { return IsCallBits::decode(bit_field_); }
242 // Interface to the register allocator and iterators.
243 bool ClobbersTemps() const { return IsCall(); }
244 bool ClobbersRegisters() const { return IsCall(); }
245 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
247 // We only have rudimentary X87Stack tracking, thus in general
248 // cannot handle phi-nodes.
252 virtual bool HasResult() const = 0;
253 virtual LOperand* result() const = 0;
255 bool HasDoubleRegisterResult();
256 bool HasDoubleRegisterInput();
257 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
259 LOperand* FirstInput() { return InputAt(0); }
260 LOperand* Output() { return HasResult() ? result() : NULL; }
262 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
273 friend class InputIterator;
275 friend class TempIterator;
276 virtual int TempCount() = 0;
277 virtual LOperand* TempAt(int i) = 0;
279 class IsCallBits: public BitField<bool, 0, 1> {};
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
288 // R = number of result operands (0 or 1).
290 class LTemplateResultInstruction : public LInstruction {
292 // Allow 0 or 1 output operands.
293 STATIC_ASSERT(R == 0 || R == 1);
294 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
295 void set_result(LOperand* operand) { results_[0] = operand; }
296 LOperand* result() const OVERRIDE { return results_[0]; }
299 EmbeddedContainer<LOperand*, R> results_;
303 // R = number of result operands (0 or 1).
304 // I = number of input operands.
305 // T = number of temporary operands.
306 template<int R, int I, int T>
307 class LTemplateInstruction : public LTemplateResultInstruction<R> {
309 EmbeddedContainer<LOperand*, I> inputs_;
310 EmbeddedContainer<LOperand*, T> temps_;
314 int InputCount() FINAL { return I; }
315 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
317 int TempCount() FINAL { return T; }
318 LOperand* TempAt(int i) FINAL { return temps_[i]; }
322 class LGap : public LTemplateInstruction<0, 0, 0> {
324 explicit LGap(HBasicBlock* block) : block_(block) {
325 parallel_moves_[BEFORE] = NULL;
326 parallel_moves_[START] = NULL;
327 parallel_moves_[END] = NULL;
328 parallel_moves_[AFTER] = NULL;
331 // Can't use the DECLARE-macro here because of sub-classes.
332 bool IsGap() const FINAL { return true; }
333 void PrintDataTo(StringStream* stream) OVERRIDE;
334 static LGap* cast(LInstruction* instr) {
335 DCHECK(instr->IsGap());
336 return reinterpret_cast<LGap*>(instr);
339 bool IsRedundant() const;
341 HBasicBlock* block() const { return block_; }
348 FIRST_INNER_POSITION = BEFORE,
349 LAST_INNER_POSITION = AFTER
352 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
353 if (parallel_moves_[pos] == NULL) {
354 parallel_moves_[pos] = new(zone) LParallelMove(zone);
356 return parallel_moves_[pos];
359 LParallelMove* GetParallelMove(InnerPosition pos) {
360 return parallel_moves_[pos];
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
369 class LInstructionGap FINAL : public LGap {
371 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
373 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
374 return !IsRedundant();
377 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
381 class LClobberDoubles FINAL : public LTemplateInstruction<0, 0, 0> {
383 explicit LClobberDoubles(Isolate* isolate) { }
385 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE { return true; }
387 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
391 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
393 explicit LGoto(HBasicBlock* block) : block_(block) { }
395 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 void PrintDataTo(StringStream* stream) OVERRIDE;
398 bool IsControl() const OVERRIDE { return true; }
400 int block_id() const { return block_->block_id(); }
401 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
405 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
406 HBasicBlock* block() const { return block_; }
413 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
415 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
419 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
422 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
426 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
428 explicit LDummyUse(LOperand* value) {
431 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
435 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
437 bool IsControl() const OVERRIDE { return true; }
438 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
439 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
443 class LLabel FINAL : public LGap {
445 explicit LLabel(HBasicBlock* block)
446 : LGap(block), replacement_(NULL) { }
448 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
449 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
451 void PrintDataTo(StringStream* stream) OVERRIDE;
453 int block_id() const { return block()->block_id(); }
454 bool is_loop_header() const { return block()->IsLoopHeader(); }
455 bool is_osr_entry() const { return block()->is_osr_entry(); }
456 Label* label() { return &label_; }
457 LLabel* replacement() const { return replacement_; }
458 void set_replacement(LLabel* label) { replacement_ = label; }
459 bool HasReplacement() const { return replacement_ != NULL; }
463 LLabel* replacement_;
467 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
469 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
470 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
474 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
476 explicit LCallStub(LOperand* context) {
477 inputs_[0] = context;
480 LOperand* context() { return inputs_[0]; }
482 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
483 DECLARE_HYDROGEN_ACCESSOR(CallStub)
487 class LTailCallThroughMegamorphicCache FINAL
488 : public LTemplateInstruction<0, 5, 0> {
490 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
491 LOperand* name, LOperand* slot,
493 inputs_[0] = context;
494 inputs_[1] = receiver;
500 LOperand* context() { return inputs_[0]; }
501 LOperand* receiver() { return inputs_[1]; }
502 LOperand* name() { return inputs_[2]; }
503 LOperand* slot() { return inputs_[3]; }
504 LOperand* vector() { return inputs_[4]; }
506 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
507 "tail-call-through-megamorphic-cache")
508 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
512 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
514 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
515 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
519 template<int I, int T>
520 class LControlInstruction: public LTemplateInstruction<0, I, T> {
522 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
524 bool IsControl() const FINAL { return true; }
526 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
527 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
529 int TrueDestination(LChunk* chunk) {
530 return chunk->LookupDestination(true_block_id());
532 int FalseDestination(LChunk* chunk) {
533 return chunk->LookupDestination(false_block_id());
536 Label* TrueLabel(LChunk* chunk) {
537 if (true_label_ == NULL) {
538 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
542 Label* FalseLabel(LChunk* chunk) {
543 if (false_label_ == NULL) {
544 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
550 int true_block_id() { return SuccessorAt(0)->block_id(); }
551 int false_block_id() { return SuccessorAt(1)->block_id(); }
554 HControlInstruction* hydrogen() {
555 return HControlInstruction::cast(this->hydrogen_value());
563 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
565 LWrapReceiver(LOperand* receiver,
568 inputs_[0] = receiver;
569 inputs_[1] = function;
573 LOperand* receiver() { return inputs_[0]; }
574 LOperand* function() { return inputs_[1]; }
575 LOperand* temp() { return temps_[0]; }
577 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
578 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
582 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
584 LApplyArguments(LOperand* function,
587 LOperand* elements) {
588 inputs_[0] = function;
589 inputs_[1] = receiver;
591 inputs_[3] = elements;
594 LOperand* function() { return inputs_[0]; }
595 LOperand* receiver() { return inputs_[1]; }
596 LOperand* length() { return inputs_[2]; }
597 LOperand* elements() { return inputs_[3]; }
599 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
603 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
605 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
606 inputs_[0] = arguments;
611 LOperand* arguments() { return inputs_[0]; }
612 LOperand* length() { return inputs_[1]; }
613 LOperand* index() { return inputs_[2]; }
615 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
617 void PrintDataTo(StringStream* stream) OVERRIDE;
621 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
623 explicit LArgumentsLength(LOperand* elements) {
624 inputs_[0] = elements;
627 LOperand* elements() { return inputs_[0]; }
629 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
633 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
635 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
636 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
640 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
642 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
646 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
648 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
649 inputs_[0] = dividend;
653 LOperand* dividend() { return inputs_[0]; }
654 int32_t divisor() const { return divisor_; }
656 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
657 DECLARE_HYDROGEN_ACCESSOR(Mod)
664 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
666 LModByConstI(LOperand* dividend,
670 inputs_[0] = dividend;
676 LOperand* dividend() { return inputs_[0]; }
677 int32_t divisor() const { return divisor_; }
678 LOperand* temp1() { return temps_[0]; }
679 LOperand* temp2() { return temps_[1]; }
681 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
682 DECLARE_HYDROGEN_ACCESSOR(Mod)
689 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
691 LModI(LOperand* left, LOperand* right, LOperand* temp) {
697 LOperand* left() { return inputs_[0]; }
698 LOperand* right() { return inputs_[1]; }
699 LOperand* temp() { return temps_[0]; }
701 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
702 DECLARE_HYDROGEN_ACCESSOR(Mod)
706 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
708 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
709 inputs_[0] = dividend;
713 LOperand* dividend() { return inputs_[0]; }
714 int32_t divisor() const { return divisor_; }
716 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
717 DECLARE_HYDROGEN_ACCESSOR(Div)
724 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
726 LDivByConstI(LOperand* dividend,
730 inputs_[0] = dividend;
736 LOperand* dividend() { return inputs_[0]; }
737 int32_t divisor() const { return divisor_; }
738 LOperand* temp1() { return temps_[0]; }
739 LOperand* temp2() { return temps_[1]; }
741 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
742 DECLARE_HYDROGEN_ACCESSOR(Div)
749 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
751 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
752 inputs_[0] = dividend;
753 inputs_[1] = divisor;
757 LOperand* dividend() { return inputs_[0]; }
758 LOperand* divisor() { return inputs_[1]; }
759 LOperand* temp() { return temps_[0]; }
761 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
762 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
766 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
768 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
769 inputs_[0] = dividend;
773 LOperand* dividend() { return inputs_[0]; }
774 int32_t divisor() const { return divisor_; }
776 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
777 "flooring-div-by-power-of-2-i")
778 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
785 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
787 LFlooringDivByConstI(LOperand* dividend,
792 inputs_[0] = dividend;
799 LOperand* dividend() { return inputs_[0]; }
800 int32_t divisor() const { return divisor_; }
801 LOperand* temp1() { return temps_[0]; }
802 LOperand* temp2() { return temps_[1]; }
803 LOperand* temp3() { return temps_[2]; }
805 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
806 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
813 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
815 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
816 inputs_[0] = dividend;
817 inputs_[1] = divisor;
821 LOperand* dividend() { return inputs_[0]; }
822 LOperand* divisor() { return inputs_[1]; }
823 LOperand* temp() { return temps_[0]; }
825 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
826 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
830 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
832 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
838 LOperand* left() { return inputs_[0]; }
839 LOperand* right() { return inputs_[1]; }
840 LOperand* temp() { return temps_[0]; }
842 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
843 DECLARE_HYDROGEN_ACCESSOR(Mul)
847 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
849 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
854 LOperand* left() { return inputs_[0]; }
855 LOperand* right() { return inputs_[1]; }
857 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
858 "compare-numeric-and-branch")
859 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
861 Token::Value op() const { return hydrogen()->token(); }
862 bool is_double() const {
863 return hydrogen()->representation().IsDouble();
866 void PrintDataTo(StringStream* stream) OVERRIDE;
870 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
872 explicit LMathFloor(LOperand* value) {
876 LOperand* value() { return inputs_[0]; }
878 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
879 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
883 class LMathRound FINAL : public LTemplateInstruction<1, 1, 0> {
885 explicit LMathRound(LOperand* value) {
889 LOperand* value() { return inputs_[0]; }
891 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
892 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
896 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
898 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
900 LOperand* value() { return inputs_[0]; }
902 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
906 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
908 LMathAbs(LOperand* context, LOperand* value) {
909 inputs_[1] = context;
913 LOperand* context() { return inputs_[1]; }
914 LOperand* value() { return inputs_[0]; }
916 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
917 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
921 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
923 explicit LMathLog(LOperand* value) {
927 LOperand* value() { return inputs_[0]; }
929 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
933 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
935 explicit LMathClz32(LOperand* value) {
939 LOperand* value() { return inputs_[0]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
945 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
947 LMathExp(LOperand* value,
953 ExternalReference::InitializeMathExpData();
956 LOperand* value() { return inputs_[0]; }
957 LOperand* temp1() { return temps_[0]; }
958 LOperand* temp2() { return temps_[1]; }
960 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
964 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 2> {
966 explicit LMathSqrt(LOperand* value,
974 LOperand* value() { return inputs_[0]; }
975 LOperand* temp1() { return temps_[0]; }
976 LOperand* temp2() { return temps_[1]; }
978 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
982 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
984 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
986 LOperand* value() { return inputs_[0]; }
988 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
992 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
994 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
999 LOperand* left() { return inputs_[0]; }
1000 LOperand* right() { return inputs_[1]; }
1002 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1006 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1008 explicit LCmpHoleAndBranch(LOperand* object) {
1009 inputs_[0] = object;
1012 LOperand* object() { return inputs_[0]; }
1014 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1015 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1019 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1021 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1026 "cmp-minus-zero-and-branch")
1027 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1031 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1033 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1038 LOperand* value() { return inputs_[0]; }
1039 LOperand* temp() { return temps_[0]; }
1041 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1043 void PrintDataTo(StringStream* stream) OVERRIDE;
1047 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1049 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1054 LOperand* value() { return inputs_[0]; }
1055 LOperand* temp() { return temps_[0]; }
1057 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1058 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1060 void PrintDataTo(StringStream* stream) OVERRIDE;
1064 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1066 explicit LIsSmiAndBranch(LOperand* value) {
1070 LOperand* value() { return inputs_[0]; }
1072 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1073 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1075 void PrintDataTo(StringStream* stream) OVERRIDE;
1079 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1081 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1086 LOperand* value() { return inputs_[0]; }
1087 LOperand* temp() { return temps_[0]; }
1089 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1090 "is-undetectable-and-branch")
1091 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1093 void PrintDataTo(StringStream* stream) OVERRIDE;
1097 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1099 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1100 inputs_[0] = context;
1105 LOperand* context() { return inputs_[1]; }
1106 LOperand* left() { return inputs_[1]; }
1107 LOperand* right() { return inputs_[2]; }
1109 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1110 "string-compare-and-branch")
1111 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1113 void PrintDataTo(StringStream* stream) OVERRIDE;
1115 Token::Value op() const { return hydrogen()->token(); }
1119 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1121 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1126 LOperand* value() { return inputs_[0]; }
1127 LOperand* temp() { return temps_[0]; }
1129 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1130 "has-instance-type-and-branch")
1131 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1133 void PrintDataTo(StringStream* stream) OVERRIDE;
1137 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1139 explicit LGetCachedArrayIndex(LOperand* value) {
1143 LOperand* value() { return inputs_[0]; }
1145 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1146 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1150 class LHasCachedArrayIndexAndBranch FINAL
1151 : public LControlInstruction<1, 0> {
1153 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1157 LOperand* value() { return inputs_[0]; }
1159 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1160 "has-cached-array-index-and-branch")
1162 void PrintDataTo(StringStream* stream) OVERRIDE;
1166 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1168 explicit LIsConstructCallAndBranch(LOperand* temp) {
1172 LOperand* temp() { return temps_[0]; }
1174 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1175 "is-construct-call-and-branch")
1179 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1181 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1187 LOperand* value() { return inputs_[0]; }
1188 LOperand* temp() { return temps_[0]; }
1189 LOperand* temp2() { return temps_[1]; }
1191 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1192 "class-of-test-and-branch")
1193 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1195 void PrintDataTo(StringStream* stream) OVERRIDE;
1199 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1201 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1202 inputs_[0] = context;
1207 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1208 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1210 LOperand* context() { return inputs_[0]; }
1211 Token::Value op() const { return hydrogen()->token(); }
1215 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1217 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1218 inputs_[0] = context;
1223 LOperand* context() { return inputs_[0]; }
1225 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1229 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1231 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1232 inputs_[0] = context;
1237 LOperand* context() { return inputs_[0]; }
1238 LOperand* value() { return inputs_[1]; }
1239 LOperand* temp() { return temps_[0]; }
1241 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1242 "instance-of-known-global")
1243 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1245 Handle<JSFunction> function() const { return hydrogen()->function(); }
1246 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1247 return lazy_deopt_env_;
1249 virtual void SetDeferredLazyDeoptimizationEnvironment(
1250 LEnvironment* env) OVERRIDE {
1251 lazy_deopt_env_ = env;
1255 LEnvironment* lazy_deopt_env_;
1259 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1261 LBoundsCheck(LOperand* index, LOperand* length) {
1263 inputs_[1] = length;
1266 LOperand* index() { return inputs_[0]; }
1267 LOperand* length() { return inputs_[1]; }
1269 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1270 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1274 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1276 LBitI(LOperand* left, LOperand* right) {
1281 LOperand* left() { return inputs_[0]; }
1282 LOperand* right() { return inputs_[1]; }
1284 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1285 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1287 Token::Value op() const { return hydrogen()->op(); }
1291 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1293 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1294 : op_(op), can_deopt_(can_deopt) {
1299 LOperand* left() { return inputs_[0]; }
1300 LOperand* right() { return inputs_[1]; }
1302 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1304 Token::Value op() const { return op_; }
1305 bool can_deopt() const { return can_deopt_; }
1313 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1315 LSubI(LOperand* left, LOperand* right) {
1320 LOperand* left() { return inputs_[0]; }
1321 LOperand* right() { return inputs_[1]; }
1323 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1324 DECLARE_HYDROGEN_ACCESSOR(Sub)
1328 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1330 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1331 DECLARE_HYDROGEN_ACCESSOR(Constant)
1333 int32_t value() const { return hydrogen()->Integer32Value(); }
1337 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1339 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1340 DECLARE_HYDROGEN_ACCESSOR(Constant)
1342 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1346 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1348 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1349 DECLARE_HYDROGEN_ACCESSOR(Constant)
1351 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1355 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1357 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1358 DECLARE_HYDROGEN_ACCESSOR(Constant)
1360 ExternalReference value() const {
1361 return hydrogen()->ExternalReferenceValue();
1366 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1368 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1369 DECLARE_HYDROGEN_ACCESSOR(Constant)
1371 Handle<Object> value(Isolate* isolate) const {
1372 return hydrogen()->handle(isolate);
1377 class LBranch FINAL : public LControlInstruction<1, 1> {
1379 LBranch(LOperand* value, LOperand* temp) {
1384 LOperand* value() { return inputs_[0]; }
1385 LOperand* temp() { return temps_[0]; }
1387 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1388 DECLARE_HYDROGEN_ACCESSOR(Branch)
1390 void PrintDataTo(StringStream* stream) OVERRIDE;
1394 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1396 explicit LCmpMapAndBranch(LOperand* value) {
1400 LOperand* value() { return inputs_[0]; }
1402 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1403 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1405 Handle<Map> map() const { return hydrogen()->map().handle(); }
1409 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1411 explicit LMapEnumLength(LOperand* value) {
1415 LOperand* value() { return inputs_[0]; }
1417 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1421 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1423 LDateField(LOperand* date, LOperand* temp, Smi* index)
1429 LOperand* date() { return inputs_[0]; }
1430 LOperand* temp() { return temps_[0]; }
1432 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1433 DECLARE_HYDROGEN_ACCESSOR(DateField)
1435 Smi* index() const { return index_; }
1442 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1444 LSeqStringGetChar(LOperand* string, LOperand* index) {
1445 inputs_[0] = string;
1449 LOperand* string() const { return inputs_[0]; }
1450 LOperand* index() const { return inputs_[1]; }
1452 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1453 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1457 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1459 LSeqStringSetChar(LOperand* context,
1463 inputs_[0] = context;
1464 inputs_[1] = string;
1469 LOperand* string() { return inputs_[1]; }
1470 LOperand* index() { return inputs_[2]; }
1471 LOperand* value() { return inputs_[3]; }
1473 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1474 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1478 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1480 LAddI(LOperand* left, LOperand* right) {
1485 LOperand* left() { return inputs_[0]; }
1486 LOperand* right() { return inputs_[1]; }
1488 static bool UseLea(HAdd* add) {
1489 return !add->CheckFlag(HValue::kCanOverflow) &&
1490 add->BetterLeftOperand()->UseCount() > 1;
1493 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1494 DECLARE_HYDROGEN_ACCESSOR(Add)
1498 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 1> {
1500 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1506 LOperand* left() { return inputs_[0]; }
1507 LOperand* right() { return inputs_[1]; }
1508 LOperand* temp() { return temps_[0]; }
1510 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1511 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1515 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1517 LPower(LOperand* left, LOperand* right) {
1522 LOperand* left() { return inputs_[0]; }
1523 LOperand* right() { return inputs_[1]; }
1525 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1526 DECLARE_HYDROGEN_ACCESSOR(Power)
1530 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1532 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1538 LOperand* left() { return inputs_[0]; }
1539 LOperand* right() { return inputs_[1]; }
1541 Token::Value op() const { return op_; }
1543 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1544 void CompileToNative(LCodeGen* generator) OVERRIDE;
1545 const char* Mnemonic() const OVERRIDE;
1552 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1554 LArithmeticT(Token::Value op,
1559 inputs_[0] = context;
1564 LOperand* context() { return inputs_[0]; }
1565 LOperand* left() { return inputs_[1]; }
1566 LOperand* right() { return inputs_[2]; }
1568 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1569 void CompileToNative(LCodeGen* generator) OVERRIDE;
1570 const char* Mnemonic() const OVERRIDE;
1572 Token::Value op() const { return op_; }
1579 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1581 explicit LReturn(LOperand* value,
1583 LOperand* parameter_count) {
1585 inputs_[1] = context;
1586 inputs_[2] = parameter_count;
1589 bool has_constant_parameter_count() {
1590 return parameter_count()->IsConstantOperand();
1592 LConstantOperand* constant_parameter_count() {
1593 DCHECK(has_constant_parameter_count());
1594 return LConstantOperand::cast(parameter_count());
1596 LOperand* parameter_count() { return inputs_[2]; }
1598 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1599 DECLARE_HYDROGEN_ACCESSOR(Return)
1603 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1605 explicit LLoadNamedField(LOperand* object) {
1606 inputs_[0] = object;
1609 LOperand* object() { return inputs_[0]; }
1611 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1612 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1616 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1618 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1619 inputs_[0] = context;
1620 inputs_[1] = object;
1624 LOperand* context() { return inputs_[0]; }
1625 LOperand* object() { return inputs_[1]; }
1626 LOperand* temp_vector() { return temps_[0]; }
1628 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1631 Handle<Object> name() const { return hydrogen()->name(); }
1635 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1637 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1638 inputs_[0] = function;
1642 LOperand* function() { return inputs_[0]; }
1643 LOperand* temp() { return temps_[0]; }
1645 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1646 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1650 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1652 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1653 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1655 Heap::RootListIndex index() const { return hydrogen()->index(); }
1659 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1661 LLoadKeyed(LOperand* elements, LOperand* key) {
1662 inputs_[0] = elements;
1665 LOperand* elements() { return inputs_[0]; }
1666 LOperand* key() { return inputs_[1]; }
1667 ElementsKind elements_kind() const {
1668 return hydrogen()->elements_kind();
1670 bool is_external() const {
1671 return hydrogen()->is_external();
1673 bool is_fixed_typed_array() const {
1674 return hydrogen()->is_fixed_typed_array();
1676 bool is_typed_elements() const {
1677 return is_external() || is_fixed_typed_array();
1680 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1681 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1683 void PrintDataTo(StringStream* stream) OVERRIDE;
1684 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1686 return hydrogen()->key()->representation().IsTagged();
1691 inline static bool ExternalArrayOpRequiresTemp(
1692 Representation key_representation,
1693 ElementsKind elements_kind) {
1694 // Operations that require the key to be divided by two to be converted into
1695 // an index cannot fold the scale operation into a load and need an extra
1696 // temp register to do the work.
1697 return key_representation.IsSmi() &&
1698 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1699 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1700 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1701 elements_kind == UINT8_ELEMENTS ||
1702 elements_kind == INT8_ELEMENTS ||
1703 elements_kind == UINT8_CLAMPED_ELEMENTS);
1707 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1709 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1711 inputs_[0] = context;
1717 LOperand* context() { return inputs_[0]; }
1718 LOperand* object() { return inputs_[1]; }
1719 LOperand* key() { return inputs_[2]; }
1720 LOperand* temp_vector() { return temps_[0]; }
1722 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1723 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1727 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1729 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1731 inputs_[0] = context;
1732 inputs_[1] = global_object;
1736 LOperand* context() { return inputs_[0]; }
1737 LOperand* global_object() { return inputs_[1]; }
1738 LOperand* temp_vector() { return temps_[0]; }
1740 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1741 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1743 Handle<Object> name() const { return hydrogen()->name(); }
1744 bool for_typeof() const { return hydrogen()->for_typeof(); }
1748 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1750 explicit LLoadContextSlot(LOperand* context) {
1751 inputs_[0] = context;
1754 LOperand* context() { return inputs_[0]; }
1756 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1757 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1759 int slot_index() { return hydrogen()->slot_index(); }
1761 void PrintDataTo(StringStream* stream) OVERRIDE;
1765 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1767 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1768 inputs_[0] = context;
1773 LOperand* context() { return inputs_[0]; }
1774 LOperand* value() { return inputs_[1]; }
1775 LOperand* temp() { return temps_[0]; }
1777 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1778 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1780 int slot_index() { return hydrogen()->slot_index(); }
1782 void PrintDataTo(StringStream* stream) OVERRIDE;
1786 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1788 explicit LPushArgument(LOperand* value) {
1792 LOperand* value() { return inputs_[0]; }
1794 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1798 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1800 explicit LDrop(int count) : count_(count) { }
1802 int count() const { return count_; }
1804 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1811 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1813 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1814 inputs_[0] = function;
1815 inputs_[1] = code_object;
1818 LOperand* function() { return inputs_[0]; }
1819 LOperand* code_object() { return inputs_[1]; }
1821 void PrintDataTo(StringStream* stream) OVERRIDE;
1823 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1824 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1828 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1830 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1831 inputs_[0] = base_object;
1832 inputs_[1] = offset;
1835 LOperand* base_object() const { return inputs_[0]; }
1836 LOperand* offset() const { return inputs_[1]; }
1838 void PrintDataTo(StringStream* stream) OVERRIDE;
1840 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1844 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1846 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1847 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1851 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1853 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1854 DECLARE_HYDROGEN_ACCESSOR(Context)
1858 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1860 explicit LDeclareGlobals(LOperand* context) {
1861 inputs_[0] = context;
1864 LOperand* context() { return inputs_[0]; }
1866 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1867 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1871 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1873 explicit LCallJSFunction(LOperand* function) {
1874 inputs_[0] = function;
1877 LOperand* function() { return inputs_[0]; }
1879 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1880 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1882 void PrintDataTo(StringStream* stream) OVERRIDE;
1884 int arity() const { return hydrogen()->argument_count() - 1; }
1888 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1890 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1891 const ZoneList<LOperand*>& operands, Zone* zone)
1892 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1893 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1894 inputs_.AddAll(operands, zone);
1897 LOperand* target() const { return inputs_[0]; }
1899 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1902 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1904 void PrintDataTo(StringStream* stream) OVERRIDE;
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1908 ZoneList<LOperand*> inputs_;
1910 // Iterator support.
1911 int InputCount() FINAL { return inputs_.length(); }
1912 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1914 int TempCount() FINAL { return 0; }
1915 LOperand* TempAt(int i) FINAL { return NULL; }
1919 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1921 LInvokeFunction(LOperand* context, LOperand* function) {
1922 inputs_[0] = context;
1923 inputs_[1] = function;
1926 LOperand* context() { return inputs_[0]; }
1927 LOperand* function() { return inputs_[1]; }
1929 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1930 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1932 void PrintDataTo(StringStream* stream) OVERRIDE;
1934 int arity() const { return hydrogen()->argument_count() - 1; }
1938 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 2> {
1940 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1942 inputs_[0] = context;
1943 inputs_[1] = function;
1948 LOperand* context() { return inputs_[0]; }
1949 LOperand* function() { return inputs_[1]; }
1950 LOperand* temp_slot() { return temps_[0]; }
1951 LOperand* temp_vector() { return temps_[1]; }
1953 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1954 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1956 void PrintDataTo(StringStream* stream) OVERRIDE;
1957 int arity() const { return hydrogen()->argument_count() - 1; }
1961 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1963 LCallNew(LOperand* context, LOperand* constructor) {
1964 inputs_[0] = context;
1965 inputs_[1] = constructor;
1968 LOperand* context() { return inputs_[0]; }
1969 LOperand* constructor() { return inputs_[1]; }
1971 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1972 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1974 void PrintDataTo(StringStream* stream) OVERRIDE;
1976 int arity() const { return hydrogen()->argument_count() - 1; }
1980 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1982 LCallNewArray(LOperand* context, LOperand* constructor) {
1983 inputs_[0] = context;
1984 inputs_[1] = constructor;
1987 LOperand* context() { return inputs_[0]; }
1988 LOperand* constructor() { return inputs_[1]; }
1990 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1991 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1993 void PrintDataTo(StringStream* stream) OVERRIDE;
1995 int arity() const { return hydrogen()->argument_count() - 1; }
1999 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2001 explicit LCallRuntime(LOperand* context) {
2002 inputs_[0] = context;
2005 LOperand* context() { return inputs_[0]; }
2007 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2008 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2010 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2011 return save_doubles() == kDontSaveFPRegs;
2014 const Runtime::Function* function() const { return hydrogen()->function(); }
2015 int arity() const { return hydrogen()->argument_count(); }
2016 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2020 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2022 explicit LInteger32ToDouble(LOperand* value) {
2026 LOperand* value() { return inputs_[0]; }
2028 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2032 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2034 explicit LUint32ToDouble(LOperand* value) {
2038 LOperand* value() { return inputs_[0]; }
2040 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2044 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2046 LNumberTagI(LOperand* value, LOperand* temp) {
2051 LOperand* value() { return inputs_[0]; }
2052 LOperand* temp() { return temps_[0]; }
2054 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2058 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2060 LNumberTagU(LOperand* value, LOperand* temp) {
2065 LOperand* value() { return inputs_[0]; }
2066 LOperand* temp() { return temps_[0]; }
2068 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2072 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2074 LNumberTagD(LOperand* value, LOperand* temp) {
2079 LOperand* value() { return inputs_[0]; }
2080 LOperand* temp() { return temps_[0]; }
2082 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2083 DECLARE_HYDROGEN_ACCESSOR(Change)
2087 // Sometimes truncating conversion from a tagged value to an int32.
2088 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2090 explicit LDoubleToI(LOperand* value) {
2094 LOperand* value() { return inputs_[0]; }
2096 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2097 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2099 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2103 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2105 explicit LDoubleToSmi(LOperand* value) {
2109 LOperand* value() { return inputs_[0]; }
2111 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2112 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2116 // Truncating conversion from a tagged value to an int32.
2117 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2119 explicit LTaggedToI(LOperand* value) {
2123 LOperand* value() { return inputs_[0]; }
2125 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2126 DECLARE_HYDROGEN_ACCESSOR(Change)
2128 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2132 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2134 explicit LSmiTag(LOperand* value) {
2138 LOperand* value() { return inputs_[0]; }
2140 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2141 DECLARE_HYDROGEN_ACCESSOR(Change)
2145 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2147 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2152 LOperand* value() { return inputs_[0]; }
2153 LOperand* temp() { return temps_[0]; }
2155 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2156 DECLARE_HYDROGEN_ACCESSOR(Change);
2160 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2162 LSmiUntag(LOperand* value, bool needs_check)
2163 : needs_check_(needs_check) {
2167 LOperand* value() { return inputs_[0]; }
2169 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2171 bool needs_check() const { return needs_check_; }
2178 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2180 LStoreNamedField(LOperand* obj,
2183 LOperand* temp_map) {
2187 temps_[1] = temp_map;
2190 LOperand* object() { return inputs_[0]; }
2191 LOperand* value() { return inputs_[1]; }
2192 LOperand* temp() { return temps_[0]; }
2193 LOperand* temp_map() { return temps_[1]; }
2195 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2196 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2198 void PrintDataTo(StringStream* stream) OVERRIDE;
2202 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2204 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2205 inputs_[0] = context;
2206 inputs_[1] = object;
2210 LOperand* context() { return inputs_[0]; }
2211 LOperand* object() { return inputs_[1]; }
2212 LOperand* value() { return inputs_[2]; }
2214 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2215 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2217 void PrintDataTo(StringStream* stream) OVERRIDE;
2218 Handle<Object> name() const { return hydrogen()->name(); }
2219 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2223 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2225 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2231 bool is_external() const { return hydrogen()->is_external(); }
2232 bool is_fixed_typed_array() const {
2233 return hydrogen()->is_fixed_typed_array();
2235 bool is_typed_elements() const {
2236 return is_external() || is_fixed_typed_array();
2238 LOperand* elements() { return inputs_[0]; }
2239 LOperand* key() { return inputs_[1]; }
2240 LOperand* value() { return inputs_[2]; }
2241 ElementsKind elements_kind() const {
2242 return hydrogen()->elements_kind();
2245 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2246 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2248 void PrintDataTo(StringStream* stream) OVERRIDE;
2249 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2250 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2254 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2256 LStoreKeyedGeneric(LOperand* context,
2260 inputs_[0] = context;
2261 inputs_[1] = object;
2266 LOperand* context() { return inputs_[0]; }
2267 LOperand* object() { return inputs_[1]; }
2268 LOperand* key() { return inputs_[2]; }
2269 LOperand* value() { return inputs_[3]; }
2271 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2272 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2274 void PrintDataTo(StringStream* stream) OVERRIDE;
2276 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2280 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2282 LTransitionElementsKind(LOperand* object,
2284 LOperand* new_map_temp,
2286 inputs_[0] = object;
2287 inputs_[1] = context;
2288 temps_[0] = new_map_temp;
2292 LOperand* context() { return inputs_[1]; }
2293 LOperand* object() { return inputs_[0]; }
2294 LOperand* new_map_temp() { return temps_[0]; }
2295 LOperand* temp() { return temps_[1]; }
2297 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2298 "transition-elements-kind")
2299 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2301 void PrintDataTo(StringStream* stream) OVERRIDE;
2303 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2304 Handle<Map> transitioned_map() {
2305 return hydrogen()->transitioned_map().handle();
2307 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2308 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2312 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2314 LTrapAllocationMemento(LOperand* object,
2316 inputs_[0] = object;
2320 LOperand* object() { return inputs_[0]; }
2321 LOperand* temp() { return temps_[0]; }
2323 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2324 "trap-allocation-memento")
2328 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2330 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2331 inputs_[0] = context;
2336 LOperand* context() { return inputs_[0]; }
2337 LOperand* left() { return inputs_[1]; }
2338 LOperand* right() { return inputs_[2]; }
2340 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2341 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2345 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2347 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2348 inputs_[0] = context;
2349 inputs_[1] = string;
2353 LOperand* context() { return inputs_[0]; }
2354 LOperand* string() { return inputs_[1]; }
2355 LOperand* index() { return inputs_[2]; }
2357 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2358 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2362 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2364 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2365 inputs_[0] = context;
2366 inputs_[1] = char_code;
2369 LOperand* context() { return inputs_[0]; }
2370 LOperand* char_code() { return inputs_[1]; }
2372 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2373 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2377 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2379 explicit LCheckValue(LOperand* value) {
2383 LOperand* value() { return inputs_[0]; }
2385 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2386 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2390 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2392 LCheckInstanceType(LOperand* value, LOperand* temp) {
2397 LOperand* value() { return inputs_[0]; }
2398 LOperand* temp() { return temps_[0]; }
2400 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2401 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2405 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2407 explicit LCheckMaps(LOperand* value = NULL) {
2411 LOperand* value() { return inputs_[0]; }
2413 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2414 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2418 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2420 explicit LCheckSmi(LOperand* value) {
2424 LOperand* value() { return inputs_[0]; }
2426 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2430 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2432 explicit LClampDToUint8(LOperand* value) {
2436 LOperand* unclamped() { return inputs_[0]; }
2438 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2442 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2444 explicit LClampIToUint8(LOperand* value) {
2448 LOperand* unclamped() { return inputs_[0]; }
2450 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2454 // Truncating conversion from a tagged value to an int32.
2455 class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2457 LClampTToUint8NoSSE2(LOperand* unclamped,
2461 inputs_[0] = unclamped;
2467 LOperand* unclamped() { return inputs_[0]; }
2468 LOperand* scratch() { return temps_[0]; }
2469 LOperand* scratch2() { return temps_[1]; }
2470 LOperand* scratch3() { return temps_[2]; }
2472 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2473 "clamp-t-to-uint8-nosse2")
2474 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2478 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2480 explicit LCheckNonSmi(LOperand* value) {
2484 LOperand* value() { return inputs_[0]; }
2486 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2487 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2491 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2493 explicit LDoubleBits(LOperand* value) {
2497 LOperand* value() { return inputs_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2500 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2504 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2506 LConstructDouble(LOperand* hi, LOperand* lo) {
2511 LOperand* hi() { return inputs_[0]; }
2512 LOperand* lo() { return inputs_[1]; }
2514 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2518 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2520 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2521 inputs_[0] = context;
2526 LOperand* context() { return inputs_[0]; }
2527 LOperand* size() { return inputs_[1]; }
2528 LOperand* temp() { return temps_[0]; }
2530 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2531 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2535 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2537 explicit LRegExpLiteral(LOperand* context) {
2538 inputs_[0] = context;
2541 LOperand* context() { return inputs_[0]; }
2543 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2544 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2548 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2550 explicit LFunctionLiteral(LOperand* context) {
2551 inputs_[0] = context;
2554 LOperand* context() { return inputs_[0]; }
2556 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2557 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2561 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2563 explicit LToFastProperties(LOperand* value) {
2567 LOperand* value() { return inputs_[0]; }
2569 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2570 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2574 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2576 LTypeof(LOperand* context, LOperand* value) {
2577 inputs_[0] = context;
2581 LOperand* context() { return inputs_[0]; }
2582 LOperand* value() { return inputs_[1]; }
2584 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2588 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2590 explicit LTypeofIsAndBranch(LOperand* value) {
2594 LOperand* value() { return inputs_[0]; }
2596 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2597 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2599 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2601 void PrintDataTo(StringStream* stream) OVERRIDE;
2605 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2607 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2608 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2612 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2614 explicit LStackCheck(LOperand* context) {
2615 inputs_[0] = context;
2618 LOperand* context() { return inputs_[0]; }
2620 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2621 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2623 Label* done_label() { return &done_label_; }
2630 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2632 LForInPrepareMap(LOperand* context, LOperand* object) {
2633 inputs_[0] = context;
2634 inputs_[1] = object;
2637 LOperand* context() { return inputs_[0]; }
2638 LOperand* object() { return inputs_[1]; }
2640 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2644 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2646 explicit LForInCacheArray(LOperand* map) {
2650 LOperand* map() { return inputs_[0]; }
2652 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2655 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2660 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2662 LCheckMapValue(LOperand* value, LOperand* map) {
2667 LOperand* value() { return inputs_[0]; }
2668 LOperand* map() { return inputs_[1]; }
2670 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2674 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2676 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2677 inputs_[0] = object;
2681 LOperand* object() { return inputs_[0]; }
2682 LOperand* index() { return inputs_[1]; }
2684 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2688 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2690 explicit LStoreFrameContext(LOperand* context) {
2691 inputs_[0] = context;
2694 LOperand* context() { return inputs_[0]; }
2696 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2700 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2702 LAllocateBlockContext(LOperand* context, LOperand* function) {
2703 inputs_[0] = context;
2704 inputs_[1] = function;
2707 LOperand* context() { return inputs_[0]; }
2708 LOperand* function() { return inputs_[1]; }
2710 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2712 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2713 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2717 class LChunkBuilder;
2718 class LPlatformChunk FINAL : public LChunk {
2720 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2721 : LChunk(info, graph),
2722 num_double_slots_(0) { }
2724 int GetNextSpillIndex(RegisterKind kind);
2725 LOperand* GetNextSpillSlot(RegisterKind kind);
2727 int num_double_slots() const { return num_double_slots_; }
2730 int num_double_slots_;
2734 class LChunkBuilder FINAL : public LChunkBuilderBase {
2736 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2737 : LChunkBuilderBase(info, graph),
2738 current_instruction_(NULL),
2739 current_block_(NULL),
2741 allocator_(allocator) {}
2743 // Build the sequence for the graph.
2744 LPlatformChunk* Build();
2746 // Declare methods that deal with the individual node types.
2747 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2748 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2751 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2752 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2753 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2754 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2755 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2756 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2757 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2758 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2759 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2760 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2761 LInstruction* DoDivByConstI(HDiv* instr);
2762 LInstruction* DoDivI(HDiv* instr);
2763 LInstruction* DoModByPowerOf2I(HMod* instr);
2764 LInstruction* DoModByConstI(HMod* instr);
2765 LInstruction* DoModI(HMod* instr);
2766 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2767 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2768 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2771 // Methods for getting operands for Use / Define / Temp.
2772 LUnallocated* ToUnallocated(Register reg);
2773 LUnallocated* ToUnallocated(X87Register reg);
2775 // Methods for setting up define-use relationships.
2776 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2777 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2779 // A value that is guaranteed to be allocated to a register.
2780 // Operand created by UseRegister is guaranteed to be live until the end of
2781 // instruction. This means that register allocator will not reuse it's
2782 // register for any other operand inside instruction.
2783 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2784 // instruction start. Register allocator is free to assign the same register
2785 // to some other operand used inside instruction (i.e. temporary or
2787 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2788 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2790 // An input operand in a register that may be trashed.
2791 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2793 // An input operand in a register or stack slot.
2794 MUST_USE_RESULT LOperand* Use(HValue* value);
2795 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2797 // An input operand in a register, stack slot or a constant operand.
2798 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2799 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2801 // An input operand in a fixed register or a constant operand.
2802 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2803 Register fixed_register);
2805 // An input operand in a register or a constant operand.
2806 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2807 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2809 // An input operand in a constant operand.
2810 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2812 // An input operand in register, stack slot or a constant operand.
2813 // Will not be moved to a register even if one is freely available.
2814 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2816 // Temporary operand that must be in a register.
2817 MUST_USE_RESULT LUnallocated* TempRegister();
2818 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2820 // Methods for setting up define-use relationships.
2821 // Return the same instruction that they are passed.
2822 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2823 LUnallocated* result);
2824 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2825 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2827 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2828 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2830 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2832 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2833 // Assigns an environment to an instruction. An instruction which can
2834 // deoptimize must have an environment.
2835 LInstruction* AssignEnvironment(LInstruction* instr);
2836 // Assigns a pointer map to an instruction. An instruction which can
2837 // trigger a GC or a lazy deoptimization must have a pointer map.
2838 LInstruction* AssignPointerMap(LInstruction* instr);
2840 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2842 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2844 // Marks a call for the register allocator. Assigns a pointer map to
2845 // support GC and lazy deoptimization. Assigns an environment to support
2846 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2847 LInstruction* MarkAsCall(
2848 LInstruction* instr,
2849 HInstruction* hinstr,
2850 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2852 void VisitInstruction(HInstruction* current);
2853 void AddInstruction(LInstruction* instr, HInstruction* current);
2855 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2856 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2857 LInstruction* DoArithmeticD(Token::Value op,
2858 HArithmeticBinaryOperation* instr);
2859 LInstruction* DoArithmeticT(Token::Value op,
2860 HBinaryOperation* instr);
2862 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2864 HInstruction* current_instruction_;
2865 HBasicBlock* current_block_;
2866 HBasicBlock* next_block_;
2867 LAllocator* allocator_;
2869 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2872 #undef DECLARE_HYDROGEN_ACCESSOR
2873 #undef DECLARE_CONCRETE_INSTRUCTION
2875 } } // namespace v8::internal
2877 #endif // V8_X87_LITHIUM_X87_H_