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_IA32_LITHIUM_IA32_H_
6 #define V8_IA32_LITHIUM_IA32_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) \
53 V(ClassOfTestAndBranch) \
54 V(CompareMinusZeroAndBranch) \
55 V(CompareNumericAndBranch) \
56 V(CmpObjectEqAndBranch) \
80 V(FlooringDivByConstI) \
81 V(FlooringDivByPowerOf2I) \
86 V(GetCachedArrayIndex) \
88 V(HasCachedArrayIndexAndBranch) \
89 V(HasInstanceTypeAndBranch) \
90 V(InnerAllocatedObject) \
92 V(InstanceOfKnownGlobal) \
94 V(Integer32ToDouble) \
96 V(IsConstructCallAndBranch) \
97 V(IsObjectAndBranch) \
98 V(IsStringAndBranch) \
100 V(IsUndetectableAndBranch) \
104 V(LoadFieldByIndex) \
105 V(LoadFunctionPrototype) \
107 V(LoadGlobalGeneric) \
109 V(LoadKeyedGeneric) \
111 V(LoadNamedGeneric) \
138 V(SeqStringGetChar) \
139 V(SeqStringSetChar) \
145 V(StoreContextSlot) \
146 V(StoreFrameContext) \
149 V(StoreKeyedGeneric) \
151 V(StoreNamedGeneric) \
153 V(StringCharCodeAt) \
154 V(StringCharFromCode) \
155 V(StringCompareAndBranch) \
158 V(TailCallThroughMegamorphicCache) \
160 V(ToFastProperties) \
161 V(TransitionElementsKind) \
162 V(TrapAllocationMemento) \
164 V(TypeofIsAndBranch) \
170 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
171 virtual Opcode opcode() const FINAL OVERRIDE { \
172 return LInstruction::k##type; \
174 virtual void CompileToNative(LCodeGen* generator) FINAL OVERRIDE; \
175 virtual const char* Mnemonic() const FINAL OVERRIDE { \
178 static L##type* cast(LInstruction* instr) { \
179 DCHECK(instr->Is##type()); \
180 return reinterpret_cast<L##type*>(instr); \
184 #define DECLARE_HYDROGEN_ACCESSOR(type) \
185 H##type* hydrogen() const { \
186 return H##type::cast(hydrogen_value()); \
190 class LInstruction : public ZoneObject {
193 : environment_(NULL),
194 hydrogen_value_(NULL),
195 bit_field_(IsCallBits::encode(false)) {
198 virtual ~LInstruction() {}
200 virtual void CompileToNative(LCodeGen* generator) = 0;
201 virtual const char* Mnemonic() const = 0;
202 virtual void PrintTo(StringStream* stream);
203 virtual void PrintDataTo(StringStream* stream);
204 virtual void PrintOutputOperandTo(StringStream* stream);
207 // Declare a unique enum value for each instruction.
208 #define DECLARE_OPCODE(type) k##type,
209 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
210 kNumberOfInstructions
211 #undef DECLARE_OPCODE
214 virtual Opcode opcode() const = 0;
216 // Declare non-virtual type testers for all leaf IR classes.
217 #define DECLARE_PREDICATE(type) \
218 bool Is##type() const { return opcode() == k##type; }
219 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
220 #undef DECLARE_PREDICATE
222 // Declare virtual predicates for instructions that don't have
224 virtual bool IsGap() const { return false; }
226 virtual bool IsControl() const { return false; }
228 // Try deleting this instruction if possible.
229 virtual bool TryDelete() { return false; }
231 void set_environment(LEnvironment* env) { environment_ = env; }
232 LEnvironment* environment() const { return environment_; }
233 bool HasEnvironment() const { return environment_ != NULL; }
235 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
236 LPointerMap* pointer_map() const { return pointer_map_.get(); }
237 bool HasPointerMap() const { return pointer_map_.is_set(); }
239 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
240 HValue* hydrogen_value() const { return hydrogen_value_; }
242 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
244 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
245 bool IsCall() const { return IsCallBits::decode(bit_field_); }
247 // Interface to the register allocator and iterators.
248 bool ClobbersTemps() const { return IsCall(); }
249 bool ClobbersRegisters() const { return IsCall(); }
250 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
254 virtual bool HasResult() const = 0;
255 virtual LOperand* result() const = 0;
257 bool HasDoubleRegisterResult();
258 bool HasDoubleRegisterInput();
260 LOperand* FirstInput() { return InputAt(0); }
261 LOperand* Output() { return HasResult() ? result() : NULL; }
263 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
269 virtual int InputCount() = 0;
270 virtual LOperand* InputAt(int i) = 0;
274 friend class InputIterator;
276 friend class TempIterator;
277 virtual int TempCount() = 0;
278 virtual LOperand* TempAt(int i) = 0;
280 class IsCallBits: public BitField<bool, 0, 1> {};
282 LEnvironment* environment_;
283 SetOncePointer<LPointerMap> pointer_map_;
284 HValue* hydrogen_value_;
289 // R = number of result operands (0 or 1).
291 class LTemplateResultInstruction : public LInstruction {
293 // Allow 0 or 1 output operands.
294 STATIC_ASSERT(R == 0 || R == 1);
295 virtual bool HasResult() const FINAL OVERRIDE {
296 return R != 0 && result() != NULL;
298 void set_result(LOperand* operand) { results_[0] = operand; }
299 LOperand* result() const { return results_[0]; }
302 EmbeddedContainer<LOperand*, R> results_;
306 // R = number of result operands (0 or 1).
307 // I = number of input operands.
308 // T = number of temporary operands.
309 template<int R, int I, int T>
310 class LTemplateInstruction : public LTemplateResultInstruction<R> {
312 EmbeddedContainer<LOperand*, I> inputs_;
313 EmbeddedContainer<LOperand*, T> temps_;
317 virtual int InputCount() FINAL OVERRIDE { return I; }
318 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
320 virtual int TempCount() FINAL OVERRIDE { return T; }
321 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return temps_[i]; }
325 class LGap : public LTemplateInstruction<0, 0, 0> {
327 explicit LGap(HBasicBlock* block) : block_(block) {
328 parallel_moves_[BEFORE] = NULL;
329 parallel_moves_[START] = NULL;
330 parallel_moves_[END] = NULL;
331 parallel_moves_[AFTER] = NULL;
334 // Can't use the DECLARE-macro here because of sub-classes.
335 virtual bool IsGap() const FINAL OVERRIDE { return true; }
336 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
337 static LGap* cast(LInstruction* instr) {
338 DCHECK(instr->IsGap());
339 return reinterpret_cast<LGap*>(instr);
342 bool IsRedundant() const;
344 HBasicBlock* block() const { return block_; }
351 FIRST_INNER_POSITION = BEFORE,
352 LAST_INNER_POSITION = AFTER
355 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
356 if (parallel_moves_[pos] == NULL) {
357 parallel_moves_[pos] = new(zone) LParallelMove(zone);
359 return parallel_moves_[pos];
362 LParallelMove* GetParallelMove(InnerPosition pos) {
363 return parallel_moves_[pos];
367 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
372 class LInstructionGap FINAL : public LGap {
374 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
376 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
377 return !IsRedundant();
380 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
384 class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
386 explicit LGoto(HBasicBlock* block) : block_(block) { }
388 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
389 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
390 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
391 virtual bool IsControl() const OVERRIDE { return true; }
393 int block_id() const { return block_->block_id(); }
394 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
398 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
405 class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
407 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
411 class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
414 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
418 class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
420 explicit LDummyUse(LOperand* value) {
423 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
427 class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
429 virtual bool IsControl() const OVERRIDE { return true; }
430 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
431 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
435 class LLabel FINAL : public LGap {
437 explicit LLabel(HBasicBlock* block)
438 : LGap(block), replacement_(NULL) { }
440 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
443 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
445 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
447 int block_id() const { return block()->block_id(); }
448 bool is_loop_header() const { return block()->IsLoopHeader(); }
449 bool is_osr_entry() const { return block()->is_osr_entry(); }
450 Label* label() { return &label_; }
451 LLabel* replacement() const { return replacement_; }
452 void set_replacement(LLabel* label) { replacement_ = label; }
453 bool HasReplacement() const { return replacement_ != NULL; }
457 LLabel* replacement_;
461 class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
463 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
466 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
470 class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
472 explicit LCallStub(LOperand* context) {
473 inputs_[0] = context;
476 LOperand* context() { return inputs_[0]; }
478 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
479 DECLARE_HYDROGEN_ACCESSOR(CallStub)
483 class LTailCallThroughMegamorphicCache FINAL
484 : public LTemplateInstruction<0, 3, 0> {
486 explicit LTailCallThroughMegamorphicCache(LOperand* context,
489 inputs_[0] = context;
490 inputs_[1] = receiver;
494 LOperand* context() { return inputs_[0]; }
495 LOperand* receiver() { return inputs_[1]; }
496 LOperand* name() { return inputs_[2]; }
498 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
499 "tail-call-through-megamorphic-cache")
500 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
504 class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
506 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
509 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
513 template<int I, int T>
514 class LControlInstruction: public LTemplateInstruction<0, I, T> {
516 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
518 virtual bool IsControl() const FINAL OVERRIDE { return true; }
520 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
521 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
523 int TrueDestination(LChunk* chunk) {
524 return chunk->LookupDestination(true_block_id());
526 int FalseDestination(LChunk* chunk) {
527 return chunk->LookupDestination(false_block_id());
530 Label* TrueLabel(LChunk* chunk) {
531 if (true_label_ == NULL) {
532 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
536 Label* FalseLabel(LChunk* chunk) {
537 if (false_label_ == NULL) {
538 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
544 int true_block_id() { return SuccessorAt(0)->block_id(); }
545 int false_block_id() { return SuccessorAt(1)->block_id(); }
548 HControlInstruction* hydrogen() {
549 return HControlInstruction::cast(this->hydrogen_value());
557 class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
559 LWrapReceiver(LOperand* receiver,
562 inputs_[0] = receiver;
563 inputs_[1] = function;
567 LOperand* receiver() { return inputs_[0]; }
568 LOperand* function() { return inputs_[1]; }
569 LOperand* temp() { return temps_[0]; }
571 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
572 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
576 class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
578 LApplyArguments(LOperand* function,
581 LOperand* elements) {
582 inputs_[0] = function;
583 inputs_[1] = receiver;
585 inputs_[3] = elements;
588 LOperand* function() { return inputs_[0]; }
589 LOperand* receiver() { return inputs_[1]; }
590 LOperand* length() { return inputs_[2]; }
591 LOperand* elements() { return inputs_[3]; }
593 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
597 class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
599 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
600 inputs_[0] = arguments;
605 LOperand* arguments() { return inputs_[0]; }
606 LOperand* length() { return inputs_[1]; }
607 LOperand* index() { return inputs_[2]; }
609 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
611 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
615 class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
617 explicit LArgumentsLength(LOperand* elements) {
618 inputs_[0] = elements;
621 LOperand* elements() { return inputs_[0]; }
623 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
627 class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
629 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
630 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
634 class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
636 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
640 class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
642 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
643 inputs_[0] = dividend;
647 LOperand* dividend() { return inputs_[0]; }
648 int32_t divisor() const { return divisor_; }
650 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
651 DECLARE_HYDROGEN_ACCESSOR(Mod)
658 class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
660 LModByConstI(LOperand* dividend,
664 inputs_[0] = dividend;
670 LOperand* dividend() { return inputs_[0]; }
671 int32_t divisor() const { return divisor_; }
672 LOperand* temp1() { return temps_[0]; }
673 LOperand* temp2() { return temps_[1]; }
675 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
676 DECLARE_HYDROGEN_ACCESSOR(Mod)
683 class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
685 LModI(LOperand* left, LOperand* right, LOperand* temp) {
691 LOperand* left() { return inputs_[0]; }
692 LOperand* right() { return inputs_[1]; }
693 LOperand* temp() { return temps_[0]; }
695 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
696 DECLARE_HYDROGEN_ACCESSOR(Mod)
700 class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
702 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
703 inputs_[0] = dividend;
707 LOperand* dividend() { return inputs_[0]; }
708 int32_t divisor() const { return divisor_; }
710 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
711 DECLARE_HYDROGEN_ACCESSOR(Div)
718 class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
720 LDivByConstI(LOperand* dividend,
724 inputs_[0] = dividend;
730 LOperand* dividend() { return inputs_[0]; }
731 int32_t divisor() const { return divisor_; }
732 LOperand* temp1() { return temps_[0]; }
733 LOperand* temp2() { return temps_[1]; }
735 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
736 DECLARE_HYDROGEN_ACCESSOR(Div)
743 class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
745 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
746 inputs_[0] = dividend;
747 inputs_[1] = divisor;
751 LOperand* dividend() { return inputs_[0]; }
752 LOperand* divisor() { return inputs_[1]; }
753 LOperand* temp() { return temps_[0]; }
755 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
756 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
760 class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
762 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
763 inputs_[0] = dividend;
767 LOperand* dividend() { return inputs_[0]; }
768 int32_t divisor() const { return divisor_; }
770 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
771 "flooring-div-by-power-of-2-i")
772 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
779 class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
781 LFlooringDivByConstI(LOperand* dividend,
786 inputs_[0] = dividend;
793 LOperand* dividend() { return inputs_[0]; }
794 int32_t divisor() const { return divisor_; }
795 LOperand* temp1() { return temps_[0]; }
796 LOperand* temp2() { return temps_[1]; }
797 LOperand* temp3() { return temps_[2]; }
799 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
800 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
807 class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
809 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
810 inputs_[0] = dividend;
811 inputs_[1] = divisor;
815 LOperand* dividend() { return inputs_[0]; }
816 LOperand* divisor() { return inputs_[1]; }
817 LOperand* temp() { return temps_[0]; }
819 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
820 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
824 class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
826 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
832 LOperand* left() { return inputs_[0]; }
833 LOperand* right() { return inputs_[1]; }
834 LOperand* temp() { return temps_[0]; }
836 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
837 DECLARE_HYDROGEN_ACCESSOR(Mul)
841 class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
843 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
848 LOperand* left() { return inputs_[0]; }
849 LOperand* right() { return inputs_[1]; }
851 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
852 "compare-numeric-and-branch")
853 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
855 Token::Value op() const { return hydrogen()->token(); }
856 bool is_double() const {
857 return hydrogen()->representation().IsDouble();
860 virtual void PrintDataTo(StringStream* stream);
864 class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
866 explicit LMathFloor(LOperand* value) {
870 LOperand* value() { return inputs_[0]; }
872 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
873 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
877 class LMathRound FINAL : public LTemplateInstruction<1, 1, 1> {
879 LMathRound(LOperand* value, LOperand* temp) {
884 LOperand* temp() { return temps_[0]; }
885 LOperand* value() { return inputs_[0]; }
887 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
888 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
892 class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
894 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
896 LOperand* value() { return inputs_[0]; }
898 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
902 class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
904 LMathAbs(LOperand* context, LOperand* value) {
905 inputs_[1] = context;
909 LOperand* context() { return inputs_[1]; }
910 LOperand* value() { return inputs_[0]; }
912 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
913 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
917 class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
919 explicit LMathLog(LOperand* value) {
923 LOperand* value() { return inputs_[0]; }
925 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
929 class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
931 explicit LMathClz32(LOperand* value) {
935 LOperand* value() { return inputs_[0]; }
937 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
941 class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
943 LMathExp(LOperand* value,
949 ExternalReference::InitializeMathExpData();
952 LOperand* value() { return inputs_[0]; }
953 LOperand* temp1() { return temps_[0]; }
954 LOperand* temp2() { return temps_[1]; }
956 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
960 class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 0> {
962 explicit LMathSqrt(LOperand* value) {
966 LOperand* value() { return inputs_[0]; }
968 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
972 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 1> {
974 LMathPowHalf(LOperand* value, LOperand* temp) {
979 LOperand* value() { return inputs_[0]; }
980 LOperand* temp() { return temps_[0]; }
982 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
986 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
988 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
993 LOperand* left() { return inputs_[0]; }
994 LOperand* right() { return inputs_[1]; }
996 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1000 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1002 explicit LCmpHoleAndBranch(LOperand* object) {
1003 inputs_[0] = object;
1006 LOperand* object() { return inputs_[0]; }
1008 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1009 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1013 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 1> {
1015 LCompareMinusZeroAndBranch(LOperand* value, LOperand* temp) {
1020 LOperand* value() { return inputs_[0]; }
1021 LOperand* temp() { return temps_[0]; }
1023 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1024 "cmp-minus-zero-and-branch")
1025 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1029 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1031 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1036 LOperand* value() { return inputs_[0]; }
1037 LOperand* temp() { return temps_[0]; }
1039 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1041 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1045 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1047 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1052 LOperand* value() { return inputs_[0]; }
1053 LOperand* temp() { return temps_[0]; }
1055 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1056 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1058 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1062 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1064 explicit LIsSmiAndBranch(LOperand* value) {
1068 LOperand* value() { return inputs_[0]; }
1070 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1073 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1077 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1079 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1084 LOperand* value() { return inputs_[0]; }
1085 LOperand* temp() { return temps_[0]; }
1087 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1088 "is-undetectable-and-branch")
1089 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1091 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1095 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1097 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1098 inputs_[0] = context;
1103 LOperand* context() { return inputs_[1]; }
1104 LOperand* left() { return inputs_[1]; }
1105 LOperand* right() { return inputs_[2]; }
1107 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1108 "string-compare-and-branch")
1109 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1111 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1113 Token::Value op() const { return hydrogen()->token(); }
1117 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1119 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1124 LOperand* value() { return inputs_[0]; }
1125 LOperand* temp() { return temps_[0]; }
1127 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1128 "has-instance-type-and-branch")
1129 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1131 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1135 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1137 explicit LGetCachedArrayIndex(LOperand* value) {
1141 LOperand* value() { return inputs_[0]; }
1143 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1144 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1148 class LHasCachedArrayIndexAndBranch FINAL
1149 : public LControlInstruction<1, 0> {
1151 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1155 LOperand* value() { return inputs_[0]; }
1157 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1158 "has-cached-array-index-and-branch")
1160 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1164 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1166 explicit LIsConstructCallAndBranch(LOperand* temp) {
1170 LOperand* temp() { return temps_[0]; }
1172 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1173 "is-construct-call-and-branch")
1177 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1179 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1185 LOperand* value() { return inputs_[0]; }
1186 LOperand* temp() { return temps_[0]; }
1187 LOperand* temp2() { return temps_[1]; }
1189 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1190 "class-of-test-and-branch")
1191 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1193 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1197 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1199 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1200 inputs_[0] = context;
1205 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1206 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1208 LOperand* context() { return inputs_[0]; }
1209 Token::Value op() const { return hydrogen()->token(); }
1213 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1215 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1216 inputs_[0] = context;
1221 LOperand* context() { return inputs_[0]; }
1223 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1227 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1229 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1230 inputs_[0] = context;
1235 LOperand* context() { return inputs_[0]; }
1236 LOperand* value() { return inputs_[1]; }
1237 LOperand* temp() { return temps_[0]; }
1239 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1240 "instance-of-known-global")
1241 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1243 Handle<JSFunction> function() const { return hydrogen()->function(); }
1244 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1245 return lazy_deopt_env_;
1247 virtual void SetDeferredLazyDeoptimizationEnvironment(
1248 LEnvironment* env) OVERRIDE {
1249 lazy_deopt_env_ = env;
1253 LEnvironment* lazy_deopt_env_;
1257 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1259 LBoundsCheck(LOperand* index, LOperand* length) {
1261 inputs_[1] = length;
1264 LOperand* index() { return inputs_[0]; }
1265 LOperand* length() { return inputs_[1]; }
1267 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1268 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1272 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1274 LBitI(LOperand* left, LOperand* right) {
1279 LOperand* left() { return inputs_[0]; }
1280 LOperand* right() { return inputs_[1]; }
1282 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1283 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1285 Token::Value op() const { return hydrogen()->op(); }
1289 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1291 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1292 : op_(op), can_deopt_(can_deopt) {
1297 LOperand* left() { return inputs_[0]; }
1298 LOperand* right() { return inputs_[1]; }
1300 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1302 Token::Value op() const { return op_; }
1303 bool can_deopt() const { return can_deopt_; }
1311 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1313 LSubI(LOperand* left, LOperand* right) {
1318 LOperand* left() { return inputs_[0]; }
1319 LOperand* right() { return inputs_[1]; }
1321 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1322 DECLARE_HYDROGEN_ACCESSOR(Sub)
1326 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1328 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1329 DECLARE_HYDROGEN_ACCESSOR(Constant)
1331 int32_t value() const { return hydrogen()->Integer32Value(); }
1335 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1337 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1338 DECLARE_HYDROGEN_ACCESSOR(Constant)
1340 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1344 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1346 explicit LConstantD(LOperand* temp) {
1350 LOperand* temp() { return temps_[0]; }
1352 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1353 DECLARE_HYDROGEN_ACCESSOR(Constant)
1355 double value() const { return hydrogen()->DoubleValue(); }
1359 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1361 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1362 DECLARE_HYDROGEN_ACCESSOR(Constant)
1364 ExternalReference value() const {
1365 return hydrogen()->ExternalReferenceValue();
1370 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1372 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1373 DECLARE_HYDROGEN_ACCESSOR(Constant)
1375 Handle<Object> value(Isolate* isolate) const {
1376 return hydrogen()->handle(isolate);
1381 class LBranch FINAL : public LControlInstruction<1, 1> {
1383 LBranch(LOperand* value, LOperand* temp) {
1388 LOperand* value() { return inputs_[0]; }
1389 LOperand* temp() { return temps_[0]; }
1391 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1392 DECLARE_HYDROGEN_ACCESSOR(Branch)
1394 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1398 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1400 explicit LCmpMapAndBranch(LOperand* value) {
1404 LOperand* value() { return inputs_[0]; }
1406 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1407 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1409 Handle<Map> map() const { return hydrogen()->map().handle(); }
1413 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1415 explicit LMapEnumLength(LOperand* value) {
1419 LOperand* value() { return inputs_[0]; }
1421 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1425 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1427 LDateField(LOperand* date, LOperand* temp, Smi* index)
1433 LOperand* date() { return inputs_[0]; }
1434 LOperand* temp() { return temps_[0]; }
1436 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1437 DECLARE_HYDROGEN_ACCESSOR(DateField)
1439 Smi* index() const { return index_; }
1446 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1448 LSeqStringGetChar(LOperand* string, LOperand* index) {
1449 inputs_[0] = string;
1453 LOperand* string() const { return inputs_[0]; }
1454 LOperand* index() const { return inputs_[1]; }
1456 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1457 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1461 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1463 LSeqStringSetChar(LOperand* context,
1467 inputs_[0] = context;
1468 inputs_[1] = string;
1473 LOperand* string() { return inputs_[1]; }
1474 LOperand* index() { return inputs_[2]; }
1475 LOperand* value() { return inputs_[3]; }
1477 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1478 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1482 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1484 LAddI(LOperand* left, LOperand* right) {
1489 LOperand* left() { return inputs_[0]; }
1490 LOperand* right() { return inputs_[1]; }
1492 static bool UseLea(HAdd* add) {
1493 return !add->CheckFlag(HValue::kCanOverflow) &&
1494 add->BetterLeftOperand()->UseCount() > 1;
1497 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1498 DECLARE_HYDROGEN_ACCESSOR(Add)
1502 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 0> {
1504 LMathMinMax(LOperand* left, LOperand* right) {
1509 LOperand* left() { return inputs_[0]; }
1510 LOperand* right() { return inputs_[1]; }
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 virtual Opcode opcode() const OVERRIDE {
1546 return LInstruction::kArithmeticD;
1548 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1549 virtual const char* Mnemonic() const OVERRIDE;
1556 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1558 LArithmeticT(Token::Value op,
1563 inputs_[0] = context;
1568 LOperand* context() { return inputs_[0]; }
1569 LOperand* left() { return inputs_[1]; }
1570 LOperand* right() { return inputs_[2]; }
1572 virtual Opcode opcode() const OVERRIDE {
1573 return LInstruction::kArithmeticT;
1575 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1576 virtual const char* Mnemonic() const OVERRIDE;
1578 Token::Value op() const { return op_; }
1585 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1587 explicit LReturn(LOperand* value,
1589 LOperand* parameter_count) {
1591 inputs_[1] = context;
1592 inputs_[2] = parameter_count;
1595 bool has_constant_parameter_count() {
1596 return parameter_count()->IsConstantOperand();
1598 LConstantOperand* constant_parameter_count() {
1599 DCHECK(has_constant_parameter_count());
1600 return LConstantOperand::cast(parameter_count());
1602 LOperand* parameter_count() { return inputs_[2]; }
1604 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1605 DECLARE_HYDROGEN_ACCESSOR(Return)
1609 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1611 explicit LLoadNamedField(LOperand* object) {
1612 inputs_[0] = object;
1615 LOperand* object() { return inputs_[0]; }
1617 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1618 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1622 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1624 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1625 inputs_[0] = context;
1626 inputs_[1] = object;
1630 LOperand* context() { return inputs_[0]; }
1631 LOperand* object() { return inputs_[1]; }
1632 LOperand* temp_vector() { return temps_[0]; }
1634 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1635 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1637 Handle<Object> name() const { return hydrogen()->name(); }
1641 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1643 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1644 inputs_[0] = function;
1648 LOperand* function() { return inputs_[0]; }
1649 LOperand* temp() { return temps_[0]; }
1651 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1656 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1658 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1659 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1661 Heap::RootListIndex index() const { return hydrogen()->index(); }
1665 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1667 LLoadKeyed(LOperand* elements, LOperand* key) {
1668 inputs_[0] = elements;
1671 LOperand* elements() { return inputs_[0]; }
1672 LOperand* key() { return inputs_[1]; }
1673 ElementsKind elements_kind() const {
1674 return hydrogen()->elements_kind();
1676 bool is_external() const {
1677 return hydrogen()->is_external();
1679 bool is_fixed_typed_array() const {
1680 return hydrogen()->is_fixed_typed_array();
1682 bool is_typed_elements() const {
1683 return is_external() || is_fixed_typed_array();
1686 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1687 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1689 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1690 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1692 return hydrogen()->key()->representation().IsTagged();
1697 inline static bool ExternalArrayOpRequiresTemp(
1698 Representation key_representation,
1699 ElementsKind elements_kind) {
1700 // Operations that require the key to be divided by two to be converted into
1701 // an index cannot fold the scale operation into a load and need an extra
1702 // temp register to do the work.
1703 return key_representation.IsSmi() &&
1704 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1705 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1706 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1707 elements_kind == UINT8_ELEMENTS ||
1708 elements_kind == INT8_ELEMENTS ||
1709 elements_kind == UINT8_CLAMPED_ELEMENTS);
1713 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1715 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1717 inputs_[0] = context;
1723 LOperand* context() { return inputs_[0]; }
1724 LOperand* object() { return inputs_[1]; }
1725 LOperand* key() { return inputs_[2]; }
1726 LOperand* temp_vector() { return temps_[0]; }
1728 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1729 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1733 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1735 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1736 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1740 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1742 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1744 inputs_[0] = context;
1745 inputs_[1] = global_object;
1749 LOperand* context() { return inputs_[0]; }
1750 LOperand* global_object() { return inputs_[1]; }
1751 LOperand* temp_vector() { return temps_[0]; }
1753 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1754 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1756 Handle<Object> name() const { return hydrogen()->name(); }
1757 bool for_typeof() const { return hydrogen()->for_typeof(); }
1761 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1763 explicit LStoreGlobalCell(LOperand* value) {
1767 LOperand* value() { return inputs_[0]; }
1769 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1770 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1774 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1776 explicit LLoadContextSlot(LOperand* context) {
1777 inputs_[0] = context;
1780 LOperand* context() { return inputs_[0]; }
1782 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1783 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1785 int slot_index() { return hydrogen()->slot_index(); }
1787 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1791 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1793 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1794 inputs_[0] = context;
1799 LOperand* context() { return inputs_[0]; }
1800 LOperand* value() { return inputs_[1]; }
1801 LOperand* temp() { return temps_[0]; }
1803 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1804 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1806 int slot_index() { return hydrogen()->slot_index(); }
1808 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1812 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1814 explicit LPushArgument(LOperand* value) {
1818 LOperand* value() { return inputs_[0]; }
1820 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1824 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1826 explicit LDrop(int count) : count_(count) { }
1828 int count() const { return count_; }
1830 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1837 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1839 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1840 inputs_[0] = function;
1841 inputs_[1] = code_object;
1844 LOperand* function() { return inputs_[0]; }
1845 LOperand* code_object() { return inputs_[1]; }
1847 virtual void PrintDataTo(StringStream* stream);
1849 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1850 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1854 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1856 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1857 inputs_[0] = base_object;
1858 inputs_[1] = offset;
1861 LOperand* base_object() const { return inputs_[0]; }
1862 LOperand* offset() const { return inputs_[1]; }
1864 virtual void PrintDataTo(StringStream* stream);
1866 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1870 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1872 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1873 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1877 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1879 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1880 DECLARE_HYDROGEN_ACCESSOR(Context)
1884 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1886 explicit LDeclareGlobals(LOperand* context) {
1887 inputs_[0] = context;
1890 LOperand* context() { return inputs_[0]; }
1892 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1893 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1897 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1899 explicit LCallJSFunction(LOperand* function) {
1900 inputs_[0] = function;
1903 LOperand* function() { return inputs_[0]; }
1905 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1906 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1908 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1910 int arity() const { return hydrogen()->argument_count() - 1; }
1914 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1916 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1917 const ZoneList<LOperand*>& operands, Zone* zone)
1918 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1919 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1920 inputs_.AddAll(operands, zone);
1923 LOperand* target() const { return inputs_[0]; }
1925 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1928 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1930 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1934 ZoneList<LOperand*> inputs_;
1936 // Iterator support.
1937 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1938 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1940 virtual int TempCount() FINAL OVERRIDE { return 0; }
1941 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1945 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1947 LInvokeFunction(LOperand* context, LOperand* function) {
1948 inputs_[0] = context;
1949 inputs_[1] = function;
1952 LOperand* context() { return inputs_[0]; }
1953 LOperand* function() { return inputs_[1]; }
1955 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1956 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1958 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1960 int arity() const { return hydrogen()->argument_count() - 1; }
1964 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1966 explicit LCallFunction(LOperand* context, LOperand* function) {
1967 inputs_[0] = context;
1968 inputs_[1] = function;
1971 LOperand* context() { return inputs_[0]; }
1972 LOperand* function() { return inputs_[1]; }
1974 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1975 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1977 int arity() const { return hydrogen()->argument_count() - 1; }
1981 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1983 LCallNew(LOperand* context, LOperand* constructor) {
1984 inputs_[0] = context;
1985 inputs_[1] = constructor;
1988 LOperand* context() { return inputs_[0]; }
1989 LOperand* constructor() { return inputs_[1]; }
1991 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1992 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1994 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1996 int arity() const { return hydrogen()->argument_count() - 1; }
2000 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2002 LCallNewArray(LOperand* context, LOperand* constructor) {
2003 inputs_[0] = context;
2004 inputs_[1] = constructor;
2007 LOperand* context() { return inputs_[0]; }
2008 LOperand* constructor() { return inputs_[1]; }
2010 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2011 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2013 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2015 int arity() const { return hydrogen()->argument_count() - 1; }
2019 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2021 explicit LCallRuntime(LOperand* context) {
2022 inputs_[0] = context;
2025 LOperand* context() { return inputs_[0]; }
2027 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2028 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2030 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2031 return save_doubles() == kDontSaveFPRegs;
2034 const Runtime::Function* function() const { return hydrogen()->function(); }
2035 int arity() const { return hydrogen()->argument_count(); }
2036 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2040 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2042 explicit LInteger32ToDouble(LOperand* value) {
2046 LOperand* value() { return inputs_[0]; }
2048 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2052 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2054 explicit LUint32ToDouble(LOperand* value) {
2058 LOperand* value() { return inputs_[0]; }
2060 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2064 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2066 LNumberTagI(LOperand* value, LOperand* temp) {
2071 LOperand* value() { return inputs_[0]; }
2072 LOperand* temp() { return temps_[0]; }
2074 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2078 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2080 LNumberTagU(LOperand* value, LOperand* temp) {
2085 LOperand* value() { return inputs_[0]; }
2086 LOperand* temp() { return temps_[0]; }
2088 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2092 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2094 LNumberTagD(LOperand* value, LOperand* temp) {
2099 LOperand* value() { return inputs_[0]; }
2100 LOperand* temp() { return temps_[0]; }
2102 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2103 DECLARE_HYDROGEN_ACCESSOR(Change)
2107 // Sometimes truncating conversion from a tagged value to an int32.
2108 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 1> {
2110 LDoubleToI(LOperand* value, LOperand* temp) {
2115 LOperand* value() { return inputs_[0]; }
2116 LOperand* temp() { return temps_[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, 1> {
2141 LTaggedToI(LOperand* value, LOperand* temp) {
2146 LOperand* value() { return inputs_[0]; }
2147 LOperand* temp() { return temps_[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 class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
2480 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2482 temps_[0] = temp_xmm;
2485 LOperand* unclamped() { return inputs_[0]; }
2486 LOperand* temp_xmm() { return temps_[0]; }
2488 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2492 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2494 explicit LCheckNonSmi(LOperand* value) {
2498 LOperand* value() { return inputs_[0]; }
2500 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2501 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2505 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2507 explicit LDoubleBits(LOperand* value) {
2511 LOperand* value() { return inputs_[0]; }
2513 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2514 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2518 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2520 LConstructDouble(LOperand* hi, LOperand* lo) {
2525 LOperand* hi() { return inputs_[0]; }
2526 LOperand* lo() { return inputs_[1]; }
2528 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2532 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2534 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2535 inputs_[0] = context;
2540 LOperand* context() { return inputs_[0]; }
2541 LOperand* size() { return inputs_[1]; }
2542 LOperand* temp() { return temps_[0]; }
2544 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2545 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2549 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2551 explicit LRegExpLiteral(LOperand* context) {
2552 inputs_[0] = context;
2555 LOperand* context() { return inputs_[0]; }
2557 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2558 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2562 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2564 explicit LFunctionLiteral(LOperand* context) {
2565 inputs_[0] = context;
2568 LOperand* context() { return inputs_[0]; }
2570 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2571 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2575 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2577 explicit LToFastProperties(LOperand* value) {
2581 LOperand* value() { return inputs_[0]; }
2583 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2584 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2588 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2590 LTypeof(LOperand* context, LOperand* value) {
2591 inputs_[0] = context;
2595 LOperand* context() { return inputs_[0]; }
2596 LOperand* value() { return inputs_[1]; }
2598 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2602 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2604 explicit LTypeofIsAndBranch(LOperand* value) {
2608 LOperand* value() { return inputs_[0]; }
2610 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2611 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2613 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2615 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2619 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2621 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2624 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2628 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2630 explicit LStackCheck(LOperand* context) {
2631 inputs_[0] = context;
2634 LOperand* context() { return inputs_[0]; }
2636 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2637 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2639 Label* done_label() { return &done_label_; }
2646 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2648 LForInPrepareMap(LOperand* context, LOperand* object) {
2649 inputs_[0] = context;
2650 inputs_[1] = object;
2653 LOperand* context() { return inputs_[0]; }
2654 LOperand* object() { return inputs_[1]; }
2656 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2660 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2662 explicit LForInCacheArray(LOperand* map) {
2666 LOperand* map() { return inputs_[0]; }
2668 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2671 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2676 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2678 LCheckMapValue(LOperand* value, LOperand* map) {
2683 LOperand* value() { return inputs_[0]; }
2684 LOperand* map() { return inputs_[1]; }
2686 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2690 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2692 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2693 inputs_[0] = object;
2697 LOperand* object() { return inputs_[0]; }
2698 LOperand* index() { return inputs_[1]; }
2700 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2704 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2706 explicit LStoreFrameContext(LOperand* context) {
2707 inputs_[0] = context;
2710 LOperand* context() { return inputs_[0]; }
2712 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2716 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2718 LAllocateBlockContext(LOperand* context, LOperand* function) {
2719 inputs_[0] = context;
2720 inputs_[1] = function;
2723 LOperand* context() { return inputs_[0]; }
2724 LOperand* function() { return inputs_[1]; }
2726 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2728 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2729 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2733 class LChunkBuilder;
2734 class LPlatformChunk FINAL : public LChunk {
2736 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2737 : LChunk(info, graph),
2738 num_double_slots_(0) { }
2740 int GetNextSpillIndex(RegisterKind kind);
2741 LOperand* GetNextSpillSlot(RegisterKind kind);
2743 int num_double_slots() const { return num_double_slots_; }
2746 int num_double_slots_;
2750 class LChunkBuilder FINAL : public LChunkBuilderBase {
2752 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2753 : LChunkBuilderBase(info, graph),
2754 current_instruction_(NULL),
2755 current_block_(NULL),
2757 allocator_(allocator) {}
2759 // Build the sequence for the graph.
2760 LPlatformChunk* Build();
2762 // Declare methods that deal with the individual node types.
2763 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2764 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2767 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2768 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2769 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2770 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2771 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2772 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2773 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2774 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2775 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2776 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2777 LInstruction* DoDivByConstI(HDiv* instr);
2778 LInstruction* DoDivI(HDiv* instr);
2779 LInstruction* DoModByPowerOf2I(HMod* instr);
2780 LInstruction* DoModByConstI(HMod* instr);
2781 LInstruction* DoModI(HMod* instr);
2782 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2783 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2784 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2787 // Methods for getting operands for Use / Define / Temp.
2788 LUnallocated* ToUnallocated(Register reg);
2789 LUnallocated* ToUnallocated(XMMRegister reg);
2791 // Methods for setting up define-use relationships.
2792 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2793 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2794 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2795 XMMRegister fixed_register);
2797 // A value that is guaranteed to be allocated to a register.
2798 // Operand created by UseRegister is guaranteed to be live until the end of
2799 // instruction. This means that register allocator will not reuse it's
2800 // register for any other operand inside instruction.
2801 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2802 // instruction start. Register allocator is free to assign the same register
2803 // to some other operand used inside instruction (i.e. temporary or
2805 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2806 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2808 // An input operand in a register that may be trashed.
2809 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2811 // An input operand in a register or stack slot.
2812 MUST_USE_RESULT LOperand* Use(HValue* value);
2813 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2815 // An input operand in a register, stack slot or a constant operand.
2816 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2817 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2819 // An input operand in a fixed register or a constant operand.
2820 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2821 Register fixed_register);
2823 // An input operand in a register or a constant operand.
2824 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2825 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2827 // An input operand in a constant operand.
2828 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2830 // An input operand in register, stack slot or a constant operand.
2831 // Will not be moved to a register even if one is freely available.
2832 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2834 // Temporary operand that must be in a register.
2835 MUST_USE_RESULT LUnallocated* TempRegister();
2836 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2837 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2839 // Methods for setting up define-use relationships.
2840 // Return the same instruction that they are passed.
2841 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2842 LUnallocated* result);
2843 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2844 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2846 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2847 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2849 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2851 // Assigns an environment to an instruction. An instruction which can
2852 // deoptimize must have an environment.
2853 LInstruction* AssignEnvironment(LInstruction* instr);
2854 // Assigns a pointer map to an instruction. An instruction which can
2855 // trigger a GC or a lazy deoptimization must have a pointer map.
2856 LInstruction* AssignPointerMap(LInstruction* instr);
2858 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2860 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2862 // Marks a call for the register allocator. Assigns a pointer map to
2863 // support GC and lazy deoptimization. Assigns an environment to support
2864 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2865 LInstruction* MarkAsCall(
2866 LInstruction* instr,
2867 HInstruction* hinstr,
2868 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2870 void VisitInstruction(HInstruction* current);
2871 void AddInstruction(LInstruction* instr, HInstruction* current);
2873 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2874 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2875 LInstruction* DoArithmeticD(Token::Value op,
2876 HArithmeticBinaryOperation* instr);
2877 LInstruction* DoArithmeticT(Token::Value op,
2878 HBinaryOperation* instr);
2880 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2882 HInstruction* current_instruction_;
2883 HBasicBlock* current_block_;
2884 HBasicBlock* next_block_;
2885 LAllocator* allocator_;
2887 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2890 #undef DECLARE_HYDROGEN_ACCESSOR
2891 #undef DECLARE_CONCRETE_INSTRUCTION
2893 } } // namespace v8::internal
2895 #endif // V8_IA32_LITHIUM_IA32_H_