blob: 7f87b028d06c647bc117f24574c64233102faaef [file] [log] [blame]
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001// Copyright 2012 the V8 project authors. All rights reserved.
lrn@chromium.org7516f052011-03-30 08:52:27 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_MIPS_LITHIUM_MIPS_H_
29#define V8_MIPS_LITHIUM_MIPS_H_
30
31#include "hydrogen.h"
32#include "lithium-allocator.h"
33#include "lithium.h"
34#include "safepoint-table.h"
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000035#include "utils.h"
lrn@chromium.org7516f052011-03-30 08:52:27 +000036
37namespace v8 {
38namespace internal {
39
40// Forward declarations.
41class LCodeGen;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000042
43#define LITHIUM_ALL_INSTRUCTION_LIST(V) \
44 V(ControlInstruction) \
45 V(Call) \
46 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
47
48
49#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
50 V(AccessArgumentsAt) \
51 V(AddI) \
ulan@chromium.org967e2702012-02-28 09:49:15 +000052 V(AllocateObject) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000053 V(ApplyArguments) \
54 V(ArgumentsElements) \
55 V(ArgumentsLength) \
56 V(ArithmeticD) \
57 V(ArithmeticT) \
58 V(ArrayLiteral) \
59 V(BitI) \
60 V(BitNotI) \
61 V(BoundsCheck) \
62 V(Branch) \
63 V(CallConstantFunction) \
64 V(CallFunction) \
65 V(CallGlobal) \
66 V(CallKeyed) \
67 V(CallKnownGlobal) \
68 V(CallNamed) \
69 V(CallNew) \
70 V(CallRuntime) \
71 V(CallStub) \
72 V(CheckFunction) \
73 V(CheckInstanceType) \
jkummerow@chromium.org1456e702012-03-30 08:38:13 +000074 V(CheckMaps) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000075 V(CheckNonSmi) \
76 V(CheckPrototypeMaps) \
77 V(CheckSmi) \
78 V(ClampDToUint8) \
79 V(ClampIToUint8) \
80 V(ClampTToUint8) \
81 V(ClassOfTestAndBranch) \
82 V(CmpConstantEqAndBranch) \
83 V(CmpIDAndBranch) \
84 V(CmpObjectEqAndBranch) \
85 V(CmpMapAndBranch) \
86 V(CmpT) \
87 V(ConstantD) \
88 V(ConstantI) \
89 V(ConstantT) \
90 V(Context) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +000091 V(DeclareGlobals) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000092 V(DeleteProperty) \
93 V(Deoptimize) \
94 V(DivI) \
95 V(DoubleToI) \
96 V(ElementsKind) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +000097 V(FastLiteral) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000098 V(FixedArrayBaseLength) \
99 V(FunctionLiteral) \
100 V(GetCachedArrayIndex) \
101 V(GlobalObject) \
102 V(GlobalReceiver) \
103 V(Goto) \
104 V(HasCachedArrayIndexAndBranch) \
105 V(HasInstanceTypeAndBranch) \
106 V(In) \
107 V(InstanceOf) \
108 V(InstanceOfKnownGlobal) \
109 V(InstructionGap) \
110 V(Integer32ToDouble) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000111 V(Uint32ToDouble) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000112 V(InvokeFunction) \
113 V(IsConstructCallAndBranch) \
114 V(IsNilAndBranch) \
115 V(IsObjectAndBranch) \
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000116 V(IsStringAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000117 V(IsSmiAndBranch) \
118 V(IsUndetectableAndBranch) \
119 V(JSArrayLength) \
120 V(Label) \
121 V(LazyBailout) \
122 V(LoadContextSlot) \
123 V(LoadElements) \
124 V(LoadExternalArrayPointer) \
125 V(LoadFunctionPrototype) \
126 V(LoadGlobalCell) \
127 V(LoadGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000128 V(LoadKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000129 V(LoadKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000130 V(LoadNamedField) \
131 V(LoadNamedFieldPolymorphic) \
132 V(LoadNamedGeneric) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000133 V(MapEnumLength) \
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000134 V(MathExp) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000135 V(MathMinMax) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000136 V(ModI) \
137 V(MulI) \
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000138 V(MultiplyAddD) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000139 V(NumberTagD) \
140 V(NumberTagI) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000141 V(NumberTagU) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000142 V(NumberUntagD) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +0000143 V(ObjectLiteral) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000144 V(OsrEntry) \
145 V(OuterContext) \
146 V(Parameter) \
147 V(Power) \
148 V(PushArgument) \
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000149 V(Random) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000150 V(RegExpLiteral) \
151 V(Return) \
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000152 V(SeqStringSetChar) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000153 V(ShiftI) \
154 V(SmiTag) \
155 V(SmiUntag) \
156 V(StackCheck) \
157 V(StoreContextSlot) \
158 V(StoreGlobalCell) \
159 V(StoreGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000160 V(StoreKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000161 V(StoreKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000162 V(StoreNamedField) \
163 V(StoreNamedGeneric) \
164 V(StringAdd) \
165 V(StringCharCodeAt) \
166 V(StringCharFromCode) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000167 V(StringCompareAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000168 V(StringLength) \
169 V(SubI) \
170 V(TaggedToI) \
171 V(ThisFunction) \
172 V(Throw) \
173 V(ToFastProperties) \
174 V(TransitionElementsKind) \
175 V(Typeof) \
176 V(TypeofIsAndBranch) \
177 V(UnaryMathOperation) \
178 V(UnknownOSRValue) \
ulan@chromium.org812308e2012-02-29 15:58:45 +0000179 V(ValueOf) \
180 V(ForInPrepareMap) \
181 V(ForInCacheArray) \
182 V(CheckMapValue) \
yangguo@chromium.org154ff992012-03-13 08:09:54 +0000183 V(LoadFieldByIndex) \
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000184 V(DateField) \
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000185 V(WrapReceiver) \
186 V(Drop)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000187
188#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
189 virtual Opcode opcode() const { return LInstruction::k##type; } \
190 virtual void CompileToNative(LCodeGen* generator); \
191 virtual const char* Mnemonic() const { return mnemonic; } \
192 static L##type* cast(LInstruction* instr) { \
193 ASSERT(instr->Is##type()); \
194 return reinterpret_cast<L##type*>(instr); \
195 }
196
197
198#define DECLARE_HYDROGEN_ACCESSOR(type) \
199 H##type* hydrogen() const { \
200 return H##type::cast(hydrogen_value()); \
201 }
202
lrn@chromium.org7516f052011-03-30 08:52:27 +0000203
204class LInstruction: public ZoneObject {
205 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000206 LInstruction()
207 : environment_(NULL),
208 hydrogen_value_(NULL),
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000209 is_call_(false) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000210 virtual ~LInstruction() { }
211
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000212 virtual void CompileToNative(LCodeGen* generator) = 0;
213 virtual const char* Mnemonic() const = 0;
214 virtual void PrintTo(StringStream* stream);
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000215 virtual void PrintDataTo(StringStream* stream);
216 virtual void PrintOutputOperandTo(StringStream* stream);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000217
218 enum Opcode {
219 // Declare a unique enum value for each instruction.
220#define DECLARE_OPCODE(type) k##type,
221 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
222 kNumberOfInstructions
223#undef DECLARE_OPCODE
224 };
225
226 virtual Opcode opcode() const = 0;
227
228 // Declare non-virtual type testers for all leaf IR classes.
229#define DECLARE_PREDICATE(type) \
230 bool Is##type() const { return opcode() == k##type; }
231 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
232#undef DECLARE_PREDICATE
233
234 // Declare virtual predicates for instructions that don't have
235 // an opcode.
236 virtual bool IsGap() const { return false; }
237
238 virtual bool IsControl() const { return false; }
239
240 void set_environment(LEnvironment* env) { environment_ = env; }
241 LEnvironment* environment() const { return environment_; }
242 bool HasEnvironment() const { return environment_ != NULL; }
243
244 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
245 LPointerMap* pointer_map() const { return pointer_map_.get(); }
246 bool HasPointerMap() const { return pointer_map_.is_set(); }
247
248 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
249 HValue* hydrogen_value() const { return hydrogen_value_; }
250
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000251 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000252
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000253 void MarkAsCall() { is_call_ = true; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000254
255 // Interface to the register allocator and iterators.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000256 bool ClobbersTemps() const { return is_call_; }
257 bool ClobbersRegisters() const { return is_call_; }
258 bool ClobbersDoubleRegisters() const { return is_call_; }
259
260 // Interface to the register allocator and iterators.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000261 bool IsMarkedAsCall() const { return is_call_; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000262
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000263 virtual bool HasResult() const = 0;
264 virtual LOperand* result() = 0;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000265
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000266 LOperand* FirstInput() { return InputAt(0); }
267 LOperand* Output() { return HasResult() ? result() : NULL; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000268
269#ifdef DEBUG
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000270 void VerifyCall();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000271#endif
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000272
273 private:
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000274 // Iterator interface.
275 friend class InputIterator;
276 virtual int InputCount() = 0;
277 virtual LOperand* InputAt(int i) = 0;
278
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000279 friend class TempIterator;
280 virtual int TempCount() = 0;
281 virtual LOperand* TempAt(int i) = 0;
282
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000283 LEnvironment* environment_;
284 SetOncePointer<LPointerMap> pointer_map_;
285 HValue* hydrogen_value_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000286 bool is_call_;
287 bool is_save_doubles_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000288};
289
290
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000291// R = number of result operands (0 or 1).
292// I = number of input operands.
293// T = number of temporary operands.
294template<int R, int I, int T>
295class LTemplateInstruction: public LInstruction {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000296 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000297 // Allow 0 or 1 output operands.
298 STATIC_ASSERT(R == 0 || R == 1);
299 virtual bool HasResult() const { return R != 0; }
300 void set_result(LOperand* operand) { results_[0] = operand; }
301 LOperand* result() { return results_[0]; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000302
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000303 protected:
304 EmbeddedContainer<LOperand*, R> results_;
305 EmbeddedContainer<LOperand*, I> inputs_;
306 EmbeddedContainer<LOperand*, T> temps_;
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000307
308 private:
309 virtual int InputCount() { return I; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000310 virtual LOperand* InputAt(int i) { return inputs_[i]; }
311
312 virtual int TempCount() { return T; }
313 virtual LOperand* TempAt(int i) { return temps_[i]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000314};
315
316
317class LGap: public LTemplateInstruction<0, 0, 0> {
318 public:
319 explicit LGap(HBasicBlock* block)
320 : block_(block) {
321 parallel_moves_[BEFORE] = NULL;
322 parallel_moves_[START] = NULL;
323 parallel_moves_[END] = NULL;
324 parallel_moves_[AFTER] = NULL;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000325 }
326
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000327 // Can't use the DECLARE-macro here because of sub-classes.
328 virtual bool IsGap() const { return true; }
329 virtual void PrintDataTo(StringStream* stream);
330 static LGap* cast(LInstruction* instr) {
331 ASSERT(instr->IsGap());
332 return reinterpret_cast<LGap*>(instr);
333 }
334
335 bool IsRedundant() const;
336
337 HBasicBlock* block() const { return block_; }
338
lrn@chromium.org7516f052011-03-30 08:52:27 +0000339 enum InnerPosition {
340 BEFORE,
341 START,
342 END,
343 AFTER,
344 FIRST_INNER_POSITION = BEFORE,
345 LAST_INNER_POSITION = AFTER
346 };
347
mmassi@chromium.org7028c052012-06-13 11:51:58 +0000348 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
349 if (parallel_moves_[pos] == NULL) {
350 parallel_moves_[pos] = new(zone) LParallelMove(zone);
351 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000352 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000353 }
354
355 LParallelMove* GetParallelMove(InnerPosition pos) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000356 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000357 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000358
359 private:
360 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
361 HBasicBlock* block_;
362};
363
364
365class LInstructionGap: public LGap {
366 public:
367 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
368
369 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
370};
371
372
373class LGoto: public LTemplateInstruction<0, 0, 0> {
374 public:
375 explicit LGoto(int block_id) : block_id_(block_id) { }
376
377 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
378 virtual void PrintDataTo(StringStream* stream);
379 virtual bool IsControl() const { return true; }
380
381 int block_id() const { return block_id_; }
382
383 private:
384 int block_id_;
385};
386
387
388class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
389 public:
390 LLazyBailout() : gap_instructions_size_(0) { }
391
392 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
393
394 void set_gap_instructions_size(int gap_instructions_size) {
395 gap_instructions_size_ = gap_instructions_size;
396 }
397 int gap_instructions_size() { return gap_instructions_size_; }
398
399 private:
400 int gap_instructions_size_;
401};
402
403
404class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
405 public:
406 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
lrn@chromium.org7516f052011-03-30 08:52:27 +0000407};
408
409
410class LLabel: public LGap {
411 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000412 explicit LLabel(HBasicBlock* block)
413 : LGap(block), replacement_(NULL) { }
414
415 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
416
417 virtual void PrintDataTo(StringStream* stream);
418
419 int block_id() const { return block()->block_id(); }
420 bool is_loop_header() const { return block()->IsLoopHeader(); }
421 Label* label() { return &label_; }
422 LLabel* replacement() const { return replacement_; }
423 void set_replacement(LLabel* label) { replacement_ = label; }
424 bool HasReplacement() const { return replacement_ != NULL; }
425
426 private:
427 Label label_;
428 LLabel* replacement_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000429};
430
431
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000432class LParameter: public LTemplateInstruction<1, 0, 0> {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000433 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000434 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
435};
lrn@chromium.org7516f052011-03-30 08:52:27 +0000436
lrn@chromium.org7516f052011-03-30 08:52:27 +0000437
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000438class LCallStub: public LTemplateInstruction<1, 0, 0> {
439 public:
440 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
441 DECLARE_HYDROGEN_ACCESSOR(CallStub)
442
443 TranscendentalCache::Type transcendental_type() {
444 return hydrogen()->transcendental_type();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000445 }
446};
447
448
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000449class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
450 public:
451 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
452};
453
454
455template<int I, int T>
456class LControlInstruction: public LTemplateInstruction<0, I, T> {
457 public:
458 virtual bool IsControl() const { return true; }
459
460 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
461 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
462 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
463 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
464
465 private:
466 HControlInstruction* hydrogen() {
467 return HControlInstruction::cast(this->hydrogen_value());
468 }
469};
470
471
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000472class LWrapReceiver: public LTemplateInstruction<1, 2, 0> {
473 public:
474 LWrapReceiver(LOperand* receiver, LOperand* function) {
475 inputs_[0] = receiver;
476 inputs_[1] = function;
477 }
478
479 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
480
481 LOperand* receiver() { return inputs_[0]; }
482 LOperand* function() { return inputs_[1]; }
483};
484
485
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000486class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
487 public:
488 LApplyArguments(LOperand* function,
489 LOperand* receiver,
490 LOperand* length,
491 LOperand* elements) {
492 inputs_[0] = function;
493 inputs_[1] = receiver;
494 inputs_[2] = length;
495 inputs_[3] = elements;
496 }
497
498 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
499
500 LOperand* function() { return inputs_[0]; }
501 LOperand* receiver() { return inputs_[1]; }
502 LOperand* length() { return inputs_[2]; }
503 LOperand* elements() { return inputs_[3]; }
504};
505
506
507class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
508 public:
509 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
510 inputs_[0] = arguments;
511 inputs_[1] = length;
512 inputs_[2] = index;
513 }
514
515 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
516
517 LOperand* arguments() { return inputs_[0]; }
518 LOperand* length() { return inputs_[1]; }
519 LOperand* index() { return inputs_[2]; }
520
521 virtual void PrintDataTo(StringStream* stream);
522};
523
524
525class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
526 public:
527 explicit LArgumentsLength(LOperand* elements) {
528 inputs_[0] = elements;
529 }
530
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000531 LOperand* elements() { return inputs_[0]; }
532
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000533 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
534};
535
536
537class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
538 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000539 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000540 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000541};
542
543
544class LModI: public LTemplateInstruction<1, 2, 3> {
545 public:
546 // Used when the right hand is a constant power of 2.
547 LModI(LOperand* left,
548 LOperand* right) {
549 inputs_[0] = left;
550 inputs_[1] = right;
551 temps_[0] = NULL;
552 temps_[1] = NULL;
553 temps_[2] = NULL;
554 }
555
556 // Used for the standard case.
557 LModI(LOperand* left,
558 LOperand* right,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000559 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000560 LOperand* temp2,
561 LOperand* temp3) {
562 inputs_[0] = left;
563 inputs_[1] = right;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000564 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000565 temps_[1] = temp2;
566 temps_[2] = temp3;
567 }
568
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000569 LOperand* left() { return inputs_[0]; }
570 LOperand* right() { return inputs_[1]; }
571 LOperand* temp() { return temps_[0]; }
572 LOperand* temp2() { return temps_[1]; }
573 LOperand* temp3() { return temps_[2]; }
574
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000575 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
576 DECLARE_HYDROGEN_ACCESSOR(Mod)
577};
578
579
580class LDivI: public LTemplateInstruction<1, 2, 0> {
581 public:
582 LDivI(LOperand* left, LOperand* right) {
583 inputs_[0] = left;
584 inputs_[1] = right;
585 }
586
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000587 LOperand* left() { return inputs_[0]; }
588 LOperand* right() { return inputs_[1]; }
589
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000590 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
591 DECLARE_HYDROGEN_ACCESSOR(Div)
592};
593
594
595class LMulI: public LTemplateInstruction<1, 2, 1> {
596 public:
597 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
598 inputs_[0] = left;
599 inputs_[1] = right;
600 temps_[0] = temp;
601 }
602
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000603 LOperand* left() { return inputs_[0]; }
604 LOperand* right() { return inputs_[1]; }
605 LOperand* temp() { return temps_[0]; }
606
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000607 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
608 DECLARE_HYDROGEN_ACCESSOR(Mul)
609};
610
611
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000612// Instruction for computing multiplier * multiplicand + addend.
613class LMultiplyAddD: public LTemplateInstruction<1, 3, 0> {
614 public:
615 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
616 LOperand* multiplicand) {
617 inputs_[0] = addend;
618 inputs_[1] = multiplier;
619 inputs_[2] = multiplicand;
620 }
621
622 LOperand* addend() { return inputs_[0]; }
623 LOperand* multiplier() { return inputs_[1]; }
624 LOperand* multiplicand() { return inputs_[2]; }
625
626 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
627};
628
629
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000630class LCmpIDAndBranch: public LControlInstruction<2, 0> {
631 public:
632 LCmpIDAndBranch(LOperand* left, LOperand* right) {
633 inputs_[0] = left;
634 inputs_[1] = right;
635 }
636
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000637 LOperand* left() { return inputs_[0]; }
638 LOperand* right() { return inputs_[1]; }
639
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000640 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
641 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
642
643 Token::Value op() const { return hydrogen()->token(); }
644 bool is_double() const {
ulan@chromium.org8e8d8822012-11-23 14:36:46 +0000645 return hydrogen()->representation().IsDouble();
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000646 }
647
648 virtual void PrintDataTo(StringStream* stream);
649};
650
651
652class LUnaryMathOperation: public LTemplateInstruction<1, 1, 1> {
653 public:
654 LUnaryMathOperation(LOperand* value, LOperand* temp) {
655 inputs_[0] = value;
656 temps_[0] = temp;
657 }
658
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000659 LOperand* value() { return inputs_[0]; }
660 LOperand* temp() { return temps_[0]; }
661
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000662 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
663 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
664
665 virtual void PrintDataTo(StringStream* stream);
666 BuiltinFunctionId op() const { return hydrogen()->op(); }
667};
668
669
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000670class LMathExp: public LTemplateInstruction<1, 1, 3> {
671 public:
672 LMathExp(LOperand* value,
673 LOperand* double_temp,
674 LOperand* temp1,
675 LOperand* temp2) {
676 inputs_[0] = value;
677 temps_[0] = temp1;
678 temps_[1] = temp2;
679 temps_[2] = double_temp;
680 ExternalReference::InitializeMathExpData();
681 }
682
683 LOperand* value() { return inputs_[0]; }
684 LOperand* temp1() { return temps_[0]; }
685 LOperand* temp2() { return temps_[1]; }
686 LOperand* double_temp() { return temps_[2]; }
687
688 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
689
690 virtual void PrintDataTo(StringStream* stream);
691};
692
693
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000694class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
695 public:
696 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
697 inputs_[0] = left;
698 inputs_[1] = right;
699 }
700
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000701 LOperand* left() { return inputs_[0]; }
702 LOperand* right() { return inputs_[1]; }
703
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000704 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
705 "cmp-object-eq-and-branch")
706 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
707};
708
709
710class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
711 public:
712 explicit LCmpConstantEqAndBranch(LOperand* left) {
713 inputs_[0] = left;
714 }
715
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000716 LOperand* left() { return inputs_[0]; }
717
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000718 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
719 "cmp-constant-eq-and-branch")
720 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
721};
722
723
724class LIsNilAndBranch: public LControlInstruction<1, 0> {
725 public:
726 explicit LIsNilAndBranch(LOperand* value) {
727 inputs_[0] = value;
728 }
729
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000730 LOperand* value() { return inputs_[0]; }
731
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000732 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
733 DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
734
735 EqualityKind kind() const { return hydrogen()->kind(); }
736 NilValue nil() const { return hydrogen()->nil(); }
737
738 virtual void PrintDataTo(StringStream* stream);
739};
740
741
742class LIsObjectAndBranch: public LControlInstruction<1, 1> {
743 public:
744 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
745 inputs_[0] = value;
746 temps_[0] = temp;
747 }
748
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000749 LOperand* value() { return inputs_[0]; }
750 LOperand* temp() { return temps_[0]; }
751
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000752 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
753 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
754
755 virtual void PrintDataTo(StringStream* stream);
756};
757
758
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000759class LIsStringAndBranch: public LControlInstruction<1, 1> {
760 public:
761 LIsStringAndBranch(LOperand* value, LOperand* temp) {
762 inputs_[0] = value;
763 temps_[0] = temp;
764 }
765
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000766 LOperand* value() { return inputs_[0]; }
767 LOperand* temp() { return temps_[0]; }
768
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000769 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
770 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
771
772 virtual void PrintDataTo(StringStream* stream);
773};
774
775
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000776class LIsSmiAndBranch: public LControlInstruction<1, 0> {
777 public:
778 explicit LIsSmiAndBranch(LOperand* value) {
779 inputs_[0] = value;
780 }
781
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000782 LOperand* value() { return inputs_[0]; }
783
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000784 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
785 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
786
787 virtual void PrintDataTo(StringStream* stream);
788};
789
790
791class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
792 public:
793 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
794 inputs_[0] = value;
795 temps_[0] = temp;
796 }
797
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000798 LOperand* value() { return inputs_[0]; }
799 LOperand* temp() { return temps_[0]; }
800
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000801 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
802 "is-undetectable-and-branch")
803 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
804
805 virtual void PrintDataTo(StringStream* stream);
806};
807
808
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000809class LStringCompareAndBranch: public LControlInstruction<2, 0> {
810 public:
811 LStringCompareAndBranch(LOperand* left, LOperand* right) {
812 inputs_[0] = left;
813 inputs_[1] = right;
814 }
815
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000816 LOperand* left() { return inputs_[0]; }
817 LOperand* right() { return inputs_[1]; }
818
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000819 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
820 "string-compare-and-branch")
821 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
822
823 Token::Value op() const { return hydrogen()->token(); }
824
825 virtual void PrintDataTo(StringStream* stream);
826};
827
828
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000829class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
830 public:
831 explicit LHasInstanceTypeAndBranch(LOperand* value) {
832 inputs_[0] = value;
833 }
834
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000835 LOperand* value() { return inputs_[0]; }
836
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000837 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
838 "has-instance-type-and-branch")
839 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
840
841 virtual void PrintDataTo(StringStream* stream);
842};
843
844
845class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
846 public:
847 explicit LGetCachedArrayIndex(LOperand* value) {
848 inputs_[0] = value;
849 }
850
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000851 LOperand* value() { return inputs_[0]; }
852
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000853 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
854 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
855};
856
857
858class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
859 public:
860 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
861 inputs_[0] = value;
862 }
863
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000864 LOperand* value() { return inputs_[0]; }
865
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000866 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
867 "has-cached-array-index-and-branch")
868 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
869
870 virtual void PrintDataTo(StringStream* stream);
871};
872
873
874class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
875 public:
876 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
877 inputs_[0] = value;
878 temps_[0] = temp;
879 }
880
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000881 LOperand* value() { return inputs_[0]; }
882 LOperand* temp() { return temps_[0]; }
883
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000884 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
885 "class-of-test-and-branch")
886 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
887
888 virtual void PrintDataTo(StringStream* stream);
889};
890
891
892class LCmpT: public LTemplateInstruction<1, 2, 0> {
893 public:
894 LCmpT(LOperand* left, LOperand* right) {
895 inputs_[0] = left;
896 inputs_[1] = right;
897 }
898
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000899 LOperand* left() { return inputs_[0]; }
900 LOperand* right() { return inputs_[1]; }
901
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000902 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
903 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
904
905 Token::Value op() const { return hydrogen()->token(); }
906};
907
908
909class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
910 public:
911 LInstanceOf(LOperand* left, LOperand* right) {
912 inputs_[0] = left;
913 inputs_[1] = right;
914 }
915
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000916 LOperand* left() { return inputs_[0]; }
917 LOperand* right() { return inputs_[1]; }
918
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000919 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
920};
921
922
923class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
924 public:
925 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
926 inputs_[0] = value;
927 temps_[0] = temp;
928 }
929
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000930 LOperand* value() { return inputs_[0]; }
931 LOperand* temp() { return temps_[0]; }
932
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000933 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
934 "instance-of-known-global")
935 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
936
937 Handle<JSFunction> function() const { return hydrogen()->function(); }
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000938 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
939 return lazy_deopt_env_;
940 }
941 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {
942 lazy_deopt_env_ = env;
943 }
944
945 private:
946 LEnvironment* lazy_deopt_env_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000947};
948
949
950class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
951 public:
952 LBoundsCheck(LOperand* index, LOperand* length) {
953 inputs_[0] = index;
954 inputs_[1] = length;
955 }
956
957 LOperand* index() { return inputs_[0]; }
958 LOperand* length() { return inputs_[1]; }
959
960 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
danno@chromium.org129d3982012-07-25 15:01:47 +0000961 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000962};
963
964
965class LBitI: public LTemplateInstruction<1, 2, 0> {
966 public:
967 LBitI(LOperand* left, LOperand* right) {
968 inputs_[0] = left;
969 inputs_[1] = right;
970 }
971
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000972 LOperand* left() { return inputs_[0]; }
973 LOperand* right() { return inputs_[1]; }
974
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000975 Token::Value op() const { return hydrogen()->op(); }
976
977 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
978 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
979};
980
981
982class LShiftI: public LTemplateInstruction<1, 2, 0> {
983 public:
984 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
985 : op_(op), can_deopt_(can_deopt) {
986 inputs_[0] = left;
987 inputs_[1] = right;
988 }
989
990 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000991 LOperand* left() { return inputs_[0]; }
992 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000993 bool can_deopt() const { return can_deopt_; }
994
995 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
996
997 private:
998 Token::Value op_;
999 bool can_deopt_;
1000};
1001
1002
1003class LSubI: public LTemplateInstruction<1, 2, 0> {
1004 public:
1005 LSubI(LOperand* left, LOperand* right) {
1006 inputs_[0] = left;
1007 inputs_[1] = right;
1008 }
1009
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001010 LOperand* left() { return inputs_[0]; }
1011 LOperand* right() { return inputs_[1]; }
1012
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001013 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1014 DECLARE_HYDROGEN_ACCESSOR(Sub)
1015};
1016
1017
1018class LConstantI: public LTemplateInstruction<1, 0, 0> {
1019 public:
1020 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1021 DECLARE_HYDROGEN_ACCESSOR(Constant)
1022
1023 int32_t value() const { return hydrogen()->Integer32Value(); }
1024};
1025
1026
1027class LConstantD: public LTemplateInstruction<1, 0, 0> {
1028 public:
1029 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1030 DECLARE_HYDROGEN_ACCESSOR(Constant)
1031
1032 double value() const { return hydrogen()->DoubleValue(); }
1033};
1034
1035
1036class LConstantT: public LTemplateInstruction<1, 0, 0> {
1037 public:
1038 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1039 DECLARE_HYDROGEN_ACCESSOR(Constant)
1040
1041 Handle<Object> value() const { return hydrogen()->handle(); }
1042};
1043
1044
1045class LBranch: public LControlInstruction<1, 0> {
1046 public:
1047 explicit LBranch(LOperand* value) {
1048 inputs_[0] = value;
1049 }
1050
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001051 LOperand* value() { return inputs_[0]; }
1052
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001053 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1054 DECLARE_HYDROGEN_ACCESSOR(Branch)
1055
1056 virtual void PrintDataTo(StringStream* stream);
1057};
1058
1059
1060class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
1061 public:
1062 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1063 inputs_[0] = value;
1064 temps_[0] = temp;
1065 }
1066
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001067 LOperand* value() { return inputs_[0]; }
1068 LOperand* temp() { return temps_[0]; }
1069
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001070 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1071 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1072
1073 virtual bool IsControl() const { return true; }
1074
1075 Handle<Map> map() const { return hydrogen()->map(); }
1076 int true_block_id() const {
1077 return hydrogen()->FirstSuccessor()->block_id();
1078 }
1079 int false_block_id() const {
1080 return hydrogen()->SecondSuccessor()->block_id();
1081 }
1082};
1083
1084
1085class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
1086 public:
1087 explicit LJSArrayLength(LOperand* value) {
1088 inputs_[0] = value;
1089 }
1090
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001091 LOperand* value() { return inputs_[0]; }
1092
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001093 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
1094 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
1095};
1096
1097
1098class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
1099 public:
1100 explicit LFixedArrayBaseLength(LOperand* value) {
1101 inputs_[0] = value;
1102 }
1103
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001104 LOperand* value() { return inputs_[0]; }
1105
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001106 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
1107 "fixed-array-base-length")
1108 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
1109};
1110
1111
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001112class LMapEnumLength: public LTemplateInstruction<1, 1, 0> {
1113 public:
1114 explicit LMapEnumLength(LOperand* value) {
1115 inputs_[0] = value;
1116 }
1117
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001118 LOperand* value() { return inputs_[0]; }
1119
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001120 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1121};
1122
1123
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001124class LElementsKind: public LTemplateInstruction<1, 1, 0> {
1125 public:
1126 explicit LElementsKind(LOperand* value) {
1127 inputs_[0] = value;
1128 }
1129
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001130 LOperand* value() { return inputs_[0]; }
1131
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001132 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1133 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1134};
1135
1136
1137class LValueOf: public LTemplateInstruction<1, 1, 1> {
1138 public:
1139 LValueOf(LOperand* value, LOperand* temp) {
1140 inputs_[0] = value;
1141 temps_[0] = temp;
1142 }
1143
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001144 LOperand* value() { return inputs_[0]; }
1145 LOperand* temp() { return temps_[0]; }
1146
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001147 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1148 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1149};
1150
1151
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001152class LDateField: public LTemplateInstruction<1, 1, 1> {
1153 public:
1154 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1155 inputs_[0] = date;
1156 temps_[0] = temp;
1157 }
1158
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001159 LOperand* date() { return inputs_[0]; }
1160 LOperand* temp() { return temps_[0]; }
1161 Smi* index() const { return index_; }
1162
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001163 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
1164 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001165
1166 private:
1167 Smi* index_;
1168};
1169
1170
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +00001171class LSeqStringSetChar: public LTemplateInstruction<1, 3, 0> {
1172 public:
1173 LSeqStringSetChar(String::Encoding encoding,
1174 LOperand* string,
1175 LOperand* index,
1176 LOperand* value) : encoding_(encoding) {
1177 inputs_[0] = string;
1178 inputs_[1] = index;
1179 inputs_[2] = value;
1180 }
1181
1182 String::Encoding encoding() { return encoding_; }
1183 LOperand* string() { return inputs_[0]; }
1184 LOperand* index() { return inputs_[1]; }
1185 LOperand* value() { return inputs_[2]; }
1186
1187 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1188 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1189
1190 private:
1191 String::Encoding encoding_;
1192};
1193
1194
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001195class LThrow: public LTemplateInstruction<0, 1, 0> {
1196 public:
1197 explicit LThrow(LOperand* value) {
1198 inputs_[0] = value;
1199 }
1200
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001201 LOperand* value() { return inputs_[0]; }
1202
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001203 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1204};
1205
1206
1207class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1208 public:
1209 explicit LBitNotI(LOperand* value) {
1210 inputs_[0] = value;
1211 }
1212
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001213 LOperand* value() { return inputs_[0]; }
1214
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001215 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1216};
1217
1218
1219class LAddI: public LTemplateInstruction<1, 2, 0> {
1220 public:
1221 LAddI(LOperand* left, LOperand* right) {
1222 inputs_[0] = left;
1223 inputs_[1] = right;
1224 }
1225
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001226 LOperand* left() { return inputs_[0]; }
1227 LOperand* right() { return inputs_[1]; }
1228
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001229 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1230 DECLARE_HYDROGEN_ACCESSOR(Add)
1231};
1232
1233
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001234class LMathMinMax: public LTemplateInstruction<1, 2, 0> {
1235 public:
1236 LMathMinMax(LOperand* left, LOperand* right) {
1237 inputs_[0] = left;
1238 inputs_[1] = right;
1239 }
1240
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001241 LOperand* left() { return inputs_[0]; }
1242 LOperand* right() { return inputs_[1]; }
1243
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001244 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "min-max")
1245 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1246};
1247
1248
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001249class LPower: public LTemplateInstruction<1, 2, 0> {
1250 public:
1251 LPower(LOperand* left, LOperand* right) {
1252 inputs_[0] = left;
1253 inputs_[1] = right;
1254 }
1255
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001256 LOperand* left() { return inputs_[0]; }
1257 LOperand* right() { return inputs_[1]; }
1258
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001259 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1260 DECLARE_HYDROGEN_ACCESSOR(Power)
1261};
1262
1263
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001264class LRandom: public LTemplateInstruction<1, 1, 0> {
1265 public:
1266 explicit LRandom(LOperand* global_object) {
1267 inputs_[0] = global_object;
1268 }
1269
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001270 LOperand* global_object() { return inputs_[0]; }
1271
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001272 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1273 DECLARE_HYDROGEN_ACCESSOR(Random)
1274};
1275
1276
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001277class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1278 public:
1279 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1280 : op_(op) {
1281 inputs_[0] = left;
1282 inputs_[1] = right;
1283 }
1284
1285 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001286 LOperand* left() { return inputs_[0]; }
1287 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001288
1289 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1290 virtual void CompileToNative(LCodeGen* generator);
1291 virtual const char* Mnemonic() const;
1292
1293 private:
1294 Token::Value op_;
1295};
1296
1297
1298class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1299 public:
1300 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1301 : op_(op) {
1302 inputs_[0] = left;
1303 inputs_[1] = right;
1304 }
1305
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001306 LOperand* left() { return inputs_[0]; }
1307 LOperand* right() { return inputs_[1]; }
1308 Token::Value op() const { return op_; }
1309
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001310 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1311 virtual void CompileToNative(LCodeGen* generator);
1312 virtual const char* Mnemonic() const;
1313
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001314 private:
1315 Token::Value op_;
1316};
1317
1318
1319class LReturn: public LTemplateInstruction<0, 1, 0> {
1320 public:
1321 explicit LReturn(LOperand* value) {
1322 inputs_[0] = value;
1323 }
1324
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001325 LOperand* value() { return inputs_[0]; }
1326
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001327 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1328};
1329
1330
1331class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1332 public:
1333 explicit LLoadNamedField(LOperand* object) {
1334 inputs_[0] = object;
1335 }
1336
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001337 LOperand* object() { return inputs_[0]; }
1338
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001339 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1340 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1341};
1342
1343
1344class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1345 public:
1346 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1347 inputs_[0] = object;
1348 }
1349
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001350 LOperand* object() { return inputs_[0]; }
1351
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001352 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1353 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001354};
1355
1356
1357class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1358 public:
1359 explicit LLoadNamedGeneric(LOperand* object) {
1360 inputs_[0] = object;
1361 }
1362
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001363 LOperand* object() { return inputs_[0]; }
1364
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001365 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1366 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1367
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001368 Handle<Object> name() const { return hydrogen()->name(); }
1369};
1370
1371
1372class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1373 public:
1374 explicit LLoadFunctionPrototype(LOperand* function) {
1375 inputs_[0] = function;
1376 }
1377
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001378 LOperand* function() { return inputs_[0]; }
1379
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001380 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1381 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001382};
1383
1384
1385class LLoadElements: public LTemplateInstruction<1, 1, 0> {
1386 public:
1387 explicit LLoadElements(LOperand* object) {
1388 inputs_[0] = object;
1389 }
1390
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001391 LOperand* object() { return inputs_[0]; }
1392
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001393 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1394};
1395
1396
1397class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1398 public:
1399 explicit LLoadExternalArrayPointer(LOperand* object) {
1400 inputs_[0] = object;
1401 }
1402
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001403 LOperand* object() { return inputs_[0]; }
1404
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001405 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1406 "load-external-array-pointer")
1407};
1408
1409
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001410class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001411 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001412 LLoadKeyed(LOperand* elements, LOperand* key) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001413 inputs_[0] = elements;
1414 inputs_[1] = key;
1415 }
1416
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001417 LOperand* elements() { return inputs_[0]; }
1418 LOperand* key() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001419 ElementsKind elements_kind() const {
1420 return hydrogen()->elements_kind();
1421 }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001422 bool is_external() const {
1423 return hydrogen()->is_external();
1424 }
1425
1426 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1427 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1428
ulan@chromium.org8e8d8822012-11-23 14:36:46 +00001429 virtual void PrintDataTo(StringStream* stream);
jkummerow@chromium.org777db6f2012-05-24 09:33:09 +00001430 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001431};
1432
1433
1434class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1435 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001436 LLoadKeyedGeneric(LOperand* object, LOperand* key) {
1437 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001438 inputs_[1] = key;
1439 }
1440
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001441 LOperand* object() { return inputs_[0]; }
1442 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001443
1444 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001445};
1446
1447
1448class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1449 public:
1450 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1451 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1452};
1453
1454
1455class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1456 public:
1457 explicit LLoadGlobalGeneric(LOperand* global_object) {
1458 inputs_[0] = global_object;
1459 }
1460
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001461 LOperand* global_object() { return inputs_[0]; }
1462
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001463 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1464 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1465
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001466 Handle<Object> name() const { return hydrogen()->name(); }
1467 bool for_typeof() const { return hydrogen()->for_typeof(); }
1468};
1469
1470
1471class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1472 public:
1473 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1474 inputs_[0] = value;
1475 temps_[0] = temp;
1476 }
1477
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001478 LOperand* value() { return inputs_[0]; }
1479 LOperand* temp() { return temps_[0]; }
1480
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001481 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1482 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1483};
1484
1485
1486class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1487 public:
1488 explicit LStoreGlobalGeneric(LOperand* global_object,
1489 LOperand* value) {
1490 inputs_[0] = global_object;
1491 inputs_[1] = value;
1492 }
1493
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001494 LOperand* global_object() { return inputs_[0]; }
1495 LOperand* value() { return inputs_[1]; }
1496
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001497 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1498 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1499
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001500 Handle<Object> name() const { return hydrogen()->name(); }
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001501 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001502};
1503
1504
1505class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1506 public:
1507 explicit LLoadContextSlot(LOperand* context) {
1508 inputs_[0] = context;
1509 }
1510
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001511 LOperand* context() { return inputs_[0]; }
1512
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001513 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1514 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1515
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001516 int slot_index() { return hydrogen()->slot_index(); }
1517
1518 virtual void PrintDataTo(StringStream* stream);
1519};
1520
1521
1522class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1523 public:
1524 LStoreContextSlot(LOperand* context, LOperand* value) {
1525 inputs_[0] = context;
1526 inputs_[1] = value;
1527 }
1528
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001529 LOperand* context() { return inputs_[0]; }
1530 LOperand* value() { return inputs_[1]; }
1531
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001532 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1533 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1534
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001535 int slot_index() { return hydrogen()->slot_index(); }
1536
1537 virtual void PrintDataTo(StringStream* stream);
1538};
1539
1540
1541class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1542 public:
1543 explicit LPushArgument(LOperand* value) {
1544 inputs_[0] = value;
1545 }
1546
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001547 LOperand* value() { return inputs_[0]; }
1548
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001549 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1550};
1551
1552
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00001553class LDrop: public LTemplateInstruction<0, 0, 0> {
1554 public:
1555 explicit LDrop(int count) : count_(count) { }
1556
1557 int count() const { return count_; }
1558
1559 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1560
1561 private:
1562 int count_;
1563};
1564
1565
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001566class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1567 public:
1568 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1569 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1570};
1571
1572
1573class LContext: public LTemplateInstruction<1, 0, 0> {
1574 public:
1575 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1576};
1577
1578
1579class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1580 public:
1581 explicit LOuterContext(LOperand* context) {
1582 inputs_[0] = context;
1583 }
1584
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001585 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001586
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001587 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001588};
1589
1590
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001591class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> {
1592 public:
1593 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1594 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1595};
1596
1597
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001598class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1599 public:
1600 explicit LGlobalObject(LOperand* context) {
1601 inputs_[0] = context;
1602 }
1603
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001604 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001605
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001606 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001607};
1608
1609
1610class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1611 public:
1612 explicit LGlobalReceiver(LOperand* global_object) {
1613 inputs_[0] = global_object;
1614 }
1615
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001616 LOperand* global_object() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001617
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001618 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001619};
1620
1621
1622class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1623 public:
1624 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1625 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1626
1627 virtual void PrintDataTo(StringStream* stream);
1628
1629 Handle<JSFunction> function() { return hydrogen()->function(); }
1630 int arity() const { return hydrogen()->argument_count() - 1; }
1631};
1632
1633
1634class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1635 public:
1636 explicit LInvokeFunction(LOperand* function) {
1637 inputs_[0] = function;
1638 }
1639
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001640 LOperand* function() { return inputs_[0]; }
1641
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001642 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1643 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1644
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001645 virtual void PrintDataTo(StringStream* stream);
1646
1647 int arity() const { return hydrogen()->argument_count() - 1; }
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00001648 Handle<JSFunction> known_function() { return hydrogen()->known_function(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001649};
1650
1651
1652class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1653 public:
1654 explicit LCallKeyed(LOperand* key) {
1655 inputs_[0] = key;
1656 }
1657
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001658 LOperand* key() { return inputs_[0]; }
1659
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001660 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1661 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1662
1663 virtual void PrintDataTo(StringStream* stream);
1664
1665 int arity() const { return hydrogen()->argument_count() - 1; }
1666};
1667
1668
1669
1670class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1671 public:
1672 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1673 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1674
1675 virtual void PrintDataTo(StringStream* stream);
1676
1677 Handle<String> name() const { return hydrogen()->name(); }
1678 int arity() const { return hydrogen()->argument_count() - 1; }
1679};
1680
1681
danno@chromium.orgc612e022011-11-10 11:38:15 +00001682class LCallFunction: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001683 public:
danno@chromium.orgc612e022011-11-10 11:38:15 +00001684 explicit LCallFunction(LOperand* function) {
1685 inputs_[0] = function;
1686 }
1687
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001688 LOperand* function() { return inputs_[0]; }
1689
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001690 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1691 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1692
danno@chromium.orgc612e022011-11-10 11:38:15 +00001693 int arity() const { return hydrogen()->argument_count() - 1; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001694};
1695
1696
1697class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1698 public:
1699 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1700 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1701
1702 virtual void PrintDataTo(StringStream* stream);
1703
1704 Handle<String> name() const {return hydrogen()->name(); }
1705 int arity() const { return hydrogen()->argument_count() - 1; }
1706};
1707
1708
1709class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1710 public:
1711 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1712 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1713
1714 virtual void PrintDataTo(StringStream* stream);
1715
1716 Handle<JSFunction> target() const { return hydrogen()->target(); }
1717 int arity() const { return hydrogen()->argument_count() - 1; }
1718};
1719
1720
1721class LCallNew: public LTemplateInstruction<1, 1, 0> {
1722 public:
1723 explicit LCallNew(LOperand* constructor) {
1724 inputs_[0] = constructor;
1725 }
1726
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001727 LOperand* constructor() { return inputs_[0]; }
1728
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001729 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1730 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1731
1732 virtual void PrintDataTo(StringStream* stream);
1733
1734 int arity() const { return hydrogen()->argument_count() - 1; }
1735};
1736
1737
1738class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1739 public:
1740 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1741 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1742
1743 const Runtime::Function* function() const { return hydrogen()->function(); }
1744 int arity() const { return hydrogen()->argument_count(); }
1745};
1746
1747
1748class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1749 public:
1750 explicit LInteger32ToDouble(LOperand* value) {
1751 inputs_[0] = value;
1752 }
1753
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001754 LOperand* value() { return inputs_[0]; }
1755
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001756 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1757};
1758
1759
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001760class LUint32ToDouble: public LTemplateInstruction<1, 1, 0> {
1761 public:
1762 explicit LUint32ToDouble(LOperand* value) {
1763 inputs_[0] = value;
1764 }
1765
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001766 LOperand* value() { return inputs_[0]; }
1767
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001768 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1769};
1770
1771
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001772class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1773 public:
1774 explicit LNumberTagI(LOperand* value) {
1775 inputs_[0] = value;
1776 }
1777
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001778 LOperand* value() { return inputs_[0]; }
1779
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001780 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1781};
1782
1783
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001784class LNumberTagU: public LTemplateInstruction<1, 1, 0> {
1785 public:
1786 explicit LNumberTagU(LOperand* value) {
1787 inputs_[0] = value;
1788 }
1789
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001790 LOperand* value() { return inputs_[0]; }
1791
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001792 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1793};
1794
1795
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001796class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1797 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001798 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001799 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001800 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001801 temps_[1] = temp2;
1802 }
1803
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001804 LOperand* value() { return inputs_[0]; }
1805 LOperand* temp() { return temps_[0]; }
1806 LOperand* temp2() { return temps_[1]; }
1807
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001808 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1809};
1810
1811
1812// Sometimes truncating conversion from a tagged value to an int32.
1813class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1814 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001815 LDoubleToI(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001816 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001817 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001818 temps_[1] = temp2;
1819 }
1820
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001821 LOperand* value() { return inputs_[0]; }
1822 LOperand* temp() { return temps_[0]; }
1823 LOperand* temp2() { return temps_[1]; }
1824
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001825 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1826 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1827
1828 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1829};
1830
1831
1832// Truncating conversion from a tagged value to an int32.
1833class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
1834 public:
1835 LTaggedToI(LOperand* value,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001836 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001837 LOperand* temp2,
1838 LOperand* temp3) {
1839 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001840 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001841 temps_[1] = temp2;
1842 temps_[2] = temp3;
1843 }
1844
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001845 LOperand* value() { return inputs_[0]; }
1846 LOperand* temp() { return temps_[0]; }
1847 LOperand* temp2() { return temps_[1]; }
1848 LOperand* temp3() { return temps_[2]; }
1849
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001850 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1851 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1852
1853 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1854};
1855
1856
1857class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1858 public:
1859 explicit LSmiTag(LOperand* value) {
1860 inputs_[0] = value;
1861 }
1862
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001863 LOperand* value() { return inputs_[0]; }
1864
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001865 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1866};
1867
1868
1869class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
1870 public:
1871 explicit LNumberUntagD(LOperand* value) {
1872 inputs_[0] = value;
1873 }
1874
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001875 LOperand* value() { return inputs_[0]; }
1876
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001877 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1878 DECLARE_HYDROGEN_ACCESSOR(Change)
1879};
1880
1881
1882class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1883 public:
1884 LSmiUntag(LOperand* value, bool needs_check)
1885 : needs_check_(needs_check) {
1886 inputs_[0] = value;
1887 }
1888
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001889 LOperand* value() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001890 bool needs_check() const { return needs_check_; }
1891
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001892 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1893
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001894 private:
1895 bool needs_check_;
1896};
1897
1898
verwaest@chromium.org37141392012-05-31 13:27:02 +00001899class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001900 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001901 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
1902 inputs_[0] = object;
1903 inputs_[1] = value;
verwaest@chromium.org37141392012-05-31 13:27:02 +00001904 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001905 }
1906
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001907 LOperand* object() { return inputs_[0]; }
1908 LOperand* value() { return inputs_[1]; }
1909 LOperand* temp() { return temps_[0]; }
1910
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001911 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1912 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1913
1914 virtual void PrintDataTo(StringStream* stream);
1915
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001916 Handle<Object> name() const { return hydrogen()->name(); }
1917 bool is_in_object() { return hydrogen()->is_in_object(); }
1918 int offset() { return hydrogen()->offset(); }
1919 Handle<Map> transition() const { return hydrogen()->transition(); }
1920};
1921
1922
1923class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1924 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001925 LStoreNamedGeneric(LOperand* object, LOperand* value) {
1926 inputs_[0] = object;
1927 inputs_[1] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001928 }
1929
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001930 LOperand* object() { return inputs_[0]; }
1931 LOperand* value() { return inputs_[1]; }
1932
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001933 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1934 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1935
1936 virtual void PrintDataTo(StringStream* stream);
1937
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001938 Handle<Object> name() const { return hydrogen()->name(); }
1939 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001940};
1941
1942
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001943class LStoreKeyed: public LTemplateInstruction<0, 3, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001944 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001945 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001946 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001947 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001948 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001949 }
1950
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001951 bool is_external() const { return hydrogen()->is_external(); }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001952 LOperand* elements() { return inputs_[0]; }
1953 LOperand* key() { return inputs_[1]; }
1954 LOperand* value() { return inputs_[2]; }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001955 ElementsKind elements_kind() const {
1956 return hydrogen()->elements_kind();
1957 }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001958
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001959 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
1960 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001961
1962 virtual void PrintDataTo(StringStream* stream);
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00001963 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001964 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001965};
1966
1967
1968class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
1969 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001970 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001971 inputs_[0] = obj;
1972 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001973 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001974 }
1975
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001976 LOperand* object() { return inputs_[0]; }
1977 LOperand* key() { return inputs_[1]; }
1978 LOperand* value() { return inputs_[2]; }
1979
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001980 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1981 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1982
1983 virtual void PrintDataTo(StringStream* stream);
1984
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001985 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001986};
1987
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001988
1989class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1990 public:
1991 LTransitionElementsKind(LOperand* object,
1992 LOperand* new_map_temp,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001993 LOperand* temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001994 inputs_[0] = object;
1995 temps_[0] = new_map_temp;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001996 temps_[1] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001997 }
1998
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001999 LOperand* object() { return inputs_[0]; }
2000 LOperand* new_map_temp() { return temps_[0]; }
2001 LOperand* temp() { return temps_[1]; }
2002
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002003 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2004 "transition-elements-kind")
2005 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2006
2007 virtual void PrintDataTo(StringStream* stream);
2008
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002009 Handle<Map> original_map() { return hydrogen()->original_map(); }
2010 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
2011};
2012
2013
2014class LStringAdd: public LTemplateInstruction<1, 2, 0> {
2015 public:
2016 LStringAdd(LOperand* left, LOperand* right) {
2017 inputs_[0] = left;
2018 inputs_[1] = right;
2019 }
2020
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002021 LOperand* left() { return inputs_[0]; }
2022 LOperand* right() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002023
2024 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2025 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002026};
2027
2028
2029
2030class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
2031 public:
2032 LStringCharCodeAt(LOperand* string, LOperand* index) {
2033 inputs_[0] = string;
2034 inputs_[1] = index;
2035 }
2036
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002037 LOperand* string() { return inputs_[0]; }
2038 LOperand* index() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002039
2040 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2041 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002042};
2043
2044
2045class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
2046 public:
2047 explicit LStringCharFromCode(LOperand* char_code) {
2048 inputs_[0] = char_code;
2049 }
2050
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002051 LOperand* char_code() { return inputs_[0]; }
2052
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002053 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2054 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002055};
2056
2057
2058class LStringLength: public LTemplateInstruction<1, 1, 0> {
2059 public:
2060 explicit LStringLength(LOperand* string) {
2061 inputs_[0] = string;
2062 }
2063
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002064 LOperand* string() { return inputs_[0]; }
2065
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002066 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
2067 DECLARE_HYDROGEN_ACCESSOR(StringLength)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002068};
2069
2070
2071class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
2072 public:
2073 explicit LCheckFunction(LOperand* value) {
2074 inputs_[0] = value;
2075 }
2076
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002077 LOperand* value() { return inputs_[0]; }
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00002078
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002079 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
2080 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
2081};
2082
2083
2084class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
2085 public:
2086 explicit LCheckInstanceType(LOperand* value) {
2087 inputs_[0] = value;
2088 }
2089
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002090 LOperand* value() { return inputs_[0]; }
2091
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002092 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2093 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2094};
2095
2096
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002097class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002098 public:
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002099 explicit LCheckMaps(LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002100 inputs_[0] = value;
2101 }
2102
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002103 LOperand* value() { return inputs_[0]; }
2104
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002105 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2106 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002107};
2108
2109
verwaest@chromium.orge4ee6de2012-11-06 12:13:00 +00002110class LCheckPrototypeMaps: public LTemplateInstruction<1, 0, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002111 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002112 LCheckPrototypeMaps(LOperand* temp, LOperand* temp2) {
2113 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002114 temps_[1] = temp2;
2115 }
2116
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002117 LOperand* temp() { return temps_[0]; }
2118 LOperand* temp2() { return temps_[1]; }
2119
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002120 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
2121 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
2122
2123 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
2124 Handle<JSObject> holder() const { return hydrogen()->holder(); }
2125};
2126
2127
2128class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
2129 public:
2130 explicit LCheckSmi(LOperand* value) {
2131 inputs_[0] = value;
2132 }
2133
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002134 LOperand* value() { return inputs_[0]; }
2135
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002136 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2137};
2138
2139
2140class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2141 public:
2142 explicit LCheckNonSmi(LOperand* value) {
2143 inputs_[0] = value;
2144 }
2145
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002146 LOperand* value() { return inputs_[0]; }
2147
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002148 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2149};
2150
2151
2152class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
2153 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002154 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2155 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002156 temps_[0] = temp;
2157 }
2158
2159 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002160 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002161
2162 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2163};
2164
2165
2166class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
2167 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002168 explicit LClampIToUint8(LOperand* unclamped) {
2169 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002170 }
2171
2172 LOperand* unclamped() { return inputs_[0]; }
2173
2174 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2175};
2176
2177
2178class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2179 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002180 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2181 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002182 temps_[0] = temp;
2183 }
2184
2185 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002186 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002187
2188 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2189};
2190
2191
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002192class LAllocateObject: public LTemplateInstruction<1, 0, 2> {
ulan@chromium.org967e2702012-02-28 09:49:15 +00002193 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002194 LAllocateObject(LOperand* temp, LOperand* temp2) {
2195 temps_[0] = temp;
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002196 temps_[1] = temp2;
2197 }
2198
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002199 LOperand* temp() { return temps_[0]; }
2200 LOperand* temp2() { return temps_[1]; }
2201
ulan@chromium.org967e2702012-02-28 09:49:15 +00002202 DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object")
2203 DECLARE_HYDROGEN_ACCESSOR(AllocateObject)
2204};
2205
2206
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002207class LFastLiteral: public LTemplateInstruction<1, 0, 0> {
2208 public:
2209 DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal")
2210 DECLARE_HYDROGEN_ACCESSOR(FastLiteral)
2211};
2212
2213
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002214class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
2215 public:
2216 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
2217 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
2218};
2219
2220
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002221class LObjectLiteral: public LTemplateInstruction<1, 0, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002222 public:
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002223 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
2224 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002225};
2226
2227
2228class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
2229 public:
2230 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2231 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2232};
2233
2234
2235class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
2236 public:
2237 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2238 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2239
2240 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2241};
2242
2243
2244class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2245 public:
2246 explicit LToFastProperties(LOperand* value) {
2247 inputs_[0] = value;
2248 }
2249
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002250 LOperand* value() { return inputs_[0]; }
2251
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002252 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2253 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2254};
2255
2256
2257class LTypeof: public LTemplateInstruction<1, 1, 0> {
2258 public:
2259 explicit LTypeof(LOperand* value) {
2260 inputs_[0] = value;
2261 }
2262
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002263 LOperand* value() { return inputs_[0]; }
2264
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002265 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2266};
2267
2268
2269class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2270 public:
2271 explicit LTypeofIsAndBranch(LOperand* value) {
2272 inputs_[0] = value;
2273 }
2274
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002275 LOperand* value() { return inputs_[0]; }
2276
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002277 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2278 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2279
2280 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2281
2282 virtual void PrintDataTo(StringStream* stream);
2283};
2284
2285
2286class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
2287 public:
2288 explicit LIsConstructCallAndBranch(LOperand* temp) {
2289 temps_[0] = temp;
2290 }
2291
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002292 LOperand* temp() { return temps_[0]; }
2293
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002294 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2295 "is-construct-call-and-branch")
2296};
2297
2298
2299class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
2300 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002301 LDeleteProperty(LOperand* object, LOperand* key) {
2302 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002303 inputs_[1] = key;
2304 }
2305
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002306 LOperand* object() { return inputs_[0]; }
2307 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002308
2309 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002310};
2311
2312
2313class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2314 public:
2315 LOsrEntry();
2316
2317 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2318
2319 LOperand** SpilledRegisterArray() { return register_spills_; }
2320 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2321
2322 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2323 void MarkSpilledDoubleRegister(int allocation_index,
2324 LOperand* spill_operand);
2325
2326 private:
2327 // Arrays of spill slot operands for registers with an assigned spill
2328 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2329 // NULL if the register has no assigned spill slot. Indexed by allocation
2330 // index.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002331 LOperand* register_spills_[Register::kMaxNumAllocatableRegisters];
2332 LOperand* double_register_spills_[
2333 DoubleRegister::kMaxNumAllocatableRegisters];
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002334};
2335
2336
2337class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2338 public:
2339 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2340 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2341
2342 Label* done_label() { return &done_label_; }
2343
2344 private:
2345 Label done_label_;
2346};
2347
2348
2349class LIn: public LTemplateInstruction<1, 2, 0> {
2350 public:
2351 LIn(LOperand* key, LOperand* object) {
2352 inputs_[0] = key;
2353 inputs_[1] = object;
2354 }
2355
2356 LOperand* key() { return inputs_[0]; }
2357 LOperand* object() { return inputs_[1]; }
2358
2359 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2360};
2361
2362
ulan@chromium.org812308e2012-02-29 15:58:45 +00002363class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> {
2364 public:
2365 explicit LForInPrepareMap(LOperand* object) {
2366 inputs_[0] = object;
2367 }
2368
2369 LOperand* object() { return inputs_[0]; }
2370
2371 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2372};
2373
2374
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002375class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002376 public:
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002377 explicit LForInCacheArray(LOperand* map) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002378 inputs_[0] = map;
2379 }
2380
2381 LOperand* map() { return inputs_[0]; }
2382
2383 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2384
2385 int idx() {
2386 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2387 }
2388};
2389
2390
2391class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2392 public:
2393 LCheckMapValue(LOperand* value, LOperand* map) {
2394 inputs_[0] = value;
2395 inputs_[1] = map;
2396 }
2397
2398 LOperand* value() { return inputs_[0]; }
2399 LOperand* map() { return inputs_[1]; }
2400
2401 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2402};
2403
2404
2405class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2406 public:
2407 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2408 inputs_[0] = object;
2409 inputs_[1] = index;
2410 }
2411
2412 LOperand* object() { return inputs_[0]; }
2413 LOperand* index() { return inputs_[1]; }
2414
2415 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2416};
2417
2418
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002419class LChunkBuilder;
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002420class LPlatformChunk: public LChunk {
lrn@chromium.org7516f052011-03-30 08:52:27 +00002421 public:
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002422 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2423 : LChunk(info, graph) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002424
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002425 int GetNextSpillIndex(bool is_double);
2426 LOperand* GetNextSpillSlot(bool is_double);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002427};
2428
2429
2430class LChunkBuilder BASE_EMBEDDED {
2431 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002432 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2433 : chunk_(NULL),
2434 info_(info),
2435 graph_(graph),
mmassi@chromium.org7028c052012-06-13 11:51:58 +00002436 zone_(graph->zone()),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002437 status_(UNUSED),
2438 current_instruction_(NULL),
2439 current_block_(NULL),
2440 next_block_(NULL),
2441 argument_count_(0),
2442 allocator_(allocator),
2443 position_(RelocInfo::kNoPosition),
2444 instruction_pending_deoptimization_environment_(NULL),
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002445 pending_deoptimization_ast_id_(BailoutId::None()) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002446
2447 // Build the sequence for the graph.
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002448 LPlatformChunk* Build();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002449
2450 // Declare methods that deal with the individual node types.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002451#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002452 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2453#undef DECLARE_DO
2454
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002455 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2456
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002457 private:
2458 enum Status {
2459 UNUSED,
2460 BUILDING,
2461 DONE,
2462 ABORTED
2463 };
2464
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002465 LPlatformChunk* chunk() const { return chunk_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002466 CompilationInfo* info() const { return info_; }
2467 HGraph* graph() const { return graph_; }
ulan@chromium.org812308e2012-02-29 15:58:45 +00002468 Zone* zone() const { return zone_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002469
2470 bool is_unused() const { return status_ == UNUSED; }
2471 bool is_building() const { return status_ == BUILDING; }
2472 bool is_done() const { return status_ == DONE; }
2473 bool is_aborted() const { return status_ == ABORTED; }
2474
yangguo@chromium.org46839fb2012-08-28 09:06:19 +00002475 void Abort(const char* reason);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002476
2477 // Methods for getting operands for Use / Define / Temp.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002478 LUnallocated* ToUnallocated(Register reg);
2479 LUnallocated* ToUnallocated(DoubleRegister reg);
2480
2481 // Methods for setting up define-use relationships.
2482 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2483 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2484 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2485 DoubleRegister fixed_register);
2486
2487 // A value that is guaranteed to be allocated to a register.
2488 // Operand created by UseRegister is guaranteed to be live until the end of
2489 // instruction. This means that register allocator will not reuse it's
2490 // register for any other operand inside instruction.
2491 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2492 // instruction start. Register allocator is free to assign the same register
2493 // to some other operand used inside instruction (i.e. temporary or
2494 // output).
2495 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2496 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2497
2498 // An input operand in a register that may be trashed.
2499 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2500
2501 // An input operand in a register or stack slot.
2502 MUST_USE_RESULT LOperand* Use(HValue* value);
2503 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2504
2505 // An input operand in a register, stack slot or a constant operand.
2506 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2507 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2508
2509 // An input operand in a register or a constant operand.
2510 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2511 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2512
2513 // An input operand in register, stack slot or a constant operand.
2514 // Will not be moved to a register even if one is freely available.
2515 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2516
2517 // Temporary operand that must be in a register.
2518 MUST_USE_RESULT LUnallocated* TempRegister();
2519 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2520 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2521
2522 // Methods for setting up define-use relationships.
2523 // Return the same instruction that they are passed.
2524 template<int I, int T>
2525 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2526 LUnallocated* result);
2527 template<int I, int T>
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002528 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2529 template<int I, int T>
2530 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2531 int index);
2532 template<int I, int T>
2533 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2534 template<int I, int T>
2535 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2536 Register reg);
2537 template<int I, int T>
2538 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2539 DoubleRegister reg);
2540 LInstruction* AssignEnvironment(LInstruction* instr);
2541 LInstruction* AssignPointerMap(LInstruction* instr);
2542
2543 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2544
2545 // By default we assume that instruction sequences generated for calls
2546 // cannot deoptimize eagerly and we do not attach environment to this
2547 // instruction.
2548 LInstruction* MarkAsCall(
2549 LInstruction* instr,
2550 HInstruction* hinstr,
2551 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002552
2553 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2554 int* argument_index_accumulator);
2555
2556 void VisitInstruction(HInstruction* current);
2557
2558 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2559 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2560 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2561 LInstruction* DoArithmeticD(Token::Value op,
2562 HArithmeticBinaryOperation* instr);
2563 LInstruction* DoArithmeticT(Token::Value op,
2564 HArithmeticBinaryOperation* instr);
2565
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002566 LPlatformChunk* chunk_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002567 CompilationInfo* info_;
2568 HGraph* const graph_;
ulan@chromium.org812308e2012-02-29 15:58:45 +00002569 Zone* zone_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002570 Status status_;
2571 HInstruction* current_instruction_;
2572 HBasicBlock* current_block_;
2573 HBasicBlock* next_block_;
2574 int argument_count_;
2575 LAllocator* allocator_;
2576 int position_;
2577 LInstruction* instruction_pending_deoptimization_environment_;
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002578 BailoutId pending_deoptimization_ast_id_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002579
lrn@chromium.org7516f052011-03-30 08:52:27 +00002580 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2581};
2582
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002583#undef DECLARE_HYDROGEN_ACCESSOR
2584#undef DECLARE_CONCRETE_INSTRUCTION
lrn@chromium.org7516f052011-03-30 08:52:27 +00002585
2586} } // namespace v8::internal
2587
2588#endif // V8_MIPS_LITHIUM_MIPS_H_