blob: 29c2fc612a5d252cf5bcc31bee35fe6cbca43337 [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
danno@chromium.orgc612e022011-11-10 11:38:15 +00001382class LCallFunction: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001383 public:
danno@chromium.orgc612e022011-11-10 11:38:15 +00001384 explicit LCallFunction(LOperand* function) {
1385 inputs_[0] = function;
1386 }
1387
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001388 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1389 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1390
danno@chromium.orgc612e022011-11-10 11:38:15 +00001391 LOperand* function() { return inputs_[0]; }
1392 int arity() const { return hydrogen()->argument_count() - 1; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001393};
1394
1395
1396class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1397 public:
1398 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1399 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1400
1401 virtual void PrintDataTo(StringStream* stream);
1402
1403 Handle<String> name() const {return hydrogen()->name(); }
1404 int arity() const { return hydrogen()->argument_count() - 1; }
1405};
1406
1407
1408class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1409 public:
1410 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1411 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1412
1413 virtual void PrintDataTo(StringStream* stream);
1414
1415 Handle<JSFunction> target() const { return hydrogen()->target(); }
1416 int arity() const { return hydrogen()->argument_count() - 1; }
1417};
1418
1419
1420class LCallNew: public LTemplateInstruction<1, 1, 0> {
1421 public:
1422 explicit LCallNew(LOperand* constructor) {
1423 inputs_[0] = constructor;
1424 }
1425
1426 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1427 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1428
1429 virtual void PrintDataTo(StringStream* stream);
1430
1431 int arity() const { return hydrogen()->argument_count() - 1; }
1432};
1433
1434
1435class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1436 public:
1437 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1438 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1439
1440 const Runtime::Function* function() const { return hydrogen()->function(); }
1441 int arity() const { return hydrogen()->argument_count(); }
1442};
1443
1444
1445class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1446 public:
1447 explicit LInteger32ToDouble(LOperand* value) {
1448 inputs_[0] = value;
1449 }
1450
1451 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1452};
1453
1454
1455class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1456 public:
1457 explicit LNumberTagI(LOperand* value) {
1458 inputs_[0] = value;
1459 }
1460
1461 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1462};
1463
1464
1465class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1466 public:
1467 LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) {
1468 inputs_[0] = value;
1469 temps_[0] = temp1;
1470 temps_[1] = temp2;
1471 }
1472
1473 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1474};
1475
1476
1477// Sometimes truncating conversion from a tagged value to an int32.
1478class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1479 public:
1480 LDoubleToI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1481 inputs_[0] = value;
1482 temps_[0] = temp1;
1483 temps_[1] = temp2;
1484 }
1485
1486 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1487 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1488
1489 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1490};
1491
1492
1493// Truncating conversion from a tagged value to an int32.
1494class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
1495 public:
1496 LTaggedToI(LOperand* value,
1497 LOperand* temp1,
1498 LOperand* temp2,
1499 LOperand* temp3) {
1500 inputs_[0] = value;
1501 temps_[0] = temp1;
1502 temps_[1] = temp2;
1503 temps_[2] = temp3;
1504 }
1505
1506 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1507 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1508
1509 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1510};
1511
1512
1513class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1514 public:
1515 explicit LSmiTag(LOperand* value) {
1516 inputs_[0] = value;
1517 }
1518
1519 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1520};
1521
1522
1523class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
1524 public:
1525 explicit LNumberUntagD(LOperand* value) {
1526 inputs_[0] = value;
1527 }
1528
1529 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1530 DECLARE_HYDROGEN_ACCESSOR(Change)
1531};
1532
1533
1534class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1535 public:
1536 LSmiUntag(LOperand* value, bool needs_check)
1537 : needs_check_(needs_check) {
1538 inputs_[0] = value;
1539 }
1540
1541 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1542
1543 bool needs_check() const { return needs_check_; }
1544
1545 private:
1546 bool needs_check_;
1547};
1548
1549
1550class LStoreNamedField: public LTemplateInstruction<0, 2, 0> {
1551 public:
1552 LStoreNamedField(LOperand* obj, LOperand* val) {
1553 inputs_[0] = obj;
1554 inputs_[1] = val;
1555 }
1556
1557 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1558 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1559
1560 virtual void PrintDataTo(StringStream* stream);
1561
1562 LOperand* object() { return inputs_[0]; }
1563 LOperand* value() { return inputs_[1]; }
1564
1565 Handle<Object> name() const { return hydrogen()->name(); }
1566 bool is_in_object() { return hydrogen()->is_in_object(); }
1567 int offset() { return hydrogen()->offset(); }
1568 Handle<Map> transition() const { return hydrogen()->transition(); }
1569};
1570
1571
1572class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1573 public:
1574 LStoreNamedGeneric(LOperand* obj, LOperand* val) {
1575 inputs_[0] = obj;
1576 inputs_[1] = val;
1577 }
1578
1579 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1580 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1581
1582 virtual void PrintDataTo(StringStream* stream);
1583
1584 LOperand* object() { return inputs_[0]; }
1585 LOperand* value() { return inputs_[1]; }
1586 Handle<Object> name() const { return hydrogen()->name(); }
1587 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1588 bool strict_mode() { return strict_mode_flag() == kStrictMode; }
1589};
1590
1591
1592class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
1593 public:
1594 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
1595 inputs_[0] = obj;
1596 inputs_[1] = key;
1597 inputs_[2] = val;
1598 }
1599
1600 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1601 "store-keyed-fast-element")
1602 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
1603
1604 virtual void PrintDataTo(StringStream* stream);
1605
1606 LOperand* object() { return inputs_[0]; }
1607 LOperand* key() { return inputs_[1]; }
1608 LOperand* value() { return inputs_[2]; }
1609};
1610
1611
1612class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1613 public:
1614 LStoreKeyedFastDoubleElement(LOperand* elements,
1615 LOperand* key,
1616 LOperand* val) {
1617 inputs_[0] = elements;
1618 inputs_[1] = key;
1619 inputs_[2] = val;
1620 }
1621
1622 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1623 "store-keyed-fast-double-element")
1624 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1625
1626 virtual void PrintDataTo(StringStream* stream);
1627
1628 LOperand* elements() { return inputs_[0]; }
1629 LOperand* key() { return inputs_[1]; }
1630 LOperand* value() { return inputs_[2]; }
1631};
1632
1633
1634class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
1635 public:
1636 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* val) {
1637 inputs_[0] = obj;
1638 inputs_[1] = key;
1639 inputs_[2] = val;
1640 }
1641
1642 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1643 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1644
1645 virtual void PrintDataTo(StringStream* stream);
1646
1647 LOperand* object() { return inputs_[0]; }
1648 LOperand* key() { return inputs_[1]; }
1649 LOperand* value() { return inputs_[2]; }
1650 bool strict_mode() { return hydrogen()->strict_mode(); }
1651};
1652
1653class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
1654 public:
1655 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1656 LOperand* key,
1657 LOperand* val) {
1658 inputs_[0] = external_pointer;
1659 inputs_[1] = key;
1660 inputs_[2] = val;
1661 }
1662
1663 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1664 "store-keyed-specialized-array-element")
1665 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
1666
1667 LOperand* external_pointer() { return inputs_[0]; }
1668 LOperand* key() { return inputs_[1]; }
1669 LOperand* value() { return inputs_[2]; }
1670 ElementsKind elements_kind() const {
1671 return hydrogen()->elements_kind();
1672 }
1673};
1674
1675
1676class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1677 public:
1678 LTransitionElementsKind(LOperand* object,
1679 LOperand* new_map_temp,
1680 LOperand* temp_reg) {
1681 inputs_[0] = object;
1682 temps_[0] = new_map_temp;
1683 temps_[1] = temp_reg;
1684 }
1685
1686 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1687 "transition-elements-kind")
1688 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1689
1690 virtual void PrintDataTo(StringStream* stream);
1691
1692 LOperand* object() { return inputs_[0]; }
1693 LOperand* new_map_reg() { return temps_[0]; }
1694 LOperand* temp_reg() { return temps_[1]; }
1695 Handle<Map> original_map() { return hydrogen()->original_map(); }
1696 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
1697};
1698
1699
1700class LStringAdd: public LTemplateInstruction<1, 2, 0> {
1701 public:
1702 LStringAdd(LOperand* left, LOperand* right) {
1703 inputs_[0] = left;
1704 inputs_[1] = right;
1705 }
1706
1707 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1708 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1709
1710 LOperand* left() { return inputs_[0]; }
1711 LOperand* right() { return inputs_[1]; }
1712};
1713
1714
1715
1716class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
1717 public:
1718 LStringCharCodeAt(LOperand* string, LOperand* index) {
1719 inputs_[0] = string;
1720 inputs_[1] = index;
1721 }
1722
1723 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1724 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1725
1726 LOperand* string() { return inputs_[0]; }
1727 LOperand* index() { return inputs_[1]; }
1728};
1729
1730
1731class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
1732 public:
1733 explicit LStringCharFromCode(LOperand* char_code) {
1734 inputs_[0] = char_code;
1735 }
1736
1737 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1738 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1739
1740 LOperand* char_code() { return inputs_[0]; }
1741};
1742
1743
1744class LStringLength: public LTemplateInstruction<1, 1, 0> {
1745 public:
1746 explicit LStringLength(LOperand* string) {
1747 inputs_[0] = string;
1748 }
1749
1750 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1751 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1752
1753 LOperand* string() { return inputs_[0]; }
1754};
1755
1756
1757class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
1758 public:
1759 explicit LCheckFunction(LOperand* value) {
1760 inputs_[0] = value;
1761 }
1762
1763 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1764 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1765};
1766
1767
1768class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
1769 public:
1770 explicit LCheckInstanceType(LOperand* value) {
1771 inputs_[0] = value;
1772 }
1773
1774 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1775 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
1776};
1777
1778
1779class LCheckMap: public LTemplateInstruction<0, 1, 0> {
1780 public:
1781 explicit LCheckMap(LOperand* value) {
1782 inputs_[0] = value;
1783 }
1784
1785 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1786 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1787};
1788
1789
1790class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
1791 public:
1792 LCheckPrototypeMaps(LOperand* temp1, LOperand* temp2) {
1793 temps_[0] = temp1;
1794 temps_[1] = temp2;
1795 }
1796
1797 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
1798 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
1799
1800 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1801 Handle<JSObject> holder() const { return hydrogen()->holder(); }
1802};
1803
1804
1805class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
1806 public:
1807 explicit LCheckSmi(LOperand* value) {
1808 inputs_[0] = value;
1809 }
1810
1811 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1812};
1813
1814
1815class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1816 public:
1817 explicit LCheckNonSmi(LOperand* value) {
1818 inputs_[0] = value;
1819 }
1820
1821 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
1822};
1823
1824
1825class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
1826 public:
1827 LClampDToUint8(LOperand* value, LOperand* temp) {
1828 inputs_[0] = value;
1829 temps_[0] = temp;
1830 }
1831
1832 LOperand* unclamped() { return inputs_[0]; }
1833
1834 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1835};
1836
1837
1838class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1839 public:
1840 explicit LClampIToUint8(LOperand* value) {
1841 inputs_[0] = value;
1842 }
1843
1844 LOperand* unclamped() { return inputs_[0]; }
1845
1846 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1847};
1848
1849
1850class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
1851 public:
1852 LClampTToUint8(LOperand* value, LOperand* temp) {
1853 inputs_[0] = value;
1854 temps_[0] = temp;
1855 }
1856
1857 LOperand* unclamped() { return inputs_[0]; }
1858
1859 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1860};
1861
1862
1863class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
1864 public:
1865 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1866 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1867};
1868
1869
1870class LObjectLiteral: public LTemplateInstruction<1, 0, 0> {
1871 public:
1872 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
1873 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
1874};
1875
1876
1877class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
1878 public:
1879 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
1880 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
1881};
1882
1883
1884class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
1885 public:
1886 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1887 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1888
1889 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
1890};
1891
1892
1893class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
1894 public:
1895 explicit LToFastProperties(LOperand* value) {
1896 inputs_[0] = value;
1897 }
1898
1899 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
1900 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
1901};
1902
1903
1904class LTypeof: public LTemplateInstruction<1, 1, 0> {
1905 public:
1906 explicit LTypeof(LOperand* value) {
1907 inputs_[0] = value;
1908 }
1909
1910 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
1911};
1912
1913
1914class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
1915 public:
1916 explicit LTypeofIsAndBranch(LOperand* value) {
1917 inputs_[0] = value;
1918 }
1919
1920 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
1921 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
1922
1923 Handle<String> type_literal() { return hydrogen()->type_literal(); }
1924
1925 virtual void PrintDataTo(StringStream* stream);
1926};
1927
1928
1929class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
1930 public:
1931 explicit LIsConstructCallAndBranch(LOperand* temp) {
1932 temps_[0] = temp;
1933 }
1934
1935 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1936 "is-construct-call-and-branch")
1937};
1938
1939
1940class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
1941 public:
1942 LDeleteProperty(LOperand* obj, LOperand* key) {
1943 inputs_[0] = obj;
1944 inputs_[1] = key;
1945 }
1946
1947 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
1948
1949 LOperand* object() { return inputs_[0]; }
1950 LOperand* key() { return inputs_[1]; }
1951};
1952
1953
1954class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
1955 public:
1956 LOsrEntry();
1957
1958 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
1959
1960 LOperand** SpilledRegisterArray() { return register_spills_; }
1961 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
1962
1963 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
1964 void MarkSpilledDoubleRegister(int allocation_index,
1965 LOperand* spill_operand);
1966
1967 private:
1968 // Arrays of spill slot operands for registers with an assigned spill
1969 // slot, i.e., that must also be restored to the spill slot on OSR entry.
1970 // NULL if the register has no assigned spill slot. Indexed by allocation
1971 // index.
1972 LOperand* register_spills_[Register::kNumAllocatableRegisters];
1973 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
1974};
1975
1976
1977class LStackCheck: public LTemplateInstruction<0, 0, 0> {
1978 public:
1979 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
1980 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
1981
1982 Label* done_label() { return &done_label_; }
1983
1984 private:
1985 Label done_label_;
1986};
1987
1988
1989class LIn: public LTemplateInstruction<1, 2, 0> {
1990 public:
1991 LIn(LOperand* key, LOperand* object) {
1992 inputs_[0] = key;
1993 inputs_[1] = object;
1994 }
1995
1996 LOperand* key() { return inputs_[0]; }
1997 LOperand* object() { return inputs_[1]; }
1998
1999 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2000};
2001
2002
2003class LChunkBuilder;
lrn@chromium.org7516f052011-03-30 08:52:27 +00002004class LChunk: public ZoneObject {
2005 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002006 explicit LChunk(CompilationInfo* info, HGraph* graph);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002007
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002008 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
2009 LConstantOperand* DefineConstantOperand(HConstant* constant);
2010 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2011 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
lrn@chromium.org7516f052011-03-30 08:52:27 +00002012
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002013 int GetNextSpillIndex(bool is_double);
2014 LOperand* GetNextSpillSlot(bool is_double);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002015
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002016 int ParameterAt(int index);
2017 int GetParameterStackSlot(int index) const;
2018 int spill_slot_count() const { return spill_slot_count_; }
2019 CompilationInfo* info() const { return info_; }
2020 HGraph* graph() const { return graph_; }
2021 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2022 void AddGapMove(int index, LOperand* from, LOperand* to);
2023 LGap* GetGapAt(int index) const;
2024 bool IsGapAt(int index) const;
2025 int NearestGapPos(int index) const;
2026 void MarkEmptyBlocks();
2027 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002028 LLabel* GetLabel(int block_id) const {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002029 HBasicBlock* block = graph_->blocks()->at(block_id);
2030 int first_instruction = block->first_instruction_index();
2031 return LLabel::cast(instructions_[first_instruction]);
2032 }
2033 int LookupDestination(int block_id) const {
2034 LLabel* cur = GetLabel(block_id);
2035 while (cur->replacement() != NULL) {
2036 cur = cur->replacement();
2037 }
2038 return cur->block_id();
2039 }
2040 Label* GetAssemblyLabel(int block_id) const {
2041 LLabel* label = GetLabel(block_id);
2042 ASSERT(!label->HasReplacement());
2043 return label->label();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002044 }
2045
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002046 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2047 return &inlined_closures_;
lrn@chromium.org7516f052011-03-30 08:52:27 +00002048 }
2049
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002050 void AddInlinedClosure(Handle<JSFunction> closure) {
2051 inlined_closures_.Add(closure);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002052 }
2053
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002054 private:
2055 int spill_slot_count_;
2056 CompilationInfo* info_;
2057 HGraph* const graph_;
2058 ZoneList<LInstruction*> instructions_;
2059 ZoneList<LPointerMap*> pointer_maps_;
2060 ZoneList<Handle<JSFunction> > inlined_closures_;
lrn@chromium.org7516f052011-03-30 08:52:27 +00002061};
2062
2063
2064class LChunkBuilder BASE_EMBEDDED {
2065 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002066 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2067 : chunk_(NULL),
2068 info_(info),
2069 graph_(graph),
2070 status_(UNUSED),
2071 current_instruction_(NULL),
2072 current_block_(NULL),
2073 next_block_(NULL),
2074 argument_count_(0),
2075 allocator_(allocator),
2076 position_(RelocInfo::kNoPosition),
2077 instruction_pending_deoptimization_environment_(NULL),
2078 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002079
2080 // Build the sequence for the graph.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002081 LChunk* Build();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002082
2083 // Declare methods that deal with the individual node types.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002084#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002085 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2086#undef DECLARE_DO
2087
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002088 private:
2089 enum Status {
2090 UNUSED,
2091 BUILDING,
2092 DONE,
2093 ABORTED
2094 };
2095
2096 LChunk* chunk() const { return chunk_; }
2097 CompilationInfo* info() const { return info_; }
2098 HGraph* graph() const { return graph_; }
2099
2100 bool is_unused() const { return status_ == UNUSED; }
2101 bool is_building() const { return status_ == BUILDING; }
2102 bool is_done() const { return status_ == DONE; }
2103 bool is_aborted() const { return status_ == ABORTED; }
2104
2105 void Abort(const char* format, ...);
2106
2107 // Methods for getting operands for Use / Define / Temp.
2108 LRegister* ToOperand(Register reg);
2109 LUnallocated* ToUnallocated(Register reg);
2110 LUnallocated* ToUnallocated(DoubleRegister reg);
2111
2112 // Methods for setting up define-use relationships.
2113 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2114 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2115 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2116 DoubleRegister fixed_register);
2117
2118 // A value that is guaranteed to be allocated to a register.
2119 // Operand created by UseRegister is guaranteed to be live until the end of
2120 // instruction. This means that register allocator will not reuse it's
2121 // register for any other operand inside instruction.
2122 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2123 // instruction start. Register allocator is free to assign the same register
2124 // to some other operand used inside instruction (i.e. temporary or
2125 // output).
2126 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2127 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2128
2129 // An input operand in a register that may be trashed.
2130 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2131
2132 // An input operand in a register or stack slot.
2133 MUST_USE_RESULT LOperand* Use(HValue* value);
2134 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2135
2136 // An input operand in a register, stack slot or a constant operand.
2137 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2138 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2139
2140 // An input operand in a register or a constant operand.
2141 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2142 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2143
2144 // An input operand in register, stack slot or a constant operand.
2145 // Will not be moved to a register even if one is freely available.
2146 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2147
2148 // Temporary operand that must be in a register.
2149 MUST_USE_RESULT LUnallocated* TempRegister();
2150 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2151 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2152
2153 // Methods for setting up define-use relationships.
2154 // Return the same instruction that they are passed.
2155 template<int I, int T>
2156 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2157 LUnallocated* result);
2158 template<int I, int T>
2159 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2160 template<int I, int T>
2161 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2162 template<int I, int T>
2163 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2164 int index);
2165 template<int I, int T>
2166 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2167 template<int I, int T>
2168 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2169 Register reg);
2170 template<int I, int T>
2171 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2172 DoubleRegister reg);
2173 LInstruction* AssignEnvironment(LInstruction* instr);
2174 LInstruction* AssignPointerMap(LInstruction* instr);
2175
2176 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2177
2178 // By default we assume that instruction sequences generated for calls
2179 // cannot deoptimize eagerly and we do not attach environment to this
2180 // instruction.
2181 LInstruction* MarkAsCall(
2182 LInstruction* instr,
2183 HInstruction* hinstr,
2184 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2185 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
2186
2187 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2188 LInstruction* instr, int ast_id);
2189 void ClearInstructionPendingDeoptimizationEnvironment();
2190
2191 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2192 int* argument_index_accumulator);
2193
2194 void VisitInstruction(HInstruction* current);
2195
2196 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2197 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2198 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2199 LInstruction* DoArithmeticD(Token::Value op,
2200 HArithmeticBinaryOperation* instr);
2201 LInstruction* DoArithmeticT(Token::Value op,
2202 HArithmeticBinaryOperation* instr);
2203
2204 LChunk* chunk_;
2205 CompilationInfo* info_;
2206 HGraph* const graph_;
2207 Status status_;
2208 HInstruction* current_instruction_;
2209 HBasicBlock* current_block_;
2210 HBasicBlock* next_block_;
2211 int argument_count_;
2212 LAllocator* allocator_;
2213 int position_;
2214 LInstruction* instruction_pending_deoptimization_environment_;
2215 int pending_deoptimization_ast_id_;
2216
lrn@chromium.org7516f052011-03-30 08:52:27 +00002217 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2218};
2219
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002220#undef DECLARE_HYDROGEN_ACCESSOR
2221#undef DECLARE_CONCRETE_INSTRUCTION
lrn@chromium.org7516f052011-03-30 08:52:27 +00002222
2223} } // namespace v8::internal
2224
2225#endif // V8_MIPS_LITHIUM_MIPS_H_