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) \
108 V(LoadGlobalGeneric) \
110 V(LoadKeyedGeneric) \
112 V(LoadNamedGeneric) \
139 V(SeqStringGetChar) \
140 V(SeqStringSetChar) \
146 V(StoreContextSlot) \
147 V(StoreFrameContext) \
150 V(StoreKeyedGeneric) \
152 V(StoreNamedGeneric) \
154 V(StringCharCodeAt) \
155 V(StringCharFromCode) \
156 V(StringCompareAndBranch) \
159 V(TailCallThroughMegamorphicCache) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
165 V(TypeofIsAndBranch) \
171 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
172 Opcode opcode() const FINAL { return LInstruction::k##type; } \
173 void CompileToNative(LCodeGen* generator) FINAL; \
174 const char* Mnemonic() const FINAL { return mnemonic; } \
175 static L##type* cast(LInstruction* instr) { \
176 DCHECK(instr->Is##type()); \
177 return reinterpret_cast<L##type*>(instr); \
181 #define DECLARE_HYDROGEN_ACCESSOR(type) \
182 H##type* hydrogen() const { \
183 return H##type::cast(hydrogen_value()); \
187 class LInstruction : public ZoneObject {
190 : environment_(NULL),
191 hydrogen_value_(NULL),
192 bit_field_(IsCallBits::encode(false)) {
195 virtual ~LInstruction() {}
197 virtual void CompileToNative(LCodeGen* generator) = 0;
198 virtual const char* Mnemonic() const = 0;
199 virtual void PrintTo(StringStream* stream);
200 virtual void PrintDataTo(StringStream* stream);
201 virtual void PrintOutputOperandTo(StringStream* stream);
204 // Declare a unique enum value for each instruction.
205 #define DECLARE_OPCODE(type) k##type,
206 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
207 kNumberOfInstructions
208 #undef DECLARE_OPCODE
211 virtual Opcode opcode() const = 0;
213 // Declare non-virtual type testers for all leaf IR classes.
214 #define DECLARE_PREDICATE(type) \
215 bool Is##type() const { return opcode() == k##type; }
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
217 #undef DECLARE_PREDICATE
219 // Declare virtual predicates for instructions that don't have
221 virtual bool IsGap() const { return false; }
223 virtual bool IsControl() const { return false; }
225 // Try deleting this instruction if possible.
226 virtual bool TryDelete() { return false; }
228 void set_environment(LEnvironment* env) { environment_ = env; }
229 LEnvironment* environment() const { return environment_; }
230 bool HasEnvironment() const { return environment_ != NULL; }
232 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
233 LPointerMap* pointer_map() const { return pointer_map_.get(); }
234 bool HasPointerMap() const { return pointer_map_.is_set(); }
236 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
237 HValue* hydrogen_value() const { return hydrogen_value_; }
239 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
241 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
242 bool IsCall() const { return IsCallBits::decode(bit_field_); }
244 // Interface to the register allocator and iterators.
245 bool ClobbersTemps() const { return IsCall(); }
246 bool ClobbersRegisters() const { return IsCall(); }
247 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
249 // We only have rudimentary X87Stack tracking, thus in general
250 // cannot handle phi-nodes.
254 virtual bool HasResult() const = 0;
255 virtual LOperand* result() const = 0;
257 bool HasDoubleRegisterResult();
258 bool HasDoubleRegisterInput();
259 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
261 LOperand* FirstInput() { return InputAt(0); }
262 LOperand* Output() { return HasResult() ? result() : NULL; }
264 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
270 virtual int InputCount() = 0;
271 virtual LOperand* InputAt(int i) = 0;
275 friend class InputIterator;
277 friend class TempIterator;
278 virtual int TempCount() = 0;
279 virtual LOperand* TempAt(int i) = 0;
281 class IsCallBits: public BitField<bool, 0, 1> {};
283 LEnvironment* environment_;
284 SetOncePointer<LPointerMap> pointer_map_;
285 HValue* hydrogen_value_;
290 // R = number of result operands (0 or 1).
292 class LTemplateResultInstruction : public LInstruction {
294 // Allow 0 or 1 output operands.
295 STATIC_ASSERT(R == 0 || R == 1);
296 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
297 void set_result(LOperand* operand) { results_[0] = operand; }
298 LOperand* result() const OVERRIDE { return results_[0]; }
301 EmbeddedContainer<LOperand*, R> results_;
305 // R = number of result operands (0 or 1).
306 // I = number of input operands.
307 // T = number of temporary operands.
308 template<int R, int I, int T>
309 class LTemplateInstruction : public LTemplateResultInstruction<R> {
311 EmbeddedContainer<LOperand*, I> inputs_;
312 EmbeddedContainer<LOperand*, T> temps_;
316 int InputCount() FINAL { return I; }
317 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
319 int TempCount() FINAL { return T; }
320 LOperand* TempAt(int i) FINAL { return temps_[i]; }
324 class LGap : public LTemplateInstruction<0, 0, 0> {
326 explicit LGap(HBasicBlock* block) : block_(block) {
327 parallel_moves_[BEFORE] = NULL;
328 parallel_moves_[START] = NULL;
329 parallel_moves_[END] = NULL;
330 parallel_moves_[AFTER] = NULL;
333 // Can't use the DECLARE-macro here because of sub-classes.
334 bool IsGap() const FINAL { return true; }
335 void PrintDataTo(StringStream* stream) OVERRIDE;
336 static LGap* cast(LInstruction* instr) {
337 DCHECK(instr->IsGap());
338 return reinterpret_cast<LGap*>(instr);
341 bool IsRedundant() const;
343 HBasicBlock* block() const { return block_; }
350 FIRST_INNER_POSITION = BEFORE,
351 LAST_INNER_POSITION = AFTER
354 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
358 return parallel_moves_[pos];
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
371 class LInstructionGap FINAL : public LGap {
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
375 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
376 return !IsRedundant();
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
383 class LClobberDoubles FINAL : public LTemplateInstruction<0, 0, 0> {
385 explicit LClobberDoubles(Isolate* isolate) { }
387 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE { return true; }
389 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
393 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
395 explicit LGoto(HBasicBlock* block) : block_(block) { }
397 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
398 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
399 void PrintDataTo(StringStream* stream) OVERRIDE;
400 bool IsControl() const OVERRIDE { return true; }
402 int block_id() const { return block_->block_id(); }
403 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
407 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
408 HBasicBlock* block() const { return block_; }
415 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
417 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
421 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
424 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
428 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
430 explicit LDummyUse(LOperand* value) {
433 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
437 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
439 bool IsControl() const OVERRIDE { return true; }
440 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
441 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
445 class LLabel FINAL : public LGap {
447 explicit LLabel(HBasicBlock* block)
448 : LGap(block), replacement_(NULL) { }
450 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
451 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
453 void PrintDataTo(StringStream* stream) 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 FINAL : public LTemplateInstruction<1, 0, 0> {
471 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
472 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
476 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
478 explicit LCallStub(LOperand* context) {
479 inputs_[0] = context;
482 LOperand* context() { return inputs_[0]; }
484 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
485 DECLARE_HYDROGEN_ACCESSOR(CallStub)
489 class LTailCallThroughMegamorphicCache FINAL
490 : public LTemplateInstruction<0, 5, 0> {
492 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
493 LOperand* name, LOperand* slot,
495 inputs_[0] = context;
496 inputs_[1] = receiver;
502 LOperand* context() { return inputs_[0]; }
503 LOperand* receiver() { return inputs_[1]; }
504 LOperand* name() { return inputs_[2]; }
505 LOperand* slot() { return inputs_[3]; }
506 LOperand* vector() { return inputs_[4]; }
508 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
509 "tail-call-through-megamorphic-cache")
510 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
514 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
516 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
517 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
521 template<int I, int T>
522 class LControlInstruction: public LTemplateInstruction<0, I, T> {
524 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
526 bool IsControl() const FINAL { return true; }
528 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
529 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
531 int TrueDestination(LChunk* chunk) {
532 return chunk->LookupDestination(true_block_id());
534 int FalseDestination(LChunk* chunk) {
535 return chunk->LookupDestination(false_block_id());
538 Label* TrueLabel(LChunk* chunk) {
539 if (true_label_ == NULL) {
540 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
544 Label* FalseLabel(LChunk* chunk) {
545 if (false_label_ == NULL) {
546 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
552 int true_block_id() { return SuccessorAt(0)->block_id(); }
553 int false_block_id() { return SuccessorAt(1)->block_id(); }
556 HControlInstruction* hydrogen() {
557 return HControlInstruction::cast(this->hydrogen_value());
565 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
567 LWrapReceiver(LOperand* receiver,
570 inputs_[0] = receiver;
571 inputs_[1] = function;
575 LOperand* receiver() { return inputs_[0]; }
576 LOperand* function() { return inputs_[1]; }
577 LOperand* temp() { return temps_[0]; }
579 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
580 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
584 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
586 LApplyArguments(LOperand* function,
589 LOperand* elements) {
590 inputs_[0] = function;
591 inputs_[1] = receiver;
593 inputs_[3] = elements;
596 LOperand* function() { return inputs_[0]; }
597 LOperand* receiver() { return inputs_[1]; }
598 LOperand* length() { return inputs_[2]; }
599 LOperand* elements() { return inputs_[3]; }
601 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
605 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
607 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
608 inputs_[0] = arguments;
613 LOperand* arguments() { return inputs_[0]; }
614 LOperand* length() { return inputs_[1]; }
615 LOperand* index() { return inputs_[2]; }
617 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
619 void PrintDataTo(StringStream* stream) OVERRIDE;
623 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
625 explicit LArgumentsLength(LOperand* elements) {
626 inputs_[0] = elements;
629 LOperand* elements() { return inputs_[0]; }
631 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
635 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
637 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
638 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
642 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
644 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
648 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
650 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
651 inputs_[0] = dividend;
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
658 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
659 DECLARE_HYDROGEN_ACCESSOR(Mod)
666 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
668 LModByConstI(LOperand* dividend,
672 inputs_[0] = dividend;
678 LOperand* dividend() { return inputs_[0]; }
679 int32_t divisor() const { return divisor_; }
680 LOperand* temp1() { return temps_[0]; }
681 LOperand* temp2() { return temps_[1]; }
683 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
684 DECLARE_HYDROGEN_ACCESSOR(Mod)
691 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
693 LModI(LOperand* left, LOperand* right, LOperand* temp) {
699 LOperand* left() { return inputs_[0]; }
700 LOperand* right() { return inputs_[1]; }
701 LOperand* temp() { return temps_[0]; }
703 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
704 DECLARE_HYDROGEN_ACCESSOR(Mod)
708 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
710 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
711 inputs_[0] = dividend;
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
718 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
719 DECLARE_HYDROGEN_ACCESSOR(Div)
726 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
728 LDivByConstI(LOperand* dividend,
732 inputs_[0] = dividend;
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
740 LOperand* temp1() { return temps_[0]; }
741 LOperand* temp2() { return temps_[1]; }
743 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
744 DECLARE_HYDROGEN_ACCESSOR(Div)
751 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
753 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
754 inputs_[0] = dividend;
755 inputs_[1] = divisor;
759 LOperand* dividend() { return inputs_[0]; }
760 LOperand* divisor() { return inputs_[1]; }
761 LOperand* temp() { return temps_[0]; }
763 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
764 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
768 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
770 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
771 inputs_[0] = dividend;
775 LOperand* dividend() { return inputs_[0]; }
776 int32_t divisor() const { return divisor_; }
778 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
779 "flooring-div-by-power-of-2-i")
780 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
787 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
789 LFlooringDivByConstI(LOperand* dividend,
794 inputs_[0] = dividend;
801 LOperand* dividend() { return inputs_[0]; }
802 int32_t divisor() const { return divisor_; }
803 LOperand* temp1() { return temps_[0]; }
804 LOperand* temp2() { return temps_[1]; }
805 LOperand* temp3() { return temps_[2]; }
807 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
808 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
815 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
817 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
818 inputs_[0] = dividend;
819 inputs_[1] = divisor;
823 LOperand* dividend() { return inputs_[0]; }
824 LOperand* divisor() { return inputs_[1]; }
825 LOperand* temp() { return temps_[0]; }
827 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
828 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
832 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
834 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
840 LOperand* left() { return inputs_[0]; }
841 LOperand* right() { return inputs_[1]; }
842 LOperand* temp() { return temps_[0]; }
844 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
845 DECLARE_HYDROGEN_ACCESSOR(Mul)
849 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
851 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
856 LOperand* left() { return inputs_[0]; }
857 LOperand* right() { return inputs_[1]; }
859 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
860 "compare-numeric-and-branch")
861 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
863 Token::Value op() const { return hydrogen()->token(); }
864 bool is_double() const {
865 return hydrogen()->representation().IsDouble();
868 void PrintDataTo(StringStream* stream) OVERRIDE;
872 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
874 explicit LMathFloor(LOperand* value) {
878 LOperand* value() { return inputs_[0]; }
880 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
885 class LMathRound FINAL : public LTemplateInstruction<1, 1, 0> {
887 explicit LMathRound(LOperand* value) {
891 LOperand* value() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
894 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
898 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
900 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
902 LOperand* value() { return inputs_[0]; }
904 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
908 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
910 LMathAbs(LOperand* context, LOperand* value) {
911 inputs_[1] = context;
915 LOperand* context() { return inputs_[1]; }
916 LOperand* value() { return inputs_[0]; }
918 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
919 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
923 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
925 explicit LMathLog(LOperand* value) {
929 LOperand* value() { return inputs_[0]; }
931 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
935 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
937 explicit LMathClz32(LOperand* value) {
941 LOperand* value() { return inputs_[0]; }
943 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
947 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
949 LMathExp(LOperand* value,
955 ExternalReference::InitializeMathExpData();
958 LOperand* value() { return inputs_[0]; }
959 LOperand* temp1() { return temps_[0]; }
960 LOperand* temp2() { return temps_[1]; }
962 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
966 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 2> {
968 explicit LMathSqrt(LOperand* value,
976 LOperand* value() { return inputs_[0]; }
977 LOperand* temp1() { return temps_[0]; }
978 LOperand* temp2() { return temps_[1]; }
980 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
984 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
986 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
988 LOperand* value() { return inputs_[0]; }
990 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
994 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
996 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1001 LOperand* left() { return inputs_[0]; }
1002 LOperand* right() { return inputs_[1]; }
1004 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1008 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1010 explicit LCmpHoleAndBranch(LOperand* object) {
1011 inputs_[0] = object;
1014 LOperand* object() { return inputs_[0]; }
1016 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1021 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1023 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1025 LOperand* value() { return inputs_[0]; }
1027 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1028 "cmp-minus-zero-and-branch")
1029 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1033 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1035 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1040 LOperand* value() { return inputs_[0]; }
1041 LOperand* temp() { return temps_[0]; }
1043 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1045 void PrintDataTo(StringStream* stream) OVERRIDE;
1049 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1051 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1056 LOperand* value() { return inputs_[0]; }
1057 LOperand* temp() { return temps_[0]; }
1059 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1060 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1062 void PrintDataTo(StringStream* stream) OVERRIDE;
1066 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1068 explicit LIsSmiAndBranch(LOperand* value) {
1072 LOperand* value() { return inputs_[0]; }
1074 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1077 void PrintDataTo(StringStream* stream) OVERRIDE;
1081 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1083 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1088 LOperand* value() { return inputs_[0]; }
1089 LOperand* temp() { return temps_[0]; }
1091 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1092 "is-undetectable-and-branch")
1093 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1095 void PrintDataTo(StringStream* stream) OVERRIDE;
1099 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1101 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1102 inputs_[0] = context;
1107 LOperand* context() { return inputs_[1]; }
1108 LOperand* left() { return inputs_[1]; }
1109 LOperand* right() { return inputs_[2]; }
1111 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1112 "string-compare-and-branch")
1113 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1115 void PrintDataTo(StringStream* stream) OVERRIDE;
1117 Token::Value op() const { return hydrogen()->token(); }
1121 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1123 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1131 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1132 "has-instance-type-and-branch")
1133 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1135 void PrintDataTo(StringStream* stream) OVERRIDE;
1139 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1141 explicit LGetCachedArrayIndex(LOperand* value) {
1145 LOperand* value() { return inputs_[0]; }
1147 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1148 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1152 class LHasCachedArrayIndexAndBranch FINAL
1153 : public LControlInstruction<1, 0> {
1155 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1159 LOperand* value() { return inputs_[0]; }
1161 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1162 "has-cached-array-index-and-branch")
1164 void PrintDataTo(StringStream* stream) OVERRIDE;
1168 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1170 explicit LIsConstructCallAndBranch(LOperand* temp) {
1174 LOperand* temp() { return temps_[0]; }
1176 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1177 "is-construct-call-and-branch")
1181 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1183 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1189 LOperand* value() { return inputs_[0]; }
1190 LOperand* temp() { return temps_[0]; }
1191 LOperand* temp2() { return temps_[1]; }
1193 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1194 "class-of-test-and-branch")
1195 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1197 void PrintDataTo(StringStream* stream) OVERRIDE;
1201 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1203 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1204 inputs_[0] = context;
1209 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1210 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1212 LOperand* context() { return inputs_[0]; }
1213 Token::Value op() const { return hydrogen()->token(); }
1217 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1219 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1220 inputs_[0] = context;
1225 LOperand* context() { return inputs_[0]; }
1227 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1231 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1233 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1234 inputs_[0] = context;
1239 LOperand* context() { return inputs_[0]; }
1240 LOperand* value() { return inputs_[1]; }
1241 LOperand* temp() { return temps_[0]; }
1243 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1244 "instance-of-known-global")
1245 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1247 Handle<JSFunction> function() const { return hydrogen()->function(); }
1248 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1249 return lazy_deopt_env_;
1251 virtual void SetDeferredLazyDeoptimizationEnvironment(
1252 LEnvironment* env) OVERRIDE {
1253 lazy_deopt_env_ = env;
1257 LEnvironment* lazy_deopt_env_;
1261 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1263 LBoundsCheck(LOperand* index, LOperand* length) {
1265 inputs_[1] = length;
1268 LOperand* index() { return inputs_[0]; }
1269 LOperand* length() { return inputs_[1]; }
1271 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1272 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1276 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1278 LBitI(LOperand* left, LOperand* right) {
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1286 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1289 Token::Value op() const { return hydrogen()->op(); }
1293 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1295 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1296 : op_(op), can_deopt_(can_deopt) {
1301 LOperand* left() { return inputs_[0]; }
1302 LOperand* right() { return inputs_[1]; }
1304 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1306 Token::Value op() const { return op_; }
1307 bool can_deopt() const { return can_deopt_; }
1315 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1317 LSubI(LOperand* left, LOperand* right) {
1322 LOperand* left() { return inputs_[0]; }
1323 LOperand* right() { return inputs_[1]; }
1325 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1326 DECLARE_HYDROGEN_ACCESSOR(Sub)
1330 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1332 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1333 DECLARE_HYDROGEN_ACCESSOR(Constant)
1335 int32_t value() const { return hydrogen()->Integer32Value(); }
1339 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1344 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1348 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1350 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1351 DECLARE_HYDROGEN_ACCESSOR(Constant)
1353 double value() const { return hydrogen()->DoubleValue(); }
1357 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1359 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1360 DECLARE_HYDROGEN_ACCESSOR(Constant)
1362 ExternalReference value() const {
1363 return hydrogen()->ExternalReferenceValue();
1368 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1370 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1371 DECLARE_HYDROGEN_ACCESSOR(Constant)
1373 Handle<Object> value(Isolate* isolate) const {
1374 return hydrogen()->handle(isolate);
1379 class LBranch FINAL : public LControlInstruction<1, 1> {
1381 LBranch(LOperand* value, LOperand* temp) {
1386 LOperand* value() { return inputs_[0]; }
1387 LOperand* temp() { return temps_[0]; }
1389 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1390 DECLARE_HYDROGEN_ACCESSOR(Branch)
1392 void PrintDataTo(StringStream* stream) OVERRIDE;
1396 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1398 explicit LCmpMapAndBranch(LOperand* value) {
1402 LOperand* value() { return inputs_[0]; }
1404 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1405 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1407 Handle<Map> map() const { return hydrogen()->map().handle(); }
1411 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1413 explicit LMapEnumLength(LOperand* value) {
1417 LOperand* value() { return inputs_[0]; }
1419 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1423 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1425 LDateField(LOperand* date, LOperand* temp, Smi* index)
1431 LOperand* date() { return inputs_[0]; }
1432 LOperand* temp() { return temps_[0]; }
1434 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1435 DECLARE_HYDROGEN_ACCESSOR(DateField)
1437 Smi* index() const { return index_; }
1444 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1446 LSeqStringGetChar(LOperand* string, LOperand* index) {
1447 inputs_[0] = string;
1451 LOperand* string() const { return inputs_[0]; }
1452 LOperand* index() const { return inputs_[1]; }
1454 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1455 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1459 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1461 LSeqStringSetChar(LOperand* context,
1465 inputs_[0] = context;
1466 inputs_[1] = string;
1471 LOperand* string() { return inputs_[1]; }
1472 LOperand* index() { return inputs_[2]; }
1473 LOperand* value() { return inputs_[3]; }
1475 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1476 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1480 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1482 LAddI(LOperand* left, LOperand* right) {
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1490 static bool UseLea(HAdd* add) {
1491 return !add->CheckFlag(HValue::kCanOverflow) &&
1492 add->BetterLeftOperand()->UseCount() > 1;
1495 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1496 DECLARE_HYDROGEN_ACCESSOR(Add)
1500 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 1> {
1502 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1508 LOperand* left() { return inputs_[0]; }
1509 LOperand* right() { return inputs_[1]; }
1510 LOperand* temp() { return temps_[0]; }
1512 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1513 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1517 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1519 LPower(LOperand* left, LOperand* right) {
1524 LOperand* left() { return inputs_[0]; }
1525 LOperand* right() { return inputs_[1]; }
1527 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1528 DECLARE_HYDROGEN_ACCESSOR(Power)
1532 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1534 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1540 LOperand* left() { return inputs_[0]; }
1541 LOperand* right() { return inputs_[1]; }
1543 Token::Value op() const { return op_; }
1545 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1546 void CompileToNative(LCodeGen* generator) OVERRIDE;
1547 const char* Mnemonic() const OVERRIDE;
1554 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1556 LArithmeticT(Token::Value op,
1561 inputs_[0] = context;
1566 LOperand* context() { return inputs_[0]; }
1567 LOperand* left() { return inputs_[1]; }
1568 LOperand* right() { return inputs_[2]; }
1570 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1571 void CompileToNative(LCodeGen* generator) OVERRIDE;
1572 const char* Mnemonic() const OVERRIDE;
1574 Token::Value op() const { return op_; }
1581 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1583 explicit LReturn(LOperand* value,
1585 LOperand* parameter_count) {
1587 inputs_[1] = context;
1588 inputs_[2] = parameter_count;
1591 bool has_constant_parameter_count() {
1592 return parameter_count()->IsConstantOperand();
1594 LConstantOperand* constant_parameter_count() {
1595 DCHECK(has_constant_parameter_count());
1596 return LConstantOperand::cast(parameter_count());
1598 LOperand* parameter_count() { return inputs_[2]; }
1600 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1601 DECLARE_HYDROGEN_ACCESSOR(Return)
1605 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1607 explicit LLoadNamedField(LOperand* object) {
1608 inputs_[0] = object;
1611 LOperand* object() { return inputs_[0]; }
1613 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1614 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1618 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1620 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1621 inputs_[0] = context;
1622 inputs_[1] = object;
1626 LOperand* context() { return inputs_[0]; }
1627 LOperand* object() { return inputs_[1]; }
1628 LOperand* temp_vector() { return temps_[0]; }
1630 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1631 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1633 Handle<Object> name() const { return hydrogen()->name(); }
1637 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1639 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1640 inputs_[0] = function;
1644 LOperand* function() { return inputs_[0]; }
1645 LOperand* temp() { return temps_[0]; }
1647 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1648 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1652 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1654 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1657 Heap::RootListIndex index() const { return hydrogen()->index(); }
1661 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1663 LLoadKeyed(LOperand* elements, LOperand* key) {
1664 inputs_[0] = elements;
1667 LOperand* elements() { return inputs_[0]; }
1668 LOperand* key() { return inputs_[1]; }
1669 ElementsKind elements_kind() const {
1670 return hydrogen()->elements_kind();
1672 bool is_external() const {
1673 return hydrogen()->is_external();
1675 bool is_fixed_typed_array() const {
1676 return hydrogen()->is_fixed_typed_array();
1678 bool is_typed_elements() const {
1679 return is_external() || is_fixed_typed_array();
1682 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1683 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1685 void PrintDataTo(StringStream* stream) OVERRIDE;
1686 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1688 return hydrogen()->key()->representation().IsTagged();
1693 inline static bool ExternalArrayOpRequiresTemp(
1694 Representation key_representation,
1695 ElementsKind elements_kind) {
1696 // Operations that require the key to be divided by two to be converted into
1697 // an index cannot fold the scale operation into a load and need an extra
1698 // temp register to do the work.
1699 return key_representation.IsSmi() &&
1700 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1701 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1702 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1703 elements_kind == UINT8_ELEMENTS ||
1704 elements_kind == INT8_ELEMENTS ||
1705 elements_kind == UINT8_CLAMPED_ELEMENTS);
1709 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1711 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1713 inputs_[0] = context;
1719 LOperand* context() { return inputs_[0]; }
1720 LOperand* object() { return inputs_[1]; }
1721 LOperand* key() { return inputs_[2]; }
1722 LOperand* temp_vector() { return temps_[0]; }
1724 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1725 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1729 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1731 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1732 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1736 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1738 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1740 inputs_[0] = context;
1741 inputs_[1] = global_object;
1745 LOperand* context() { return inputs_[0]; }
1746 LOperand* global_object() { return inputs_[1]; }
1747 LOperand* temp_vector() { return temps_[0]; }
1749 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1750 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1752 Handle<Object> name() const { return hydrogen()->name(); }
1753 bool for_typeof() const { return hydrogen()->for_typeof(); }
1757 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1759 explicit LStoreGlobalCell(LOperand* value) {
1763 LOperand* value() { return inputs_[0]; }
1765 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1766 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1770 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1772 explicit LLoadContextSlot(LOperand* context) {
1773 inputs_[0] = context;
1776 LOperand* context() { return inputs_[0]; }
1778 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1779 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1781 int slot_index() { return hydrogen()->slot_index(); }
1783 void PrintDataTo(StringStream* stream) OVERRIDE;
1787 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1789 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1790 inputs_[0] = context;
1795 LOperand* context() { return inputs_[0]; }
1796 LOperand* value() { return inputs_[1]; }
1797 LOperand* temp() { return temps_[0]; }
1799 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1800 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1802 int slot_index() { return hydrogen()->slot_index(); }
1804 void PrintDataTo(StringStream* stream) OVERRIDE;
1808 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1810 explicit LPushArgument(LOperand* value) {
1814 LOperand* value() { return inputs_[0]; }
1816 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1820 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1822 explicit LDrop(int count) : count_(count) { }
1824 int count() const { return count_; }
1826 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1833 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1835 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1836 inputs_[0] = function;
1837 inputs_[1] = code_object;
1840 LOperand* function() { return inputs_[0]; }
1841 LOperand* code_object() { return inputs_[1]; }
1843 void PrintDataTo(StringStream* stream) OVERRIDE;
1845 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1846 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1850 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1852 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1853 inputs_[0] = base_object;
1854 inputs_[1] = offset;
1857 LOperand* base_object() const { return inputs_[0]; }
1858 LOperand* offset() const { return inputs_[1]; }
1860 void PrintDataTo(StringStream* stream) OVERRIDE;
1862 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1866 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1868 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1869 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1873 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1875 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1876 DECLARE_HYDROGEN_ACCESSOR(Context)
1880 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1882 explicit LDeclareGlobals(LOperand* context) {
1883 inputs_[0] = context;
1886 LOperand* context() { return inputs_[0]; }
1888 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1889 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1893 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1895 explicit LCallJSFunction(LOperand* function) {
1896 inputs_[0] = function;
1899 LOperand* function() { return inputs_[0]; }
1901 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1902 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1904 void PrintDataTo(StringStream* stream) OVERRIDE;
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1910 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1912 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1913 const ZoneList<LOperand*>& operands, Zone* zone)
1914 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1915 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1916 inputs_.AddAll(operands, zone);
1919 LOperand* target() const { return inputs_[0]; }
1921 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1924 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1926 void PrintDataTo(StringStream* stream) OVERRIDE;
1928 int arity() const { return hydrogen()->argument_count() - 1; }
1930 ZoneList<LOperand*> inputs_;
1932 // Iterator support.
1933 int InputCount() FINAL { return inputs_.length(); }
1934 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
1936 int TempCount() FINAL { return 0; }
1937 LOperand* TempAt(int i) FINAL { return NULL; }
1941 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1943 LInvokeFunction(LOperand* context, LOperand* function) {
1944 inputs_[0] = context;
1945 inputs_[1] = function;
1948 LOperand* context() { return inputs_[0]; }
1949 LOperand* function() { return inputs_[1]; }
1951 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1952 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1954 void PrintDataTo(StringStream* stream) OVERRIDE;
1956 int arity() const { return hydrogen()->argument_count() - 1; }
1960 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1962 explicit LCallFunction(LOperand* context, LOperand* function) {
1963 inputs_[0] = context;
1964 inputs_[1] = function;
1967 LOperand* context() { return inputs_[0]; }
1968 LOperand* function() { return inputs_[1]; }
1970 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1971 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1973 int arity() const { return hydrogen()->argument_count() - 1; }
1977 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1979 LCallNew(LOperand* context, LOperand* constructor) {
1980 inputs_[0] = context;
1981 inputs_[1] = constructor;
1984 LOperand* context() { return inputs_[0]; }
1985 LOperand* constructor() { return inputs_[1]; }
1987 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1988 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1990 void PrintDataTo(StringStream* stream) OVERRIDE;
1992 int arity() const { return hydrogen()->argument_count() - 1; }
1996 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1998 LCallNewArray(LOperand* context, LOperand* constructor) {
1999 inputs_[0] = context;
2000 inputs_[1] = constructor;
2003 LOperand* context() { return inputs_[0]; }
2004 LOperand* constructor() { return inputs_[1]; }
2006 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2007 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2009 void PrintDataTo(StringStream* stream) OVERRIDE;
2011 int arity() const { return hydrogen()->argument_count() - 1; }
2015 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2017 explicit LCallRuntime(LOperand* context) {
2018 inputs_[0] = context;
2021 LOperand* context() { return inputs_[0]; }
2023 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2024 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2026 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2027 return save_doubles() == kDontSaveFPRegs;
2030 const Runtime::Function* function() const { return hydrogen()->function(); }
2031 int arity() const { return hydrogen()->argument_count(); }
2032 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2036 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2038 explicit LInteger32ToDouble(LOperand* value) {
2042 LOperand* value() { return inputs_[0]; }
2044 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2048 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2050 explicit LUint32ToDouble(LOperand* value) {
2054 LOperand* value() { return inputs_[0]; }
2056 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2060 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2062 LNumberTagI(LOperand* value, LOperand* temp) {
2067 LOperand* value() { return inputs_[0]; }
2068 LOperand* temp() { return temps_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2074 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2076 LNumberTagU(LOperand* value, LOperand* temp) {
2081 LOperand* value() { return inputs_[0]; }
2082 LOperand* temp() { return temps_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2088 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2090 LNumberTagD(LOperand* value, LOperand* temp) {
2095 LOperand* value() { return inputs_[0]; }
2096 LOperand* temp() { return temps_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2099 DECLARE_HYDROGEN_ACCESSOR(Change)
2103 // Sometimes truncating conversion from a tagged value to an int32.
2104 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2106 explicit LDoubleToI(LOperand* value) {
2110 LOperand* value() { return inputs_[0]; }
2112 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2113 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2115 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2119 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2121 explicit LDoubleToSmi(LOperand* value) {
2125 LOperand* value() { return inputs_[0]; }
2127 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2128 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2132 // Truncating conversion from a tagged value to an int32.
2133 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2135 explicit LTaggedToI(LOperand* value) {
2139 LOperand* value() { return inputs_[0]; }
2141 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2142 DECLARE_HYDROGEN_ACCESSOR(Change)
2144 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2148 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2150 explicit LSmiTag(LOperand* value) {
2154 LOperand* value() { return inputs_[0]; }
2156 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2157 DECLARE_HYDROGEN_ACCESSOR(Change)
2161 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2163 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2168 LOperand* value() { return inputs_[0]; }
2169 LOperand* temp() { return temps_[0]; }
2171 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2172 DECLARE_HYDROGEN_ACCESSOR(Change);
2176 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2178 LSmiUntag(LOperand* value, bool needs_check)
2179 : needs_check_(needs_check) {
2183 LOperand* value() { return inputs_[0]; }
2185 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2187 bool needs_check() const { return needs_check_; }
2194 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2196 LStoreNamedField(LOperand* obj,
2199 LOperand* temp_map) {
2203 temps_[1] = temp_map;
2206 LOperand* object() { return inputs_[0]; }
2207 LOperand* value() { return inputs_[1]; }
2208 LOperand* temp() { return temps_[0]; }
2209 LOperand* temp_map() { return temps_[1]; }
2211 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2212 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2214 void PrintDataTo(StringStream* stream) OVERRIDE;
2218 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2220 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2221 inputs_[0] = context;
2222 inputs_[1] = object;
2226 LOperand* context() { return inputs_[0]; }
2227 LOperand* object() { return inputs_[1]; }
2228 LOperand* value() { return inputs_[2]; }
2230 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2231 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2233 void PrintDataTo(StringStream* stream) OVERRIDE;
2234 Handle<Object> name() const { return hydrogen()->name(); }
2235 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2239 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2241 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2247 bool is_external() const { return hydrogen()->is_external(); }
2248 bool is_fixed_typed_array() const {
2249 return hydrogen()->is_fixed_typed_array();
2251 bool is_typed_elements() const {
2252 return is_external() || is_fixed_typed_array();
2254 LOperand* elements() { return inputs_[0]; }
2255 LOperand* key() { return inputs_[1]; }
2256 LOperand* value() { return inputs_[2]; }
2257 ElementsKind elements_kind() const {
2258 return hydrogen()->elements_kind();
2261 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2262 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2264 void PrintDataTo(StringStream* stream) OVERRIDE;
2265 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2266 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2270 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2272 LStoreKeyedGeneric(LOperand* context,
2276 inputs_[0] = context;
2277 inputs_[1] = object;
2282 LOperand* context() { return inputs_[0]; }
2283 LOperand* object() { return inputs_[1]; }
2284 LOperand* key() { return inputs_[2]; }
2285 LOperand* value() { return inputs_[3]; }
2287 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2288 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2290 void PrintDataTo(StringStream* stream) OVERRIDE;
2292 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2296 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2298 LTransitionElementsKind(LOperand* object,
2300 LOperand* new_map_temp,
2302 inputs_[0] = object;
2303 inputs_[1] = context;
2304 temps_[0] = new_map_temp;
2308 LOperand* context() { return inputs_[1]; }
2309 LOperand* object() { return inputs_[0]; }
2310 LOperand* new_map_temp() { return temps_[0]; }
2311 LOperand* temp() { return temps_[1]; }
2313 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2314 "transition-elements-kind")
2315 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2317 void PrintDataTo(StringStream* stream) OVERRIDE;
2319 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2320 Handle<Map> transitioned_map() {
2321 return hydrogen()->transitioned_map().handle();
2323 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2324 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2328 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2330 LTrapAllocationMemento(LOperand* object,
2332 inputs_[0] = object;
2336 LOperand* object() { return inputs_[0]; }
2337 LOperand* temp() { return temps_[0]; }
2339 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2340 "trap-allocation-memento")
2344 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2346 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2347 inputs_[0] = context;
2352 LOperand* context() { return inputs_[0]; }
2353 LOperand* left() { return inputs_[1]; }
2354 LOperand* right() { return inputs_[2]; }
2356 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2357 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2361 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2363 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2364 inputs_[0] = context;
2365 inputs_[1] = string;
2369 LOperand* context() { return inputs_[0]; }
2370 LOperand* string() { return inputs_[1]; }
2371 LOperand* index() { return inputs_[2]; }
2373 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2374 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2378 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2380 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2381 inputs_[0] = context;
2382 inputs_[1] = char_code;
2385 LOperand* context() { return inputs_[0]; }
2386 LOperand* char_code() { return inputs_[1]; }
2388 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2389 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2393 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2395 explicit LCheckValue(LOperand* value) {
2399 LOperand* value() { return inputs_[0]; }
2401 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2402 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2406 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2408 LCheckInstanceType(LOperand* value, LOperand* temp) {
2413 LOperand* value() { return inputs_[0]; }
2414 LOperand* temp() { return temps_[0]; }
2416 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2417 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2421 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2423 explicit LCheckMaps(LOperand* value = NULL) {
2427 LOperand* value() { return inputs_[0]; }
2429 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2430 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2434 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2436 explicit LCheckSmi(LOperand* value) {
2440 LOperand* value() { return inputs_[0]; }
2442 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2446 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2448 explicit LClampDToUint8(LOperand* value) {
2452 LOperand* unclamped() { return inputs_[0]; }
2454 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2458 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2460 explicit LClampIToUint8(LOperand* value) {
2464 LOperand* unclamped() { return inputs_[0]; }
2466 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2470 // Truncating conversion from a tagged value to an int32.
2471 class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2473 LClampTToUint8NoSSE2(LOperand* unclamped,
2477 inputs_[0] = unclamped;
2483 LOperand* unclamped() { return inputs_[0]; }
2484 LOperand* scratch() { return temps_[0]; }
2485 LOperand* scratch2() { return temps_[1]; }
2486 LOperand* scratch3() { return temps_[2]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2489 "clamp-t-to-uint8-nosse2")
2490 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2494 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2496 explicit LCheckNonSmi(LOperand* value) {
2500 LOperand* value() { return inputs_[0]; }
2502 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2503 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2507 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2509 explicit LDoubleBits(LOperand* value) {
2513 LOperand* value() { return inputs_[0]; }
2515 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2516 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2520 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2522 LConstructDouble(LOperand* hi, LOperand* lo) {
2527 LOperand* hi() { return inputs_[0]; }
2528 LOperand* lo() { return inputs_[1]; }
2530 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2534 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2536 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2537 inputs_[0] = context;
2542 LOperand* context() { return inputs_[0]; }
2543 LOperand* size() { return inputs_[1]; }
2544 LOperand* temp() { return temps_[0]; }
2546 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2547 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2551 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2553 explicit LRegExpLiteral(LOperand* context) {
2554 inputs_[0] = context;
2557 LOperand* context() { return inputs_[0]; }
2559 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2560 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2564 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2566 explicit LFunctionLiteral(LOperand* context) {
2567 inputs_[0] = context;
2570 LOperand* context() { return inputs_[0]; }
2572 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2573 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2577 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2579 explicit LToFastProperties(LOperand* value) {
2583 LOperand* value() { return inputs_[0]; }
2585 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2586 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2590 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2592 LTypeof(LOperand* context, LOperand* value) {
2593 inputs_[0] = context;
2597 LOperand* context() { return inputs_[0]; }
2598 LOperand* value() { return inputs_[1]; }
2600 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2604 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2606 explicit LTypeofIsAndBranch(LOperand* value) {
2610 LOperand* value() { return inputs_[0]; }
2612 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2613 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2615 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2617 void PrintDataTo(StringStream* stream) OVERRIDE;
2621 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2623 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2624 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2628 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2630 explicit LStackCheck(LOperand* context) {
2631 inputs_[0] = context;
2634 LOperand* context() { return inputs_[0]; }
2636 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2637 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2639 Label* done_label() { return &done_label_; }
2646 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2648 LForInPrepareMap(LOperand* context, LOperand* object) {
2649 inputs_[0] = context;
2650 inputs_[1] = object;
2653 LOperand* context() { return inputs_[0]; }
2654 LOperand* object() { return inputs_[1]; }
2656 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2660 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2662 explicit LForInCacheArray(LOperand* map) {
2666 LOperand* map() { return inputs_[0]; }
2668 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2671 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2676 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2678 LCheckMapValue(LOperand* value, LOperand* map) {
2683 LOperand* value() { return inputs_[0]; }
2684 LOperand* map() { return inputs_[1]; }
2686 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2690 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2692 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2693 inputs_[0] = object;
2697 LOperand* object() { return inputs_[0]; }
2698 LOperand* index() { return inputs_[1]; }
2700 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2704 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2706 explicit LStoreFrameContext(LOperand* context) {
2707 inputs_[0] = context;
2710 LOperand* context() { return inputs_[0]; }
2712 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2716 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2718 LAllocateBlockContext(LOperand* context, LOperand* function) {
2719 inputs_[0] = context;
2720 inputs_[1] = function;
2723 LOperand* context() { return inputs_[0]; }
2724 LOperand* function() { return inputs_[1]; }
2726 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2728 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2729 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2733 class LChunkBuilder;
2734 class LPlatformChunk FINAL : public LChunk {
2736 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2737 : LChunk(info, graph),
2738 num_double_slots_(0) { }
2740 int GetNextSpillIndex(RegisterKind kind);
2741 LOperand* GetNextSpillSlot(RegisterKind kind);
2743 int num_double_slots() const { return num_double_slots_; }
2746 int num_double_slots_;
2750 class LChunkBuilder FINAL : public LChunkBuilderBase {
2752 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2753 : LChunkBuilderBase(info, graph),
2754 current_instruction_(NULL),
2755 current_block_(NULL),
2757 allocator_(allocator) {}
2759 // Build the sequence for the graph.
2760 LPlatformChunk* Build();
2762 // Declare methods that deal with the individual node types.
2763 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2764 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2767 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2768 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2769 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2770 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2771 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2772 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2773 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2774 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2775 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2776 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2777 LInstruction* DoDivByConstI(HDiv* instr);
2778 LInstruction* DoDivI(HDiv* instr);
2779 LInstruction* DoModByPowerOf2I(HMod* instr);
2780 LInstruction* DoModByConstI(HMod* instr);
2781 LInstruction* DoModI(HMod* instr);
2782 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2783 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2784 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2787 // Methods for getting operands for Use / Define / Temp.
2788 LUnallocated* ToUnallocated(Register reg);
2789 LUnallocated* ToUnallocated(X87Register reg);
2791 // Methods for setting up define-use relationships.
2792 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2793 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2795 // A value that is guaranteed to be allocated to a register.
2796 // Operand created by UseRegister is guaranteed to be live until the end of
2797 // instruction. This means that register allocator will not reuse it's
2798 // register for any other operand inside instruction.
2799 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2800 // instruction start. Register allocator is free to assign the same register
2801 // to some other operand used inside instruction (i.e. temporary or
2803 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2804 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2806 // An input operand in a register that may be trashed.
2807 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2809 // An input operand in a register or stack slot.
2810 MUST_USE_RESULT LOperand* Use(HValue* value);
2811 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2813 // An input operand in a register, stack slot or a constant operand.
2814 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2815 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2817 // An input operand in a fixed register or a constant operand.
2818 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2819 Register fixed_register);
2821 // An input operand in a register or a constant operand.
2822 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2823 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2825 // An input operand in a constant operand.
2826 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2828 // An input operand in register, stack slot or a constant operand.
2829 // Will not be moved to a register even if one is freely available.
2830 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2832 // Temporary operand that must be in a register.
2833 MUST_USE_RESULT LUnallocated* TempRegister();
2834 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2836 // Methods for setting up define-use relationships.
2837 // Return the same instruction that they are passed.
2838 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2839 LUnallocated* result);
2840 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2841 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2843 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2844 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2846 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2848 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2849 // Assigns an environment to an instruction. An instruction which can
2850 // deoptimize must have an environment.
2851 LInstruction* AssignEnvironment(LInstruction* instr);
2852 // Assigns a pointer map to an instruction. An instruction which can
2853 // trigger a GC or a lazy deoptimization must have a pointer map.
2854 LInstruction* AssignPointerMap(LInstruction* instr);
2856 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2858 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2860 // Marks a call for the register allocator. Assigns a pointer map to
2861 // support GC and lazy deoptimization. Assigns an environment to support
2862 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2863 LInstruction* MarkAsCall(
2864 LInstruction* instr,
2865 HInstruction* hinstr,
2866 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2868 void VisitInstruction(HInstruction* current);
2869 void AddInstruction(LInstruction* instr, HInstruction* current);
2871 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2872 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2873 LInstruction* DoArithmeticD(Token::Value op,
2874 HArithmeticBinaryOperation* instr);
2875 LInstruction* DoArithmeticT(Token::Value op,
2876 HBinaryOperation* instr);
2878 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2880 HInstruction* current_instruction_;
2881 HBasicBlock* current_block_;
2882 HBasicBlock* next_block_;
2883 LAllocator* allocator_;
2885 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2888 #undef DECLARE_HYDROGEN_ACCESSOR
2889 #undef DECLARE_CONCRETE_INSTRUCTION
2891 } } // namespace v8::internal
2893 #endif // V8_X87_LITHIUM_X87_H_