blob: eb85f10ed5bb77815be979a5a924aaa60d084782 [file] [log] [blame]
Steve Block44f0eee2011-05-26 01:26:41 +01001// Copyright 2011 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
4// met:
5//
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.
15//
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.
27
28#ifndef V8_MIPS_LITHIUM_MIPS_H_
29#define V8_MIPS_LITHIUM_MIPS_H_
30
31#include "hydrogen.h"
32#include "lithium-allocator.h"
33#include "lithium.h"
34#include "safepoint-table.h"
Ben Murdoch592a9fc2012-03-05 11:04:45 +000035#include "utils.h"
Steve Block44f0eee2011-05-26 01:26:41 +010036
37namespace v8 {
38namespace internal {
39
40// Forward declarations.
41class LCodeGen;
Ben Murdoch592a9fc2012-03-05 11:04:45 +000042
43#define LITHIUM_ALL_INSTRUCTION_LIST(V) \
44 V(ControlInstruction) \
45 V(Call) \
46 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
47
48
49#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
50 V(AccessArgumentsAt) \
51 V(AddI) \
52 V(ApplyArguments) \
53 V(ArgumentsElements) \
54 V(ArgumentsLength) \
55 V(ArithmeticD) \
56 V(ArithmeticT) \
57 V(ArrayLiteral) \
58 V(BitI) \
59 V(BitNotI) \
60 V(BoundsCheck) \
61 V(Branch) \
62 V(CallConstantFunction) \
63 V(CallFunction) \
64 V(CallGlobal) \
65 V(CallKeyed) \
66 V(CallKnownGlobal) \
67 V(CallNamed) \
68 V(CallNew) \
69 V(CallRuntime) \
70 V(CallStub) \
71 V(CheckFunction) \
72 V(CheckInstanceType) \
73 V(CheckMap) \
74 V(CheckNonSmi) \
75 V(CheckPrototypeMaps) \
76 V(CheckSmi) \
77 V(ClampDToUint8) \
78 V(ClampIToUint8) \
79 V(ClampTToUint8) \
80 V(ClassOfTestAndBranch) \
81 V(CmpConstantEqAndBranch) \
82 V(CmpIDAndBranch) \
83 V(CmpObjectEqAndBranch) \
84 V(CmpMapAndBranch) \
85 V(CmpT) \
86 V(ConstantD) \
87 V(ConstantI) \
88 V(ConstantT) \
89 V(Context) \
90 V(DeleteProperty) \
91 V(Deoptimize) \
92 V(DivI) \
93 V(DoubleToI) \
94 V(ElementsKind) \
95 V(FixedArrayBaseLength) \
96 V(FunctionLiteral) \
97 V(GetCachedArrayIndex) \
98 V(GlobalObject) \
99 V(GlobalReceiver) \
100 V(Goto) \
101 V(HasCachedArrayIndexAndBranch) \
102 V(HasInstanceTypeAndBranch) \
103 V(In) \
104 V(InstanceOf) \
105 V(InstanceOfKnownGlobal) \
106 V(InstructionGap) \
107 V(Integer32ToDouble) \
108 V(InvokeFunction) \
109 V(IsConstructCallAndBranch) \
110 V(IsNilAndBranch) \
111 V(IsObjectAndBranch) \
112 V(IsStringAndBranch) \
113 V(IsSmiAndBranch) \
114 V(IsUndetectableAndBranch) \
115 V(StringCompareAndBranch) \
116 V(JSArrayLength) \
117 V(Label) \
118 V(LazyBailout) \
119 V(LoadContextSlot) \
120 V(LoadElements) \
121 V(LoadExternalArrayPointer) \
122 V(LoadFunctionPrototype) \
123 V(LoadGlobalCell) \
124 V(LoadGlobalGeneric) \
125 V(LoadKeyedFastDoubleElement) \
126 V(LoadKeyedFastElement) \
127 V(LoadKeyedGeneric) \
128 V(LoadKeyedSpecializedArrayElement) \
129 V(LoadNamedField) \
130 V(LoadNamedFieldPolymorphic) \
131 V(LoadNamedGeneric) \
132 V(ModI) \
133 V(MulI) \
134 V(NumberTagD) \
135 V(NumberTagI) \
136 V(NumberUntagD) \
137 V(ObjectLiteralFast) \
138 V(ObjectLiteralGeneric) \
139 V(OsrEntry) \
140 V(OuterContext) \
141 V(Parameter) \
142 V(Power) \
143 V(PushArgument) \
144 V(RegExpLiteral) \
145 V(Return) \
146 V(ShiftI) \
147 V(SmiTag) \
148 V(SmiUntag) \
149 V(StackCheck) \
150 V(StoreContextSlot) \
151 V(StoreGlobalCell) \
152 V(StoreGlobalGeneric) \
153 V(StoreKeyedFastDoubleElement) \
154 V(StoreKeyedFastElement) \
155 V(StoreKeyedGeneric) \
156 V(StoreKeyedSpecializedArrayElement) \
157 V(StoreNamedField) \
158 V(StoreNamedGeneric) \
159 V(StringAdd) \
160 V(StringCharCodeAt) \
161 V(StringCharFromCode) \
162 V(StringLength) \
163 V(SubI) \
164 V(TaggedToI) \
165 V(ThisFunction) \
166 V(Throw) \
167 V(ToFastProperties) \
168 V(TransitionElementsKind) \
169 V(Typeof) \
170 V(TypeofIsAndBranch) \
171 V(UnaryMathOperation) \
172 V(UnknownOSRValue) \
173 V(ValueOf)
174
175
176#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
177 virtual Opcode opcode() const { return LInstruction::k##type; } \
178 virtual void CompileToNative(LCodeGen* generator); \
179 virtual const char* Mnemonic() const { return mnemonic; } \
180 static L##type* cast(LInstruction* instr) { \
181 ASSERT(instr->Is##type()); \
182 return reinterpret_cast<L##type*>(instr); \
183 }
184
185
186#define DECLARE_HYDROGEN_ACCESSOR(type) \
187 H##type* hydrogen() const { \
188 return H##type::cast(hydrogen_value()); \
189 }
190
Steve Block44f0eee2011-05-26 01:26:41 +0100191
192class LInstruction: public ZoneObject {
193 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000194 LInstruction()
195 : environment_(NULL),
196 hydrogen_value_(NULL),
197 is_call_(false),
198 is_save_doubles_(false) { }
Steve Block44f0eee2011-05-26 01:26:41 +0100199 virtual ~LInstruction() { }
200
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000201 virtual void CompileToNative(LCodeGen* generator) = 0;
202 virtual const char* Mnemonic() const = 0;
203 virtual void PrintTo(StringStream* stream);
204 virtual void PrintDataTo(StringStream* stream) = 0;
205 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
206
207 enum Opcode {
208 // Declare a unique enum value for each instruction.
209#define DECLARE_OPCODE(type) k##type,
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
211 kNumberOfInstructions
212#undef DECLARE_OPCODE
213 };
214
215 virtual Opcode opcode() const = 0;
216
217 // Declare non-virtual type testers for all leaf IR classes.
218#define DECLARE_PREDICATE(type) \
219 bool Is##type() const { return opcode() == k##type; }
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
221#undef DECLARE_PREDICATE
222
223 // Declare virtual predicates for instructions that don't have
224 // an opcode.
225 virtual bool IsGap() const { return false; }
226
227 virtual bool IsControl() const { return false; }
228
229 void set_environment(LEnvironment* env) { environment_ = env; }
230 LEnvironment* environment() const { return environment_; }
231 bool HasEnvironment() const { return environment_ != NULL; }
232
233 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
234 LPointerMap* pointer_map() const { return pointer_map_.get(); }
235 bool HasPointerMap() const { return pointer_map_.is_set(); }
236
237 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
238 HValue* hydrogen_value() const { return hydrogen_value_; }
239
240 void set_deoptimization_environment(LEnvironment* env) {
241 deoptimization_environment_.set(env);
Steve Block44f0eee2011-05-26 01:26:41 +0100242 }
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000243 LEnvironment* deoptimization_environment() const {
244 return deoptimization_environment_.get();
245 }
246 bool HasDeoptimizationEnvironment() const {
247 return deoptimization_environment_.is_set();
Steve Block44f0eee2011-05-26 01:26:41 +0100248 }
249
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000250 void MarkAsCall() { is_call_ = true; }
251 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
Steve Block44f0eee2011-05-26 01:26:41 +0100252
253 // Interface to the register allocator and iterators.
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000254 bool IsMarkedAsCall() const { return is_call_; }
255 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
Steve Block44f0eee2011-05-26 01:26:41 +0100256
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000257 virtual bool HasResult() const = 0;
258 virtual LOperand* result() = 0;
Steve Block44f0eee2011-05-26 01:26:41 +0100259
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000260 virtual int InputCount() = 0;
261 virtual LOperand* InputAt(int i) = 0;
262 virtual int TempCount() = 0;
263 virtual LOperand* TempAt(int i) = 0;
Steve Block44f0eee2011-05-26 01:26:41 +0100264
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000265 LOperand* FirstInput() { return InputAt(0); }
266 LOperand* Output() { return HasResult() ? result() : NULL; }
Steve Block44f0eee2011-05-26 01:26:41 +0100267
268#ifdef DEBUG
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000269 void VerifyCall();
Steve Block44f0eee2011-05-26 01:26:41 +0100270#endif
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000271
272 private:
273 LEnvironment* environment_;
274 SetOncePointer<LPointerMap> pointer_map_;
275 HValue* hydrogen_value_;
276 SetOncePointer<LEnvironment> deoptimization_environment_;
277 bool is_call_;
278 bool is_save_doubles_;
Steve Block44f0eee2011-05-26 01:26:41 +0100279};
280
281
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000282// R = number of result operands (0 or 1).
283// I = number of input operands.
284// T = number of temporary operands.
285template<int R, int I, int T>
286class LTemplateInstruction: public LInstruction {
Steve Block44f0eee2011-05-26 01:26:41 +0100287 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000288 // Allow 0 or 1 output operands.
289 STATIC_ASSERT(R == 0 || R == 1);
290 virtual bool HasResult() const { return R != 0; }
291 void set_result(LOperand* operand) { results_[0] = operand; }
292 LOperand* result() { return results_[0]; }
Steve Block44f0eee2011-05-26 01:26:41 +0100293
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000294 int InputCount() { return I; }
295 LOperand* InputAt(int i) { return inputs_[i]; }
296
297 int TempCount() { return T; }
298 LOperand* TempAt(int i) { return temps_[i]; }
299
300 virtual void PrintDataTo(StringStream* stream);
301 virtual void PrintOutputOperandTo(StringStream* stream);
302
303 protected:
304 EmbeddedContainer<LOperand*, R> results_;
305 EmbeddedContainer<LOperand*, I> inputs_;
306 EmbeddedContainer<LOperand*, T> temps_;
307};
308
309
310class LGap: public LTemplateInstruction<0, 0, 0> {
311 public:
312 explicit LGap(HBasicBlock* block)
313 : block_(block) {
314 parallel_moves_[BEFORE] = NULL;
315 parallel_moves_[START] = NULL;
316 parallel_moves_[END] = NULL;
317 parallel_moves_[AFTER] = NULL;
Steve Block44f0eee2011-05-26 01:26:41 +0100318 }
319
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000320 // Can't use the DECLARE-macro here because of sub-classes.
321 virtual bool IsGap() const { return true; }
322 virtual void PrintDataTo(StringStream* stream);
323 static LGap* cast(LInstruction* instr) {
324 ASSERT(instr->IsGap());
325 return reinterpret_cast<LGap*>(instr);
326 }
327
328 bool IsRedundant() const;
329
330 HBasicBlock* block() const { return block_; }
331
Steve Block44f0eee2011-05-26 01:26:41 +0100332 enum InnerPosition {
333 BEFORE,
334 START,
335 END,
336 AFTER,
337 FIRST_INNER_POSITION = BEFORE,
338 LAST_INNER_POSITION = AFTER
339 };
340
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000341 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
342 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
343 return parallel_moves_[pos];
Steve Block44f0eee2011-05-26 01:26:41 +0100344 }
345
346 LParallelMove* GetParallelMove(InnerPosition pos) {
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000347 return parallel_moves_[pos];
Steve Block44f0eee2011-05-26 01:26:41 +0100348 }
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000349
350 private:
351 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
352 HBasicBlock* block_;
353};
354
355
356class LInstructionGap: public LGap {
357 public:
358 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
359
360 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
361};
362
363
364class LGoto: public LTemplateInstruction<0, 0, 0> {
365 public:
366 explicit LGoto(int block_id) : block_id_(block_id) { }
367
368 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
369 virtual void PrintDataTo(StringStream* stream);
370 virtual bool IsControl() const { return true; }
371
372 int block_id() const { return block_id_; }
373
374 private:
375 int block_id_;
376};
377
378
379class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
380 public:
381 LLazyBailout() : gap_instructions_size_(0) { }
382
383 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
384
385 void set_gap_instructions_size(int gap_instructions_size) {
386 gap_instructions_size_ = gap_instructions_size;
387 }
388 int gap_instructions_size() { return gap_instructions_size_; }
389
390 private:
391 int gap_instructions_size_;
392};
393
394
395class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
396 public:
397 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
Steve Block44f0eee2011-05-26 01:26:41 +0100398};
399
400
401class LLabel: public LGap {
402 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000403 explicit LLabel(HBasicBlock* block)
404 : LGap(block), replacement_(NULL) { }
405
406 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
407
408 virtual void PrintDataTo(StringStream* stream);
409
410 int block_id() const { return block()->block_id(); }
411 bool is_loop_header() const { return block()->IsLoopHeader(); }
412 Label* label() { return &label_; }
413 LLabel* replacement() const { return replacement_; }
414 void set_replacement(LLabel* label) { replacement_ = label; }
415 bool HasReplacement() const { return replacement_ != NULL; }
416
417 private:
418 Label label_;
419 LLabel* replacement_;
Steve Block44f0eee2011-05-26 01:26:41 +0100420};
421
422
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000423class LParameter: public LTemplateInstruction<1, 0, 0> {
Steve Block44f0eee2011-05-26 01:26:41 +0100424 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000425 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
426};
Steve Block44f0eee2011-05-26 01:26:41 +0100427
Steve Block44f0eee2011-05-26 01:26:41 +0100428
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000429class LCallStub: public LTemplateInstruction<1, 0, 0> {
430 public:
431 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
432 DECLARE_HYDROGEN_ACCESSOR(CallStub)
433
434 TranscendentalCache::Type transcendental_type() {
435 return hydrogen()->transcendental_type();
Steve Block44f0eee2011-05-26 01:26:41 +0100436 }
437};
438
439
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000440class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
441 public:
442 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
443};
444
445
446template<int I, int T>
447class LControlInstruction: public LTemplateInstruction<0, I, T> {
448 public:
449 virtual bool IsControl() const { return true; }
450
451 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
452 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
453 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
454 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
455
456 private:
457 HControlInstruction* hydrogen() {
458 return HControlInstruction::cast(this->hydrogen_value());
459 }
460};
461
462
463class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
464 public:
465 LApplyArguments(LOperand* function,
466 LOperand* receiver,
467 LOperand* length,
468 LOperand* elements) {
469 inputs_[0] = function;
470 inputs_[1] = receiver;
471 inputs_[2] = length;
472 inputs_[3] = elements;
473 }
474
475 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
476
477 LOperand* function() { return inputs_[0]; }
478 LOperand* receiver() { return inputs_[1]; }
479 LOperand* length() { return inputs_[2]; }
480 LOperand* elements() { return inputs_[3]; }
481};
482
483
484class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
485 public:
486 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
487 inputs_[0] = arguments;
488 inputs_[1] = length;
489 inputs_[2] = index;
490 }
491
492 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
493
494 LOperand* arguments() { return inputs_[0]; }
495 LOperand* length() { return inputs_[1]; }
496 LOperand* index() { return inputs_[2]; }
497
498 virtual void PrintDataTo(StringStream* stream);
499};
500
501
502class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
503 public:
504 explicit LArgumentsLength(LOperand* elements) {
505 inputs_[0] = elements;
506 }
507
508 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
509};
510
511
512class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
513 public:
514 LArgumentsElements() { }
515
516 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
517};
518
519
520class LModI: public LTemplateInstruction<1, 2, 3> {
521 public:
522 // Used when the right hand is a constant power of 2.
523 LModI(LOperand* left,
524 LOperand* right) {
525 inputs_[0] = left;
526 inputs_[1] = right;
527 temps_[0] = NULL;
528 temps_[1] = NULL;
529 temps_[2] = NULL;
530 }
531
532 // Used for the standard case.
533 LModI(LOperand* left,
534 LOperand* right,
535 LOperand* temp1,
536 LOperand* temp2,
537 LOperand* temp3) {
538 inputs_[0] = left;
539 inputs_[1] = right;
540 temps_[0] = temp1;
541 temps_[1] = temp2;
542 temps_[2] = temp3;
543 }
544
545 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
546 DECLARE_HYDROGEN_ACCESSOR(Mod)
547};
548
549
550class LDivI: public LTemplateInstruction<1, 2, 0> {
551 public:
552 LDivI(LOperand* left, LOperand* right) {
553 inputs_[0] = left;
554 inputs_[1] = right;
555 }
556
557 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
558 DECLARE_HYDROGEN_ACCESSOR(Div)
559};
560
561
562class LMulI: public LTemplateInstruction<1, 2, 1> {
563 public:
564 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
565 inputs_[0] = left;
566 inputs_[1] = right;
567 temps_[0] = temp;
568 }
569
570 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
571 DECLARE_HYDROGEN_ACCESSOR(Mul)
572};
573
574
575class LCmpIDAndBranch: public LControlInstruction<2, 0> {
576 public:
577 LCmpIDAndBranch(LOperand* left, LOperand* right) {
578 inputs_[0] = left;
579 inputs_[1] = right;
580 }
581
582 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
583 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
584
585 Token::Value op() const { return hydrogen()->token(); }
586 bool is_double() const {
587 return hydrogen()->GetInputRepresentation().IsDouble();
588 }
589
590 virtual void PrintDataTo(StringStream* stream);
591};
592
593
594class LUnaryMathOperation: public LTemplateInstruction<1, 1, 1> {
595 public:
596 LUnaryMathOperation(LOperand* value, LOperand* temp) {
597 inputs_[0] = value;
598 temps_[0] = temp;
599 }
600
601 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
602 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
603
604 virtual void PrintDataTo(StringStream* stream);
605 BuiltinFunctionId op() const { return hydrogen()->op(); }
606};
607
608
609class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
610 public:
611 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
612 inputs_[0] = left;
613 inputs_[1] = right;
614 }
615
616 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
617 "cmp-object-eq-and-branch")
618 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
619};
620
621
622class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
623 public:
624 explicit LCmpConstantEqAndBranch(LOperand* left) {
625 inputs_[0] = left;
626 }
627
628 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
629 "cmp-constant-eq-and-branch")
630 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
631};
632
633
634class LIsNilAndBranch: public LControlInstruction<1, 0> {
635 public:
636 explicit LIsNilAndBranch(LOperand* value) {
637 inputs_[0] = value;
638 }
639
640 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
641 DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
642
643 EqualityKind kind() const { return hydrogen()->kind(); }
644 NilValue nil() const { return hydrogen()->nil(); }
645
646 virtual void PrintDataTo(StringStream* stream);
647};
648
649
650class LIsObjectAndBranch: public LControlInstruction<1, 1> {
651 public:
652 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
653 inputs_[0] = value;
654 temps_[0] = temp;
655 }
656
657 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
658 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
659
660 virtual void PrintDataTo(StringStream* stream);
661};
662
663
664class LIsStringAndBranch: public LControlInstruction<1, 1> {
665 public:
666 LIsStringAndBranch(LOperand* value, LOperand* temp) {
667 inputs_[0] = value;
668 temps_[0] = temp;
669 }
670
671 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
672 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
673
674 virtual void PrintDataTo(StringStream* stream);
675};
676
677
678class LIsSmiAndBranch: public LControlInstruction<1, 0> {
679 public:
680 explicit LIsSmiAndBranch(LOperand* value) {
681 inputs_[0] = value;
682 }
683
684 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
685 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
686
687 virtual void PrintDataTo(StringStream* stream);
688};
689
690
691class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
692 public:
693 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
694 inputs_[0] = value;
695 temps_[0] = temp;
696 }
697
698 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
699 "is-undetectable-and-branch")
700 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
701
702 virtual void PrintDataTo(StringStream* stream);
703};
704
705
706class LStringCompareAndBranch: public LControlInstruction<2, 0> {
707 public:
708 LStringCompareAndBranch(LOperand* left, LOperand* right) {
709 inputs_[0] = left;
710 inputs_[1] = right;
711 }
712
713 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
714 "string-compare-and-branch")
715 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
716
717 Token::Value op() const { return hydrogen()->token(); }
718
719 virtual void PrintDataTo(StringStream* stream);
720};
721
722
723class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
724 public:
725 explicit LHasInstanceTypeAndBranch(LOperand* value) {
726 inputs_[0] = value;
727 }
728
729 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
730 "has-instance-type-and-branch")
731 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
732
733 virtual void PrintDataTo(StringStream* stream);
734};
735
736
737class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
738 public:
739 explicit LGetCachedArrayIndex(LOperand* value) {
740 inputs_[0] = value;
741 }
742
743 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
744 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
745};
746
747
748class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
749 public:
750 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
751 inputs_[0] = value;
752 }
753
754 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
755 "has-cached-array-index-and-branch")
756 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
757
758 virtual void PrintDataTo(StringStream* stream);
759};
760
761
762class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
763 public:
764 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
765 inputs_[0] = value;
766 temps_[0] = temp;
767 }
768
769 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
770 "class-of-test-and-branch")
771 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
772
773 virtual void PrintDataTo(StringStream* stream);
774};
775
776
777class LCmpT: public LTemplateInstruction<1, 2, 0> {
778 public:
779 LCmpT(LOperand* left, LOperand* right) {
780 inputs_[0] = left;
781 inputs_[1] = right;
782 }
783
784 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
785 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
786
787 Token::Value op() const { return hydrogen()->token(); }
788};
789
790
791class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
792 public:
793 LInstanceOf(LOperand* left, LOperand* right) {
794 inputs_[0] = left;
795 inputs_[1] = right;
796 }
797
798 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
799};
800
801
802class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
803 public:
804 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
805 inputs_[0] = value;
806 temps_[0] = temp;
807 }
808
809 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
810 "instance-of-known-global")
811 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
812
813 Handle<JSFunction> function() const { return hydrogen()->function(); }
814};
815
816
817class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
818 public:
819 LBoundsCheck(LOperand* index, LOperand* length) {
820 inputs_[0] = index;
821 inputs_[1] = length;
822 }
823
824 LOperand* index() { return inputs_[0]; }
825 LOperand* length() { return inputs_[1]; }
826
827 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
828};
829
830
831class LBitI: public LTemplateInstruction<1, 2, 0> {
832 public:
833 LBitI(LOperand* left, LOperand* right) {
834 inputs_[0] = left;
835 inputs_[1] = right;
836 }
837
838 Token::Value op() const { return hydrogen()->op(); }
839
840 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
841 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
842};
843
844
845class LShiftI: public LTemplateInstruction<1, 2, 0> {
846 public:
847 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
848 : op_(op), can_deopt_(can_deopt) {
849 inputs_[0] = left;
850 inputs_[1] = right;
851 }
852
853 Token::Value op() const { return op_; }
854
855 bool can_deopt() const { return can_deopt_; }
856
857 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
858
859 private:
860 Token::Value op_;
861 bool can_deopt_;
862};
863
864
865class LSubI: public LTemplateInstruction<1, 2, 0> {
866 public:
867 LSubI(LOperand* left, LOperand* right) {
868 inputs_[0] = left;
869 inputs_[1] = right;
870 }
871
872 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
873 DECLARE_HYDROGEN_ACCESSOR(Sub)
874};
875
876
877class LConstantI: public LTemplateInstruction<1, 0, 0> {
878 public:
879 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
880 DECLARE_HYDROGEN_ACCESSOR(Constant)
881
882 int32_t value() const { return hydrogen()->Integer32Value(); }
883};
884
885
886class LConstantD: public LTemplateInstruction<1, 0, 0> {
887 public:
888 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
889 DECLARE_HYDROGEN_ACCESSOR(Constant)
890
891 double value() const { return hydrogen()->DoubleValue(); }
892};
893
894
895class LConstantT: public LTemplateInstruction<1, 0, 0> {
896 public:
897 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
898 DECLARE_HYDROGEN_ACCESSOR(Constant)
899
900 Handle<Object> value() const { return hydrogen()->handle(); }
901};
902
903
904class LBranch: public LControlInstruction<1, 0> {
905 public:
906 explicit LBranch(LOperand* value) {
907 inputs_[0] = value;
908 }
909
910 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
911 DECLARE_HYDROGEN_ACCESSOR(Branch)
912
913 virtual void PrintDataTo(StringStream* stream);
914};
915
916
917class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
918 public:
919 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
920 inputs_[0] = value;
921 temps_[0] = temp;
922 }
923
924 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
925 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
926
927 virtual bool IsControl() const { return true; }
928
929 Handle<Map> map() const { return hydrogen()->map(); }
930 int true_block_id() const {
931 return hydrogen()->FirstSuccessor()->block_id();
932 }
933 int false_block_id() const {
934 return hydrogen()->SecondSuccessor()->block_id();
935 }
936};
937
938
939class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
940 public:
941 explicit LJSArrayLength(LOperand* value) {
942 inputs_[0] = value;
943 }
944
945 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
946 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
947};
948
949
950class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
951 public:
952 explicit LFixedArrayBaseLength(LOperand* value) {
953 inputs_[0] = value;
954 }
955
956 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
957 "fixed-array-base-length")
958 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
959};
960
961
962class LElementsKind: public LTemplateInstruction<1, 1, 0> {
963 public:
964 explicit LElementsKind(LOperand* value) {
965 inputs_[0] = value;
966 }
967
968 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
969 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
970};
971
972
973class LValueOf: public LTemplateInstruction<1, 1, 1> {
974 public:
975 LValueOf(LOperand* value, LOperand* temp) {
976 inputs_[0] = value;
977 temps_[0] = temp;
978 }
979
980 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
981 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
982};
983
984
985class LThrow: public LTemplateInstruction<0, 1, 0> {
986 public:
987 explicit LThrow(LOperand* value) {
988 inputs_[0] = value;
989 }
990
991 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
992};
993
994
995class LBitNotI: public LTemplateInstruction<1, 1, 0> {
996 public:
997 explicit LBitNotI(LOperand* value) {
998 inputs_[0] = value;
999 }
1000
1001 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1002};
1003
1004
1005class LAddI: public LTemplateInstruction<1, 2, 0> {
1006 public:
1007 LAddI(LOperand* left, LOperand* right) {
1008 inputs_[0] = left;
1009 inputs_[1] = right;
1010 }
1011
1012 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1013 DECLARE_HYDROGEN_ACCESSOR(Add)
1014};
1015
1016
1017class LPower: public LTemplateInstruction<1, 2, 0> {
1018 public:
1019 LPower(LOperand* left, LOperand* right) {
1020 inputs_[0] = left;
1021 inputs_[1] = right;
1022 }
1023
1024 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1025 DECLARE_HYDROGEN_ACCESSOR(Power)
1026};
1027
1028
1029class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1030 public:
1031 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1032 : op_(op) {
1033 inputs_[0] = left;
1034 inputs_[1] = right;
1035 }
1036
1037 Token::Value op() const { return op_; }
1038
1039 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1040 virtual void CompileToNative(LCodeGen* generator);
1041 virtual const char* Mnemonic() const;
1042
1043 private:
1044 Token::Value op_;
1045};
1046
1047
1048class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1049 public:
1050 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1051 : op_(op) {
1052 inputs_[0] = left;
1053 inputs_[1] = right;
1054 }
1055
1056 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1057 virtual void CompileToNative(LCodeGen* generator);
1058 virtual const char* Mnemonic() const;
1059
1060 Token::Value op() const { return op_; }
1061
1062 private:
1063 Token::Value op_;
1064};
1065
1066
1067class LReturn: public LTemplateInstruction<0, 1, 0> {
1068 public:
1069 explicit LReturn(LOperand* value) {
1070 inputs_[0] = value;
1071 }
1072
1073 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1074};
1075
1076
1077class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1078 public:
1079 explicit LLoadNamedField(LOperand* object) {
1080 inputs_[0] = object;
1081 }
1082
1083 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1084 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1085};
1086
1087
1088class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1089 public:
1090 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1091 inputs_[0] = object;
1092 }
1093
1094 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1095 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1096
1097 LOperand* object() { return inputs_[0]; }
1098};
1099
1100
1101class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1102 public:
1103 explicit LLoadNamedGeneric(LOperand* object) {
1104 inputs_[0] = object;
1105 }
1106
1107 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1108 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1109
1110 LOperand* object() { return inputs_[0]; }
1111 Handle<Object> name() const { return hydrogen()->name(); }
1112};
1113
1114
1115class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1116 public:
1117 explicit LLoadFunctionPrototype(LOperand* function) {
1118 inputs_[0] = function;
1119 }
1120
1121 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1122 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1123
1124 LOperand* function() { return inputs_[0]; }
1125};
1126
1127
1128class LLoadElements: public LTemplateInstruction<1, 1, 0> {
1129 public:
1130 explicit LLoadElements(LOperand* object) {
1131 inputs_[0] = object;
1132 }
1133
1134 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1135};
1136
1137
1138class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1139 public:
1140 explicit LLoadExternalArrayPointer(LOperand* object) {
1141 inputs_[0] = object;
1142 }
1143
1144 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1145 "load-external-array-pointer")
1146};
1147
1148
1149class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
1150 public:
1151 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1152 inputs_[0] = elements;
1153 inputs_[1] = key;
1154 }
1155
1156 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1157 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1158
1159 LOperand* elements() { return inputs_[0]; }
1160 LOperand* key() { return inputs_[1]; }
1161};
1162
1163
1164class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> {
1165 public:
1166 LLoadKeyedFastDoubleElement(LOperand* elements, LOperand* key) {
1167 inputs_[0] = elements;
1168 inputs_[1] = key;
1169 }
1170
1171 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement,
1172 "load-keyed-fast-double-element")
1173 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement)
1174
1175 LOperand* elements() { return inputs_[0]; }
1176 LOperand* key() { return inputs_[1]; }
1177};
1178
1179
1180class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
1181 public:
1182 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1183 LOperand* key) {
1184 inputs_[0] = external_pointer;
1185 inputs_[1] = key;
1186 }
1187
1188 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1189 "load-keyed-specialized-array-element")
1190 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
1191
1192 LOperand* external_pointer() { return inputs_[0]; }
1193 LOperand* key() { return inputs_[1]; }
1194 ElementsKind elements_kind() const {
1195 return hydrogen()->elements_kind();
1196 }
1197};
1198
1199
1200class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1201 public:
1202 LLoadKeyedGeneric(LOperand* obj, LOperand* key) {
1203 inputs_[0] = obj;
1204 inputs_[1] = key;
1205 }
1206
1207 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1208
1209 LOperand* object() { return inputs_[0]; }
1210 LOperand* key() { return inputs_[1]; }
1211};
1212
1213
1214class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1215 public:
1216 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1217 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1218};
1219
1220
1221class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1222 public:
1223 explicit LLoadGlobalGeneric(LOperand* global_object) {
1224 inputs_[0] = global_object;
1225 }
1226
1227 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1228 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1229
1230 LOperand* global_object() { return inputs_[0]; }
1231 Handle<Object> name() const { return hydrogen()->name(); }
1232 bool for_typeof() const { return hydrogen()->for_typeof(); }
1233};
1234
1235
1236class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1237 public:
1238 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1239 inputs_[0] = value;
1240 temps_[0] = temp;
1241 }
1242
1243 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1244 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1245};
1246
1247
1248class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1249 public:
1250 explicit LStoreGlobalGeneric(LOperand* global_object,
1251 LOperand* value) {
1252 inputs_[0] = global_object;
1253 inputs_[1] = value;
1254 }
1255
1256 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1257 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1258
1259 LOperand* global_object() { return InputAt(0); }
1260 Handle<Object> name() const { return hydrogen()->name(); }
1261 LOperand* value() { return InputAt(1); }
1262 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1263};
1264
1265
1266class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1267 public:
1268 explicit LLoadContextSlot(LOperand* context) {
1269 inputs_[0] = context;
1270 }
1271
1272 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1273 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1274
1275 LOperand* context() { return InputAt(0); }
1276 int slot_index() { return hydrogen()->slot_index(); }
1277
1278 virtual void PrintDataTo(StringStream* stream);
1279};
1280
1281
1282class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1283 public:
1284 LStoreContextSlot(LOperand* context, LOperand* value) {
1285 inputs_[0] = context;
1286 inputs_[1] = value;
1287 }
1288
1289 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1290 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1291
1292 LOperand* context() { return InputAt(0); }
1293 LOperand* value() { return InputAt(1); }
1294 int slot_index() { return hydrogen()->slot_index(); }
1295
1296 virtual void PrintDataTo(StringStream* stream);
1297};
1298
1299
1300class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1301 public:
1302 explicit LPushArgument(LOperand* value) {
1303 inputs_[0] = value;
1304 }
1305
1306 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1307};
1308
1309
1310class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1311 public:
1312 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1313 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1314};
1315
1316
1317class LContext: public LTemplateInstruction<1, 0, 0> {
1318 public:
1319 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1320};
1321
1322
1323class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1324 public:
1325 explicit LOuterContext(LOperand* context) {
1326 inputs_[0] = context;
1327 }
1328
1329 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1330
1331 LOperand* context() { return InputAt(0); }
1332};
1333
1334
1335class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1336 public:
1337 explicit LGlobalObject(LOperand* context) {
1338 inputs_[0] = context;
1339 }
1340
1341 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1342
1343 LOperand* context() { return InputAt(0); }
1344};
1345
1346
1347class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1348 public:
1349 explicit LGlobalReceiver(LOperand* global_object) {
1350 inputs_[0] = global_object;
1351 }
1352
1353 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1354
1355 LOperand* global() { return InputAt(0); }
1356};
1357
1358
1359class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1360 public:
1361 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1362 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1363
1364 virtual void PrintDataTo(StringStream* stream);
1365
1366 Handle<JSFunction> function() { return hydrogen()->function(); }
1367 int arity() const { return hydrogen()->argument_count() - 1; }
1368};
1369
1370
1371class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1372 public:
1373 explicit LInvokeFunction(LOperand* function) {
1374 inputs_[0] = function;
1375 }
1376
1377 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1378 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1379
1380 LOperand* function() { return inputs_[0]; }
1381
1382 virtual void PrintDataTo(StringStream* stream);
1383
1384 int arity() const { return hydrogen()->argument_count() - 1; }
1385};
1386
1387
1388class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1389 public:
1390 explicit LCallKeyed(LOperand* key) {
1391 inputs_[0] = key;
1392 }
1393
1394 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1395 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1396
1397 virtual void PrintDataTo(StringStream* stream);
1398
1399 int arity() const { return hydrogen()->argument_count() - 1; }
1400};
1401
1402
1403
1404class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1405 public:
1406 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1407 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1408
1409 virtual void PrintDataTo(StringStream* stream);
1410
1411 Handle<String> name() const { return hydrogen()->name(); }
1412 int arity() const { return hydrogen()->argument_count() - 1; }
1413};
1414
1415
1416class LCallFunction: public LTemplateInstruction<1, 1, 0> {
1417 public:
1418 explicit LCallFunction(LOperand* function) {
1419 inputs_[0] = function;
1420 }
1421
1422 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1423 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1424
1425 LOperand* function() { return inputs_[0]; }
1426 int arity() const { return hydrogen()->argument_count() - 1; }
1427};
1428
1429
1430class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1431 public:
1432 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1433 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1434
1435 virtual void PrintDataTo(StringStream* stream);
1436
1437 Handle<String> name() const {return hydrogen()->name(); }
1438 int arity() const { return hydrogen()->argument_count() - 1; }
1439};
1440
1441
1442class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1443 public:
1444 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1445 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1446
1447 virtual void PrintDataTo(StringStream* stream);
1448
1449 Handle<JSFunction> target() const { return hydrogen()->target(); }
1450 int arity() const { return hydrogen()->argument_count() - 1; }
1451};
1452
1453
1454class LCallNew: public LTemplateInstruction<1, 1, 0> {
1455 public:
1456 explicit LCallNew(LOperand* constructor) {
1457 inputs_[0] = constructor;
1458 }
1459
1460 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1461 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1462
1463 virtual void PrintDataTo(StringStream* stream);
1464
1465 int arity() const { return hydrogen()->argument_count() - 1; }
1466};
1467
1468
1469class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1470 public:
1471 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1472 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1473
1474 const Runtime::Function* function() const { return hydrogen()->function(); }
1475 int arity() const { return hydrogen()->argument_count(); }
1476};
1477
1478
1479class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1480 public:
1481 explicit LInteger32ToDouble(LOperand* value) {
1482 inputs_[0] = value;
1483 }
1484
1485 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1486};
1487
1488
1489class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1490 public:
1491 explicit LNumberTagI(LOperand* value) {
1492 inputs_[0] = value;
1493 }
1494
1495 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1496};
1497
1498
1499class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1500 public:
1501 LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) {
1502 inputs_[0] = value;
1503 temps_[0] = temp1;
1504 temps_[1] = temp2;
1505 }
1506
1507 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1508};
1509
1510
1511// Sometimes truncating conversion from a tagged value to an int32.
1512class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1513 public:
1514 LDoubleToI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1515 inputs_[0] = value;
1516 temps_[0] = temp1;
1517 temps_[1] = temp2;
1518 }
1519
1520 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1521 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1522
1523 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1524};
1525
1526
1527// Truncating conversion from a tagged value to an int32.
1528class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
1529 public:
1530 LTaggedToI(LOperand* value,
1531 LOperand* temp1,
1532 LOperand* temp2,
1533 LOperand* temp3) {
1534 inputs_[0] = value;
1535 temps_[0] = temp1;
1536 temps_[1] = temp2;
1537 temps_[2] = temp3;
1538 }
1539
1540 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1541 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1542
1543 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1544};
1545
1546
1547class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1548 public:
1549 explicit LSmiTag(LOperand* value) {
1550 inputs_[0] = value;
1551 }
1552
1553 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1554};
1555
1556
1557class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
1558 public:
1559 explicit LNumberUntagD(LOperand* value) {
1560 inputs_[0] = value;
1561 }
1562
1563 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1564 DECLARE_HYDROGEN_ACCESSOR(Change)
1565};
1566
1567
1568class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1569 public:
1570 LSmiUntag(LOperand* value, bool needs_check)
1571 : needs_check_(needs_check) {
1572 inputs_[0] = value;
1573 }
1574
1575 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1576
1577 bool needs_check() const { return needs_check_; }
1578
1579 private:
1580 bool needs_check_;
1581};
1582
1583
1584class LStoreNamedField: public LTemplateInstruction<0, 2, 0> {
1585 public:
1586 LStoreNamedField(LOperand* obj, LOperand* val) {
1587 inputs_[0] = obj;
1588 inputs_[1] = val;
1589 }
1590
1591 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1592 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1593
1594 virtual void PrintDataTo(StringStream* stream);
1595
1596 LOperand* object() { return inputs_[0]; }
1597 LOperand* value() { return inputs_[1]; }
1598
1599 Handle<Object> name() const { return hydrogen()->name(); }
1600 bool is_in_object() { return hydrogen()->is_in_object(); }
1601 int offset() { return hydrogen()->offset(); }
1602 Handle<Map> transition() const { return hydrogen()->transition(); }
1603};
1604
1605
1606class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1607 public:
1608 LStoreNamedGeneric(LOperand* obj, LOperand* val) {
1609 inputs_[0] = obj;
1610 inputs_[1] = val;
1611 }
1612
1613 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1614 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1615
1616 virtual void PrintDataTo(StringStream* stream);
1617
1618 LOperand* object() { return inputs_[0]; }
1619 LOperand* value() { return inputs_[1]; }
1620 Handle<Object> name() const { return hydrogen()->name(); }
1621 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1622};
1623
1624
1625class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
1626 public:
1627 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
1628 inputs_[0] = obj;
1629 inputs_[1] = key;
1630 inputs_[2] = val;
1631 }
1632
1633 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1634 "store-keyed-fast-element")
1635 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
1636
1637 virtual void PrintDataTo(StringStream* stream);
1638
1639 LOperand* object() { return inputs_[0]; }
1640 LOperand* key() { return inputs_[1]; }
1641 LOperand* value() { return inputs_[2]; }
1642};
1643
1644
1645class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1646 public:
1647 LStoreKeyedFastDoubleElement(LOperand* elements,
1648 LOperand* key,
1649 LOperand* val) {
1650 inputs_[0] = elements;
1651 inputs_[1] = key;
1652 inputs_[2] = val;
1653 }
1654
1655 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1656 "store-keyed-fast-double-element")
1657 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1658
1659 virtual void PrintDataTo(StringStream* stream);
1660
1661 LOperand* elements() { return inputs_[0]; }
1662 LOperand* key() { return inputs_[1]; }
1663 LOperand* value() { return inputs_[2]; }
1664};
1665
1666
1667class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
1668 public:
1669 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* val) {
1670 inputs_[0] = obj;
1671 inputs_[1] = key;
1672 inputs_[2] = val;
1673 }
1674
1675 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1676 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1677
1678 virtual void PrintDataTo(StringStream* stream);
1679
1680 LOperand* object() { return inputs_[0]; }
1681 LOperand* key() { return inputs_[1]; }
1682 LOperand* value() { return inputs_[2]; }
1683 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1684};
1685
1686class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
1687 public:
1688 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1689 LOperand* key,
1690 LOperand* val) {
1691 inputs_[0] = external_pointer;
1692 inputs_[1] = key;
1693 inputs_[2] = val;
1694 }
1695
1696 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1697 "store-keyed-specialized-array-element")
1698 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
1699
1700 LOperand* external_pointer() { return inputs_[0]; }
1701 LOperand* key() { return inputs_[1]; }
1702 LOperand* value() { return inputs_[2]; }
1703 ElementsKind elements_kind() const {
1704 return hydrogen()->elements_kind();
1705 }
1706};
1707
1708
1709class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1710 public:
1711 LTransitionElementsKind(LOperand* object,
1712 LOperand* new_map_temp,
1713 LOperand* temp_reg) {
1714 inputs_[0] = object;
1715 temps_[0] = new_map_temp;
1716 temps_[1] = temp_reg;
1717 }
1718
1719 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1720 "transition-elements-kind")
1721 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1722
1723 virtual void PrintDataTo(StringStream* stream);
1724
1725 LOperand* object() { return inputs_[0]; }
1726 LOperand* new_map_reg() { return temps_[0]; }
1727 LOperand* temp_reg() { return temps_[1]; }
1728 Handle<Map> original_map() { return hydrogen()->original_map(); }
1729 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
1730};
1731
1732
1733class LStringAdd: public LTemplateInstruction<1, 2, 0> {
1734 public:
1735 LStringAdd(LOperand* left, LOperand* right) {
1736 inputs_[0] = left;
1737 inputs_[1] = right;
1738 }
1739
1740 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1741 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1742
1743 LOperand* left() { return inputs_[0]; }
1744 LOperand* right() { return inputs_[1]; }
1745};
1746
1747
1748
1749class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
1750 public:
1751 LStringCharCodeAt(LOperand* string, LOperand* index) {
1752 inputs_[0] = string;
1753 inputs_[1] = index;
1754 }
1755
1756 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1757 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1758
1759 LOperand* string() { return inputs_[0]; }
1760 LOperand* index() { return inputs_[1]; }
1761};
1762
1763
1764class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
1765 public:
1766 explicit LStringCharFromCode(LOperand* char_code) {
1767 inputs_[0] = char_code;
1768 }
1769
1770 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1771 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1772
1773 LOperand* char_code() { return inputs_[0]; }
1774};
1775
1776
1777class LStringLength: public LTemplateInstruction<1, 1, 0> {
1778 public:
1779 explicit LStringLength(LOperand* string) {
1780 inputs_[0] = string;
1781 }
1782
1783 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1784 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1785
1786 LOperand* string() { return inputs_[0]; }
1787};
1788
1789
1790class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
1791 public:
1792 explicit LCheckFunction(LOperand* value) {
1793 inputs_[0] = value;
1794 }
1795
1796 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1797 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1798};
1799
1800
1801class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
1802 public:
1803 explicit LCheckInstanceType(LOperand* value) {
1804 inputs_[0] = value;
1805 }
1806
1807 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1808 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
1809};
1810
1811
1812class LCheckMap: public LTemplateInstruction<0, 1, 0> {
1813 public:
1814 explicit LCheckMap(LOperand* value) {
1815 inputs_[0] = value;
1816 }
1817
1818 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1819 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1820};
1821
1822
1823class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
1824 public:
1825 LCheckPrototypeMaps(LOperand* temp1, LOperand* temp2) {
1826 temps_[0] = temp1;
1827 temps_[1] = temp2;
1828 }
1829
1830 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
1831 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
1832
1833 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1834 Handle<JSObject> holder() const { return hydrogen()->holder(); }
1835};
1836
1837
1838class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
1839 public:
1840 explicit LCheckSmi(LOperand* value) {
1841 inputs_[0] = value;
1842 }
1843
1844 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1845};
1846
1847
1848class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1849 public:
1850 explicit LCheckNonSmi(LOperand* value) {
1851 inputs_[0] = value;
1852 }
1853
1854 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
1855};
1856
1857
1858class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
1859 public:
1860 LClampDToUint8(LOperand* value, LOperand* temp) {
1861 inputs_[0] = value;
1862 temps_[0] = temp;
1863 }
1864
1865 LOperand* unclamped() { return inputs_[0]; }
1866
1867 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1868};
1869
1870
1871class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1872 public:
1873 explicit LClampIToUint8(LOperand* value) {
1874 inputs_[0] = value;
1875 }
1876
1877 LOperand* unclamped() { return inputs_[0]; }
1878
1879 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1880};
1881
1882
1883class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
1884 public:
1885 LClampTToUint8(LOperand* value, LOperand* temp) {
1886 inputs_[0] = value;
1887 temps_[0] = temp;
1888 }
1889
1890 LOperand* unclamped() { return inputs_[0]; }
1891
1892 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1893};
1894
1895
1896class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
1897 public:
1898 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1899 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1900};
1901
1902
1903class LObjectLiteralFast: public LTemplateInstruction<1, 0, 0> {
1904 public:
1905 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteralFast, "object-literal-fast")
1906 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteralFast)
1907};
1908
1909
1910class LObjectLiteralGeneric: public LTemplateInstruction<1, 0, 0> {
1911 public:
1912 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteralGeneric, "object-literal-generic")
1913 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteralGeneric)
1914};
1915
1916
1917class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
1918 public:
1919 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
1920 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
1921};
1922
1923
1924class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
1925 public:
1926 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1927 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1928
1929 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
1930};
1931
1932
1933class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
1934 public:
1935 explicit LToFastProperties(LOperand* value) {
1936 inputs_[0] = value;
1937 }
1938
1939 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
1940 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
1941};
1942
1943
1944class LTypeof: public LTemplateInstruction<1, 1, 0> {
1945 public:
1946 explicit LTypeof(LOperand* value) {
1947 inputs_[0] = value;
1948 }
1949
1950 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
1951};
1952
1953
1954class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
1955 public:
1956 explicit LTypeofIsAndBranch(LOperand* value) {
1957 inputs_[0] = value;
1958 }
1959
1960 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
1961 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
1962
1963 Handle<String> type_literal() { return hydrogen()->type_literal(); }
1964
1965 virtual void PrintDataTo(StringStream* stream);
1966};
1967
1968
1969class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
1970 public:
1971 explicit LIsConstructCallAndBranch(LOperand* temp) {
1972 temps_[0] = temp;
1973 }
1974
1975 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1976 "is-construct-call-and-branch")
1977};
1978
1979
1980class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
1981 public:
1982 LDeleteProperty(LOperand* obj, LOperand* key) {
1983 inputs_[0] = obj;
1984 inputs_[1] = key;
1985 }
1986
1987 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
1988
1989 LOperand* object() { return inputs_[0]; }
1990 LOperand* key() { return inputs_[1]; }
1991};
1992
1993
1994class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
1995 public:
1996 LOsrEntry();
1997
1998 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
1999
2000 LOperand** SpilledRegisterArray() { return register_spills_; }
2001 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2002
2003 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2004 void MarkSpilledDoubleRegister(int allocation_index,
2005 LOperand* spill_operand);
2006
2007 private:
2008 // Arrays of spill slot operands for registers with an assigned spill
2009 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2010 // NULL if the register has no assigned spill slot. Indexed by allocation
2011 // index.
2012 LOperand* register_spills_[Register::kNumAllocatableRegisters];
2013 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2014};
2015
2016
2017class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2018 public:
2019 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2020 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2021
2022 Label* done_label() { return &done_label_; }
2023
2024 private:
2025 Label done_label_;
2026};
2027
2028
2029class LIn: public LTemplateInstruction<1, 2, 0> {
2030 public:
2031 LIn(LOperand* key, LOperand* object) {
2032 inputs_[0] = key;
2033 inputs_[1] = object;
2034 }
2035
2036 LOperand* key() { return inputs_[0]; }
2037 LOperand* object() { return inputs_[1]; }
2038
2039 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2040};
2041
2042
2043class LChunkBuilder;
Steve Block44f0eee2011-05-26 01:26:41 +01002044class LChunk: public ZoneObject {
2045 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002046 explicit LChunk(CompilationInfo* info, HGraph* graph);
Steve Block44f0eee2011-05-26 01:26:41 +01002047
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002048 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
2049 LConstantOperand* DefineConstantOperand(HConstant* constant);
2050 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2051 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
Steve Block44f0eee2011-05-26 01:26:41 +01002052
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002053 int GetNextSpillIndex(bool is_double);
2054 LOperand* GetNextSpillSlot(bool is_double);
Steve Block44f0eee2011-05-26 01:26:41 +01002055
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002056 int ParameterAt(int index);
2057 int GetParameterStackSlot(int index) const;
2058 int spill_slot_count() const { return spill_slot_count_; }
2059 CompilationInfo* info() const { return info_; }
2060 HGraph* graph() const { return graph_; }
2061 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2062 void AddGapMove(int index, LOperand* from, LOperand* to);
2063 LGap* GetGapAt(int index) const;
2064 bool IsGapAt(int index) const;
2065 int NearestGapPos(int index) const;
2066 void MarkEmptyBlocks();
2067 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
Steve Block44f0eee2011-05-26 01:26:41 +01002068 LLabel* GetLabel(int block_id) const {
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002069 HBasicBlock* block = graph_->blocks()->at(block_id);
2070 int first_instruction = block->first_instruction_index();
2071 return LLabel::cast(instructions_[first_instruction]);
2072 }
2073 int LookupDestination(int block_id) const {
2074 LLabel* cur = GetLabel(block_id);
2075 while (cur->replacement() != NULL) {
2076 cur = cur->replacement();
2077 }
2078 return cur->block_id();
2079 }
2080 Label* GetAssemblyLabel(int block_id) const {
2081 LLabel* label = GetLabel(block_id);
2082 ASSERT(!label->HasReplacement());
2083 return label->label();
Steve Block44f0eee2011-05-26 01:26:41 +01002084 }
2085
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002086 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2087 return &inlined_closures_;
Steve Block44f0eee2011-05-26 01:26:41 +01002088 }
2089
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002090 void AddInlinedClosure(Handle<JSFunction> closure) {
2091 inlined_closures_.Add(closure);
Steve Block44f0eee2011-05-26 01:26:41 +01002092 }
2093
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002094 private:
2095 int spill_slot_count_;
2096 CompilationInfo* info_;
2097 HGraph* const graph_;
2098 ZoneList<LInstruction*> instructions_;
2099 ZoneList<LPointerMap*> pointer_maps_;
2100 ZoneList<Handle<JSFunction> > inlined_closures_;
Steve Block44f0eee2011-05-26 01:26:41 +01002101};
2102
2103
2104class LChunkBuilder BASE_EMBEDDED {
2105 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002106 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2107 : chunk_(NULL),
2108 info_(info),
2109 graph_(graph),
2110 status_(UNUSED),
2111 current_instruction_(NULL),
2112 current_block_(NULL),
2113 next_block_(NULL),
2114 argument_count_(0),
2115 allocator_(allocator),
2116 position_(RelocInfo::kNoPosition),
2117 instruction_pending_deoptimization_environment_(NULL),
2118 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
Steve Block44f0eee2011-05-26 01:26:41 +01002119
2120 // Build the sequence for the graph.
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002121 LChunk* Build();
Steve Block44f0eee2011-05-26 01:26:41 +01002122
2123 // Declare methods that deal with the individual node types.
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002124#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
Steve Block44f0eee2011-05-26 01:26:41 +01002125 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2126#undef DECLARE_DO
2127
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002128 private:
2129 enum Status {
2130 UNUSED,
2131 BUILDING,
2132 DONE,
2133 ABORTED
2134 };
2135
2136 LChunk* chunk() const { return chunk_; }
2137 CompilationInfo* info() const { return info_; }
2138 HGraph* graph() const { return graph_; }
2139
2140 bool is_unused() const { return status_ == UNUSED; }
2141 bool is_building() const { return status_ == BUILDING; }
2142 bool is_done() const { return status_ == DONE; }
2143 bool is_aborted() const { return status_ == ABORTED; }
2144
2145 void Abort(const char* format, ...);
2146
2147 // Methods for getting operands for Use / Define / Temp.
2148 LRegister* ToOperand(Register reg);
2149 LUnallocated* ToUnallocated(Register reg);
2150 LUnallocated* ToUnallocated(DoubleRegister reg);
2151
2152 // Methods for setting up define-use relationships.
2153 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2154 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2155 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2156 DoubleRegister fixed_register);
2157
2158 // A value that is guaranteed to be allocated to a register.
2159 // Operand created by UseRegister is guaranteed to be live until the end of
2160 // instruction. This means that register allocator will not reuse it's
2161 // register for any other operand inside instruction.
2162 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2163 // instruction start. Register allocator is free to assign the same register
2164 // to some other operand used inside instruction (i.e. temporary or
2165 // output).
2166 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2167 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2168
2169 // An input operand in a register that may be trashed.
2170 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2171
2172 // An input operand in a register or stack slot.
2173 MUST_USE_RESULT LOperand* Use(HValue* value);
2174 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2175
2176 // An input operand in a register, stack slot or a constant operand.
2177 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2178 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2179
2180 // An input operand in a register or a constant operand.
2181 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2182 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2183
2184 // An input operand in register, stack slot or a constant operand.
2185 // Will not be moved to a register even if one is freely available.
2186 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2187
2188 // Temporary operand that must be in a register.
2189 MUST_USE_RESULT LUnallocated* TempRegister();
2190 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2191 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2192
2193 // Methods for setting up define-use relationships.
2194 // Return the same instruction that they are passed.
2195 template<int I, int T>
2196 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2197 LUnallocated* result);
2198 template<int I, int T>
2199 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2200 template<int I, int T>
2201 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2202 template<int I, int T>
2203 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2204 int index);
2205 template<int I, int T>
2206 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2207 template<int I, int T>
2208 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2209 Register reg);
2210 template<int I, int T>
2211 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2212 DoubleRegister reg);
2213 LInstruction* AssignEnvironment(LInstruction* instr);
2214 LInstruction* AssignPointerMap(LInstruction* instr);
2215
2216 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2217
2218 // By default we assume that instruction sequences generated for calls
2219 // cannot deoptimize eagerly and we do not attach environment to this
2220 // instruction.
2221 LInstruction* MarkAsCall(
2222 LInstruction* instr,
2223 HInstruction* hinstr,
2224 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2225 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
2226
2227 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2228 LInstruction* instr, int ast_id);
2229 void ClearInstructionPendingDeoptimizationEnvironment();
2230
2231 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2232 int* argument_index_accumulator);
2233
2234 void VisitInstruction(HInstruction* current);
2235
2236 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2237 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2238 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2239 LInstruction* DoArithmeticD(Token::Value op,
2240 HArithmeticBinaryOperation* instr);
2241 LInstruction* DoArithmeticT(Token::Value op,
2242 HArithmeticBinaryOperation* instr);
2243
2244 LChunk* chunk_;
2245 CompilationInfo* info_;
2246 HGraph* const graph_;
2247 Status status_;
2248 HInstruction* current_instruction_;
2249 HBasicBlock* current_block_;
2250 HBasicBlock* next_block_;
2251 int argument_count_;
2252 LAllocator* allocator_;
2253 int position_;
2254 LInstruction* instruction_pending_deoptimization_environment_;
2255 int pending_deoptimization_ast_id_;
2256
Steve Block44f0eee2011-05-26 01:26:41 +01002257 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2258};
2259
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002260#undef DECLARE_HYDROGEN_ACCESSOR
2261#undef DECLARE_CONCRETE_INSTRUCTION
Steve Block44f0eee2011-05-26 01:26:41 +01002262
2263} } // namespace v8::internal
2264
2265#endif // V8_MIPS_LITHIUM_MIPS_H_