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 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
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, 2> {
1962 LCallFunction(LOperand* context, LOperand* function, LOperand* slot,
1964 inputs_[0] = context;
1965 inputs_[1] = function;
1970 LOperand* context() { return inputs_[0]; }
1971 LOperand* function() { return inputs_[1]; }
1972 LOperand* temp_slot() { return temps_[0]; }
1973 LOperand* temp_vector() { return temps_[1]; }
1975 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1976 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1978 void PrintDataTo(StringStream* stream) OVERRIDE;
1979 int arity() const { return hydrogen()->argument_count() - 1; }
1983 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1985 LCallNew(LOperand* context, LOperand* constructor) {
1986 inputs_[0] = context;
1987 inputs_[1] = constructor;
1990 LOperand* context() { return inputs_[0]; }
1991 LOperand* constructor() { return inputs_[1]; }
1993 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1994 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1996 void PrintDataTo(StringStream* stream) OVERRIDE;
1998 int arity() const { return hydrogen()->argument_count() - 1; }
2002 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2004 LCallNewArray(LOperand* context, LOperand* constructor) {
2005 inputs_[0] = context;
2006 inputs_[1] = constructor;
2009 LOperand* context() { return inputs_[0]; }
2010 LOperand* constructor() { return inputs_[1]; }
2012 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2013 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2015 void PrintDataTo(StringStream* stream) OVERRIDE;
2017 int arity() const { return hydrogen()->argument_count() - 1; }
2021 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2023 explicit LCallRuntime(LOperand* context) {
2024 inputs_[0] = context;
2027 LOperand* context() { return inputs_[0]; }
2029 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2030 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2032 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2033 return save_doubles() == kDontSaveFPRegs;
2036 const Runtime::Function* function() const { return hydrogen()->function(); }
2037 int arity() const { return hydrogen()->argument_count(); }
2038 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2042 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2044 explicit LInteger32ToDouble(LOperand* value) {
2048 LOperand* value() { return inputs_[0]; }
2050 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2054 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2056 explicit LUint32ToDouble(LOperand* value) {
2060 LOperand* value() { return inputs_[0]; }
2062 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2066 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2068 LNumberTagI(LOperand* value, LOperand* temp) {
2073 LOperand* value() { return inputs_[0]; }
2074 LOperand* temp() { return temps_[0]; }
2076 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2080 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2082 LNumberTagU(LOperand* value, LOperand* temp) {
2087 LOperand* value() { return inputs_[0]; }
2088 LOperand* temp() { return temps_[0]; }
2090 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2094 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2096 LNumberTagD(LOperand* value, LOperand* temp) {
2101 LOperand* value() { return inputs_[0]; }
2102 LOperand* temp() { return temps_[0]; }
2104 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2105 DECLARE_HYDROGEN_ACCESSOR(Change)
2109 // Sometimes truncating conversion from a tagged value to an int32.
2110 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2112 explicit LDoubleToI(LOperand* value) {
2116 LOperand* value() { return inputs_[0]; }
2118 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2119 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2121 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2125 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2127 explicit LDoubleToSmi(LOperand* value) {
2131 LOperand* value() { return inputs_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2134 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2138 // Truncating conversion from a tagged value to an int32.
2139 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2141 explicit LTaggedToI(LOperand* value) {
2145 LOperand* value() { return inputs_[0]; }
2147 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2148 DECLARE_HYDROGEN_ACCESSOR(Change)
2150 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2154 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2156 explicit LSmiTag(LOperand* value) {
2160 LOperand* value() { return inputs_[0]; }
2162 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2163 DECLARE_HYDROGEN_ACCESSOR(Change)
2167 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2169 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2174 LOperand* value() { return inputs_[0]; }
2175 LOperand* temp() { return temps_[0]; }
2177 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2178 DECLARE_HYDROGEN_ACCESSOR(Change);
2182 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2184 LSmiUntag(LOperand* value, bool needs_check)
2185 : needs_check_(needs_check) {
2189 LOperand* value() { return inputs_[0]; }
2191 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2193 bool needs_check() const { return needs_check_; }
2200 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2202 LStoreNamedField(LOperand* obj,
2205 LOperand* temp_map) {
2209 temps_[1] = temp_map;
2212 LOperand* object() { return inputs_[0]; }
2213 LOperand* value() { return inputs_[1]; }
2214 LOperand* temp() { return temps_[0]; }
2215 LOperand* temp_map() { return temps_[1]; }
2217 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2218 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2220 void PrintDataTo(StringStream* stream) OVERRIDE;
2224 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2226 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2227 inputs_[0] = context;
2228 inputs_[1] = object;
2232 LOperand* context() { return inputs_[0]; }
2233 LOperand* object() { return inputs_[1]; }
2234 LOperand* value() { return inputs_[2]; }
2236 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2237 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2239 void PrintDataTo(StringStream* stream) OVERRIDE;
2240 Handle<Object> name() const { return hydrogen()->name(); }
2241 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2245 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2247 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2253 bool is_external() const { return hydrogen()->is_external(); }
2254 bool is_fixed_typed_array() const {
2255 return hydrogen()->is_fixed_typed_array();
2257 bool is_typed_elements() const {
2258 return is_external() || is_fixed_typed_array();
2260 LOperand* elements() { return inputs_[0]; }
2261 LOperand* key() { return inputs_[1]; }
2262 LOperand* value() { return inputs_[2]; }
2263 ElementsKind elements_kind() const {
2264 return hydrogen()->elements_kind();
2267 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2268 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2270 void PrintDataTo(StringStream* stream) OVERRIDE;
2271 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2272 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2276 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2278 LStoreKeyedGeneric(LOperand* context,
2282 inputs_[0] = context;
2283 inputs_[1] = object;
2288 LOperand* context() { return inputs_[0]; }
2289 LOperand* object() { return inputs_[1]; }
2290 LOperand* key() { return inputs_[2]; }
2291 LOperand* value() { return inputs_[3]; }
2293 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2294 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2296 void PrintDataTo(StringStream* stream) OVERRIDE;
2298 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2302 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2304 LTransitionElementsKind(LOperand* object,
2306 LOperand* new_map_temp,
2308 inputs_[0] = object;
2309 inputs_[1] = context;
2310 temps_[0] = new_map_temp;
2314 LOperand* context() { return inputs_[1]; }
2315 LOperand* object() { return inputs_[0]; }
2316 LOperand* new_map_temp() { return temps_[0]; }
2317 LOperand* temp() { return temps_[1]; }
2319 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2320 "transition-elements-kind")
2321 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2323 void PrintDataTo(StringStream* stream) OVERRIDE;
2325 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2326 Handle<Map> transitioned_map() {
2327 return hydrogen()->transitioned_map().handle();
2329 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2330 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2334 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2336 LTrapAllocationMemento(LOperand* object,
2338 inputs_[0] = object;
2342 LOperand* object() { return inputs_[0]; }
2343 LOperand* temp() { return temps_[0]; }
2345 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2346 "trap-allocation-memento")
2350 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2352 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2353 inputs_[0] = context;
2358 LOperand* context() { return inputs_[0]; }
2359 LOperand* left() { return inputs_[1]; }
2360 LOperand* right() { return inputs_[2]; }
2362 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2363 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2367 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2369 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2370 inputs_[0] = context;
2371 inputs_[1] = string;
2375 LOperand* context() { return inputs_[0]; }
2376 LOperand* string() { return inputs_[1]; }
2377 LOperand* index() { return inputs_[2]; }
2379 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2380 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2384 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2386 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2387 inputs_[0] = context;
2388 inputs_[1] = char_code;
2391 LOperand* context() { return inputs_[0]; }
2392 LOperand* char_code() { return inputs_[1]; }
2394 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2395 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2399 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2401 explicit LCheckValue(LOperand* value) {
2405 LOperand* value() { return inputs_[0]; }
2407 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2408 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2412 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2414 LCheckInstanceType(LOperand* value, LOperand* temp) {
2419 LOperand* value() { return inputs_[0]; }
2420 LOperand* temp() { return temps_[0]; }
2422 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2423 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2427 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2429 explicit LCheckMaps(LOperand* value = NULL) {
2433 LOperand* value() { return inputs_[0]; }
2435 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2436 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2440 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2442 explicit LCheckSmi(LOperand* value) {
2446 LOperand* value() { return inputs_[0]; }
2448 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2452 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2454 explicit LClampDToUint8(LOperand* value) {
2458 LOperand* unclamped() { return inputs_[0]; }
2460 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2464 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2466 explicit LClampIToUint8(LOperand* value) {
2470 LOperand* unclamped() { return inputs_[0]; }
2472 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2476 // Truncating conversion from a tagged value to an int32.
2477 class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2479 LClampTToUint8NoSSE2(LOperand* unclamped,
2483 inputs_[0] = unclamped;
2489 LOperand* unclamped() { return inputs_[0]; }
2490 LOperand* scratch() { return temps_[0]; }
2491 LOperand* scratch2() { return temps_[1]; }
2492 LOperand* scratch3() { return temps_[2]; }
2494 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2495 "clamp-t-to-uint8-nosse2")
2496 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2500 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2502 explicit LCheckNonSmi(LOperand* value) {
2506 LOperand* value() { return inputs_[0]; }
2508 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2509 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2513 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2515 explicit LDoubleBits(LOperand* value) {
2519 LOperand* value() { return inputs_[0]; }
2521 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2522 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2526 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2528 LConstructDouble(LOperand* hi, LOperand* lo) {
2533 LOperand* hi() { return inputs_[0]; }
2534 LOperand* lo() { return inputs_[1]; }
2536 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2540 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2542 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2543 inputs_[0] = context;
2548 LOperand* context() { return inputs_[0]; }
2549 LOperand* size() { return inputs_[1]; }
2550 LOperand* temp() { return temps_[0]; }
2552 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2553 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2557 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2559 explicit LRegExpLiteral(LOperand* context) {
2560 inputs_[0] = context;
2563 LOperand* context() { return inputs_[0]; }
2565 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2566 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2570 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2572 explicit LFunctionLiteral(LOperand* context) {
2573 inputs_[0] = context;
2576 LOperand* context() { return inputs_[0]; }
2578 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2579 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2583 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2585 explicit LToFastProperties(LOperand* value) {
2589 LOperand* value() { return inputs_[0]; }
2591 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2592 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2596 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2598 LTypeof(LOperand* context, LOperand* value) {
2599 inputs_[0] = context;
2603 LOperand* context() { return inputs_[0]; }
2604 LOperand* value() { return inputs_[1]; }
2606 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2610 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2612 explicit LTypeofIsAndBranch(LOperand* value) {
2616 LOperand* value() { return inputs_[0]; }
2618 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2619 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2621 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2623 void PrintDataTo(StringStream* stream) OVERRIDE;
2627 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2629 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
2630 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2634 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2636 explicit LStackCheck(LOperand* context) {
2637 inputs_[0] = context;
2640 LOperand* context() { return inputs_[0]; }
2642 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2643 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2645 Label* done_label() { return &done_label_; }
2652 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2654 LForInPrepareMap(LOperand* context, LOperand* object) {
2655 inputs_[0] = context;
2656 inputs_[1] = object;
2659 LOperand* context() { return inputs_[0]; }
2660 LOperand* object() { return inputs_[1]; }
2662 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2666 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2668 explicit LForInCacheArray(LOperand* map) {
2672 LOperand* map() { return inputs_[0]; }
2674 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2677 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2682 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2684 LCheckMapValue(LOperand* value, LOperand* map) {
2689 LOperand* value() { return inputs_[0]; }
2690 LOperand* map() { return inputs_[1]; }
2692 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2696 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2698 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2699 inputs_[0] = object;
2703 LOperand* object() { return inputs_[0]; }
2704 LOperand* index() { return inputs_[1]; }
2706 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2710 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2712 explicit LStoreFrameContext(LOperand* context) {
2713 inputs_[0] = context;
2716 LOperand* context() { return inputs_[0]; }
2718 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2722 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2724 LAllocateBlockContext(LOperand* context, LOperand* function) {
2725 inputs_[0] = context;
2726 inputs_[1] = function;
2729 LOperand* context() { return inputs_[0]; }
2730 LOperand* function() { return inputs_[1]; }
2732 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2734 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2735 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2739 class LChunkBuilder;
2740 class LPlatformChunk FINAL : public LChunk {
2742 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2743 : LChunk(info, graph),
2744 num_double_slots_(0) { }
2746 int GetNextSpillIndex(RegisterKind kind);
2747 LOperand* GetNextSpillSlot(RegisterKind kind);
2749 int num_double_slots() const { return num_double_slots_; }
2752 int num_double_slots_;
2756 class LChunkBuilder FINAL : public LChunkBuilderBase {
2758 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2759 : LChunkBuilderBase(info, graph),
2760 current_instruction_(NULL),
2761 current_block_(NULL),
2763 allocator_(allocator) {}
2765 // Build the sequence for the graph.
2766 LPlatformChunk* Build();
2768 // Declare methods that deal with the individual node types.
2769 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2770 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2773 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2774 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2775 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2776 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2777 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2778 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2779 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2780 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2781 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2782 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2783 LInstruction* DoDivByConstI(HDiv* instr);
2784 LInstruction* DoDivI(HDiv* instr);
2785 LInstruction* DoModByPowerOf2I(HMod* instr);
2786 LInstruction* DoModByConstI(HMod* instr);
2787 LInstruction* DoModI(HMod* instr);
2788 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2789 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2790 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2793 // Methods for getting operands for Use / Define / Temp.
2794 LUnallocated* ToUnallocated(Register reg);
2795 LUnallocated* ToUnallocated(X87Register reg);
2797 // Methods for setting up define-use relationships.
2798 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2799 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2801 // A value that is guaranteed to be allocated to a register.
2802 // Operand created by UseRegister is guaranteed to be live until the end of
2803 // instruction. This means that register allocator will not reuse it's
2804 // register for any other operand inside instruction.
2805 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2806 // instruction start. Register allocator is free to assign the same register
2807 // to some other operand used inside instruction (i.e. temporary or
2809 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2810 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2812 // An input operand in a register that may be trashed.
2813 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2815 // An input operand in a register or stack slot.
2816 MUST_USE_RESULT LOperand* Use(HValue* value);
2817 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2819 // An input operand in a register, stack slot or a constant operand.
2820 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2821 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2823 // An input operand in a fixed register or a constant operand.
2824 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2825 Register fixed_register);
2827 // An input operand in a register or a constant operand.
2828 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2829 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2831 // An input operand in a constant operand.
2832 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2834 // An input operand in register, stack slot or a constant operand.
2835 // Will not be moved to a register even if one is freely available.
2836 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2838 // Temporary operand that must be in a register.
2839 MUST_USE_RESULT LUnallocated* TempRegister();
2840 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2842 // Methods for setting up define-use relationships.
2843 // Return the same instruction that they are passed.
2844 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2845 LUnallocated* result);
2846 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2847 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2849 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2850 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2852 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2854 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2855 // Assigns an environment to an instruction. An instruction which can
2856 // deoptimize must have an environment.
2857 LInstruction* AssignEnvironment(LInstruction* instr);
2858 // Assigns a pointer map to an instruction. An instruction which can
2859 // trigger a GC or a lazy deoptimization must have a pointer map.
2860 LInstruction* AssignPointerMap(LInstruction* instr);
2862 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2864 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2866 // Marks a call for the register allocator. Assigns a pointer map to
2867 // support GC and lazy deoptimization. Assigns an environment to support
2868 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2869 LInstruction* MarkAsCall(
2870 LInstruction* instr,
2871 HInstruction* hinstr,
2872 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2874 void VisitInstruction(HInstruction* current);
2875 void AddInstruction(LInstruction* instr, HInstruction* current);
2877 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2878 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2879 LInstruction* DoArithmeticD(Token::Value op,
2880 HArithmeticBinaryOperation* instr);
2881 LInstruction* DoArithmeticT(Token::Value op,
2882 HBinaryOperation* instr);
2884 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2886 HInstruction* current_instruction_;
2887 HBasicBlock* current_block_;
2888 HBasicBlock* next_block_;
2889 LAllocator* allocator_;
2891 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2894 #undef DECLARE_HYDROGEN_ACCESSOR
2895 #undef DECLARE_CONCRETE_INSTRUCTION
2897 } } // namespace v8::internal
2899 #endif // V8_X87_LITHIUM_X87_H_