1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef V8_IA32_LITHIUM_IA32_H_
29 #define V8_IA32_LITHIUM_IA32_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
48 V(ArgumentsElements) \
55 V(CallConstantFunction) \
65 V(CheckInstanceType) \
74 V(ClampTToUint8NoSSE2) \
75 V(ClassOfTestAndBranch) \
77 V(CompareNumericAndBranch) \
78 V(CmpObjectEqAndBranch) \
101 V(GetCachedArrayIndex) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(InnerAllocatedObject) \
109 V(InstanceOfKnownGlobal) \
111 V(Integer32ToDouble) \
114 V(IsConstructCallAndBranch) \
115 V(IsObjectAndBranch) \
116 V(IsStringAndBranch) \
118 V(IsUndetectableAndBranch) \
122 V(LoadExternalArrayPointer) \
123 V(LoadFieldByIndex) \
124 V(LoadFunctionPrototype) \
126 V(LoadGlobalGeneric) \
128 V(LoadKeyedGeneric) \
130 V(LoadNamedGeneric) \
159 V(SeqStringSetChar) \
165 V(StoreContextSlot) \
167 V(StoreGlobalGeneric) \
169 V(StoreKeyedGeneric) \
171 V(StoreNamedGeneric) \
173 V(StringCharCodeAt) \
174 V(StringCharFromCode) \
175 V(StringCompareAndBranch) \
180 V(ToFastProperties) \
181 V(TransitionElementsKind) \
182 V(TrapAllocationMemento) \
184 V(TypeofIsAndBranch) \
192 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
193 virtual Opcode opcode() const V8_FINAL V8_OVERRIDE { \
194 return LInstruction::k##type; \
196 virtual void CompileToNative(LCodeGen* generator) V8_FINAL V8_OVERRIDE; \
197 virtual const char* Mnemonic() const V8_FINAL V8_OVERRIDE { \
200 static L##type* cast(LInstruction* instr) { \
201 ASSERT(instr->Is##type()); \
202 return reinterpret_cast<L##type*>(instr); \
206 #define DECLARE_HYDROGEN_ACCESSOR(type) \
207 H##type* hydrogen() const { \
208 return H##type::cast(hydrogen_value()); \
212 class LInstruction : public ZoneObject {
215 : environment_(NULL),
216 hydrogen_value_(NULL),
217 bit_field_(IsCallBits::encode(false)) {
220 virtual ~LInstruction() {}
222 virtual void CompileToNative(LCodeGen* generator) = 0;
223 virtual const char* Mnemonic() const = 0;
224 virtual void PrintTo(StringStream* stream);
225 virtual void PrintDataTo(StringStream* stream);
226 virtual void PrintOutputOperandTo(StringStream* stream);
229 // Declare a unique enum value for each instruction.
230 #define DECLARE_OPCODE(type) k##type,
231 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
232 kNumberOfInstructions
233 #undef DECLARE_OPCODE
236 virtual Opcode opcode() const = 0;
238 // Declare non-virtual type testers for all leaf IR classes.
239 #define DECLARE_PREDICATE(type) \
240 bool Is##type() const { return opcode() == k##type; }
241 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
242 #undef DECLARE_PREDICATE
244 // Declare virtual predicates for instructions that don't have
246 virtual bool IsGap() const { return false; }
248 virtual bool IsControl() const { return false; }
250 void set_environment(LEnvironment* env) { environment_ = env; }
251 LEnvironment* environment() const { return environment_; }
252 bool HasEnvironment() const { return environment_ != NULL; }
254 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
255 LPointerMap* pointer_map() const { return pointer_map_.get(); }
256 bool HasPointerMap() const { return pointer_map_.is_set(); }
258 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
259 HValue* hydrogen_value() const { return hydrogen_value_; }
261 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
263 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
264 bool IsCall() const { return IsCallBits::decode(bit_field_); }
266 // Interface to the register allocator and iterators.
267 bool ClobbersTemps() const { return IsCall(); }
268 bool ClobbersRegisters() const { return IsCall(); }
269 virtual bool ClobbersDoubleRegisters() const {
271 // We only have rudimentary X87Stack tracking, thus in general
272 // cannot handle phi-nodes.
273 (!CpuFeatures::IsSafeForSnapshot(SSE2) && IsControl());
276 virtual bool HasResult() const = 0;
277 virtual LOperand* result() const = 0;
279 bool HasDoubleRegisterResult();
280 bool HasDoubleRegisterInput();
281 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
283 LOperand* FirstInput() { return InputAt(0); }
284 LOperand* Output() { return HasResult() ? result() : NULL; }
286 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
294 friend class InputIterator;
295 virtual int InputCount() = 0;
296 virtual LOperand* InputAt(int i) = 0;
298 friend class TempIterator;
299 virtual int TempCount() = 0;
300 virtual LOperand* TempAt(int i) = 0;
302 class IsCallBits: public BitField<bool, 0, 1> {};
304 LEnvironment* environment_;
305 SetOncePointer<LPointerMap> pointer_map_;
306 HValue* hydrogen_value_;
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 LInstruction {
317 // Allow 0 or 1 output operands.
318 STATIC_ASSERT(R == 0 || R == 1);
319 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
320 return R != 0 && result() != NULL;
322 void set_result(LOperand* operand) { results_[0] = operand; }
323 LOperand* result() const { return results_[0]; }
326 EmbeddedContainer<LOperand*, R> results_;
327 EmbeddedContainer<LOperand*, I> inputs_;
328 EmbeddedContainer<LOperand*, T> temps_;
332 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
333 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
335 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
336 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
340 class LGap : public LTemplateInstruction<0, 0, 0> {
342 explicit LGap(HBasicBlock* block) : block_(block) {
343 parallel_moves_[BEFORE] = NULL;
344 parallel_moves_[START] = NULL;
345 parallel_moves_[END] = NULL;
346 parallel_moves_[AFTER] = NULL;
349 // Can't use the DECLARE-macro here because of sub-classes.
350 virtual bool IsGap() const V8_FINAL V8_OVERRIDE { return true; }
351 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
352 static LGap* cast(LInstruction* instr) {
353 ASSERT(instr->IsGap());
354 return reinterpret_cast<LGap*>(instr);
357 bool IsRedundant() const;
359 HBasicBlock* block() const { return block_; }
366 FIRST_INNER_POSITION = BEFORE,
367 LAST_INNER_POSITION = AFTER
370 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
371 if (parallel_moves_[pos] == NULL) {
372 parallel_moves_[pos] = new(zone) LParallelMove(zone);
374 return parallel_moves_[pos];
377 LParallelMove* GetParallelMove(InnerPosition pos) {
378 return parallel_moves_[pos];
382 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
387 class LInstructionGap V8_FINAL : public LGap {
389 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
391 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
392 return !IsRedundant();
395 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
399 class LClobberDoubles V8_FINAL : public LTemplateInstruction<0, 0, 0> {
401 LClobberDoubles() { ASSERT(!CpuFeatures::IsSafeForSnapshot(SSE2)); }
403 virtual bool ClobbersDoubleRegisters() const { return true; }
405 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
409 class LGoto V8_FINAL : public LTemplateInstruction<0, 0, 0> {
411 explicit LGoto(HBasicBlock* block) : block_(block) { }
413 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE;
414 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
415 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
416 virtual bool IsControl() const V8_OVERRIDE { return true; }
418 int block_id() const { return block_->block_id(); }
419 virtual bool ClobbersDoubleRegisters() const { return false; }
421 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
428 class LLazyBailout V8_FINAL : public LTemplateInstruction<0, 0, 0> {
430 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
434 class LDummyUse V8_FINAL : public LTemplateInstruction<1, 1, 0> {
436 explicit LDummyUse(LOperand* value) {
439 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
443 class LDeoptimize V8_FINAL : public LTemplateInstruction<0, 0, 0> {
445 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
446 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
450 class LLabel V8_FINAL : public LGap {
452 explicit LLabel(HBasicBlock* block)
453 : LGap(block), replacement_(NULL) { }
455 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
458 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
460 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
462 int block_id() const { return block()->block_id(); }
463 bool is_loop_header() const { return block()->IsLoopHeader(); }
464 bool is_osr_entry() const { return block()->is_osr_entry(); }
465 Label* label() { return &label_; }
466 LLabel* replacement() const { return replacement_; }
467 void set_replacement(LLabel* label) { replacement_ = label; }
468 bool HasReplacement() const { return replacement_ != NULL; }
472 LLabel* replacement_;
476 class LParameter V8_FINAL : public LTemplateInstruction<1, 0, 0> {
478 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
481 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
485 class LCallStub V8_FINAL : public LTemplateInstruction<1, 1, 0> {
487 explicit LCallStub(LOperand* context) {
488 inputs_[0] = context;
491 LOperand* context() { return inputs_[0]; }
493 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
494 DECLARE_HYDROGEN_ACCESSOR(CallStub)
496 TranscendentalCache::Type transcendental_type() {
497 return hydrogen()->transcendental_type();
502 class LUnknownOSRValue V8_FINAL : public LTemplateInstruction<1, 0, 0> {
504 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
507 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
511 template<int I, int T>
512 class LControlInstruction: public LTemplateInstruction<0, I, T> {
514 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
516 virtual bool IsControl() const V8_FINAL V8_OVERRIDE { return true; }
518 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
519 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
521 int TrueDestination(LChunk* chunk) {
522 return chunk->LookupDestination(true_block_id());
524 int FalseDestination(LChunk* chunk) {
525 return chunk->LookupDestination(false_block_id());
528 Label* TrueLabel(LChunk* chunk) {
529 if (true_label_ == NULL) {
530 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
534 Label* FalseLabel(LChunk* chunk) {
535 if (false_label_ == NULL) {
536 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
542 int true_block_id() { return SuccessorAt(0)->block_id(); }
543 int false_block_id() { return SuccessorAt(1)->block_id(); }
546 HControlInstruction* hydrogen() {
547 return HControlInstruction::cast(this->hydrogen_value());
555 class LWrapReceiver V8_FINAL : public LTemplateInstruction<1, 2, 1> {
557 LWrapReceiver(LOperand* receiver,
560 inputs_[0] = receiver;
561 inputs_[1] = function;
565 LOperand* receiver() { return inputs_[0]; }
566 LOperand* function() { return inputs_[1]; }
567 LOperand* temp() { return temps_[0]; }
569 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
573 class LApplyArguments V8_FINAL : public LTemplateInstruction<1, 4, 0> {
575 LApplyArguments(LOperand* function,
578 LOperand* elements) {
579 inputs_[0] = function;
580 inputs_[1] = receiver;
582 inputs_[3] = elements;
585 LOperand* function() { return inputs_[0]; }
586 LOperand* receiver() { return inputs_[1]; }
587 LOperand* length() { return inputs_[2]; }
588 LOperand* elements() { return inputs_[3]; }
590 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
594 class LAccessArgumentsAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
596 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
597 inputs_[0] = arguments;
602 LOperand* arguments() { return inputs_[0]; }
603 LOperand* length() { return inputs_[1]; }
604 LOperand* index() { return inputs_[2]; }
606 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
608 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
612 class LArgumentsLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
614 explicit LArgumentsLength(LOperand* elements) {
615 inputs_[0] = elements;
618 LOperand* elements() { return inputs_[0]; }
620 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
624 class LArgumentsElements V8_FINAL : public LTemplateInstruction<1, 0, 0> {
626 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
627 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
631 class LDebugBreak V8_FINAL : public LTemplateInstruction<0, 0, 0> {
633 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
637 class LModI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
639 LModI(LOperand* left, LOperand* right, LOperand* temp) {
645 LOperand* left() { return inputs_[0]; }
646 LOperand* right() { return inputs_[1]; }
647 LOperand* temp() { return temps_[0]; }
649 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
650 DECLARE_HYDROGEN_ACCESSOR(Mod)
654 class LDivI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
656 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
662 LOperand* left() { return inputs_[0]; }
663 LOperand* right() { return inputs_[1]; }
665 bool is_flooring() { return hydrogen_value()->IsMathFloorOfDiv(); }
667 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
668 DECLARE_HYDROGEN_ACCESSOR(Div)
672 class LMathFloorOfDiv V8_FINAL : public LTemplateInstruction<1, 2, 1> {
674 LMathFloorOfDiv(LOperand* left,
676 LOperand* temp = NULL) {
682 LOperand* left() { return inputs_[0]; }
683 LOperand* right() { return inputs_[1]; }
684 LOperand* temp() { return temps_[0]; }
686 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
687 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
691 class LMulI V8_FINAL : public LTemplateInstruction<1, 2, 1> {
693 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
699 LOperand* left() { return inputs_[0]; }
700 LOperand* right() { return inputs_[1]; }
701 LOperand* temp() { return temps_[0]; }
703 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
704 DECLARE_HYDROGEN_ACCESSOR(Mul)
708 class LCompareNumericAndBranch V8_FINAL : public LControlInstruction<2, 0> {
710 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
715 LOperand* left() { return inputs_[0]; }
716 LOperand* right() { return inputs_[1]; }
718 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
719 "compare-numeric-and-branch")
720 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
722 Token::Value op() const { return hydrogen()->token(); }
723 bool is_double() const {
724 return hydrogen()->representation().IsDouble();
727 virtual void PrintDataTo(StringStream* stream);
731 class LMathFloor V8_FINAL : public LTemplateInstruction<1, 1, 0> {
733 explicit LMathFloor(LOperand* value) {
737 LOperand* value() { return inputs_[0]; }
739 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
740 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
744 class LMathRound V8_FINAL : public LTemplateInstruction<1, 2, 1> {
746 LMathRound(LOperand* context, LOperand* value, LOperand* temp) {
747 inputs_[1] = context;
752 LOperand* context() { return inputs_[1]; }
753 LOperand* value() { return inputs_[0]; }
754 LOperand* temp() { return temps_[0]; }
756 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
757 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
761 class LMathAbs V8_FINAL : public LTemplateInstruction<1, 2, 0> {
763 LMathAbs(LOperand* context, LOperand* value) {
764 inputs_[1] = context;
768 LOperand* context() { return inputs_[1]; }
769 LOperand* value() { return inputs_[0]; }
771 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
772 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
776 class LMathLog V8_FINAL : public LTemplateInstruction<1, 1, 0> {
778 explicit LMathLog(LOperand* value) {
782 LOperand* value() { return inputs_[0]; }
784 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
788 class LMathSin V8_FINAL : public LTemplateInstruction<1, 1, 0> {
790 explicit LMathSin(LOperand* value) {
794 LOperand* value() { return inputs_[0]; }
796 DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
800 class LMathCos V8_FINAL : public LTemplateInstruction<1, 1, 0> {
802 explicit LMathCos(LOperand* value) {
806 LOperand* value() { return inputs_[0]; }
808 DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
812 class LMathTan V8_FINAL : public LTemplateInstruction<1, 1, 0> {
814 explicit LMathTan(LOperand* value) {
818 LOperand* value() { return inputs_[0]; }
820 DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan")
824 class LMathExp V8_FINAL : public LTemplateInstruction<1, 1, 2> {
826 LMathExp(LOperand* value,
832 ExternalReference::InitializeMathExpData();
835 LOperand* value() { return inputs_[0]; }
836 LOperand* temp1() { return temps_[0]; }
837 LOperand* temp2() { return temps_[1]; }
839 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
843 class LMathSqrt V8_FINAL : public LTemplateInstruction<1, 1, 0> {
845 explicit LMathSqrt(LOperand* value) {
849 LOperand* value() { return inputs_[0]; }
851 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
855 class LMathPowHalf V8_FINAL : public LTemplateInstruction<1, 2, 1> {
857 LMathPowHalf(LOperand* context, LOperand* value, LOperand* temp) {
858 inputs_[1] = context;
863 LOperand* context() { return inputs_[1]; }
864 LOperand* value() { return inputs_[0]; }
865 LOperand* temp() { return temps_[0]; }
867 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
871 class LCmpObjectEqAndBranch V8_FINAL : public LControlInstruction<2, 0> {
873 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
878 LOperand* left() { return inputs_[0]; }
879 LOperand* right() { return inputs_[1]; }
881 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
885 class LCmpHoleAndBranch V8_FINAL : public LControlInstruction<1, 0> {
887 explicit LCmpHoleAndBranch(LOperand* object) {
891 LOperand* object() { return inputs_[0]; }
893 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
894 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
898 class LIsObjectAndBranch V8_FINAL : public LControlInstruction<1, 1> {
900 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
905 LOperand* value() { return inputs_[0]; }
906 LOperand* temp() { return temps_[0]; }
908 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
910 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
914 class LIsStringAndBranch V8_FINAL : public LControlInstruction<1, 1> {
916 LIsStringAndBranch(LOperand* value, LOperand* temp) {
921 LOperand* value() { return inputs_[0]; }
922 LOperand* temp() { return temps_[0]; }
924 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
925 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
927 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
931 class LIsSmiAndBranch V8_FINAL : public LControlInstruction<1, 0> {
933 explicit LIsSmiAndBranch(LOperand* value) {
937 LOperand* value() { return inputs_[0]; }
939 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
940 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
942 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
946 class LIsUndetectableAndBranch V8_FINAL : public LControlInstruction<1, 1> {
948 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
953 LOperand* value() { return inputs_[0]; }
954 LOperand* temp() { return temps_[0]; }
956 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
957 "is-undetectable-and-branch")
958 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
960 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
964 class LStringCompareAndBranch V8_FINAL : public LControlInstruction<3, 0> {
966 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
967 inputs_[0] = context;
972 LOperand* left() { return inputs_[1]; }
973 LOperand* right() { return inputs_[2]; }
975 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
976 "string-compare-and-branch")
977 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
979 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
981 Token::Value op() const { return hydrogen()->token(); }
985 class LHasInstanceTypeAndBranch V8_FINAL : public LControlInstruction<1, 1> {
987 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
992 LOperand* value() { return inputs_[0]; }
993 LOperand* temp() { return temps_[0]; }
995 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
996 "has-instance-type-and-branch")
997 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
999 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1003 class LGetCachedArrayIndex V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1005 explicit LGetCachedArrayIndex(LOperand* value) {
1009 LOperand* value() { return inputs_[0]; }
1011 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1012 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1016 class LHasCachedArrayIndexAndBranch V8_FINAL
1017 : public LControlInstruction<1, 0> {
1019 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1023 LOperand* value() { return inputs_[0]; }
1025 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1026 "has-cached-array-index-and-branch")
1028 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1032 class LIsConstructCallAndBranch V8_FINAL : public LControlInstruction<0, 1> {
1034 explicit LIsConstructCallAndBranch(LOperand* temp) {
1038 LOperand* temp() { return temps_[0]; }
1040 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1041 "is-construct-call-and-branch")
1045 class LClassOfTestAndBranch V8_FINAL : public LControlInstruction<1, 2> {
1047 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1053 LOperand* value() { return inputs_[0]; }
1054 LOperand* temp() { return temps_[0]; }
1055 LOperand* temp2() { return temps_[1]; }
1057 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1058 "class-of-test-and-branch")
1059 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1061 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1065 class LCmpT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1067 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1068 inputs_[0] = context;
1073 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1074 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1076 Token::Value op() const { return hydrogen()->token(); }
1080 class LInstanceOf V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1082 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1083 inputs_[0] = context;
1088 LOperand* context() { return inputs_[0]; }
1090 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1094 class LInstanceOfKnownGlobal V8_FINAL : public LTemplateInstruction<1, 2, 1> {
1096 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1097 inputs_[0] = context;
1102 LOperand* value() { return inputs_[1]; }
1103 LOperand* temp() { return temps_[0]; }
1105 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1106 "instance-of-known-global")
1107 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1109 Handle<JSFunction> function() const { return hydrogen()->function(); }
1110 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1111 return lazy_deopt_env_;
1113 virtual void SetDeferredLazyDeoptimizationEnvironment(
1114 LEnvironment* env) V8_OVERRIDE {
1115 lazy_deopt_env_ = env;
1119 LEnvironment* lazy_deopt_env_;
1123 class LBoundsCheck V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1125 LBoundsCheck(LOperand* index, LOperand* length) {
1127 inputs_[1] = length;
1130 LOperand* index() { return inputs_[0]; }
1131 LOperand* length() { return inputs_[1]; }
1133 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1134 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1138 class LBitI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1140 LBitI(LOperand* left, LOperand* right) {
1145 LOperand* left() { return inputs_[0]; }
1146 LOperand* right() { return inputs_[1]; }
1148 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1149 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1151 Token::Value op() const { return hydrogen()->op(); }
1155 class LShiftI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1157 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1158 : op_(op), can_deopt_(can_deopt) {
1163 LOperand* left() { return inputs_[0]; }
1164 LOperand* right() { return inputs_[1]; }
1166 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1168 Token::Value op() const { return op_; }
1169 bool can_deopt() const { return can_deopt_; }
1177 class LSubI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1179 LSubI(LOperand* left, LOperand* right) {
1184 LOperand* left() { return inputs_[0]; }
1185 LOperand* right() { return inputs_[1]; }
1187 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1188 DECLARE_HYDROGEN_ACCESSOR(Sub)
1192 class LConstantI V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1194 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1195 DECLARE_HYDROGEN_ACCESSOR(Constant)
1197 int32_t value() const { return hydrogen()->Integer32Value(); }
1201 class LConstantS V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1203 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1204 DECLARE_HYDROGEN_ACCESSOR(Constant)
1206 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1210 class LConstantD V8_FINAL : public LTemplateInstruction<1, 0, 1> {
1212 explicit LConstantD(LOperand* temp) {
1216 LOperand* temp() { return temps_[0]; }
1218 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1219 DECLARE_HYDROGEN_ACCESSOR(Constant)
1221 double value() const { return hydrogen()->DoubleValue(); }
1225 class LConstantE V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1227 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1228 DECLARE_HYDROGEN_ACCESSOR(Constant)
1230 ExternalReference value() const {
1231 return hydrogen()->ExternalReferenceValue();
1236 class LConstantT V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1238 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1239 DECLARE_HYDROGEN_ACCESSOR(Constant)
1241 Handle<Object> value(Isolate* isolate) const {
1242 return hydrogen()->handle(isolate);
1247 class LBranch V8_FINAL : public LControlInstruction<1, 1> {
1249 LBranch(LOperand* value, LOperand* temp) {
1254 LOperand* value() { return inputs_[0]; }
1255 LOperand* temp() { return temps_[0]; }
1257 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1258 DECLARE_HYDROGEN_ACCESSOR(Branch)
1260 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1264 class LCmpMapAndBranch V8_FINAL : public LControlInstruction<1, 0> {
1266 explicit LCmpMapAndBranch(LOperand* value) {
1270 LOperand* value() { return inputs_[0]; }
1272 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1273 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1275 Handle<Map> map() const { return hydrogen()->map().handle(); }
1279 class LMapEnumLength V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1281 explicit LMapEnumLength(LOperand* value) {
1285 LOperand* value() { return inputs_[0]; }
1287 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1291 class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1293 explicit LElementsKind(LOperand* value) {
1297 LOperand* value() { return inputs_[0]; }
1299 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1300 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1304 class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1306 LValueOf(LOperand* value, LOperand* temp) {
1311 LOperand* value() { return inputs_[0]; }
1312 LOperand* temp() { return temps_[0]; }
1314 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1315 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1319 class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1321 LDateField(LOperand* date, LOperand* temp, Smi* index)
1327 LOperand* date() { return inputs_[0]; }
1328 LOperand* temp() { return temps_[0]; }
1330 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1331 DECLARE_HYDROGEN_ACCESSOR(DateField)
1333 Smi* index() const { return index_; }
1340 class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1342 LSeqStringSetChar(String::Encoding encoding,
1345 LOperand* value) : encoding_(encoding) {
1346 inputs_[0] = string;
1351 String::Encoding encoding() { return encoding_; }
1352 LOperand* string() { return inputs_[0]; }
1353 LOperand* index() { return inputs_[1]; }
1354 LOperand* value() { return inputs_[2]; }
1356 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1357 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1360 String::Encoding encoding_;
1364 class LThrow V8_FINAL : public LTemplateInstruction<0, 2, 0> {
1366 LThrow(LOperand* context, LOperand* value) {
1367 inputs_[0] = context;
1371 LOperand* context() { return inputs_[0]; }
1372 LOperand* value() { return inputs_[1]; }
1374 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1378 class LAddI V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1380 LAddI(LOperand* left, LOperand* right) {
1385 LOperand* left() { return inputs_[0]; }
1386 LOperand* right() { return inputs_[1]; }
1388 static bool UseLea(HAdd* add) {
1389 return !add->CheckFlag(HValue::kCanOverflow) &&
1390 add->BetterLeftOperand()->UseCount() > 1;
1393 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1394 DECLARE_HYDROGEN_ACCESSOR(Add)
1398 class LMathMinMax V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1400 LMathMinMax(LOperand* left, LOperand* right) {
1405 LOperand* left() { return inputs_[0]; }
1406 LOperand* right() { return inputs_[1]; }
1408 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1409 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1413 class LPower V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1415 LPower(LOperand* left, LOperand* right) {
1420 LOperand* left() { return inputs_[0]; }
1421 LOperand* right() { return inputs_[1]; }
1423 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1424 DECLARE_HYDROGEN_ACCESSOR(Power)
1428 class LRandom V8_FINAL : public LTemplateInstruction<1, 1, 3> {
1430 LRandom(LOperand* global_object,
1433 LOperand* scratch3) {
1434 inputs_[0] = global_object;
1435 temps_[0] = scratch;
1436 temps_[1] = scratch2;
1437 temps_[2] = scratch3;
1440 LOperand* global_object() const { return inputs_[0]; }
1441 LOperand* scratch() const { return temps_[0]; }
1442 LOperand* scratch2() const { return temps_[1]; }
1443 LOperand* scratch3() const { return temps_[2]; }
1445 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1446 DECLARE_HYDROGEN_ACCESSOR(Random)
1450 class LArithmeticD V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1452 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1458 LOperand* left() { return inputs_[0]; }
1459 LOperand* right() { return inputs_[1]; }
1461 Token::Value op() const { return op_; }
1463 virtual Opcode opcode() const V8_OVERRIDE {
1464 return LInstruction::kArithmeticD;
1466 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1467 virtual const char* Mnemonic() const V8_OVERRIDE;
1474 class LArithmeticT V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1476 LArithmeticT(Token::Value op,
1481 inputs_[0] = context;
1486 LOperand* context() { return inputs_[0]; }
1487 LOperand* left() { return inputs_[1]; }
1488 LOperand* right() { return inputs_[2]; }
1490 virtual Opcode opcode() const V8_OVERRIDE {
1491 return LInstruction::kArithmeticT;
1493 virtual void CompileToNative(LCodeGen* generator) V8_OVERRIDE;
1494 virtual const char* Mnemonic() const V8_OVERRIDE;
1496 Token::Value op() const { return op_; }
1503 class LReturn V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1505 explicit LReturn(LOperand* value, LOperand* context,
1506 LOperand* parameter_count) {
1508 inputs_[1] = context;
1509 inputs_[2] = parameter_count;
1512 bool has_constant_parameter_count() {
1513 return parameter_count()->IsConstantOperand();
1515 LConstantOperand* constant_parameter_count() {
1516 ASSERT(has_constant_parameter_count());
1517 return LConstantOperand::cast(parameter_count());
1519 LOperand* parameter_count() { return inputs_[2]; }
1521 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1522 DECLARE_HYDROGEN_ACCESSOR(Return)
1526 class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1528 explicit LLoadNamedField(LOperand* object) {
1529 inputs_[0] = object;
1532 LOperand* object() { return inputs_[0]; }
1534 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1535 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1539 class LLoadNamedGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1541 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1542 inputs_[0] = context;
1543 inputs_[1] = object;
1546 LOperand* context() { return inputs_[0]; }
1547 LOperand* object() { return inputs_[1]; }
1549 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1550 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1552 Handle<Object> name() const { return hydrogen()->name(); }
1556 class LLoadFunctionPrototype V8_FINAL : public LTemplateInstruction<1, 1, 1> {
1558 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1559 inputs_[0] = function;
1563 LOperand* function() { return inputs_[0]; }
1564 LOperand* temp() { return temps_[0]; }
1566 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1567 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1571 class LLoadRoot V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1573 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1574 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1576 Heap::RootListIndex index() const { return hydrogen()->index(); }
1580 class LLoadExternalArrayPointer V8_FINAL
1581 : public LTemplateInstruction<1, 1, 0> {
1583 explicit LLoadExternalArrayPointer(LOperand* object) {
1584 inputs_[0] = object;
1587 LOperand* object() { return inputs_[0]; }
1589 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1590 "load-external-array-pointer")
1594 class LLoadKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1596 LLoadKeyed(LOperand* elements, LOperand* key) {
1597 inputs_[0] = elements;
1600 LOperand* elements() { return inputs_[0]; }
1601 LOperand* key() { return inputs_[1]; }
1602 ElementsKind elements_kind() const {
1603 return hydrogen()->elements_kind();
1605 bool is_external() const {
1606 return hydrogen()->is_external();
1609 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1610 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1612 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1613 uint32_t additional_index() const { return hydrogen()->index_offset(); }
1615 return hydrogen()->key()->representation().IsTagged();
1620 inline static bool ExternalArrayOpRequiresTemp(
1621 Representation key_representation,
1622 ElementsKind elements_kind) {
1623 // Operations that require the key to be divided by two to be converted into
1624 // an index cannot fold the scale operation into a load and need an extra
1625 // temp register to do the work.
1626 return key_representation.IsSmi() &&
1627 (elements_kind == EXTERNAL_BYTE_ELEMENTS ||
1628 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS ||
1629 elements_kind == EXTERNAL_PIXEL_ELEMENTS);
1633 class LLoadKeyedGeneric V8_FINAL : public LTemplateInstruction<1, 3, 0> {
1635 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1636 inputs_[0] = context;
1641 LOperand* context() { return inputs_[0]; }
1642 LOperand* object() { return inputs_[1]; }
1643 LOperand* key() { return inputs_[2]; }
1645 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1649 class LLoadGlobalCell V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1651 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1652 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1656 class LLoadGlobalGeneric V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1658 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1659 inputs_[0] = context;
1660 inputs_[1] = global_object;
1663 LOperand* context() { return inputs_[0]; }
1664 LOperand* global_object() { return inputs_[1]; }
1666 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1667 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1669 Handle<Object> name() const { return hydrogen()->name(); }
1670 bool for_typeof() const { return hydrogen()->for_typeof(); }
1674 class LStoreGlobalCell V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1676 explicit LStoreGlobalCell(LOperand* value) {
1680 LOperand* value() { return inputs_[0]; }
1682 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1683 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1687 class LStoreGlobalGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
1689 LStoreGlobalGeneric(LOperand* context,
1690 LOperand* global_object,
1692 inputs_[0] = context;
1693 inputs_[1] = global_object;
1697 LOperand* context() { return inputs_[0]; }
1698 LOperand* global_object() { return inputs_[1]; }
1699 LOperand* value() { return inputs_[2]; }
1701 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1702 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1704 Handle<Object> name() const { return hydrogen()->name(); }
1705 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1709 class LLoadContextSlot V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1711 explicit LLoadContextSlot(LOperand* context) {
1712 inputs_[0] = context;
1715 LOperand* context() { return inputs_[0]; }
1717 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1718 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1720 int slot_index() { return hydrogen()->slot_index(); }
1722 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1726 class LStoreContextSlot V8_FINAL : public LTemplateInstruction<0, 2, 1> {
1728 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1729 inputs_[0] = context;
1734 LOperand* context() { return inputs_[0]; }
1735 LOperand* value() { return inputs_[1]; }
1736 LOperand* temp() { return temps_[0]; }
1738 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1739 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1741 int slot_index() { return hydrogen()->slot_index(); }
1743 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1747 class LPushArgument V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1749 explicit LPushArgument(LOperand* value) {
1753 LOperand* value() { return inputs_[0]; }
1755 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1759 class LDrop V8_FINAL : public LTemplateInstruction<0, 0, 0> {
1761 explicit LDrop(int count) : count_(count) { }
1763 int count() const { return count_; }
1765 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1772 class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> {
1774 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1775 inputs_[0] = function;
1776 temps_[0] = code_object;
1779 LOperand* function() { return inputs_[0]; }
1780 LOperand* code_object() { return temps_[0]; }
1782 virtual void PrintDataTo(StringStream* stream);
1784 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1785 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1789 class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 1, 0> {
1791 explicit LInnerAllocatedObject(LOperand* base_object) {
1792 inputs_[0] = base_object;
1795 LOperand* base_object() { return inputs_[0]; }
1796 int offset() { return hydrogen()->offset(); }
1798 virtual void PrintDataTo(StringStream* stream);
1800 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
1801 DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
1805 class LThisFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1807 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1808 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1812 class LContext V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1814 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1815 DECLARE_HYDROGEN_ACCESSOR(Context)
1819 class LOuterContext V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1821 explicit LOuterContext(LOperand* context) {
1822 inputs_[0] = context;
1825 LOperand* context() { return inputs_[0]; }
1827 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1831 class LDeclareGlobals V8_FINAL : public LTemplateInstruction<0, 1, 0> {
1833 explicit LDeclareGlobals(LOperand* context) {
1834 inputs_[0] = context;
1837 LOperand* context() { return inputs_[0]; }
1839 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1840 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1844 class LGlobalObject V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1846 explicit LGlobalObject(LOperand* context) {
1847 inputs_[0] = context;
1850 LOperand* context() { return inputs_[0]; }
1852 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1856 class LGlobalReceiver V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1858 explicit LGlobalReceiver(LOperand* global_object) {
1859 inputs_[0] = global_object;
1862 LOperand* global() { return inputs_[0]; }
1864 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1868 class LCallConstantFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1870 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1871 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1873 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1875 Handle<JSFunction> function() { return hydrogen()->function(); }
1876 int arity() const { return hydrogen()->argument_count() - 1; }
1880 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1882 LInvokeFunction(LOperand* context, LOperand* function) {
1883 inputs_[0] = context;
1884 inputs_[1] = function;
1887 LOperand* context() { return inputs_[0]; }
1888 LOperand* function() { return inputs_[1]; }
1890 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1891 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1893 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1895 int arity() const { return hydrogen()->argument_count() - 1; }
1899 class LCallKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1901 LCallKeyed(LOperand* context, LOperand* key) {
1902 inputs_[0] = context;
1906 LOperand* context() { return inputs_[0]; }
1907 LOperand* key() { return inputs_[1]; }
1909 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1910 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1912 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1914 int arity() const { return hydrogen()->argument_count() - 1; }
1918 class LCallNamed V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1920 explicit LCallNamed(LOperand* context) {
1921 inputs_[0] = context;
1924 LOperand* context() { return inputs_[0]; }
1926 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1927 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1929 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1931 Handle<String> name() const { return hydrogen()->name(); }
1932 int arity() const { return hydrogen()->argument_count() - 1; }
1936 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1938 explicit LCallFunction(LOperand* context, LOperand* function) {
1939 inputs_[0] = context;
1940 inputs_[1] = function;
1943 LOperand* context() { return inputs_[0]; }
1944 LOperand* function() { return inputs_[1]; }
1946 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1947 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1949 int arity() const { return hydrogen()->argument_count() - 1; }
1953 class LCallGlobal V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1955 explicit LCallGlobal(LOperand* context) {
1956 inputs_[0] = context;
1959 LOperand* context() { return inputs_[0]; }
1961 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1962 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1964 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1966 Handle<String> name() const {return hydrogen()->name(); }
1967 int arity() const { return hydrogen()->argument_count() - 1; }
1971 class LCallKnownGlobal V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1973 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1974 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1976 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1978 int arity() const { return hydrogen()->argument_count() - 1; }
1982 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1984 LCallNew(LOperand* context, LOperand* constructor) {
1985 inputs_[0] = context;
1986 inputs_[1] = constructor;
1989 LOperand* context() { return inputs_[0]; }
1990 LOperand* constructor() { return inputs_[1]; }
1992 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1993 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1995 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1997 int arity() const { return hydrogen()->argument_count() - 1; }
2001 class LCallNewArray V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2003 LCallNewArray(LOperand* context, LOperand* constructor) {
2004 inputs_[0] = context;
2005 inputs_[1] = constructor;
2008 LOperand* context() { return inputs_[0]; }
2009 LOperand* constructor() { return inputs_[1]; }
2011 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2012 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2014 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2016 int arity() const { return hydrogen()->argument_count() - 1; }
2020 class LCallRuntime V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2022 explicit LCallRuntime(LOperand* context) {
2023 inputs_[0] = context;
2026 LOperand* context() { return inputs_[0]; }
2028 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2029 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2031 virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE {
2032 return save_doubles() == kDontSaveFPRegs;
2035 const Runtime::Function* function() const { return hydrogen()->function(); }
2036 int arity() const { return hydrogen()->argument_count(); }
2037 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2041 class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2043 explicit LInteger32ToDouble(LOperand* value) {
2047 LOperand* value() { return inputs_[0]; }
2049 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2053 class LInteger32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2055 explicit LInteger32ToSmi(LOperand* value) {
2059 LOperand* value() { return inputs_[0]; }
2061 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
2062 DECLARE_HYDROGEN_ACCESSOR(Change)
2066 class LUint32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2068 explicit LUint32ToDouble(LOperand* value, LOperand* temp) {
2073 LOperand* value() { return inputs_[0]; }
2074 LOperand* temp() { return temps_[0]; }
2076 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2080 class LUint32ToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2082 explicit LUint32ToSmi(LOperand* value) {
2086 LOperand* value() { return inputs_[0]; }
2088 DECLARE_CONCRETE_INSTRUCTION(Uint32ToSmi, "uint32-to-smi")
2089 DECLARE_HYDROGEN_ACCESSOR(Change)
2093 class LNumberTagI V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2095 explicit LNumberTagI(LOperand* value) {
2099 LOperand* value() { return inputs_[0]; }
2101 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2105 class LNumberTagU V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2107 LNumberTagU(LOperand* value, LOperand* temp) {
2112 LOperand* value() { return inputs_[0]; }
2113 LOperand* temp() { return temps_[0]; }
2115 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2119 class LNumberTagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2121 LNumberTagD(LOperand* value, LOperand* temp) {
2126 LOperand* value() { return inputs_[0]; }
2127 LOperand* temp() { return temps_[0]; }
2129 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2130 DECLARE_HYDROGEN_ACCESSOR(Change)
2134 // Sometimes truncating conversion from a tagged value to an int32.
2135 class LDoubleToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2137 LDoubleToI(LOperand* value, LOperand* temp) {
2142 LOperand* value() { return inputs_[0]; }
2143 LOperand* temp() { return temps_[0]; }
2145 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2146 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2148 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2152 class LDoubleToSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2154 explicit LDoubleToSmi(LOperand* value) {
2158 LOperand* value() { return inputs_[0]; }
2160 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2161 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2165 // Truncating conversion from a tagged value to an int32.
2166 class LTaggedToI V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2168 LTaggedToI(LOperand* value, LOperand* temp) {
2173 LOperand* value() { return inputs_[0]; }
2174 LOperand* temp() { return temps_[0]; }
2176 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2177 DECLARE_HYDROGEN_ACCESSOR(Change)
2179 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2183 class LSmiTag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2185 explicit LSmiTag(LOperand* value) {
2189 LOperand* value() { return inputs_[0]; }
2191 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2195 class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2197 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2202 LOperand* value() { return inputs_[0]; }
2203 LOperand* temp() { return temps_[0]; }
2205 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2206 DECLARE_HYDROGEN_ACCESSOR(Change);
2210 class LSmiUntag V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2212 LSmiUntag(LOperand* value, bool needs_check)
2213 : needs_check_(needs_check) {
2217 LOperand* value() { return inputs_[0]; }
2219 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2221 bool needs_check() const { return needs_check_; }
2228 class LStoreNamedField V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2230 LStoreNamedField(LOperand* obj,
2233 LOperand* temp_map) {
2237 temps_[1] = temp_map;
2240 LOperand* object() { return inputs_[0]; }
2241 LOperand* value() { return inputs_[1]; }
2242 LOperand* temp() { return temps_[0]; }
2243 LOperand* temp_map() { return temps_[1]; }
2245 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2246 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2248 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2250 Handle<Map> transition() const { return hydrogen()->transition_map(); }
2251 Representation representation() const {
2252 return hydrogen()->field_representation();
2257 class LStoreNamedGeneric V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2259 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2260 inputs_[0] = context;
2261 inputs_[1] = object;
2265 LOperand* context() { return inputs_[0]; }
2266 LOperand* object() { return inputs_[1]; }
2267 LOperand* value() { return inputs_[2]; }
2269 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2270 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2272 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2273 Handle<Object> name() const { return hydrogen()->name(); }
2274 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2278 class LStoreKeyed V8_FINAL : public LTemplateInstruction<0, 3, 0> {
2280 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2286 bool is_external() const { return hydrogen()->is_external(); }
2287 LOperand* elements() { return inputs_[0]; }
2288 LOperand* key() { return inputs_[1]; }
2289 LOperand* value() { return inputs_[2]; }
2290 ElementsKind elements_kind() const {
2291 return hydrogen()->elements_kind();
2294 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2295 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2297 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2298 uint32_t additional_index() const { return hydrogen()->index_offset(); }
2299 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2303 class LStoreKeyedGeneric V8_FINAL : public LTemplateInstruction<0, 4, 0> {
2305 LStoreKeyedGeneric(LOperand* context,
2309 inputs_[0] = context;
2310 inputs_[1] = object;
2315 LOperand* context() { return inputs_[0]; }
2316 LOperand* object() { return inputs_[1]; }
2317 LOperand* key() { return inputs_[2]; }
2318 LOperand* value() { return inputs_[3]; }
2320 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2321 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2323 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2325 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
2329 class LTransitionElementsKind V8_FINAL : public LTemplateInstruction<0, 2, 2> {
2331 LTransitionElementsKind(LOperand* object,
2333 LOperand* new_map_temp,
2335 inputs_[0] = object;
2336 inputs_[1] = context;
2337 temps_[0] = new_map_temp;
2341 LOperand* context() { return inputs_[1]; }
2342 LOperand* object() { return inputs_[0]; }
2343 LOperand* new_map_temp() { return temps_[0]; }
2344 LOperand* temp() { return temps_[1]; }
2346 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2347 "transition-elements-kind")
2348 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2350 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2352 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2353 Handle<Map> transitioned_map() {
2354 return hydrogen()->transitioned_map().handle();
2356 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2357 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2361 class LTrapAllocationMemento V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2363 LTrapAllocationMemento(LOperand* object,
2365 inputs_[0] = object;
2369 LOperand* object() { return inputs_[0]; }
2370 LOperand* temp() { return temps_[0]; }
2372 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2373 "trap-allocation-memento")
2377 class LStringAdd V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2379 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2380 inputs_[0] = context;
2385 LOperand* context() { return inputs_[0]; }
2386 LOperand* left() { return inputs_[1]; }
2387 LOperand* right() { return inputs_[2]; }
2389 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2390 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2394 class LStringCharCodeAt V8_FINAL : public LTemplateInstruction<1, 3, 0> {
2396 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2397 inputs_[0] = context;
2398 inputs_[1] = string;
2402 LOperand* context() { return inputs_[0]; }
2403 LOperand* string() { return inputs_[1]; }
2404 LOperand* index() { return inputs_[2]; }
2406 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2407 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2411 class LStringCharFromCode V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2413 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2414 inputs_[0] = context;
2415 inputs_[1] = char_code;
2418 LOperand* context() { return inputs_[0]; }
2419 LOperand* char_code() { return inputs_[1]; }
2421 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2422 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2426 class LCheckValue V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2428 explicit LCheckValue(LOperand* value) {
2432 LOperand* value() { return inputs_[0]; }
2434 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2435 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2439 class LCheckInstanceType V8_FINAL : public LTemplateInstruction<0, 1, 1> {
2441 LCheckInstanceType(LOperand* value, LOperand* temp) {
2446 LOperand* value() { return inputs_[0]; }
2447 LOperand* temp() { return temps_[0]; }
2449 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2450 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2454 class LCheckMaps V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2456 explicit LCheckMaps(LOperand* value) {
2460 LOperand* value() { return inputs_[0]; }
2462 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2463 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2467 class LCheckSmi V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2469 explicit LCheckSmi(LOperand* value) {
2473 LOperand* value() { return inputs_[0]; }
2475 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2479 class LClampDToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2481 explicit LClampDToUint8(LOperand* value) {
2485 LOperand* unclamped() { return inputs_[0]; }
2487 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2491 class LClampIToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2493 explicit LClampIToUint8(LOperand* value) {
2497 LOperand* unclamped() { return inputs_[0]; }
2499 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2503 class LClampTToUint8 V8_FINAL : public LTemplateInstruction<1, 1, 1> {
2505 LClampTToUint8(LOperand* value, LOperand* temp_xmm) {
2507 temps_[0] = temp_xmm;
2510 LOperand* unclamped() { return inputs_[0]; }
2511 LOperand* temp_xmm() { return temps_[0]; }
2513 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2517 // Truncating conversion from a tagged value to an int32.
2518 class LClampTToUint8NoSSE2 V8_FINAL : public LTemplateInstruction<1, 1, 3> {
2520 LClampTToUint8NoSSE2(LOperand* unclamped,
2524 inputs_[0] = unclamped;
2530 LOperand* unclamped() { return inputs_[0]; }
2531 LOperand* scratch() { return temps_[0]; }
2532 LOperand* scratch2() { return temps_[1]; }
2533 LOperand* scratch3() { return temps_[2]; }
2535 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2536 "clamp-t-to-uint8-nosse2")
2537 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2541 class LCheckNonSmi V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2543 explicit LCheckNonSmi(LOperand* value) {
2547 LOperand* value() { return inputs_[0]; }
2549 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2550 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2554 class LAllocate V8_FINAL : public LTemplateInstruction<1, 2, 1> {
2556 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2557 inputs_[0] = context;
2562 LOperand* context() { return inputs_[0]; }
2563 LOperand* size() { return inputs_[1]; }
2564 LOperand* temp() { return temps_[0]; }
2566 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2567 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2571 class LRegExpLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2573 explicit LRegExpLiteral(LOperand* context) {
2574 inputs_[0] = context;
2577 LOperand* context() { return inputs_[0]; }
2579 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2580 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2584 class LFunctionLiteral V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2586 explicit LFunctionLiteral(LOperand* context) {
2587 inputs_[0] = context;
2590 LOperand* context() { return inputs_[0]; }
2592 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2593 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2597 class LToFastProperties V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2599 explicit LToFastProperties(LOperand* value) {
2603 LOperand* value() { return inputs_[0]; }
2605 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2606 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2610 class LTypeof V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2612 LTypeof(LOperand* context, LOperand* value) {
2613 inputs_[0] = context;
2617 LOperand* context() { return inputs_[0]; }
2618 LOperand* value() { return inputs_[1]; }
2620 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2624 class LTypeofIsAndBranch V8_FINAL : public LControlInstruction<1, 0> {
2626 explicit LTypeofIsAndBranch(LOperand* value) {
2630 LOperand* value() { return inputs_[0]; }
2632 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2633 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2635 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2637 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
2641 class LOsrEntry V8_FINAL : public LTemplateInstruction<0, 0, 0> {
2643 virtual bool HasInterestingComment(LCodeGen* gen) const V8_OVERRIDE {
2646 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2650 class LStackCheck V8_FINAL : public LTemplateInstruction<0, 1, 0> {
2652 explicit LStackCheck(LOperand* context) {
2653 inputs_[0] = context;
2656 LOperand* context() { return inputs_[0]; }
2658 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2659 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2661 Label* done_label() { return &done_label_; }
2668 class LForInPrepareMap V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2670 LForInPrepareMap(LOperand* context, LOperand* object) {
2671 inputs_[0] = context;
2672 inputs_[1] = object;
2675 LOperand* context() { return inputs_[0]; }
2676 LOperand* object() { return inputs_[1]; }
2678 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2682 class LForInCacheArray V8_FINAL : public LTemplateInstruction<1, 1, 0> {
2684 explicit LForInCacheArray(LOperand* map) {
2688 LOperand* map() { return inputs_[0]; }
2690 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2693 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2698 class LCheckMapValue V8_FINAL : public LTemplateInstruction<0, 2, 0> {
2700 LCheckMapValue(LOperand* value, LOperand* map) {
2705 LOperand* value() { return inputs_[0]; }
2706 LOperand* map() { return inputs_[1]; }
2708 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2712 class LLoadFieldByIndex V8_FINAL : public LTemplateInstruction<1, 2, 0> {
2714 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2715 inputs_[0] = object;
2719 LOperand* object() { return inputs_[0]; }
2720 LOperand* index() { return inputs_[1]; }
2722 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2726 class LChunkBuilder;
2727 class LPlatformChunk V8_FINAL : public LChunk {
2729 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2730 : LChunk(info, graph),
2731 num_double_slots_(0) { }
2733 int GetNextSpillIndex(RegisterKind kind);
2734 LOperand* GetNextSpillSlot(RegisterKind kind);
2736 int num_double_slots() const { return num_double_slots_; }
2739 int num_double_slots_;
2743 class LChunkBuilder V8_FINAL BASE_EMBEDDED {
2745 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2749 zone_(graph->zone()),
2751 current_instruction_(NULL),
2752 current_block_(NULL),
2755 allocator_(allocator),
2756 instruction_pending_deoptimization_environment_(NULL),
2757 pending_deoptimization_ast_id_(BailoutId::None()) { }
2759 // Build the sequence for the graph.
2760 LPlatformChunk* Build();
2762 LInstruction* CheckElideControlInstruction(HControlInstruction* instr);
2764 // Declare methods that deal with the individual node types.
2765 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2766 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2769 static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
2771 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2772 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2773 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2774 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2775 LInstruction* DoMathSin(HUnaryMathOperation* instr);
2776 LInstruction* DoMathCos(HUnaryMathOperation* instr);
2777 LInstruction* DoMathTan(HUnaryMathOperation* instr);
2778 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2779 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2780 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2790 LPlatformChunk* chunk() const { return chunk_; }
2791 CompilationInfo* info() const { return info_; }
2792 HGraph* graph() const { return graph_; }
2793 Zone* zone() const { return zone_; }
2795 bool is_unused() const { return status_ == UNUSED; }
2796 bool is_building() const { return status_ == BUILDING; }
2797 bool is_done() const { return status_ == DONE; }
2798 bool is_aborted() const { return status_ == ABORTED; }
2800 void Abort(BailoutReason reason);
2802 // Methods for getting operands for Use / Define / Temp.
2803 LUnallocated* ToUnallocated(Register reg);
2804 LUnallocated* ToUnallocated(XMMRegister 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);
2810 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2811 XMMRegister fixed_register);
2813 // A value that is guaranteed to be allocated to a register.
2814 // Operand created by UseRegister is guaranteed to be live until the end of
2815 // instruction. This means that register allocator will not reuse it's
2816 // register for any other operand inside instruction.
2817 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2818 // instruction start. Register allocator is free to assign the same register
2819 // to some other operand used inside instruction (i.e. temporary or
2821 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2822 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2824 // An input operand in a register that may be trashed.
2825 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2827 // An input operand in a register or stack slot.
2828 MUST_USE_RESULT LOperand* Use(HValue* value);
2829 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2831 // An input operand in a register, stack slot or a constant operand.
2832 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2833 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2835 // An input operand in a register or a constant operand.
2836 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2837 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2839 // An input operand in a constant operand.
2840 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2842 // An input operand in register, stack slot or a constant operand.
2843 // Will not be moved to a register even if one is freely available.
2844 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2846 // Temporary operand that must be in a register.
2847 MUST_USE_RESULT LUnallocated* TempRegister();
2848 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2849 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2851 // Methods for setting up define-use relationships.
2852 // Return the same instruction that they are passed.
2853 template<int I, int T>
2854 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2855 LUnallocated* result);
2856 template<int I, int T>
2857 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2858 template<int I, int T>
2859 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2861 template<int I, int T>
2862 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2863 template<int I, int T>
2864 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2866 template<int I, int T>
2867 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2869 template<int I, int T>
2870 LInstruction* DefineX87TOS(LTemplateInstruction<1, I, T>* instr);
2871 // Assigns an environment to an instruction. An instruction which can
2872 // deoptimize must have an environment.
2873 LInstruction* AssignEnvironment(LInstruction* instr);
2874 // Assigns a pointer map to an instruction. An instruction which can
2875 // trigger a GC or a lazy deoptimization must have a pointer map.
2876 LInstruction* AssignPointerMap(LInstruction* instr);
2878 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2880 // Marks a call for the register allocator. Assigns a pointer map to
2881 // support GC and lazy deoptimization. Assigns an environment to support
2882 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2883 LInstruction* MarkAsCall(
2884 LInstruction* instr,
2885 HInstruction* hinstr,
2886 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2888 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2889 int* argument_index_accumulator,
2890 ZoneList<HValue*>* objects_to_materialize);
2892 void VisitInstruction(HInstruction* current);
2894 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2895 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2896 LInstruction* DoArithmeticD(Token::Value op,
2897 HArithmeticBinaryOperation* instr);
2898 LInstruction* DoArithmeticT(Token::Value op,
2899 HBinaryOperation* instr);
2901 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2903 LPlatformChunk* chunk_;
2904 CompilationInfo* info_;
2905 HGraph* const graph_;
2908 HInstruction* current_instruction_;
2909 HBasicBlock* current_block_;
2910 HBasicBlock* next_block_;
2911 int argument_count_;
2912 LAllocator* allocator_;
2913 LInstruction* instruction_pending_deoptimization_environment_;
2914 BailoutId pending_deoptimization_ast_id_;
2916 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2919 #undef DECLARE_HYDROGEN_ACCESSOR
2920 #undef DECLARE_CONCRETE_INSTRUCTION
2922 } } // namespace v8::internal
2924 #endif // V8_IA32_LITHIUM_IA32_H_