Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/mips/lithium-mips.h

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

Powered by Google App Engine
This is Rietveld 408576698