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