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