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