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, 2> {
978 explicit LMathSqrt(LOperand* value,
986 LOperand* value() { return inputs_[0]; }
987 LOperand* temp1() { return temps_[0]; }
988 LOperand* temp2() { return temps_[1]; }
990 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
994 class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
996 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
998 LOperand* value() { return inputs_[0]; }
1000 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
1004 class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
1006 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
1011 LOperand* left() { return inputs_[0]; }
1012 LOperand* right() { return inputs_[1]; }
1014 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1018 class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1020 explicit LCmpHoleAndBranch(LOperand* object) {
1021 inputs_[0] = object;
1024 LOperand* object() { return inputs_[0]; }
1026 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1027 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1031 class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1033 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1035 LOperand* value() { return inputs_[0]; }
1037 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1038 "cmp-minus-zero-and-branch")
1039 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1043 class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1045 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1050 LOperand* value() { return inputs_[0]; }
1051 LOperand* temp() { return temps_[0]; }
1053 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1055 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1059 class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1061 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1066 LOperand* value() { return inputs_[0]; }
1067 LOperand* temp() { return temps_[0]; }
1069 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1070 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1072 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1076 class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1078 explicit LIsSmiAndBranch(LOperand* value) {
1082 LOperand* value() { return inputs_[0]; }
1084 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1085 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1087 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1091 class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1093 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1098 LOperand* value() { return inputs_[0]; }
1099 LOperand* temp() { return temps_[0]; }
1101 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1102 "is-undetectable-and-branch")
1103 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1105 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1109 class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1111 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1112 inputs_[0] = context;
1117 LOperand* context() { return inputs_[1]; }
1118 LOperand* left() { return inputs_[1]; }
1119 LOperand* right() { return inputs_[2]; }
1121 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1122 "string-compare-and-branch")
1123 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1125 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1127 Token::Value op() const { return hydrogen()->token(); }
1131 class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1133 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1138 LOperand* value() { return inputs_[0]; }
1139 LOperand* temp() { return temps_[0]; }
1141 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1142 "has-instance-type-and-branch")
1143 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1145 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1149 class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1151 explicit LGetCachedArrayIndex(LOperand* value) {
1155 LOperand* value() { return inputs_[0]; }
1157 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1158 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1162 class LHasCachedArrayIndexAndBranch FINAL
1163 : public LControlInstruction<1, 0> {
1165 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1169 LOperand* value() { return inputs_[0]; }
1171 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1172 "has-cached-array-index-and-branch")
1174 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1178 class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1180 explicit LIsConstructCallAndBranch(LOperand* temp) {
1184 LOperand* temp() { return temps_[0]; }
1186 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1187 "is-construct-call-and-branch")
1191 class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1193 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1199 LOperand* value() { return inputs_[0]; }
1200 LOperand* temp() { return temps_[0]; }
1201 LOperand* temp2() { return temps_[1]; }
1203 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1204 "class-of-test-and-branch")
1205 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1207 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1211 class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1213 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1214 inputs_[0] = context;
1219 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1220 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1222 LOperand* context() { return inputs_[0]; }
1223 Token::Value op() const { return hydrogen()->token(); }
1227 class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1229 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1230 inputs_[0] = context;
1235 LOperand* context() { return inputs_[0]; }
1237 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1241 class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1243 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1244 inputs_[0] = context;
1249 LOperand* context() { return inputs_[0]; }
1250 LOperand* value() { return inputs_[1]; }
1251 LOperand* temp() { return temps_[0]; }
1253 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1254 "instance-of-known-global")
1255 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1257 Handle<JSFunction> function() const { return hydrogen()->function(); }
1258 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1259 return lazy_deopt_env_;
1261 virtual void SetDeferredLazyDeoptimizationEnvironment(
1262 LEnvironment* env) OVERRIDE {
1263 lazy_deopt_env_ = env;
1267 LEnvironment* lazy_deopt_env_;
1271 class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1273 LBoundsCheck(LOperand* index, LOperand* length) {
1275 inputs_[1] = length;
1278 LOperand* index() { return inputs_[0]; }
1279 LOperand* length() { return inputs_[1]; }
1281 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1282 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1286 class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1288 LBitI(LOperand* left, LOperand* right) {
1293 LOperand* left() { return inputs_[0]; }
1294 LOperand* right() { return inputs_[1]; }
1296 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1297 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1299 Token::Value op() const { return hydrogen()->op(); }
1303 class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1305 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1306 : op_(op), can_deopt_(can_deopt) {
1311 LOperand* left() { return inputs_[0]; }
1312 LOperand* right() { return inputs_[1]; }
1314 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1316 Token::Value op() const { return op_; }
1317 bool can_deopt() const { return can_deopt_; }
1325 class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1327 LSubI(LOperand* left, LOperand* right) {
1332 LOperand* left() { return inputs_[0]; }
1333 LOperand* right() { return inputs_[1]; }
1335 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1336 DECLARE_HYDROGEN_ACCESSOR(Sub)
1340 class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1342 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1343 DECLARE_HYDROGEN_ACCESSOR(Constant)
1345 int32_t value() const { return hydrogen()->Integer32Value(); }
1349 class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1351 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1352 DECLARE_HYDROGEN_ACCESSOR(Constant)
1354 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1358 class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1360 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1361 DECLARE_HYDROGEN_ACCESSOR(Constant)
1363 double value() const { return hydrogen()->DoubleValue(); }
1367 class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1369 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1370 DECLARE_HYDROGEN_ACCESSOR(Constant)
1372 ExternalReference value() const {
1373 return hydrogen()->ExternalReferenceValue();
1378 class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1380 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1381 DECLARE_HYDROGEN_ACCESSOR(Constant)
1383 Handle<Object> value(Isolate* isolate) const {
1384 return hydrogen()->handle(isolate);
1389 class LBranch FINAL : public LControlInstruction<1, 1> {
1391 LBranch(LOperand* value, LOperand* temp) {
1396 LOperand* value() { return inputs_[0]; }
1397 LOperand* temp() { return temps_[0]; }
1399 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1400 DECLARE_HYDROGEN_ACCESSOR(Branch)
1402 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1406 class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1408 explicit LCmpMapAndBranch(LOperand* value) {
1412 LOperand* value() { return inputs_[0]; }
1414 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1415 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1417 Handle<Map> map() const { return hydrogen()->map().handle(); }
1421 class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1423 explicit LMapEnumLength(LOperand* value) {
1427 LOperand* value() { return inputs_[0]; }
1429 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1433 class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1435 LDateField(LOperand* date, LOperand* temp, Smi* index)
1441 LOperand* date() { return inputs_[0]; }
1442 LOperand* temp() { return temps_[0]; }
1444 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1445 DECLARE_HYDROGEN_ACCESSOR(DateField)
1447 Smi* index() const { return index_; }
1454 class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1456 LSeqStringGetChar(LOperand* string, LOperand* index) {
1457 inputs_[0] = string;
1461 LOperand* string() const { return inputs_[0]; }
1462 LOperand* index() const { return inputs_[1]; }
1464 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1465 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1469 class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1471 LSeqStringSetChar(LOperand* context,
1475 inputs_[0] = context;
1476 inputs_[1] = string;
1481 LOperand* string() { return inputs_[1]; }
1482 LOperand* index() { return inputs_[2]; }
1483 LOperand* value() { return inputs_[3]; }
1485 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1486 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1490 class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1492 LAddI(LOperand* left, LOperand* right) {
1497 LOperand* left() { return inputs_[0]; }
1498 LOperand* right() { return inputs_[1]; }
1500 static bool UseLea(HAdd* add) {
1501 return !add->CheckFlag(HValue::kCanOverflow) &&
1502 add->BetterLeftOperand()->UseCount() > 1;
1505 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1506 DECLARE_HYDROGEN_ACCESSOR(Add)
1510 class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 1> {
1512 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1518 LOperand* left() { return inputs_[0]; }
1519 LOperand* right() { return inputs_[1]; }
1520 LOperand* temp() { return temps_[0]; }
1522 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1523 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1527 class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1529 LPower(LOperand* left, LOperand* right) {
1534 LOperand* left() { return inputs_[0]; }
1535 LOperand* right() { return inputs_[1]; }
1537 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1538 DECLARE_HYDROGEN_ACCESSOR(Power)
1542 class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1544 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1550 LOperand* left() { return inputs_[0]; }
1551 LOperand* right() { return inputs_[1]; }
1553 Token::Value op() const { return op_; }
1555 virtual Opcode opcode() const OVERRIDE {
1556 return LInstruction::kArithmeticD;
1558 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1559 virtual const char* Mnemonic() const OVERRIDE;
1566 class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1568 LArithmeticT(Token::Value op,
1573 inputs_[0] = context;
1578 LOperand* context() { return inputs_[0]; }
1579 LOperand* left() { return inputs_[1]; }
1580 LOperand* right() { return inputs_[2]; }
1582 virtual Opcode opcode() const OVERRIDE {
1583 return LInstruction::kArithmeticT;
1585 virtual void CompileToNative(LCodeGen* generator) OVERRIDE;
1586 virtual const char* Mnemonic() const OVERRIDE;
1588 Token::Value op() const { return op_; }
1595 class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1597 explicit LReturn(LOperand* value,
1599 LOperand* parameter_count) {
1601 inputs_[1] = context;
1602 inputs_[2] = parameter_count;
1605 bool has_constant_parameter_count() {
1606 return parameter_count()->IsConstantOperand();
1608 LConstantOperand* constant_parameter_count() {
1609 DCHECK(has_constant_parameter_count());
1610 return LConstantOperand::cast(parameter_count());
1612 LOperand* parameter_count() { return inputs_[2]; }
1614 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1615 DECLARE_HYDROGEN_ACCESSOR(Return)
1619 class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1621 explicit LLoadNamedField(LOperand* object) {
1622 inputs_[0] = object;
1625 LOperand* object() { return inputs_[0]; }
1627 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1628 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1632 class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1634 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1635 inputs_[0] = context;
1636 inputs_[1] = object;
1640 LOperand* context() { return inputs_[0]; }
1641 LOperand* object() { return inputs_[1]; }
1642 LOperand* temp_vector() { return temps_[0]; }
1644 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1645 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1647 Handle<Object> name() const { return hydrogen()->name(); }
1651 class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1653 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1654 inputs_[0] = function;
1658 LOperand* function() { return inputs_[0]; }
1659 LOperand* temp() { return temps_[0]; }
1661 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1662 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1666 class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1668 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1669 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1671 Heap::RootListIndex index() const { return hydrogen()->index(); }
1675 class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1677 LLoadKeyed(LOperand* elements, LOperand* key) {
1678 inputs_[0] = elements;
1681 LOperand* elements() { return inputs_[0]; }
1682 LOperand* key() { return inputs_[1]; }
1683 ElementsKind elements_kind() const {
1684 return hydrogen()->elements_kind();
1686 bool is_external() const {
1687 return hydrogen()->is_external();
1689 bool is_fixed_typed_array() const {
1690 return hydrogen()->is_fixed_typed_array();
1692 bool is_typed_elements() const {
1693 return is_external() || is_fixed_typed_array();
1696 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1697 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1699 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1700 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1702 return hydrogen()->key()->representation().IsTagged();
1707 inline static bool ExternalArrayOpRequiresTemp(
1708 Representation key_representation,
1709 ElementsKind elements_kind) {
1710 // Operations that require the key to be divided by two to be converted into
1711 // an index cannot fold the scale operation into a load and need an extra
1712 // temp register to do the work.
1713 return key_representation.IsSmi() &&
1714 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1715 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1716 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1717 elements_kind == UINT8_ELEMENTS ||
1718 elements_kind == INT8_ELEMENTS ||
1719 elements_kind == UINT8_CLAMPED_ELEMENTS);
1723 class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1725 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1727 inputs_[0] = context;
1733 LOperand* context() { return inputs_[0]; }
1734 LOperand* object() { return inputs_[1]; }
1735 LOperand* key() { return inputs_[2]; }
1736 LOperand* temp_vector() { return temps_[0]; }
1738 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1739 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1743 class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1745 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1746 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1750 class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1752 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1754 inputs_[0] = context;
1755 inputs_[1] = global_object;
1759 LOperand* context() { return inputs_[0]; }
1760 LOperand* global_object() { return inputs_[1]; }
1761 LOperand* temp_vector() { return temps_[0]; }
1763 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1764 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1766 Handle<Object> name() const { return hydrogen()->name(); }
1767 bool for_typeof() const { return hydrogen()->for_typeof(); }
1771 class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1773 explicit LStoreGlobalCell(LOperand* value) {
1777 LOperand* value() { return inputs_[0]; }
1779 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1780 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1784 class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1786 explicit LLoadContextSlot(LOperand* context) {
1787 inputs_[0] = context;
1790 LOperand* context() { return inputs_[0]; }
1792 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1793 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1795 int slot_index() { return hydrogen()->slot_index(); }
1797 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1801 class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1803 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1804 inputs_[0] = context;
1809 LOperand* context() { return inputs_[0]; }
1810 LOperand* value() { return inputs_[1]; }
1811 LOperand* temp() { return temps_[0]; }
1813 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1814 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1816 int slot_index() { return hydrogen()->slot_index(); }
1818 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1822 class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1824 explicit LPushArgument(LOperand* value) {
1828 LOperand* value() { return inputs_[0]; }
1830 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1834 class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1836 explicit LDrop(int count) : count_(count) { }
1838 int count() const { return count_; }
1840 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1847 class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1849 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1850 inputs_[0] = function;
1851 inputs_[1] = code_object;
1854 LOperand* function() { return inputs_[0]; }
1855 LOperand* code_object() { return inputs_[1]; }
1857 virtual void PrintDataTo(StringStream* stream);
1859 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1860 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1864 class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1866 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1867 inputs_[0] = base_object;
1868 inputs_[1] = offset;
1871 LOperand* base_object() const { return inputs_[0]; }
1872 LOperand* offset() const { return inputs_[1]; }
1874 virtual void PrintDataTo(StringStream* stream);
1876 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1880 class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1882 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1883 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1887 class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1889 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1890 DECLARE_HYDROGEN_ACCESSOR(Context)
1894 class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1896 explicit LDeclareGlobals(LOperand* context) {
1897 inputs_[0] = context;
1900 LOperand* context() { return inputs_[0]; }
1902 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1903 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1907 class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1909 explicit LCallJSFunction(LOperand* function) {
1910 inputs_[0] = function;
1913 LOperand* function() { return inputs_[0]; }
1915 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1916 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1918 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1920 int arity() const { return hydrogen()->argument_count() - 1; }
1924 class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1926 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1927 const ZoneList<LOperand*>& operands, Zone* zone)
1928 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1929 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1930 inputs_.AddAll(operands, zone);
1933 LOperand* target() const { return inputs_[0]; }
1935 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1938 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1940 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1942 int arity() const { return hydrogen()->argument_count() - 1; }
1944 ZoneList<LOperand*> inputs_;
1946 // Iterator support.
1947 virtual int InputCount() FINAL OVERRIDE { return inputs_.length(); }
1948 virtual LOperand* InputAt(int i) FINAL OVERRIDE { return inputs_[i]; }
1950 virtual int TempCount() FINAL OVERRIDE { return 0; }
1951 virtual LOperand* TempAt(int i) FINAL OVERRIDE { return NULL; }
1955 class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1957 LInvokeFunction(LOperand* context, LOperand* function) {
1958 inputs_[0] = context;
1959 inputs_[1] = function;
1962 LOperand* context() { return inputs_[0]; }
1963 LOperand* function() { return inputs_[1]; }
1965 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1966 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1968 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
1970 int arity() const { return hydrogen()->argument_count() - 1; }
1974 class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1976 explicit LCallFunction(LOperand* context, LOperand* function) {
1977 inputs_[0] = context;
1978 inputs_[1] = function;
1981 LOperand* context() { return inputs_[0]; }
1982 LOperand* function() { return inputs_[1]; }
1984 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1985 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1987 int arity() const { return hydrogen()->argument_count() - 1; }
1991 class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1993 LCallNew(LOperand* context, LOperand* constructor) {
1994 inputs_[0] = context;
1995 inputs_[1] = constructor;
1998 LOperand* context() { return inputs_[0]; }
1999 LOperand* constructor() { return inputs_[1]; }
2001 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
2002 DECLARE_HYDROGEN_ACCESSOR(CallNew)
2004 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2006 int arity() const { return hydrogen()->argument_count() - 1; }
2010 class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
2012 LCallNewArray(LOperand* context, LOperand* constructor) {
2013 inputs_[0] = context;
2014 inputs_[1] = constructor;
2017 LOperand* context() { return inputs_[0]; }
2018 LOperand* constructor() { return inputs_[1]; }
2020 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2021 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2023 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2025 int arity() const { return hydrogen()->argument_count() - 1; }
2029 class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2031 explicit LCallRuntime(LOperand* context) {
2032 inputs_[0] = context;
2035 LOperand* context() { return inputs_[0]; }
2037 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2038 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2040 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
2041 return save_doubles() == kDontSaveFPRegs;
2044 const Runtime::Function* function() const { return hydrogen()->function(); }
2045 int arity() const { return hydrogen()->argument_count(); }
2046 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2050 class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2052 explicit LInteger32ToDouble(LOperand* value) {
2056 LOperand* value() { return inputs_[0]; }
2058 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2062 class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2064 explicit LUint32ToDouble(LOperand* value) {
2068 LOperand* value() { return inputs_[0]; }
2070 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2074 class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2076 LNumberTagI(LOperand* value, LOperand* temp) {
2081 LOperand* value() { return inputs_[0]; }
2082 LOperand* temp() { return temps_[0]; }
2084 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2088 class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2090 LNumberTagU(LOperand* value, LOperand* temp) {
2095 LOperand* value() { return inputs_[0]; }
2096 LOperand* temp() { return temps_[0]; }
2098 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2102 class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2104 LNumberTagD(LOperand* value, LOperand* temp) {
2109 LOperand* value() { return inputs_[0]; }
2110 LOperand* temp() { return temps_[0]; }
2112 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2113 DECLARE_HYDROGEN_ACCESSOR(Change)
2117 // Sometimes truncating conversion from a tagged value to an int32.
2118 class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2120 explicit LDoubleToI(LOperand* value) {
2124 LOperand* value() { return inputs_[0]; }
2126 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2127 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2129 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2133 class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2135 explicit LDoubleToSmi(LOperand* value) {
2139 LOperand* value() { return inputs_[0]; }
2141 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2142 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2146 // Truncating conversion from a tagged value to an int32.
2147 class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2149 explicit LTaggedToI(LOperand* value) {
2153 LOperand* value() { return inputs_[0]; }
2155 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2156 DECLARE_HYDROGEN_ACCESSOR(Change)
2158 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2162 class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2164 explicit LSmiTag(LOperand* value) {
2168 LOperand* value() { return inputs_[0]; }
2170 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2171 DECLARE_HYDROGEN_ACCESSOR(Change)
2175 class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2177 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2182 LOperand* value() { return inputs_[0]; }
2183 LOperand* temp() { return temps_[0]; }
2185 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2186 DECLARE_HYDROGEN_ACCESSOR(Change);
2190 class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2192 LSmiUntag(LOperand* value, bool needs_check)
2193 : needs_check_(needs_check) {
2197 LOperand* value() { return inputs_[0]; }
2199 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2201 bool needs_check() const { return needs_check_; }
2208 class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2210 LStoreNamedField(LOperand* obj,
2213 LOperand* temp_map) {
2217 temps_[1] = temp_map;
2220 LOperand* object() { return inputs_[0]; }
2221 LOperand* value() { return inputs_[1]; }
2222 LOperand* temp() { return temps_[0]; }
2223 LOperand* temp_map() { return temps_[1]; }
2225 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2226 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2228 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2232 class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2234 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2235 inputs_[0] = context;
2236 inputs_[1] = object;
2240 LOperand* context() { return inputs_[0]; }
2241 LOperand* object() { return inputs_[1]; }
2242 LOperand* value() { return inputs_[2]; }
2244 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2245 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2247 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2248 Handle<Object> name() const { return hydrogen()->name(); }
2249 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2253 class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2255 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2261 bool is_external() const { return hydrogen()->is_external(); }
2262 bool is_fixed_typed_array() const {
2263 return hydrogen()->is_fixed_typed_array();
2265 bool is_typed_elements() const {
2266 return is_external() || is_fixed_typed_array();
2268 LOperand* elements() { return inputs_[0]; }
2269 LOperand* key() { return inputs_[1]; }
2270 LOperand* value() { return inputs_[2]; }
2271 ElementsKind elements_kind() const {
2272 return hydrogen()->elements_kind();
2275 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2276 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2278 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2279 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2280 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2284 class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2286 LStoreKeyedGeneric(LOperand* context,
2290 inputs_[0] = context;
2291 inputs_[1] = object;
2296 LOperand* context() { return inputs_[0]; }
2297 LOperand* object() { return inputs_[1]; }
2298 LOperand* key() { return inputs_[2]; }
2299 LOperand* value() { return inputs_[3]; }
2301 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2302 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2304 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2306 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2310 class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2312 LTransitionElementsKind(LOperand* object,
2314 LOperand* new_map_temp,
2316 inputs_[0] = object;
2317 inputs_[1] = context;
2318 temps_[0] = new_map_temp;
2322 LOperand* context() { return inputs_[1]; }
2323 LOperand* object() { return inputs_[0]; }
2324 LOperand* new_map_temp() { return temps_[0]; }
2325 LOperand* temp() { return temps_[1]; }
2327 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2328 "transition-elements-kind")
2329 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2331 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2333 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2334 Handle<Map> transitioned_map() {
2335 return hydrogen()->transitioned_map().handle();
2337 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2338 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2342 class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2344 LTrapAllocationMemento(LOperand* object,
2346 inputs_[0] = object;
2350 LOperand* object() { return inputs_[0]; }
2351 LOperand* temp() { return temps_[0]; }
2353 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2354 "trap-allocation-memento")
2358 class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2360 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2361 inputs_[0] = context;
2366 LOperand* context() { return inputs_[0]; }
2367 LOperand* left() { return inputs_[1]; }
2368 LOperand* right() { return inputs_[2]; }
2370 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2371 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2375 class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2377 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2378 inputs_[0] = context;
2379 inputs_[1] = string;
2383 LOperand* context() { return inputs_[0]; }
2384 LOperand* string() { return inputs_[1]; }
2385 LOperand* index() { return inputs_[2]; }
2387 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2388 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2392 class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2394 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2395 inputs_[0] = context;
2396 inputs_[1] = char_code;
2399 LOperand* context() { return inputs_[0]; }
2400 LOperand* char_code() { return inputs_[1]; }
2402 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2403 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2407 class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2409 explicit LCheckValue(LOperand* value) {
2413 LOperand* value() { return inputs_[0]; }
2415 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2416 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2420 class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2422 LCheckInstanceType(LOperand* value, LOperand* temp) {
2427 LOperand* value() { return inputs_[0]; }
2428 LOperand* temp() { return temps_[0]; }
2430 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2431 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2435 class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2437 explicit LCheckMaps(LOperand* value = NULL) {
2441 LOperand* value() { return inputs_[0]; }
2443 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2444 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2448 class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2450 explicit LCheckSmi(LOperand* value) {
2454 LOperand* value() { return inputs_[0]; }
2456 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2460 class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2462 explicit LClampDToUint8(LOperand* value) {
2466 LOperand* unclamped() { return inputs_[0]; }
2468 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2472 class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2474 explicit LClampIToUint8(LOperand* value) {
2478 LOperand* unclamped() { return inputs_[0]; }
2480 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2484 // Truncating conversion from a tagged value to an int32.
2485 class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2487 LClampTToUint8NoSSE2(LOperand* unclamped,
2491 inputs_[0] = unclamped;
2497 LOperand* unclamped() { return inputs_[0]; }
2498 LOperand* scratch() { return temps_[0]; }
2499 LOperand* scratch2() { return temps_[1]; }
2500 LOperand* scratch3() { return temps_[2]; }
2502 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2503 "clamp-t-to-uint8-nosse2")
2504 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2508 class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2510 explicit LCheckNonSmi(LOperand* value) {
2514 LOperand* value() { return inputs_[0]; }
2516 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2517 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2521 class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2523 explicit LDoubleBits(LOperand* value) {
2527 LOperand* value() { return inputs_[0]; }
2529 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2530 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2534 class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2536 LConstructDouble(LOperand* hi, LOperand* lo) {
2541 LOperand* hi() { return inputs_[0]; }
2542 LOperand* lo() { return inputs_[1]; }
2544 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2548 class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2550 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2551 inputs_[0] = context;
2556 LOperand* context() { return inputs_[0]; }
2557 LOperand* size() { return inputs_[1]; }
2558 LOperand* temp() { return temps_[0]; }
2560 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2561 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2565 class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2567 explicit LRegExpLiteral(LOperand* context) {
2568 inputs_[0] = context;
2571 LOperand* context() { return inputs_[0]; }
2573 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2574 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2578 class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2580 explicit LFunctionLiteral(LOperand* context) {
2581 inputs_[0] = context;
2584 LOperand* context() { return inputs_[0]; }
2586 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2587 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2591 class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2593 explicit LToFastProperties(LOperand* value) {
2597 LOperand* value() { return inputs_[0]; }
2599 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2600 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2604 class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2606 LTypeof(LOperand* context, LOperand* value) {
2607 inputs_[0] = context;
2611 LOperand* context() { return inputs_[0]; }
2612 LOperand* value() { return inputs_[1]; }
2614 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2618 class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2620 explicit LTypeofIsAndBranch(LOperand* value) {
2624 LOperand* value() { return inputs_[0]; }
2626 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2627 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2629 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2631 virtual void PrintDataTo(StringStream* stream) OVERRIDE;
2635 class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2637 virtual bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
2640 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2644 class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2646 explicit LStackCheck(LOperand* context) {
2647 inputs_[0] = context;
2650 LOperand* context() { return inputs_[0]; }
2652 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2653 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2655 Label* done_label() { return &done_label_; }
2662 class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2664 LForInPrepareMap(LOperand* context, LOperand* object) {
2665 inputs_[0] = context;
2666 inputs_[1] = object;
2669 LOperand* context() { return inputs_[0]; }
2670 LOperand* object() { return inputs_[1]; }
2672 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2676 class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2678 explicit LForInCacheArray(LOperand* map) {
2682 LOperand* map() { return inputs_[0]; }
2684 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2687 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2692 class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2694 LCheckMapValue(LOperand* value, LOperand* map) {
2699 LOperand* value() { return inputs_[0]; }
2700 LOperand* map() { return inputs_[1]; }
2702 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2706 class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2708 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2709 inputs_[0] = object;
2713 LOperand* object() { return inputs_[0]; }
2714 LOperand* index() { return inputs_[1]; }
2716 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2720 class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2722 explicit LStoreFrameContext(LOperand* context) {
2723 inputs_[0] = context;
2726 LOperand* context() { return inputs_[0]; }
2728 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2732 class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2734 LAllocateBlockContext(LOperand* context, LOperand* function) {
2735 inputs_[0] = context;
2736 inputs_[1] = function;
2739 LOperand* context() { return inputs_[0]; }
2740 LOperand* function() { return inputs_[1]; }
2742 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2744 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2745 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2749 class LChunkBuilder;
2750 class LPlatformChunk FINAL : public LChunk {
2752 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2753 : LChunk(info, graph),
2754 num_double_slots_(0) { }
2756 int GetNextSpillIndex(RegisterKind kind);
2757 LOperand* GetNextSpillSlot(RegisterKind kind);
2759 int num_double_slots() const { return num_double_slots_; }
2762 int num_double_slots_;
2766 class LChunkBuilder FINAL : public LChunkBuilderBase {
2768 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2769 : LChunkBuilderBase(info, graph),
2770 current_instruction_(NULL),
2771 current_block_(NULL),
2773 allocator_(allocator) {}
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);
2803 // Methods for getting operands for Use / Define / Temp.
2804 LUnallocated* ToUnallocated(Register reg);
2805 LUnallocated* ToUnallocated(X87Register reg);
2807 // Methods for setting up define-use relationships.
2808 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2809 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2811 // A value that is guaranteed to be allocated to a register.
2812 // Operand created by UseRegister is guaranteed to be live until the end of
2813 // instruction. This means that register allocator will not reuse it's
2814 // register for any other operand inside instruction.
2815 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2816 // instruction start. Register allocator is free to assign the same register
2817 // to some other operand used inside instruction (i.e. temporary or
2819 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2820 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2822 // An input operand in a register that may be trashed.
2823 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2825 // An input operand in a register or stack slot.
2826 MUST_USE_RESULT LOperand* Use(HValue* value);
2827 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2829 // An input operand in a register, stack slot or a constant operand.
2830 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2831 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2833 // An input operand in a fixed register or a constant operand.
2834 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2835 Register fixed_register);
2837 // An input operand in a register or a constant operand.
2838 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2839 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2841 // An input operand in a constant operand.
2842 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2844 // An input operand in register, stack slot or a constant operand.
2845 // Will not be moved to a register even if one is freely available.
2846 virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
2848 // Temporary operand that must be in a register.
2849 MUST_USE_RESULT LUnallocated* TempRegister();
2850 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2852 // Methods for setting up define-use relationships.
2853 // Return the same instruction that they are passed.
2854 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2855 LUnallocated* result);
2856 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2857 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2859 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2860 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2862 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2864 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2865 // Assigns an environment to an instruction. An instruction which can
2866 // deoptimize must have an environment.
2867 LInstruction* AssignEnvironment(LInstruction* instr);
2868 // Assigns a pointer map to an instruction. An instruction which can
2869 // trigger a GC or a lazy deoptimization must have a pointer map.
2870 LInstruction* AssignPointerMap(LInstruction* instr);
2872 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2874 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2876 // Marks a call for the register allocator. Assigns a pointer map to
2877 // support GC and lazy deoptimization. Assigns an environment to support
2878 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2879 LInstruction* MarkAsCall(
2880 LInstruction* instr,
2881 HInstruction* hinstr,
2882 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2884 void VisitInstruction(HInstruction* current);
2885 void AddInstruction(LInstruction* instr, HInstruction* current);
2887 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2888 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2889 LInstruction* DoArithmeticD(Token::Value op,
2890 HArithmeticBinaryOperation* instr);
2891 LInstruction* DoArithmeticT(Token::Value op,
2892 HBinaryOperation* instr);
2894 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2896 HInstruction* current_instruction_;
2897 HBasicBlock* current_block_;
2898 HBasicBlock* next_block_;
2899 LAllocator* allocator_;
2901 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2904 #undef DECLARE_HYDROGEN_ACCESSOR
2905 #undef DECLARE_CONCRETE_INSTRUCTION
2907 } } // namespace v8::internal
2909 #endif // V8_X87_LITHIUM_X87_H_