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_MIPS_LITHIUM_MIPS_H_
29 #define V8_MIPS_LITHIUM_MIPS_H_
32 #include "lithium-allocator.h"
34 #include "safepoint-table.h"
40 // Forward declarations.
43 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \
44 V(ControlInstruction) \
46 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
49 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
50 V(AccessArgumentsAt) \
54 V(ArgumentsElements) \
63 V(CallConstantFunction) \
73 V(CheckInstanceType) \
76 V(CheckPrototypeMaps) \
81 V(ClassOfTestAndBranch) \
82 V(CmpConstantEqAndBranch) \
84 V(CmpObjectEqAndBranch) \
98 V(FixedArrayBaseLength) \
100 V(GetCachedArrayIndex) \
104 V(HasCachedArrayIndexAndBranch) \
105 V(HasInstanceTypeAndBranch) \
108 V(InstanceOfKnownGlobal) \
110 V(Integer32ToDouble) \
112 V(IsConstructCallAndBranch) \
114 V(IsObjectAndBranch) \
115 V(IsStringAndBranch) \
117 V(IsUndetectableAndBranch) \
118 V(StringCompareAndBranch) \
124 V(LoadExternalArrayPointer) \
125 V(LoadFunctionPrototype) \
127 V(LoadGlobalGeneric) \
128 V(LoadKeyedFastDoubleElement) \
129 V(LoadKeyedFastElement) \
130 V(LoadKeyedGeneric) \
131 V(LoadKeyedSpecializedArrayElement) \
133 V(LoadNamedFieldPolymorphic) \
134 V(LoadNamedGeneric) \
153 V(StoreContextSlot) \
155 V(StoreGlobalGeneric) \
156 V(StoreKeyedFastDoubleElement) \
157 V(StoreKeyedFastElement) \
158 V(StoreKeyedGeneric) \
159 V(StoreKeyedSpecializedArrayElement) \
161 V(StoreNamedGeneric) \
163 V(StringCharCodeAt) \
164 V(StringCharFromCode) \
170 V(ToFastProperties) \
171 V(TransitionElementsKind) \
173 V(TypeofIsAndBranch) \
174 V(UnaryMathOperation) \
180 V(LoadFieldByIndex) \
184 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
185 virtual Opcode opcode() const { return LInstruction::k##type; } \
186 virtual void CompileToNative(LCodeGen* generator); \
187 virtual const char* Mnemonic() const { return mnemonic; } \
188 static L##type* cast(LInstruction* instr) { \
189 ASSERT(instr->Is##type()); \
190 return reinterpret_cast<L##type*>(instr); \
194 #define DECLARE_HYDROGEN_ACCESSOR(type) \
195 H##type* hydrogen() const { \
196 return H##type::cast(hydrogen_value()); \
200 class LInstruction: public ZoneObject {
203 : environment_(NULL),
204 hydrogen_value_(NULL),
206 is_save_doubles_(false) { }
207 virtual ~LInstruction() { }
209 virtual void CompileToNative(LCodeGen* generator) = 0;
210 virtual const char* Mnemonic() const = 0;
211 virtual void PrintTo(StringStream* stream);
212 virtual void PrintDataTo(StringStream* stream) = 0;
213 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
216 // Declare a unique enum value for each instruction.
217 #define DECLARE_OPCODE(type) k##type,
218 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
219 kNumberOfInstructions
220 #undef DECLARE_OPCODE
223 virtual Opcode opcode() const = 0;
225 // Declare non-virtual type testers for all leaf IR classes.
226 #define DECLARE_PREDICATE(type) \
227 bool Is##type() const { return opcode() == k##type; }
228 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
229 #undef DECLARE_PREDICATE
231 // Declare virtual predicates for instructions that don't have
233 virtual bool IsGap() const { return false; }
235 virtual bool IsControl() const { return false; }
237 void set_environment(LEnvironment* env) { environment_ = env; }
238 LEnvironment* environment() const { return environment_; }
239 bool HasEnvironment() const { return environment_ != NULL; }
241 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
242 LPointerMap* pointer_map() const { return pointer_map_.get(); }
243 bool HasPointerMap() const { return pointer_map_.is_set(); }
245 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
246 HValue* hydrogen_value() const { return hydrogen_value_; }
248 void set_deoptimization_environment(LEnvironment* env) {
249 deoptimization_environment_.set(env);
251 LEnvironment* deoptimization_environment() const {
252 return deoptimization_environment_.get();
254 bool HasDeoptimizationEnvironment() const {
255 return deoptimization_environment_.is_set();
258 void MarkAsCall() { is_call_ = true; }
259 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
261 // Interface to the register allocator and iterators.
262 bool IsMarkedAsCall() const { return is_call_; }
263 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
265 virtual bool HasResult() const = 0;
266 virtual LOperand* result() = 0;
268 virtual int InputCount() = 0;
269 virtual LOperand* InputAt(int i) = 0;
270 virtual int TempCount() = 0;
271 virtual LOperand* TempAt(int i) = 0;
273 LOperand* FirstInput() { return InputAt(0); }
274 LOperand* Output() { return HasResult() ? result() : NULL; }
281 LEnvironment* environment_;
282 SetOncePointer<LPointerMap> pointer_map_;
283 HValue* hydrogen_value_;
284 SetOncePointer<LEnvironment> deoptimization_environment_;
286 bool is_save_doubles_;
290 // R = number of result operands (0 or 1).
291 // I = number of input operands.
292 // T = number of temporary operands.
293 template<int R, int I, int T>
294 class LTemplateInstruction: public LInstruction {
296 // Allow 0 or 1 output operands.
297 STATIC_ASSERT(R == 0 || R == 1);
298 virtual bool HasResult() const { return R != 0; }
299 void set_result(LOperand* operand) { results_[0] = operand; }
300 LOperand* result() { return results_[0]; }
302 int InputCount() { return I; }
303 LOperand* InputAt(int i) { return inputs_[i]; }
305 int TempCount() { return T; }
306 LOperand* TempAt(int i) { return temps_[i]; }
308 virtual void PrintDataTo(StringStream* stream);
309 virtual void PrintOutputOperandTo(StringStream* stream);
312 EmbeddedContainer<LOperand*, R> results_;
313 EmbeddedContainer<LOperand*, I> inputs_;
314 EmbeddedContainer<LOperand*, T> temps_;
318 class LGap: public LTemplateInstruction<0, 0, 0> {
320 explicit LGap(HBasicBlock* block)
322 parallel_moves_[BEFORE] = NULL;
323 parallel_moves_[START] = NULL;
324 parallel_moves_[END] = NULL;
325 parallel_moves_[AFTER] = NULL;
328 // Can't use the DECLARE-macro here because of sub-classes.
329 virtual bool IsGap() const { return true; }
330 virtual void PrintDataTo(StringStream* stream);
331 static LGap* cast(LInstruction* instr) {
332 ASSERT(instr->IsGap());
333 return reinterpret_cast<LGap*>(instr);
336 bool IsRedundant() const;
338 HBasicBlock* block() const { return block_; }
345 FIRST_INNER_POSITION = BEFORE,
346 LAST_INNER_POSITION = AFTER
349 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
350 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
351 return parallel_moves_[pos];
354 LParallelMove* GetParallelMove(InnerPosition pos) {
355 return parallel_moves_[pos];
359 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
364 class LInstructionGap: public LGap {
366 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
372 class LGoto: public LTemplateInstruction<0, 0, 0> {
374 explicit LGoto(int block_id) : block_id_(block_id) { }
376 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
377 virtual void PrintDataTo(StringStream* stream);
378 virtual bool IsControl() const { return true; }
380 int block_id() const { return block_id_; }
387 class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
389 LLazyBailout() : gap_instructions_size_(0) { }
391 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
393 void set_gap_instructions_size(int gap_instructions_size) {
394 gap_instructions_size_ = gap_instructions_size;
396 int gap_instructions_size() { return gap_instructions_size_; }
399 int gap_instructions_size_;
403 class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
405 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
409 class LLabel: public LGap {
411 explicit LLabel(HBasicBlock* block)
412 : LGap(block), replacement_(NULL) { }
414 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
416 virtual void PrintDataTo(StringStream* stream);
418 int block_id() const { return block()->block_id(); }
419 bool is_loop_header() const { return block()->IsLoopHeader(); }
420 Label* label() { return &label_; }
421 LLabel* replacement() const { return replacement_; }
422 void set_replacement(LLabel* label) { replacement_ = label; }
423 bool HasReplacement() const { return replacement_ != NULL; }
427 LLabel* replacement_;
431 class LParameter: public LTemplateInstruction<1, 0, 0> {
433 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
437 class LCallStub: public LTemplateInstruction<1, 0, 0> {
439 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
440 DECLARE_HYDROGEN_ACCESSOR(CallStub)
442 TranscendentalCache::Type transcendental_type() {
443 return hydrogen()->transcendental_type();
448 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
450 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
454 template<int I, int T>
455 class LControlInstruction: public LTemplateInstruction<0, I, T> {
457 virtual bool IsControl() const { return true; }
459 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
460 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
461 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
462 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
465 HControlInstruction* hydrogen() {
466 return HControlInstruction::cast(this->hydrogen_value());
471 class LWrapReceiver: public LTemplateInstruction<1, 2, 0> {
473 LWrapReceiver(LOperand* receiver, LOperand* function) {
474 inputs_[0] = receiver;
475 inputs_[1] = function;
478 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
480 LOperand* receiver() { return inputs_[0]; }
481 LOperand* function() { return inputs_[1]; }
485 class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
487 LApplyArguments(LOperand* function,
490 LOperand* elements) {
491 inputs_[0] = function;
492 inputs_[1] = receiver;
494 inputs_[3] = elements;
497 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
499 LOperand* function() { return inputs_[0]; }
500 LOperand* receiver() { return inputs_[1]; }
501 LOperand* length() { return inputs_[2]; }
502 LOperand* elements() { return inputs_[3]; }
506 class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
508 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
509 inputs_[0] = arguments;
514 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
516 LOperand* arguments() { return inputs_[0]; }
517 LOperand* length() { return inputs_[1]; }
518 LOperand* index() { return inputs_[2]; }
520 virtual void PrintDataTo(StringStream* stream);
524 class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
526 explicit LArgumentsLength(LOperand* elements) {
527 inputs_[0] = elements;
530 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
534 class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
536 LArgumentsElements() { }
538 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
542 class LModI: public LTemplateInstruction<1, 2, 3> {
544 // Used when the right hand is a constant power of 2.
545 LModI(LOperand* left,
554 // Used for the standard case.
555 LModI(LOperand* left,
567 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
568 DECLARE_HYDROGEN_ACCESSOR(Mod)
572 class LDivI: public LTemplateInstruction<1, 2, 0> {
574 LDivI(LOperand* left, LOperand* right) {
579 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
580 DECLARE_HYDROGEN_ACCESSOR(Div)
584 class LMulI: public LTemplateInstruction<1, 2, 1> {
586 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
592 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
593 DECLARE_HYDROGEN_ACCESSOR(Mul)
597 class LCmpIDAndBranch: public LControlInstruction<2, 0> {
599 LCmpIDAndBranch(LOperand* left, LOperand* right) {
604 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
605 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
607 Token::Value op() const { return hydrogen()->token(); }
608 bool is_double() const {
609 return hydrogen()->GetInputRepresentation().IsDouble();
612 virtual void PrintDataTo(StringStream* stream);
616 class LUnaryMathOperation: public LTemplateInstruction<1, 1, 1> {
618 LUnaryMathOperation(LOperand* value, LOperand* temp) {
623 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
624 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
626 virtual void PrintDataTo(StringStream* stream);
627 BuiltinFunctionId op() const { return hydrogen()->op(); }
631 class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
633 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
638 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
639 "cmp-object-eq-and-branch")
640 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
644 class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
646 explicit LCmpConstantEqAndBranch(LOperand* left) {
650 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
651 "cmp-constant-eq-and-branch")
652 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
656 class LIsNilAndBranch: public LControlInstruction<1, 0> {
658 explicit LIsNilAndBranch(LOperand* value) {
662 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
663 DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
665 EqualityKind kind() const { return hydrogen()->kind(); }
666 NilValue nil() const { return hydrogen()->nil(); }
668 virtual void PrintDataTo(StringStream* stream);
672 class LIsObjectAndBranch: public LControlInstruction<1, 1> {
674 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
679 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
680 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
682 virtual void PrintDataTo(StringStream* stream);
686 class LIsStringAndBranch: public LControlInstruction<1, 1> {
688 LIsStringAndBranch(LOperand* value, LOperand* temp) {
693 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
694 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
696 virtual void PrintDataTo(StringStream* stream);
700 class LIsSmiAndBranch: public LControlInstruction<1, 0> {
702 explicit LIsSmiAndBranch(LOperand* value) {
706 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
707 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
709 virtual void PrintDataTo(StringStream* stream);
713 class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
715 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
720 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
721 "is-undetectable-and-branch")
722 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
724 virtual void PrintDataTo(StringStream* stream);
728 class LStringCompareAndBranch: public LControlInstruction<2, 0> {
730 LStringCompareAndBranch(LOperand* left, LOperand* right) {
735 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
736 "string-compare-and-branch")
737 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
739 Token::Value op() const { return hydrogen()->token(); }
741 virtual void PrintDataTo(StringStream* stream);
745 class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
747 explicit LHasInstanceTypeAndBranch(LOperand* value) {
751 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
752 "has-instance-type-and-branch")
753 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
755 virtual void PrintDataTo(StringStream* stream);
759 class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
761 explicit LGetCachedArrayIndex(LOperand* value) {
765 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
766 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
770 class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
772 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
776 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
777 "has-cached-array-index-and-branch")
778 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
780 virtual void PrintDataTo(StringStream* stream);
784 class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
786 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
791 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
792 "class-of-test-and-branch")
793 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
795 virtual void PrintDataTo(StringStream* stream);
799 class LCmpT: public LTemplateInstruction<1, 2, 0> {
801 LCmpT(LOperand* left, LOperand* right) {
806 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
807 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
809 Token::Value op() const { return hydrogen()->token(); }
813 class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
815 LInstanceOf(LOperand* left, LOperand* right) {
820 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
824 class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
826 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
831 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
832 "instance-of-known-global")
833 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
835 Handle<JSFunction> function() const { return hydrogen()->function(); }
839 class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
841 LBoundsCheck(LOperand* index, LOperand* length) {
846 LOperand* index() { return inputs_[0]; }
847 LOperand* length() { return inputs_[1]; }
849 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
853 class LBitI: public LTemplateInstruction<1, 2, 0> {
855 LBitI(LOperand* left, LOperand* right) {
860 Token::Value op() const { return hydrogen()->op(); }
862 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
863 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
867 class LShiftI: public LTemplateInstruction<1, 2, 0> {
869 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
870 : op_(op), can_deopt_(can_deopt) {
875 Token::Value op() const { return op_; }
877 bool can_deopt() const { return can_deopt_; }
879 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
887 class LSubI: public LTemplateInstruction<1, 2, 0> {
889 LSubI(LOperand* left, LOperand* right) {
894 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
895 DECLARE_HYDROGEN_ACCESSOR(Sub)
899 class LConstantI: public LTemplateInstruction<1, 0, 0> {
901 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
902 DECLARE_HYDROGEN_ACCESSOR(Constant)
904 int32_t value() const { return hydrogen()->Integer32Value(); }
908 class LConstantD: public LTemplateInstruction<1, 0, 0> {
910 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
911 DECLARE_HYDROGEN_ACCESSOR(Constant)
913 double value() const { return hydrogen()->DoubleValue(); }
917 class LConstantT: public LTemplateInstruction<1, 0, 0> {
919 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
920 DECLARE_HYDROGEN_ACCESSOR(Constant)
922 Handle<Object> value() const { return hydrogen()->handle(); }
926 class LBranch: public LControlInstruction<1, 0> {
928 explicit LBranch(LOperand* value) {
932 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
933 DECLARE_HYDROGEN_ACCESSOR(Branch)
935 virtual void PrintDataTo(StringStream* stream);
939 class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
941 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
946 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
947 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
949 virtual bool IsControl() const { return true; }
951 Handle<Map> map() const { return hydrogen()->map(); }
952 int true_block_id() const {
953 return hydrogen()->FirstSuccessor()->block_id();
955 int false_block_id() const {
956 return hydrogen()->SecondSuccessor()->block_id();
961 class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
963 explicit LJSArrayLength(LOperand* value) {
967 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
968 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
972 class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
974 explicit LFixedArrayBaseLength(LOperand* value) {
978 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
979 "fixed-array-base-length")
980 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
984 class LElementsKind: public LTemplateInstruction<1, 1, 0> {
986 explicit LElementsKind(LOperand* value) {
990 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
991 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
995 class LValueOf: public LTemplateInstruction<1, 1, 1> {
997 LValueOf(LOperand* value, LOperand* temp) {
1002 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1003 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1007 class LDateField: public LTemplateInstruction<1, 1, 1> {
1009 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1014 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
1015 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1016 Smi* index() const { return index_; }
1023 class LThrow: public LTemplateInstruction<0, 1, 0> {
1025 explicit LThrow(LOperand* value) {
1029 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1033 class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1035 explicit LBitNotI(LOperand* value) {
1039 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1043 class LAddI: public LTemplateInstruction<1, 2, 0> {
1045 LAddI(LOperand* left, LOperand* right) {
1050 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1051 DECLARE_HYDROGEN_ACCESSOR(Add)
1055 class LPower: public LTemplateInstruction<1, 2, 0> {
1057 LPower(LOperand* left, LOperand* right) {
1062 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1063 DECLARE_HYDROGEN_ACCESSOR(Power)
1067 class LRandom: public LTemplateInstruction<1, 1, 0> {
1069 explicit LRandom(LOperand* global_object) {
1070 inputs_[0] = global_object;
1073 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1074 DECLARE_HYDROGEN_ACCESSOR(Random)
1078 class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1080 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1086 Token::Value op() const { return op_; }
1088 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1089 virtual void CompileToNative(LCodeGen* generator);
1090 virtual const char* Mnemonic() const;
1097 class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1099 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1105 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1106 virtual void CompileToNative(LCodeGen* generator);
1107 virtual const char* Mnemonic() const;
1109 Token::Value op() const { return op_; }
1116 class LReturn: public LTemplateInstruction<0, 1, 0> {
1118 explicit LReturn(LOperand* value) {
1122 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1126 class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1128 explicit LLoadNamedField(LOperand* object) {
1129 inputs_[0] = object;
1132 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1133 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1137 class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1139 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1140 inputs_[0] = object;
1143 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1144 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1146 LOperand* object() { return inputs_[0]; }
1150 class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1152 explicit LLoadNamedGeneric(LOperand* object) {
1153 inputs_[0] = object;
1156 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1157 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1159 LOperand* object() { return inputs_[0]; }
1160 Handle<Object> name() const { return hydrogen()->name(); }
1164 class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1166 explicit LLoadFunctionPrototype(LOperand* function) {
1167 inputs_[0] = function;
1170 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1171 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1173 LOperand* function() { return inputs_[0]; }
1177 class LLoadElements: public LTemplateInstruction<1, 1, 0> {
1179 explicit LLoadElements(LOperand* object) {
1180 inputs_[0] = object;
1183 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1187 class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1189 explicit LLoadExternalArrayPointer(LOperand* object) {
1190 inputs_[0] = object;
1193 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1194 "load-external-array-pointer")
1198 class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
1200 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1201 inputs_[0] = elements;
1205 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1206 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1208 LOperand* elements() { return inputs_[0]; }
1209 LOperand* key() { return inputs_[1]; }
1213 class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> {
1215 LLoadKeyedFastDoubleElement(LOperand* elements, LOperand* key) {
1216 inputs_[0] = elements;
1220 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement,
1221 "load-keyed-fast-double-element")
1222 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement)
1224 LOperand* elements() { return inputs_[0]; }
1225 LOperand* key() { return inputs_[1]; }
1229 class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
1231 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1233 inputs_[0] = external_pointer;
1237 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1238 "load-keyed-specialized-array-element")
1239 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
1241 LOperand* external_pointer() { return inputs_[0]; }
1242 LOperand* key() { return inputs_[1]; }
1243 ElementsKind elements_kind() const {
1244 return hydrogen()->elements_kind();
1249 class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1251 LLoadKeyedGeneric(LOperand* obj, LOperand* key) {
1256 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1258 LOperand* object() { return inputs_[0]; }
1259 LOperand* key() { return inputs_[1]; }
1263 class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1265 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1266 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1270 class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1272 explicit LLoadGlobalGeneric(LOperand* global_object) {
1273 inputs_[0] = global_object;
1276 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1277 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1279 LOperand* global_object() { return inputs_[0]; }
1280 Handle<Object> name() const { return hydrogen()->name(); }
1281 bool for_typeof() const { return hydrogen()->for_typeof(); }
1285 class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1287 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1292 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1293 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1295 LOperand* value() { return inputs_[0]; }
1299 class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1301 explicit LStoreGlobalGeneric(LOperand* global_object,
1303 inputs_[0] = global_object;
1307 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1308 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1310 LOperand* global_object() { return InputAt(0); }
1311 Handle<Object> name() const { return hydrogen()->name(); }
1312 LOperand* value() { return InputAt(1); }
1313 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1317 class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1319 explicit LLoadContextSlot(LOperand* context) {
1320 inputs_[0] = context;
1323 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1324 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1326 LOperand* context() { return InputAt(0); }
1327 int slot_index() { return hydrogen()->slot_index(); }
1329 virtual void PrintDataTo(StringStream* stream);
1333 class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1335 LStoreContextSlot(LOperand* context, LOperand* value) {
1336 inputs_[0] = context;
1340 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1341 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1343 LOperand* context() { return InputAt(0); }
1344 LOperand* value() { return InputAt(1); }
1345 int slot_index() { return hydrogen()->slot_index(); }
1347 virtual void PrintDataTo(StringStream* stream);
1351 class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1353 explicit LPushArgument(LOperand* value) {
1357 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1361 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1363 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1364 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1368 class LContext: public LTemplateInstruction<1, 0, 0> {
1370 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1374 class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1376 explicit LOuterContext(LOperand* context) {
1377 inputs_[0] = context;
1380 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1382 LOperand* context() { return InputAt(0); }
1386 class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> {
1388 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1389 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1393 class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1395 explicit LGlobalObject(LOperand* context, bool qml_global) {
1396 inputs_[0] = context;
1397 qml_global_ = qml_global;
1400 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1402 LOperand* context() { return InputAt(0); }
1403 bool qml_global() { return qml_global_; }
1409 class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1411 explicit LGlobalReceiver(LOperand* global_object) {
1412 inputs_[0] = global_object;
1415 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1417 LOperand* global() { return InputAt(0); }
1421 class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1423 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1424 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1426 virtual void PrintDataTo(StringStream* stream);
1428 Handle<JSFunction> function() { return hydrogen()->function(); }
1429 int arity() const { return hydrogen()->argument_count() - 1; }
1433 class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1435 explicit LInvokeFunction(LOperand* function) {
1436 inputs_[0] = function;
1439 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1440 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1442 LOperand* function() { return inputs_[0]; }
1444 virtual void PrintDataTo(StringStream* stream);
1446 int arity() const { return hydrogen()->argument_count() - 1; }
1450 class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1452 explicit LCallKeyed(LOperand* key) {
1456 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1457 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1459 virtual void PrintDataTo(StringStream* stream);
1461 int arity() const { return hydrogen()->argument_count() - 1; }
1466 class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1468 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1469 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1471 virtual void PrintDataTo(StringStream* stream);
1473 Handle<String> name() const { return hydrogen()->name(); }
1474 int arity() const { return hydrogen()->argument_count() - 1; }
1478 class LCallFunction: public LTemplateInstruction<1, 1, 0> {
1480 explicit LCallFunction(LOperand* function) {
1481 inputs_[0] = function;
1484 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1485 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1487 LOperand* function() { return inputs_[0]; }
1488 int arity() const { return hydrogen()->argument_count() - 1; }
1492 class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1494 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1495 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1497 explicit LCallGlobal(bool qml_global) : qml_global_(qml_global) {}
1499 virtual void PrintDataTo(StringStream* stream);
1501 Handle<String> name() const {return hydrogen()->name(); }
1502 int arity() const { return hydrogen()->argument_count() - 1; }
1504 bool qml_global() { return qml_global_; }
1510 class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1512 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1513 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1515 virtual void PrintDataTo(StringStream* stream);
1517 Handle<JSFunction> target() const { return hydrogen()->target(); }
1518 int arity() const { return hydrogen()->argument_count() - 1; }
1522 class LCallNew: public LTemplateInstruction<1, 1, 0> {
1524 explicit LCallNew(LOperand* constructor) {
1525 inputs_[0] = constructor;
1528 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1529 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1531 virtual void PrintDataTo(StringStream* stream);
1533 int arity() const { return hydrogen()->argument_count() - 1; }
1537 class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1539 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1540 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1542 const Runtime::Function* function() const { return hydrogen()->function(); }
1543 int arity() const { return hydrogen()->argument_count(); }
1547 class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1549 explicit LInteger32ToDouble(LOperand* value) {
1553 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1557 class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1559 explicit LNumberTagI(LOperand* value) {
1563 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1567 class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1569 LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) {
1575 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1579 // Sometimes truncating conversion from a tagged value to an int32.
1580 class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1582 LDoubleToI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1588 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1589 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1591 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1595 // Truncating conversion from a tagged value to an int32.
1596 class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
1598 LTaggedToI(LOperand* value,
1608 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1609 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1611 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1615 class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1617 explicit LSmiTag(LOperand* value) {
1621 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1625 class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
1627 explicit LNumberUntagD(LOperand* value) {
1631 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1632 DECLARE_HYDROGEN_ACCESSOR(Change)
1636 class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1638 LSmiUntag(LOperand* value, bool needs_check)
1639 : needs_check_(needs_check) {
1643 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1645 bool needs_check() const { return needs_check_; }
1652 class LStoreNamedField: public LTemplateInstruction<0, 2, 0> {
1654 LStoreNamedField(LOperand* obj, LOperand* val) {
1659 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1660 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1662 virtual void PrintDataTo(StringStream* stream);
1664 LOperand* object() { return inputs_[0]; }
1665 LOperand* value() { return inputs_[1]; }
1667 Handle<Object> name() const { return hydrogen()->name(); }
1668 bool is_in_object() { return hydrogen()->is_in_object(); }
1669 int offset() { return hydrogen()->offset(); }
1670 Handle<Map> transition() const { return hydrogen()->transition(); }
1674 class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1676 LStoreNamedGeneric(LOperand* obj, LOperand* val) {
1681 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1682 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1684 virtual void PrintDataTo(StringStream* stream);
1686 LOperand* object() { return inputs_[0]; }
1687 LOperand* value() { return inputs_[1]; }
1688 Handle<Object> name() const { return hydrogen()->name(); }
1689 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1693 class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
1695 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
1701 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1702 "store-keyed-fast-element")
1703 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
1705 virtual void PrintDataTo(StringStream* stream);
1707 LOperand* object() { return inputs_[0]; }
1708 LOperand* key() { return inputs_[1]; }
1709 LOperand* value() { return inputs_[2]; }
1713 class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1715 LStoreKeyedFastDoubleElement(LOperand* elements,
1718 inputs_[0] = elements;
1723 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1724 "store-keyed-fast-double-element")
1725 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1727 virtual void PrintDataTo(StringStream* stream);
1729 LOperand* elements() { return inputs_[0]; }
1730 LOperand* key() { return inputs_[1]; }
1731 LOperand* value() { return inputs_[2]; }
1735 class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
1737 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* val) {
1743 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1744 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1746 virtual void PrintDataTo(StringStream* stream);
1748 LOperand* object() { return inputs_[0]; }
1749 LOperand* key() { return inputs_[1]; }
1750 LOperand* value() { return inputs_[2]; }
1751 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1754 class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
1756 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1759 inputs_[0] = external_pointer;
1764 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1765 "store-keyed-specialized-array-element")
1766 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
1768 LOperand* external_pointer() { return inputs_[0]; }
1769 LOperand* key() { return inputs_[1]; }
1770 LOperand* value() { return inputs_[2]; }
1771 ElementsKind elements_kind() const {
1772 return hydrogen()->elements_kind();
1777 class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1779 LTransitionElementsKind(LOperand* object,
1780 LOperand* new_map_temp,
1781 LOperand* temp_reg) {
1782 inputs_[0] = object;
1783 temps_[0] = new_map_temp;
1784 temps_[1] = temp_reg;
1787 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1788 "transition-elements-kind")
1789 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1791 virtual void PrintDataTo(StringStream* stream);
1793 LOperand* object() { return inputs_[0]; }
1794 LOperand* new_map_reg() { return temps_[0]; }
1795 LOperand* temp_reg() { return temps_[1]; }
1796 Handle<Map> original_map() { return hydrogen()->original_map(); }
1797 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
1801 class LStringAdd: public LTemplateInstruction<1, 2, 0> {
1803 LStringAdd(LOperand* left, LOperand* right) {
1808 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1809 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1811 LOperand* left() { return inputs_[0]; }
1812 LOperand* right() { return inputs_[1]; }
1817 class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
1819 LStringCharCodeAt(LOperand* string, LOperand* index) {
1820 inputs_[0] = string;
1824 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1825 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1827 LOperand* string() { return inputs_[0]; }
1828 LOperand* index() { return inputs_[1]; }
1832 class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
1834 explicit LStringCharFromCode(LOperand* char_code) {
1835 inputs_[0] = char_code;
1838 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1839 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1841 LOperand* char_code() { return inputs_[0]; }
1845 class LStringLength: public LTemplateInstruction<1, 1, 0> {
1847 explicit LStringLength(LOperand* string) {
1848 inputs_[0] = string;
1851 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1852 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1854 LOperand* string() { return inputs_[0]; }
1858 class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
1860 explicit LCheckFunction(LOperand* value) {
1864 LOperand* value() { return InputAt(0); }
1866 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1867 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1871 class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
1873 explicit LCheckInstanceType(LOperand* value) {
1877 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1878 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
1882 class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
1884 explicit LCheckMaps(LOperand* value) {
1888 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
1889 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
1893 class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
1895 LCheckPrototypeMaps(LOperand* temp1, LOperand* temp2) {
1900 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
1901 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
1903 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1904 Handle<JSObject> holder() const { return hydrogen()->holder(); }
1908 class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
1910 explicit LCheckSmi(LOperand* value) {
1914 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1918 class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1920 explicit LCheckNonSmi(LOperand* value) {
1924 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
1928 class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
1930 LClampDToUint8(LOperand* value, LOperand* temp) {
1935 LOperand* unclamped() { return inputs_[0]; }
1937 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1941 class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1943 explicit LClampIToUint8(LOperand* value) {
1947 LOperand* unclamped() { return inputs_[0]; }
1949 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1953 class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
1955 LClampTToUint8(LOperand* value, LOperand* temp) {
1960 LOperand* unclamped() { return inputs_[0]; }
1962 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1966 class LAllocateObject: public LTemplateInstruction<1, 0, 2> {
1968 LAllocateObject(LOperand* temp1, LOperand* temp2) {
1973 DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object")
1974 DECLARE_HYDROGEN_ACCESSOR(AllocateObject)
1978 class LFastLiteral: public LTemplateInstruction<1, 0, 0> {
1980 DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal")
1981 DECLARE_HYDROGEN_ACCESSOR(FastLiteral)
1985 class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
1987 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1988 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1992 class LObjectLiteral: public LTemplateInstruction<1, 0, 0> {
1994 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
1995 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
1999 class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
2001 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2002 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2006 class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
2008 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2009 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2011 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2015 class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2017 explicit LToFastProperties(LOperand* value) {
2021 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2022 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2026 class LTypeof: public LTemplateInstruction<1, 1, 0> {
2028 explicit LTypeof(LOperand* value) {
2032 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2036 class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2038 explicit LTypeofIsAndBranch(LOperand* value) {
2042 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2043 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2045 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2047 virtual void PrintDataTo(StringStream* stream);
2051 class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
2053 explicit LIsConstructCallAndBranch(LOperand* temp) {
2057 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2058 "is-construct-call-and-branch")
2062 class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
2064 LDeleteProperty(LOperand* obj, LOperand* key) {
2069 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
2071 LOperand* object() { return inputs_[0]; }
2072 LOperand* key() { return inputs_[1]; }
2076 class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2080 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2082 LOperand** SpilledRegisterArray() { return register_spills_; }
2083 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2085 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2086 void MarkSpilledDoubleRegister(int allocation_index,
2087 LOperand* spill_operand);
2090 // Arrays of spill slot operands for registers with an assigned spill
2091 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2092 // NULL if the register has no assigned spill slot. Indexed by allocation
2094 LOperand* register_spills_[Register::kNumAllocatableRegisters];
2095 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2099 class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2101 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2102 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2104 Label* done_label() { return &done_label_; }
2111 class LIn: public LTemplateInstruction<1, 2, 0> {
2113 LIn(LOperand* key, LOperand* object) {
2115 inputs_[1] = object;
2118 LOperand* key() { return inputs_[0]; }
2119 LOperand* object() { return inputs_[1]; }
2121 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2125 class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> {
2127 explicit LForInPrepareMap(LOperand* object) {
2128 inputs_[0] = object;
2131 LOperand* object() { return inputs_[0]; }
2133 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2137 class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
2139 explicit LForInCacheArray(LOperand* map) {
2143 LOperand* map() { return inputs_[0]; }
2145 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2148 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2153 class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2155 LCheckMapValue(LOperand* value, LOperand* map) {
2160 LOperand* value() { return inputs_[0]; }
2161 LOperand* map() { return inputs_[1]; }
2163 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2167 class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2169 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2170 inputs_[0] = object;
2174 LOperand* object() { return inputs_[0]; }
2175 LOperand* index() { return inputs_[1]; }
2177 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2181 class LChunkBuilder;
2182 class LChunk: public ZoneObject {
2184 explicit LChunk(CompilationInfo* info, HGraph* graph);
2186 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
2187 LConstantOperand* DefineConstantOperand(HConstant* constant);
2188 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2189 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
2191 int GetNextSpillIndex(bool is_double);
2192 LOperand* GetNextSpillSlot(bool is_double);
2194 int ParameterAt(int index);
2195 int GetParameterStackSlot(int index) const;
2196 int spill_slot_count() const { return spill_slot_count_; }
2197 CompilationInfo* info() const { return info_; }
2198 HGraph* graph() const { return graph_; }
2199 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2200 void AddGapMove(int index, LOperand* from, LOperand* to);
2201 LGap* GetGapAt(int index) const;
2202 bool IsGapAt(int index) const;
2203 int NearestGapPos(int index) const;
2204 void MarkEmptyBlocks();
2205 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
2206 LLabel* GetLabel(int block_id) const {
2207 HBasicBlock* block = graph_->blocks()->at(block_id);
2208 int first_instruction = block->first_instruction_index();
2209 return LLabel::cast(instructions_[first_instruction]);
2211 int LookupDestination(int block_id) const {
2212 LLabel* cur = GetLabel(block_id);
2213 while (cur->replacement() != NULL) {
2214 cur = cur->replacement();
2216 return cur->block_id();
2218 Label* GetAssemblyLabel(int block_id) const {
2219 LLabel* label = GetLabel(block_id);
2220 ASSERT(!label->HasReplacement());
2221 return label->label();
2224 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2225 return &inlined_closures_;
2228 void AddInlinedClosure(Handle<JSFunction> closure) {
2229 inlined_closures_.Add(closure);
2233 int spill_slot_count_;
2234 CompilationInfo* info_;
2235 HGraph* const graph_;
2236 ZoneList<LInstruction*> instructions_;
2237 ZoneList<LPointerMap*> pointer_maps_;
2238 ZoneList<Handle<JSFunction> > inlined_closures_;
2242 class LChunkBuilder BASE_EMBEDDED {
2244 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2248 zone_(graph->isolate()->zone()),
2250 current_instruction_(NULL),
2251 current_block_(NULL),
2254 allocator_(allocator),
2255 position_(RelocInfo::kNoPosition),
2256 instruction_pending_deoptimization_environment_(NULL),
2257 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
2259 // Build the sequence for the graph.
2262 // Declare methods that deal with the individual node types.
2263 #define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2264 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2275 LChunk* chunk() const { return chunk_; }
2276 CompilationInfo* info() const { return info_; }
2277 HGraph* graph() const { return graph_; }
2278 Zone* zone() const { return zone_; }
2280 bool is_unused() const { return status_ == UNUSED; }
2281 bool is_building() const { return status_ == BUILDING; }
2282 bool is_done() const { return status_ == DONE; }
2283 bool is_aborted() const { return status_ == ABORTED; }
2285 void Abort(const char* format, ...);
2287 // Methods for getting operands for Use / Define / Temp.
2288 LUnallocated* ToUnallocated(Register reg);
2289 LUnallocated* ToUnallocated(DoubleRegister reg);
2291 // Methods for setting up define-use relationships.
2292 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2293 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2294 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2295 DoubleRegister fixed_register);
2297 // A value that is guaranteed to be allocated to a register.
2298 // Operand created by UseRegister is guaranteed to be live until the end of
2299 // instruction. This means that register allocator will not reuse it's
2300 // register for any other operand inside instruction.
2301 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2302 // instruction start. Register allocator is free to assign the same register
2303 // to some other operand used inside instruction (i.e. temporary or
2305 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2306 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2308 // An input operand in a register that may be trashed.
2309 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2311 // An input operand in a register or stack slot.
2312 MUST_USE_RESULT LOperand* Use(HValue* value);
2313 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2315 // An input operand in a register, stack slot or a constant operand.
2316 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2317 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2319 // An input operand in a register or a constant operand.
2320 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2321 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2323 // An input operand in register, stack slot or a constant operand.
2324 // Will not be moved to a register even if one is freely available.
2325 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2327 // Temporary operand that must be in a register.
2328 MUST_USE_RESULT LUnallocated* TempRegister();
2329 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2330 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2332 // Methods for setting up define-use relationships.
2333 // Return the same instruction that they are passed.
2334 template<int I, int T>
2335 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2336 LUnallocated* result);
2337 template<int I, int T>
2338 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2339 template<int I, int T>
2340 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2342 template<int I, int T>
2343 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2344 template<int I, int T>
2345 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2347 template<int I, int T>
2348 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2349 DoubleRegister reg);
2350 LInstruction* AssignEnvironment(LInstruction* instr);
2351 LInstruction* AssignPointerMap(LInstruction* instr);
2353 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2355 // By default we assume that instruction sequences generated for calls
2356 // cannot deoptimize eagerly and we do not attach environment to this
2358 LInstruction* MarkAsCall(
2359 LInstruction* instr,
2360 HInstruction* hinstr,
2361 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2362 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
2364 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2365 LInstruction* instr, int ast_id);
2366 void ClearInstructionPendingDeoptimizationEnvironment();
2368 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2369 int* argument_index_accumulator);
2371 void VisitInstruction(HInstruction* current);
2373 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2374 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2375 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2376 LInstruction* DoArithmeticD(Token::Value op,
2377 HArithmeticBinaryOperation* instr);
2378 LInstruction* DoArithmeticT(Token::Value op,
2379 HArithmeticBinaryOperation* instr);
2382 CompilationInfo* info_;
2383 HGraph* const graph_;
2386 HInstruction* current_instruction_;
2387 HBasicBlock* current_block_;
2388 HBasicBlock* next_block_;
2389 int argument_count_;
2390 LAllocator* allocator_;
2392 LInstruction* instruction_pending_deoptimization_environment_;
2393 int pending_deoptimization_ast_id_;
2395 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2398 #undef DECLARE_HYDROGEN_ACCESSOR
2399 #undef DECLARE_CONCRETE_INSTRUCTION
2401 } } // namespace v8::internal
2403 #endif // V8_MIPS_LITHIUM_MIPS_H_