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 virtual Opcode opcode() const FINAL OVERRIDE { \
173 return LInstruction::k##type; \
175 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
176 virtual const char* Mnemonic() const FINAL OVERRIDE { \
179 static L##type* cast(LInstruction* instr) { \
180 DCHECK(instr->Is##type()); \
181 return reinterpret_cast<L##type*>(instr); \
185 #define DECLARE_HYDROGEN_ACCESSOR(type) \
186 H##type* hydrogen() const { \
187 return H##type::cast(hydrogen_value()); \
191 class LInstruction : public ZoneObject {
194 : environment_(NULL),
195 hydrogen_value_(NULL),
196 bit_field_(IsCallBits::encode(false)) {
199 virtual ~LInstruction() {}
201 virtual void CompileToNative(LCodeGen* generator) = 0;
202 virtual const char* Mnemonic() const = 0;
203 virtual void PrintTo(StringStream* stream);
204 virtual void PrintDataTo(StringStream* stream);
205 virtual void PrintOutputOperandTo(StringStream* stream);
208 // Declare a unique enum value for each instruction.
209 #define DECLARE_OPCODE(type) k##type,
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
211 kNumberOfInstructions
212 #undef DECLARE_OPCODE
215 virtual Opcode opcode() const = 0;
217 // Declare non-virtual type testers for all leaf IR classes.
218 #define DECLARE_PREDICATE(type) \
219 bool Is##type() const { return opcode() == k##type; }
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
221 #undef DECLARE_PREDICATE
223 // Declare virtual predicates for instructions that don't have
225 virtual bool IsGap() const { return false; }
227 virtual bool IsControl() const { return false; }
229 // Try deleting this instruction if possible.
230 virtual bool TryDelete() { return false; }
232 void set_environment(LEnvironment* env) { environment_ = env; }
233 LEnvironment* environment() const { return environment_; }
234 bool HasEnvironment() const { return environment_ != NULL; }
236 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
237 LPointerMap* pointer_map() const { return pointer_map_.get(); }
238 bool HasPointerMap() const { return pointer_map_.is_set(); }
240 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
241 HValue* hydrogen_value() const { return hydrogen_value_; }
243 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
245 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
246 bool IsCall() const { return IsCallBits::decode(bit_field_); }
248 // Interface to the register allocator and iterators.
249 bool ClobbersTemps() const { return IsCall(); }
250 bool ClobbersRegisters() const { return IsCall(); }
251 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
253 // We only have rudimentary X87Stack tracking, thus in general
254 // cannot handle phi-nodes.
258 virtual bool HasResult() const = 0;
259 virtual LOperand* result() const = 0;
261 bool HasDoubleRegisterResult();
262 bool HasDoubleRegisterInput();
263 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
265 LOperand* FirstInput() { return InputAt(0); }
266 LOperand* Output() { return HasResult() ? result() : NULL; }
268 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
274 virtual int InputCount() = 0;
275 virtual LOperand* InputAt(int i) = 0;
279 friend class InputIterator;
281 friend class TempIterator;
282 virtual int TempCount() = 0;
283 virtual LOperand* TempAt(int i) = 0;
285 class IsCallBits: public BitField<bool, 0, 1> {};
287 LEnvironment* environment_;
288 SetOncePointer<LPointerMap> pointer_map_;
289 HValue* hydrogen_value_;
294 // R = number of result operands (0 or 1).
296 class LTemplateResultInstruction : public LInstruction {
298 // Allow 0 or 1 output operands.
299 STATIC_ASSERT(R == 0 || R == 1);
300 virtual bool HasResult() const FINAL OVERRIDE {
301 return R != 0 && result() != NULL;
303 void set_result(LOperand* operand) { results_[0] = operand; }
304 LOperand* result() const { return results_[0]; }
307 EmbeddedContainer<LOperand*, R> results_;
311 // R = number of result operands (0 or 1).
312 // I = number of input operands.
313 // T = number of temporary operands.
314 template<int R, int I, int T>
315 class LTemplateInstruction : public LTemplateResultInstruction<R> {
317 EmbeddedContainer<LOperand*, I> inputs_;
318 EmbeddedContainer<LOperand*, T> temps_;
322 virtual int InputCount() FINAL OVERRIDE { return I; }
323 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
325 virtual int TempCount() FINAL OVERRIDE { return T; }
326 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
330 class LGap : public LTemplateInstruction<0, 0, 0> {
332 explicit LGap(HBasicBlock* block) : block_(block) {
333 parallel_moves_[BEFORE] = NULL;
334 parallel_moves_[START] = NULL;
335 parallel_moves_[END] = NULL;
336 parallel_moves_[AFTER] = NULL;
339 // Can't use the DECLARE-macro here because of sub-classes.
340 virtual bool IsGap() const FINAL OVERRIDE { return true; }
341 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
342 static LGap* cast(LInstruction* instr) {
343 DCHECK(instr->IsGap());
344 return reinterpret_cast<LGap*>(instr);
347 bool IsRedundant() const;
349 HBasicBlock* block() const { return block_; }
356 FIRST_INNER_POSITION = BEFORE,
357 LAST_INNER_POSITION = AFTER
360 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
361 if (parallel_moves_[pos] == NULL) {
362 parallel_moves_[pos] = new(zone) LParallelMove(zone);
364 return parallel_moves_[pos];
367 LParallelMove* GetParallelMove(InnerPosition pos) {
368 return parallel_moves_[pos];
372 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
377 class LInstructionGap FINAL : public LGap {
379 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
381 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
382 return !IsRedundant();
385 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
389 class LClobberDoubles FINAL : public LTemplateInstruction<0, 0, 0> {
391 explicit LClobberDoubles(Isolate* isolate) { }
393 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
397 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
401 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
403 explicit LGoto(HBasicBlock* block) : block_(block) { }
405 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
406 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
407 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
408 virtual bool IsControl() const OVERRIDE { return true; }
410 int block_id() const { return block_->block_id(); }
411 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
415 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
416 HBasicBlock* block() const { return block_; }
423 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
425 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
429 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
432 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
436 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
438 explicit LDummyUse(LOperand* value) {
441 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
445 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
447 virtual bool IsControl() const OVERRIDE { return true; }
448 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
449 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
453 class LLabel FINAL : public LGap {
455 explicit LLabel(HBasicBlock* block)
456 : LGap(block), replacement_(NULL) { }
458 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
461 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
463 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
465 int block_id() const { return block()->block_id(); }
466 bool is_loop_header() const { return block()->IsLoopHeader(); }
467 bool is_osr_entry() const { return block()->is_osr_entry(); }
468 Label* label() { return &label_; }
469 LLabel* replacement() const { return replacement_; }
470 void set_replacement(LLabel* label) { replacement_ = label; }
471 bool HasReplacement() const { return replacement_ != NULL; }
475 LLabel* replacement_;
479 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
481 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
484 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
488 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
490 explicit LCallStub(LOperand* context) {
491 inputs_[0] = context;
494 LOperand* context() { return inputs_[0]; }
496 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
497 DECLARE_HYDROGEN_ACCESSOR(CallStub)
501 class LTailCallThroughMegamorphicCache FINAL
502 : public LTemplateInstruction<0, 3, 0> {
504 explicit LTailCallThroughMegamorphicCache(LOperand* context,
507 inputs_[0] = context;
508 inputs_[1] = receiver;
512 LOperand* context() { return inputs_[0]; }
513 LOperand* receiver() { return inputs_[1]; }
514 LOperand* name() { return inputs_[2]; }
516 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
517 "tail-call-through-megamorphic-cache")
518 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
522 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
524 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
527 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
531 template<int I, int T>
532 class LControlInstruction: public LTemplateInstruction<0, I, T> {
534 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
536 virtual bool IsControl() const FINAL OVERRIDE { return true; }
538 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
539 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
541 int TrueDestination(LChunk* chunk) {
542 return chunk->LookupDestination(true_block_id());
544 int FalseDestination(LChunk* chunk) {
545 return chunk->LookupDestination(false_block_id());
548 Label* TrueLabel(LChunk* chunk) {
549 if (true_label_ == NULL) {
550 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
554 Label* FalseLabel(LChunk* chunk) {
555 if (false_label_ == NULL) {
556 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
562 int true_block_id() { return SuccessorAt(0)->block_id(); }
563 int false_block_id() { return SuccessorAt(1)->block_id(); }
566 HControlInstruction* hydrogen() {
567 return HControlInstruction::cast(this->hydrogen_value());
575 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
577 LWrapReceiver(LOperand* receiver,
580 inputs_[0] = receiver;
581 inputs_[1] = function;
585 LOperand* receiver() { return inputs_[0]; }
586 LOperand* function() { return inputs_[1]; }
587 LOperand* temp() { return temps_[0]; }
589 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
590 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
594 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
596 LApplyArguments(LOperand* function,
599 LOperand* elements) {
600 inputs_[0] = function;
601 inputs_[1] = receiver;
603 inputs_[3] = elements;
606 LOperand* function() { return inputs_[0]; }
607 LOperand* receiver() { return inputs_[1]; }
608 LOperand* length() { return inputs_[2]; }
609 LOperand* elements() { return inputs_[3]; }
611 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
615 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
617 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
618 inputs_[0] = arguments;
623 LOperand* arguments() { return inputs_[0]; }
624 LOperand* length() { return inputs_[1]; }
625 LOperand* index() { return inputs_[2]; }
627 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
629 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
633 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
635 explicit LArgumentsLength(LOperand* elements) {
636 inputs_[0] = elements;
639 LOperand* elements() { return inputs_[0]; }
641 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
645 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
647 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
648 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
652 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
654 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
658 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
660 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
661 inputs_[0] = dividend;
665 LOperand* dividend() { return inputs_[0]; }
666 int32_t divisor() const { return divisor_; }
668 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
669 DECLARE_HYDROGEN_ACCESSOR(Mod)
676 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
678 LModByConstI(LOperand* dividend,
682 inputs_[0] = dividend;
688 LOperand* dividend() { return inputs_[0]; }
689 int32_t divisor() const { return divisor_; }
690 LOperand* temp1() { return temps_[0]; }
691 LOperand* temp2() { return temps_[1]; }
693 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
694 DECLARE_HYDROGEN_ACCESSOR(Mod)
701 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
703 LModI(LOperand* left, LOperand* right, LOperand* temp) {
709 LOperand* left() { return inputs_[0]; }
710 LOperand* right() { return inputs_[1]; }
711 LOperand* temp() { return temps_[0]; }
713 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
714 DECLARE_HYDROGEN_ACCESSOR(Mod)
718 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
720 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
721 inputs_[0] = dividend;
725 LOperand* dividend() { return inputs_[0]; }
726 int32_t divisor() const { return divisor_; }
728 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
729 DECLARE_HYDROGEN_ACCESSOR(Div)
736 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
738 LDivByConstI(LOperand* dividend,
742 inputs_[0] = dividend;
748 LOperand* dividend() { return inputs_[0]; }
749 int32_t divisor() const { return divisor_; }
750 LOperand* temp1() { return temps_[0]; }
751 LOperand* temp2() { return temps_[1]; }
753 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
754 DECLARE_HYDROGEN_ACCESSOR(Div)
761 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
763 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
764 inputs_[0] = dividend;
765 inputs_[1] = divisor;
769 LOperand* dividend() { return inputs_[0]; }
770 LOperand* divisor() { return inputs_[1]; }
771 LOperand* temp() { return temps_[0]; }
773 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
774 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
778 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
780 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
781 inputs_[0] = dividend;
785 LOperand* dividend() { return inputs_[0]; }
786 int32_t divisor() const { return divisor_; }
788 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
789 "flooring-div-by-power-of-2-i")
790 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
797 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
799 LFlooringDivByConstI(LOperand* dividend,
804 inputs_[0] = dividend;
811 LOperand* dividend() { return inputs_[0]; }
812 int32_t divisor() const { return divisor_; }
813 LOperand* temp1() { return temps_[0]; }
814 LOperand* temp2() { return temps_[1]; }
815 LOperand* temp3() { return temps_[2]; }
817 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
818 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
825 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
827 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
828 inputs_[0] = dividend;
829 inputs_[1] = divisor;
833 LOperand* dividend() { return inputs_[0]; }
834 LOperand* divisor() { return inputs_[1]; }
835 LOperand* temp() { return temps_[0]; }
837 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
838 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
842 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
844 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
850 LOperand* left() { return inputs_[0]; }
851 LOperand* right() { return inputs_[1]; }
852 LOperand* temp() { return temps_[0]; }
854 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
855 DECLARE_HYDROGEN_ACCESSOR(Mul)
859 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
861 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
866 LOperand* left() { return inputs_[0]; }
867 LOperand* right() { return inputs_[1]; }
869 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
870 "compare-numeric-and-branch")
871 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
873 Token::Value op() const { return hydrogen()->token(); }
874 bool is_double() const {
875 return hydrogen()->representation().IsDouble();
878 virtual void PrintDataTo(StringStream* stream);
882 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
884 explicit LMathFloor(LOperand* value) {
888 LOperand* value() { return inputs_[0]; }
890 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
891 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
895 class LMathRound FINAL : public LTemplateInstruction<1, 1, 0> {
897 explicit LMathRound(LOperand* value) {
901 LOperand* value() { return inputs_[0]; }
903 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
904 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
908 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
910 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
912 LOperand* value() { return inputs_[0]; }
914 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
918 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
920 LMathAbs(LOperand* context, LOperand* value) {
921 inputs_[1] = context;
925 LOperand* context() { return inputs_[1]; }
926 LOperand* value() { return inputs_[0]; }
928 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
929 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
933 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
935 explicit LMathLog(LOperand* value) {
939 LOperand* value() { return inputs_[0]; }
941 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
945 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
947 explicit LMathClz32(LOperand* value) {
951 LOperand* value() { return inputs_[0]; }
953 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
957 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
959 LMathExp(LOperand* value,
965 ExternalReference::InitializeMathExpData();
968 LOperand* value() { return inputs_[0]; }
969 LOperand* temp1() { return temps_[0]; }
970 LOperand* temp2() { return temps_[1]; }
972 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
976 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
978 explicit LMathSqrt(LOperand* value) {
982 LOperand* value() { return inputs_[0]; }
984 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
988 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
990 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
992 LOperand* value() { return inputs_[0]; }
994 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
998 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
1000 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1005 LOperand* left() { return inputs_[0]; }
1006 LOperand* right() { return inputs_[1]; }
1008 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1012 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1014 explicit LCmpHoleAndBranch(LOperand* object) {
1015 inputs_[0] = object;
1018 LOperand* object() { return inputs_[0]; }
1020 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1021 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1025 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1027 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1029 LOperand* value() { return inputs_[0]; }
1031 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1032 "cmp-minus-zero-and-branch")
1033 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1037 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1039 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1044 LOperand* value() { return inputs_[0]; }
1045 LOperand* temp() { return temps_[0]; }
1047 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1049 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1053 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1055 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1060 LOperand* value() { return inputs_[0]; }
1061 LOperand* temp() { return temps_[0]; }
1063 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1064 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1066 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1070 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1072 explicit LIsSmiAndBranch(LOperand* value) {
1076 LOperand* value() { return inputs_[0]; }
1078 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1079 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1081 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1085 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1087 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1092 LOperand* value() { return inputs_[0]; }
1093 LOperand* temp() { return temps_[0]; }
1095 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1096 "is-undetectable-and-branch")
1097 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1099 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1103 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1105 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1106 inputs_[0] = context;
1111 LOperand* context() { return inputs_[1]; }
1112 LOperand* left() { return inputs_[1]; }
1113 LOperand* right() { return inputs_[2]; }
1115 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1116 "string-compare-and-branch")
1117 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1119 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1121 Token::Value op() const { return hydrogen()->token(); }
1125 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1127 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1132 LOperand* value() { return inputs_[0]; }
1133 LOperand* temp() { return temps_[0]; }
1135 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1136 "has-instance-type-and-branch")
1137 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1139 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1143 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1145 explicit LGetCachedArrayIndex(LOperand* value) {
1149 LOperand* value() { return inputs_[0]; }
1151 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1152 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1156 class LHasCachedArrayIndexAndBranch FINAL
1157 : public LControlInstruction<1, 0> {
1159 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1163 LOperand* value() { return inputs_[0]; }
1165 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1166 "has-cached-array-index-and-branch")
1168 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1172 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1174 explicit LIsConstructCallAndBranch(LOperand* temp) {
1178 LOperand* temp() { return temps_[0]; }
1180 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1181 "is-construct-call-and-branch")
1185 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1187 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1193 LOperand* value() { return inputs_[0]; }
1194 LOperand* temp() { return temps_[0]; }
1195 LOperand* temp2() { return temps_[1]; }
1197 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1198 "class-of-test-and-branch")
1199 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1201 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1205 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1207 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1208 inputs_[0] = context;
1213 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1214 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1216 LOperand* context() { return inputs_[0]; }
1217 Token::Value op() const { return hydrogen()->token(); }
1221 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1223 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1224 inputs_[0] = context;
1229 LOperand* context() { return inputs_[0]; }
1231 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1235 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1237 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1238 inputs_[0] = context;
1243 LOperand* context() { return inputs_[0]; }
1244 LOperand* value() { return inputs_[1]; }
1245 LOperand* temp() { return temps_[0]; }
1247 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1248 "instance-of-known-global")
1249 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1251 Handle<JSFunction> function() const { return hydrogen()->function(); }
1252 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1253 return lazy_deopt_env_;
1255 virtual void SetDeferredLazyDeoptimizationEnvironment(
1256 LEnvironment* env) OVERRIDE {
1257 lazy_deopt_env_ = env;
1261 LEnvironment* lazy_deopt_env_;
1265 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1267 LBoundsCheck(LOperand* index, LOperand* length) {
1269 inputs_[1] = length;
1272 LOperand* index() { return inputs_[0]; }
1273 LOperand* length() { return inputs_[1]; }
1275 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1276 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1280 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1282 LBitI(LOperand* left, LOperand* right) {
1287 LOperand* left() { return inputs_[0]; }
1288 LOperand* right() { return inputs_[1]; }
1290 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1291 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1293 Token::Value op() const { return hydrogen()->op(); }
1297 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1299 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1300 : op_(op), can_deopt_(can_deopt) {
1305 LOperand* left() { return inputs_[0]; }
1306 LOperand* right() { return inputs_[1]; }
1308 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1310 Token::Value op() const { return op_; }
1311 bool can_deopt() const { return can_deopt_; }
1319 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1321 LSubI(LOperand* left, LOperand* right) {
1326 LOperand* left() { return inputs_[0]; }
1327 LOperand* right() { return inputs_[1]; }
1329 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1330 DECLARE_HYDROGEN_ACCESSOR(Sub)
1334 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1336 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1337 DECLARE_HYDROGEN_ACCESSOR(Constant)
1339 int32_t value() const { return hydrogen()->Integer32Value(); }
1343 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1345 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1346 DECLARE_HYDROGEN_ACCESSOR(Constant)
1348 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1352 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1354 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1355 DECLARE_HYDROGEN_ACCESSOR(Constant)
1357 double value() const { return hydrogen()->DoubleValue(); }
1361 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1364 DECLARE_HYDROGEN_ACCESSOR(Constant)
1366 ExternalReference value() const {
1367 return hydrogen()->ExternalReferenceValue();
1372 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1374 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1375 DECLARE_HYDROGEN_ACCESSOR(Constant)
1377 Handle<Object> value(Isolate* isolate) const {
1378 return hydrogen()->handle(isolate);
1383 class LBranch FINAL : public LControlInstruction<1, 1> {
1385 LBranch(LOperand* value, LOperand* temp) {
1390 LOperand* value() { return inputs_[0]; }
1391 LOperand* temp() { return temps_[0]; }
1393 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1394 DECLARE_HYDROGEN_ACCESSOR(Branch)
1396 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1400 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1402 explicit LCmpMapAndBranch(LOperand* value) {
1406 LOperand* value() { return inputs_[0]; }
1408 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1409 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1411 Handle<Map> map() const { return hydrogen()->map().handle(); }
1415 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1417 explicit LMapEnumLength(LOperand* value) {
1421 LOperand* value() { return inputs_[0]; }
1423 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1427 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1429 LDateField(LOperand* date, LOperand* temp, Smi* index)
1435 LOperand* date() { return inputs_[0]; }
1436 LOperand* temp() { return temps_[0]; }
1438 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1439 DECLARE_HYDROGEN_ACCESSOR(DateField)
1441 Smi* index() const { return index_; }
1448 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1450 LSeqStringGetChar(LOperand* string, LOperand* index) {
1451 inputs_[0] = string;
1455 LOperand* string() const { return inputs_[0]; }
1456 LOperand* index() const { return inputs_[1]; }
1458 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1459 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1463 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1465 LSeqStringSetChar(LOperand* context,
1469 inputs_[0] = context;
1470 inputs_[1] = string;
1475 LOperand* string() { return inputs_[1]; }
1476 LOperand* index() { return inputs_[2]; }
1477 LOperand* value() { return inputs_[3]; }
1479 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1480 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1484 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1486 LAddI(LOperand* left, LOperand* right) {
1491 LOperand* left() { return inputs_[0]; }
1492 LOperand* right() { return inputs_[1]; }
1494 static bool UseLea(HAdd* add) {
1495 return !add->CheckFlag(HValue::kCanOverflow) &&
1496 add->BetterLeftOperand()->UseCount() > 1;
1499 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1500 DECLARE_HYDROGEN_ACCESSOR(Add)
1504 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 1> {
1506 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1512 LOperand* left() { return inputs_[0]; }
1513 LOperand* right() { return inputs_[1]; }
1514 LOperand* temp() { return temps_[0]; }
1516 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1517 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1521 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1523 LPower(LOperand* left, LOperand* right) {
1528 LOperand* left() { return inputs_[0]; }
1529 LOperand* right() { return inputs_[1]; }
1531 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1532 DECLARE_HYDROGEN_ACCESSOR(Power)
1536 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1538 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1544 LOperand* left() { return inputs_[0]; }
1545 LOperand* right() { return inputs_[1]; }
1547 Token::Value op() const { return op_; }
1549 virtual Opcode opcode() const OVERRIDE {
1550 return LInstruction::kArithmeticD;
1552 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1553 virtual const char* Mnemonic() const OVERRIDE;
1560 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1562 LArithmeticT(Token::Value op,
1567 inputs_[0] = context;
1572 LOperand* context() { return inputs_[0]; }
1573 LOperand* left() { return inputs_[1]; }
1574 LOperand* right() { return inputs_[2]; }
1576 virtual Opcode opcode() const OVERRIDE {
1577 return LInstruction::kArithmeticT;
1579 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1580 virtual const char* Mnemonic() const OVERRIDE;
1582 Token::Value op() const { return op_; }
1589 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1591 explicit LReturn(LOperand* value,
1593 LOperand* parameter_count) {
1595 inputs_[1] = context;
1596 inputs_[2] = parameter_count;
1599 bool has_constant_parameter_count() {
1600 return parameter_count()->IsConstantOperand();
1602 LConstantOperand* constant_parameter_count() {
1603 DCHECK(has_constant_parameter_count());
1604 return LConstantOperand::cast(parameter_count());
1606 LOperand* parameter_count() { return inputs_[2]; }
1608 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1609 DECLARE_HYDROGEN_ACCESSOR(Return)
1613 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1615 explicit LLoadNamedField(LOperand* object) {
1616 inputs_[0] = object;
1619 LOperand* object() { return inputs_[0]; }
1621 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1622 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1626 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1628 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1629 inputs_[0] = context;
1630 inputs_[1] = object;
1634 LOperand* context() { return inputs_[0]; }
1635 LOperand* object() { return inputs_[1]; }
1636 LOperand* temp_vector() { return temps_[0]; }
1638 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1639 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1641 Handle<Object> name() const { return hydrogen()->name(); }
1645 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1647 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1648 inputs_[0] = function;
1652 LOperand* function() { return inputs_[0]; }
1653 LOperand* temp() { return temps_[0]; }
1655 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1656 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1660 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1662 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1663 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1665 Heap::RootListIndex index() const { return hydrogen()->index(); }
1669 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1671 LLoadKeyed(LOperand* elements, LOperand* key) {
1672 inputs_[0] = elements;
1675 LOperand* elements() { return inputs_[0]; }
1676 LOperand* key() { return inputs_[1]; }
1677 ElementsKind elements_kind() const {
1678 return hydrogen()->elements_kind();
1680 bool is_external() const {
1681 return hydrogen()->is_external();
1683 bool is_fixed_typed_array() const {
1684 return hydrogen()->is_fixed_typed_array();
1686 bool is_typed_elements() const {
1687 return is_external() || is_fixed_typed_array();
1690 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1691 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1693 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1694 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1696 return hydrogen()->key()->representation().IsTagged();
1701 inline static bool ExternalArrayOpRequiresTemp(
1702 Representation key_representation,
1703 ElementsKind elements_kind) {
1704 // Operations that require the key to be divided by two to be converted into
1705 // an index cannot fold the scale operation into a load and need an extra
1706 // temp register to do the work.
1707 return key_representation.IsSmi() &&
1708 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1709 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1710 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1711 elements_kind == UINT8_ELEMENTS ||
1712 elements_kind == INT8_ELEMENTS ||
1713 elements_kind == UINT8_CLAMPED_ELEMENTS);
1717 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1719 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1721 inputs_[0] = context;
1727 LOperand* context() { return inputs_[0]; }
1728 LOperand* object() { return inputs_[1]; }
1729 LOperand* key() { return inputs_[2]; }
1730 LOperand* temp_vector() { return temps_[0]; }
1732 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1733 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1737 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1739 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1740 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1744 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1746 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1748 inputs_[0] = context;
1749 inputs_[1] = global_object;
1753 LOperand* context() { return inputs_[0]; }
1754 LOperand* global_object() { return inputs_[1]; }
1755 LOperand* temp_vector() { return temps_[0]; }
1757 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1758 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1760 Handle<Object> name() const { return hydrogen()->name(); }
1761 bool for_typeof() const { return hydrogen()->for_typeof(); }
1765 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1767 explicit LStoreGlobalCell(LOperand* value) {
1771 LOperand* value() { return inputs_[0]; }
1773 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1774 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1778 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1780 explicit LLoadContextSlot(LOperand* context) {
1781 inputs_[0] = context;
1784 LOperand* context() { return inputs_[0]; }
1786 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1787 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1789 int slot_index() { return hydrogen()->slot_index(); }
1791 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1795 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1797 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1798 inputs_[0] = context;
1803 LOperand* context() { return inputs_[0]; }
1804 LOperand* value() { return inputs_[1]; }
1805 LOperand* temp() { return temps_[0]; }
1807 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1808 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1810 int slot_index() { return hydrogen()->slot_index(); }
1812 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1816 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1818 explicit LPushArgument(LOperand* value) {
1822 LOperand* value() { return inputs_[0]; }
1824 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1828 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1830 explicit LDrop(int count) : count_(count) { }
1832 int count() const { return count_; }
1834 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1841 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1843 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1844 inputs_[0] = function;
1845 inputs_[1] = code_object;
1848 LOperand* function() { return inputs_[0]; }
1849 LOperand* code_object() { return inputs_[1]; }
1851 virtual void PrintDataTo(StringStream* stream);
1853 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1854 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1858 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1860 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1861 inputs_[0] = base_object;
1862 inputs_[1] = offset;
1865 LOperand* base_object() const { return inputs_[0]; }
1866 LOperand* offset() const { return inputs_[1]; }
1868 virtual void PrintDataTo(StringStream* stream);
1870 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1874 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1876 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1877 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1881 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1883 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1884 DECLARE_HYDROGEN_ACCESSOR(Context)
1888 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1890 explicit LDeclareGlobals(LOperand* context) {
1891 inputs_[0] = context;
1894 LOperand* context() { return inputs_[0]; }
1896 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1897 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1901 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1903 explicit LCallJSFunction(LOperand* function) {
1904 inputs_[0] = function;
1907 LOperand* function() { return inputs_[0]; }
1909 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1910 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1912 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1914 int arity() const { return hydrogen()->argument_count() - 1; }
1918 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1920 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1921 const ZoneList<LOperand*>& operands, Zone* zone)
1922 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1923 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1924 inputs_.AddAll(operands, zone);
1927 LOperand* target() const { return inputs_[0]; }
1929 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1932 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1934 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1936 int arity() const { return hydrogen()->argument_count() - 1; }
1938 ZoneList<LOperand*> inputs_;
1940 // Iterator support.
1941 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1942 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1944 virtual int TempCount() FINAL OVERRIDE { return 0; }
1945 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1949 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1951 LInvokeFunction(LOperand* context, LOperand* function) {
1952 inputs_[0] = context;
1953 inputs_[1] = function;
1956 LOperand* context() { return inputs_[0]; }
1957 LOperand* function() { return inputs_[1]; }
1959 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1960 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1962 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1964 int arity() const { return hydrogen()->argument_count() - 1; }
1968 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1970 explicit LCallFunction(LOperand* context, LOperand* function) {
1971 inputs_[0] = context;
1972 inputs_[1] = function;
1975 LOperand* context() { return inputs_[0]; }
1976 LOperand* function() { return inputs_[1]; }
1978 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1979 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1981 int arity() const { return hydrogen()->argument_count() - 1; }
1985 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1987 LCallNew(LOperand* context, LOperand* constructor) {
1988 inputs_[0] = context;
1989 inputs_[1] = constructor;
1992 LOperand* context() { return inputs_[0]; }
1993 LOperand* constructor() { return inputs_[1]; }
1995 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1996 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1998 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2000 int arity() const { return hydrogen()->argument_count() - 1; }
2004 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2006 LCallNewArray(LOperand* context, LOperand* constructor) {
2007 inputs_[0] = context;
2008 inputs_[1] = constructor;
2011 LOperand* context() { return inputs_[0]; }
2012 LOperand* constructor() { return inputs_[1]; }
2014 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2015 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2017 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2019 int arity() const { return hydrogen()->argument_count() - 1; }
2023 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2025 explicit LCallRuntime(LOperand* context) {
2026 inputs_[0] = context;
2029 LOperand* context() { return inputs_[0]; }
2031 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2032 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2034 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2035 return save_doubles() == kDontSaveFPRegs;
2038 const Runtime::Function* function() const { return hydrogen()->function(); }
2039 int arity() const { return hydrogen()->argument_count(); }
2040 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2044 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2046 explicit LInteger32ToDouble(LOperand* value) {
2050 LOperand* value() { return inputs_[0]; }
2052 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2056 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2058 explicit LUint32ToDouble(LOperand* value) {
2062 LOperand* value() { return inputs_[0]; }
2064 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2068 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2070 LNumberTagI(LOperand* value, LOperand* temp) {
2075 LOperand* value() { return inputs_[0]; }
2076 LOperand* temp() { return temps_[0]; }
2078 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2082 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2084 LNumberTagU(LOperand* value, LOperand* temp) {
2089 LOperand* value() { return inputs_[0]; }
2090 LOperand* temp() { return temps_[0]; }
2092 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2096 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2098 LNumberTagD(LOperand* value, LOperand* temp) {
2103 LOperand* value() { return inputs_[0]; }
2104 LOperand* temp() { return temps_[0]; }
2106 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2107 DECLARE_HYDROGEN_ACCESSOR(Change)
2111 // Sometimes truncating conversion from a tagged value to an int32.
2112 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2114 explicit LDoubleToI(LOperand* value) {
2118 LOperand* value() { return inputs_[0]; }
2120 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2121 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2123 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2127 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2129 explicit LDoubleToSmi(LOperand* value) {
2133 LOperand* value() { return inputs_[0]; }
2135 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2136 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2140 // Truncating conversion from a tagged value to an int32.
2141 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2143 explicit LTaggedToI(LOperand* value) {
2147 LOperand* value() { return inputs_[0]; }
2149 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2150 DECLARE_HYDROGEN_ACCESSOR(Change)
2152 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2156 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2158 explicit LSmiTag(LOperand* value) {
2162 LOperand* value() { return inputs_[0]; }
2164 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2165 DECLARE_HYDROGEN_ACCESSOR(Change)
2169 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2171 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2176 LOperand* value() { return inputs_[0]; }
2177 LOperand* temp() { return temps_[0]; }
2179 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2180 DECLARE_HYDROGEN_ACCESSOR(Change);
2184 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2186 LSmiUntag(LOperand* value, bool needs_check)
2187 : needs_check_(needs_check) {
2191 LOperand* value() { return inputs_[0]; }
2193 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2195 bool needs_check() const { return needs_check_; }
2202 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2204 LStoreNamedField(LOperand* obj,
2207 LOperand* temp_map) {
2211 temps_[1] = temp_map;
2214 LOperand* object() { return inputs_[0]; }
2215 LOperand* value() { return inputs_[1]; }
2216 LOperand* temp() { return temps_[0]; }
2217 LOperand* temp_map() { return temps_[1]; }
2219 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2220 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2222 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2226 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2228 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2229 inputs_[0] = context;
2230 inputs_[1] = object;
2234 LOperand* context() { return inputs_[0]; }
2235 LOperand* object() { return inputs_[1]; }
2236 LOperand* value() { return inputs_[2]; }
2238 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2239 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2241 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2242 Handle<Object> name() const { return hydrogen()->name(); }
2243 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2247 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2249 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2255 bool is_external() const { return hydrogen()->is_external(); }
2256 bool is_fixed_typed_array() const {
2257 return hydrogen()->is_fixed_typed_array();
2259 bool is_typed_elements() const {
2260 return is_external() || is_fixed_typed_array();
2262 LOperand* elements() { return inputs_[0]; }
2263 LOperand* key() { return inputs_[1]; }
2264 LOperand* value() { return inputs_[2]; }
2265 ElementsKind elements_kind() const {
2266 return hydrogen()->elements_kind();
2269 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2270 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2272 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2273 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2274 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2278 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2280 LStoreKeyedGeneric(LOperand* context,
2284 inputs_[0] = context;
2285 inputs_[1] = object;
2290 LOperand* context() { return inputs_[0]; }
2291 LOperand* object() { return inputs_[1]; }
2292 LOperand* key() { return inputs_[2]; }
2293 LOperand* value() { return inputs_[3]; }
2295 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2296 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2298 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2300 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2304 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2306 LTransitionElementsKind(LOperand* object,
2308 LOperand* new_map_temp,
2310 inputs_[0] = object;
2311 inputs_[1] = context;
2312 temps_[0] = new_map_temp;
2316 LOperand* context() { return inputs_[1]; }
2317 LOperand* object() { return inputs_[0]; }
2318 LOperand* new_map_temp() { return temps_[0]; }
2319 LOperand* temp() { return temps_[1]; }
2321 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2322 "transition-elements-kind")
2323 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2325 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2327 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2328 Handle<Map> transitioned_map() {
2329 return hydrogen()->transitioned_map().handle();
2331 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2332 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2336 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2338 LTrapAllocationMemento(LOperand* object,
2340 inputs_[0] = object;
2344 LOperand* object() { return inputs_[0]; }
2345 LOperand* temp() { return temps_[0]; }
2347 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2348 "trap-allocation-memento")
2352 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2354 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2355 inputs_[0] = context;
2360 LOperand* context() { return inputs_[0]; }
2361 LOperand* left() { return inputs_[1]; }
2362 LOperand* right() { return inputs_[2]; }
2364 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2365 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2369 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2371 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2372 inputs_[0] = context;
2373 inputs_[1] = string;
2377 LOperand* context() { return inputs_[0]; }
2378 LOperand* string() { return inputs_[1]; }
2379 LOperand* index() { return inputs_[2]; }
2381 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2382 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2386 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2388 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2389 inputs_[0] = context;
2390 inputs_[1] = char_code;
2393 LOperand* context() { return inputs_[0]; }
2394 LOperand* char_code() { return inputs_[1]; }
2396 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2397 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2401 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2403 explicit LCheckValue(LOperand* value) {
2407 LOperand* value() { return inputs_[0]; }
2409 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2410 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2414 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2416 LCheckInstanceType(LOperand* value, LOperand* temp) {
2421 LOperand* value() { return inputs_[0]; }
2422 LOperand* temp() { return temps_[0]; }
2424 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2425 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2429 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2431 explicit LCheckMaps(LOperand* value = NULL) {
2435 LOperand* value() { return inputs_[0]; }
2437 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2438 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2442 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2444 explicit LCheckSmi(LOperand* value) {
2448 LOperand* value() { return inputs_[0]; }
2450 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2454 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2456 explicit LClampDToUint8(LOperand* value) {
2460 LOperand* unclamped() { return inputs_[0]; }
2462 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2466 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2468 explicit LClampIToUint8(LOperand* value) {
2472 LOperand* unclamped() { return inputs_[0]; }
2474 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2478 // Truncating conversion from a tagged value to an int32.
2479 class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2481 LClampTToUint8NoSSE2(LOperand* unclamped,
2485 inputs_[0] = unclamped;
2491 LOperand* unclamped() { return inputs_[0]; }
2492 LOperand* scratch() { return temps_[0]; }
2493 LOperand* scratch2() { return temps_[1]; }
2494 LOperand* scratch3() { return temps_[2]; }
2496 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2497 "clamp-t-to-uint8-nosse2")
2498 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2502 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2504 explicit LCheckNonSmi(LOperand* value) {
2508 LOperand* value() { return inputs_[0]; }
2510 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2511 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2515 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2517 explicit LDoubleBits(LOperand* value) {
2521 LOperand* value() { return inputs_[0]; }
2523 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2524 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2528 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2530 LConstructDouble(LOperand* hi, LOperand* lo) {
2535 LOperand* hi() { return inputs_[0]; }
2536 LOperand* lo() { return inputs_[1]; }
2538 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2542 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2544 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2545 inputs_[0] = context;
2550 LOperand* context() { return inputs_[0]; }
2551 LOperand* size() { return inputs_[1]; }
2552 LOperand* temp() { return temps_[0]; }
2554 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2555 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2559 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2561 explicit LRegExpLiteral(LOperand* context) {
2562 inputs_[0] = context;
2565 LOperand* context() { return inputs_[0]; }
2567 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2568 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2572 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2574 explicit LFunctionLiteral(LOperand* context) {
2575 inputs_[0] = context;
2578 LOperand* context() { return inputs_[0]; }
2580 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2581 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2585 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2587 explicit LToFastProperties(LOperand* value) {
2591 LOperand* value() { return inputs_[0]; }
2593 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2594 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2598 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2600 LTypeof(LOperand* context, LOperand* value) {
2601 inputs_[0] = context;
2605 LOperand* context() { return inputs_[0]; }
2606 LOperand* value() { return inputs_[1]; }
2608 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2612 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2614 explicit LTypeofIsAndBranch(LOperand* value) {
2618 LOperand* value() { return inputs_[0]; }
2620 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2621 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2623 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2625 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2629 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2631 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2634 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2638 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2640 explicit LStackCheck(LOperand* context) {
2641 inputs_[0] = context;
2644 LOperand* context() { return inputs_[0]; }
2646 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2647 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2649 Label* done_label() { return &done_label_; }
2656 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2658 LForInPrepareMap(LOperand* context, LOperand* object) {
2659 inputs_[0] = context;
2660 inputs_[1] = object;
2663 LOperand* context() { return inputs_[0]; }
2664 LOperand* object() { return inputs_[1]; }
2666 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2670 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2672 explicit LForInCacheArray(LOperand* map) {
2676 LOperand* map() { return inputs_[0]; }
2678 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2681 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2686 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2688 LCheckMapValue(LOperand* value, LOperand* map) {
2693 LOperand* value() { return inputs_[0]; }
2694 LOperand* map() { return inputs_[1]; }
2696 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2700 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2702 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2703 inputs_[0] = object;
2707 LOperand* object() { return inputs_[0]; }
2708 LOperand* index() { return inputs_[1]; }
2710 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2714 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2716 explicit LStoreFrameContext(LOperand* context) {
2717 inputs_[0] = context;
2720 LOperand* context() { return inputs_[0]; }
2722 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2726 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2728 LAllocateBlockContext(LOperand* context, LOperand* function) {
2729 inputs_[0] = context;
2730 inputs_[1] = function;
2733 LOperand* context() { return inputs_[0]; }
2734 LOperand* function() { return inputs_[1]; }
2736 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2738 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2739 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2743 class LChunkBuilder;
2744 class LPlatformChunk FINAL : public LChunk {
2746 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2747 : LChunk(info, graph),
2748 num_double_slots_(0) { }
2750 int GetNextSpillIndex(RegisterKind kind);
2751 LOperand* GetNextSpillSlot(RegisterKind kind);
2753 int num_double_slots() const { return num_double_slots_; }
2756 int num_double_slots_;
2760 class LChunkBuilder FINAL : public LChunkBuilderBase {
2762 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2763 : LChunkBuilderBase(graph->zone()),
2768 current_instruction_(NULL),
2769 current_block_(NULL),
2771 allocator_(allocator) { }
2773 Isolate* isolate() const { return graph_->isolate(); }
2775 // Build the sequence for the graph.
2776 LPlatformChunk* Build();
2778 // Declare methods that deal with the individual node types.
2779 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2780 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2783 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2784 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2785 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2786 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2787 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2788 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2789 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2790 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2791 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2792 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2793 LInstruction* DoDivByConstI(HDiv* instr);
2794 LInstruction* DoDivI(HDiv* instr);
2795 LInstruction* DoModByPowerOf2I(HMod* instr);
2796 LInstruction* DoModByConstI(HMod* instr);
2797 LInstruction* DoModI(HMod* instr);
2798 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2799 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2800 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2810 LPlatformChunk* chunk() const { return chunk_; }
2811 CompilationInfo* info() const { return info_; }
2812 HGraph* graph() const { return graph_; }
2814 bool is_unused() const { return status_ == UNUSED; }
2815 bool is_building() const { return status_ == BUILDING; }
2816 bool is_done() const { return status_ == DONE; }
2817 bool is_aborted() const { return status_ == ABORTED; }
2819 void Abort(BailoutReason reason);
2821 // Methods for getting operands for Use / Define / Temp.
2822 LUnallocated* ToUnallocated(Register reg);
2823 LUnallocated* ToUnallocated(X87Register reg);
2825 // Methods for setting up define-use relationships.
2826 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2827 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2829 // A value that is guaranteed to be allocated to a register.
2830 // Operand created by UseRegister is guaranteed to be live until the end of
2831 // instruction. This means that register allocator will not reuse it's
2832 // register for any other operand inside instruction.
2833 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2834 // instruction start. Register allocator is free to assign the same register
2835 // to some other operand used inside instruction (i.e. temporary or
2837 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2838 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2840 // An input operand in a register that may be trashed.
2841 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2843 // An input operand in a register or stack slot.
2844 MUST_USE_RESULT LOperand* Use(HValue* value);
2845 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2847 // An input operand in a register, stack slot or a constant operand.
2848 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2849 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2851 // An input operand in a fixed register or a constant operand.
2852 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2853 Register fixed_register);
2855 // An input operand in a register or a constant operand.
2856 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2857 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2859 // An input operand in a constant operand.
2860 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2862 // An input operand in register, stack slot or a constant operand.
2863 // Will not be moved to a register even if one is freely available.
2864 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2866 // Temporary operand that must be in a register.
2867 MUST_USE_RESULT LUnallocated* TempRegister();
2868 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2870 // Methods for setting up define-use relationships.
2871 // Return the same instruction that they are passed.
2872 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2873 LUnallocated* result);
2874 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2875 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2877 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2878 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2880 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2882 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2883 // Assigns an environment to an instruction. An instruction which can
2884 // deoptimize must have an environment.
2885 LInstruction* AssignEnvironment(LInstruction* instr);
2886 // Assigns a pointer map to an instruction. An instruction which can
2887 // trigger a GC or a lazy deoptimization must have a pointer map.
2888 LInstruction* AssignPointerMap(LInstruction* instr);
2890 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2892 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2894 // Marks a call for the register allocator. Assigns a pointer map to
2895 // support GC and lazy deoptimization. Assigns an environment to support
2896 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2897 LInstruction* MarkAsCall(
2898 LInstruction* instr,
2899 HInstruction* hinstr,
2900 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2902 void VisitInstruction(HInstruction* current);
2903 void AddInstruction(LInstruction* instr, HInstruction* current);
2905 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2906 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2907 LInstruction* DoArithmeticD(Token::Value op,
2908 HArithmeticBinaryOperation* instr);
2909 LInstruction* DoArithmeticT(Token::Value op,
2910 HBinaryOperation* instr);
2912 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2914 LPlatformChunk* chunk_;
2915 CompilationInfo* info_;
2916 HGraph* const graph_;
2918 HInstruction* current_instruction_;
2919 HBasicBlock* current_block_;
2920 HBasicBlock* next_block_;
2921 LAllocator* allocator_;
2923 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2926 #undef DECLARE_HYDROGEN_ACCESSOR
2927 #undef DECLARE_CONCRETE_INSTRUCTION
2929 } } // namespace v8::internal
2931 #endif // V8_X87_LITHIUM_X87_H_