blob: 45754aa437ad14370e5a38081261614d83be94c7 [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) \
yangguo@chromium.org46a2a512013-01-18 16:29:40 +000096 V(DummyUse) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000097 V(ElementsKind) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +000098 V(FastLiteral) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000099 V(FixedArrayBaseLength) \
100 V(FunctionLiteral) \
101 V(GetCachedArrayIndex) \
102 V(GlobalObject) \
103 V(GlobalReceiver) \
104 V(Goto) \
105 V(HasCachedArrayIndexAndBranch) \
106 V(HasInstanceTypeAndBranch) \
107 V(In) \
108 V(InstanceOf) \
109 V(InstanceOfKnownGlobal) \
110 V(InstructionGap) \
111 V(Integer32ToDouble) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000112 V(Uint32ToDouble) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000113 V(InvokeFunction) \
114 V(IsConstructCallAndBranch) \
115 V(IsNilAndBranch) \
116 V(IsObjectAndBranch) \
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000117 V(IsStringAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000118 V(IsSmiAndBranch) \
119 V(IsUndetectableAndBranch) \
120 V(JSArrayLength) \
121 V(Label) \
122 V(LazyBailout) \
123 V(LoadContextSlot) \
124 V(LoadElements) \
125 V(LoadExternalArrayPointer) \
126 V(LoadFunctionPrototype) \
127 V(LoadGlobalCell) \
128 V(LoadGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000129 V(LoadKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000130 V(LoadKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000131 V(LoadNamedField) \
132 V(LoadNamedFieldPolymorphic) \
133 V(LoadNamedGeneric) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000134 V(MapEnumLength) \
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000135 V(MathExp) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000136 V(MathMinMax) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000137 V(ModI) \
138 V(MulI) \
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000139 V(MultiplyAddD) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000140 V(NumberTagD) \
141 V(NumberTagI) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000142 V(NumberTagU) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000143 V(NumberUntagD) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +0000144 V(ObjectLiteral) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000145 V(OsrEntry) \
146 V(OuterContext) \
147 V(Parameter) \
148 V(Power) \
149 V(PushArgument) \
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000150 V(Random) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000151 V(RegExpLiteral) \
152 V(Return) \
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000153 V(SeqStringSetChar) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000154 V(ShiftI) \
155 V(SmiTag) \
156 V(SmiUntag) \
157 V(StackCheck) \
158 V(StoreContextSlot) \
159 V(StoreGlobalCell) \
160 V(StoreGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000161 V(StoreKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000162 V(StoreKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000163 V(StoreNamedField) \
164 V(StoreNamedGeneric) \
165 V(StringAdd) \
166 V(StringCharCodeAt) \
167 V(StringCharFromCode) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000168 V(StringCompareAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000169 V(StringLength) \
170 V(SubI) \
171 V(TaggedToI) \
172 V(ThisFunction) \
173 V(Throw) \
174 V(ToFastProperties) \
175 V(TransitionElementsKind) \
176 V(Typeof) \
177 V(TypeofIsAndBranch) \
178 V(UnaryMathOperation) \
179 V(UnknownOSRValue) \
ulan@chromium.org812308e2012-02-29 15:58:45 +0000180 V(ValueOf) \
181 V(ForInPrepareMap) \
182 V(ForInCacheArray) \
183 V(CheckMapValue) \
yangguo@chromium.org154ff992012-03-13 08:09:54 +0000184 V(LoadFieldByIndex) \
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000185 V(DateField) \
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000186 V(WrapReceiver) \
187 V(Drop)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000188
189#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
190 virtual Opcode opcode() const { return LInstruction::k##type; } \
191 virtual void CompileToNative(LCodeGen* generator); \
192 virtual const char* Mnemonic() const { return mnemonic; } \
193 static L##type* cast(LInstruction* instr) { \
194 ASSERT(instr->Is##type()); \
195 return reinterpret_cast<L##type*>(instr); \
196 }
197
198
199#define DECLARE_HYDROGEN_ACCESSOR(type) \
200 H##type* hydrogen() const { \
201 return H##type::cast(hydrogen_value()); \
202 }
203
lrn@chromium.org7516f052011-03-30 08:52:27 +0000204
205class LInstruction: public ZoneObject {
206 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000207 LInstruction()
208 : environment_(NULL),
209 hydrogen_value_(NULL),
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000210 is_call_(false) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000211 virtual ~LInstruction() { }
212
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000213 virtual void CompileToNative(LCodeGen* generator) = 0;
214 virtual const char* Mnemonic() const = 0;
215 virtual void PrintTo(StringStream* stream);
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000216 virtual void PrintDataTo(StringStream* stream);
217 virtual void PrintOutputOperandTo(StringStream* stream);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000218
219 enum Opcode {
220 // Declare a unique enum value for each instruction.
221#define DECLARE_OPCODE(type) k##type,
222 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
223 kNumberOfInstructions
224#undef DECLARE_OPCODE
225 };
226
227 virtual Opcode opcode() const = 0;
228
229 // Declare non-virtual type testers for all leaf IR classes.
230#define DECLARE_PREDICATE(type) \
231 bool Is##type() const { return opcode() == k##type; }
232 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
233#undef DECLARE_PREDICATE
234
235 // Declare virtual predicates for instructions that don't have
236 // an opcode.
237 virtual bool IsGap() const { return false; }
238
239 virtual bool IsControl() const { return false; }
240
241 void set_environment(LEnvironment* env) { environment_ = env; }
242 LEnvironment* environment() const { return environment_; }
243 bool HasEnvironment() const { return environment_ != NULL; }
244
245 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
246 LPointerMap* pointer_map() const { return pointer_map_.get(); }
247 bool HasPointerMap() const { return pointer_map_.is_set(); }
248
249 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
250 HValue* hydrogen_value() const { return hydrogen_value_; }
251
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000252 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000253
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000254 void MarkAsCall() { is_call_ = true; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000255
256 // Interface to the register allocator and iterators.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000257 bool ClobbersTemps() const { return is_call_; }
258 bool ClobbersRegisters() const { return is_call_; }
259 bool ClobbersDoubleRegisters() const { return is_call_; }
260
261 // Interface to the register allocator and iterators.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000262 bool IsMarkedAsCall() const { return is_call_; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000263
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000264 virtual bool HasResult() const = 0;
265 virtual LOperand* result() = 0;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000266
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000267 LOperand* FirstInput() { return InputAt(0); }
268 LOperand* Output() { return HasResult() ? result() : NULL; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000269
270#ifdef DEBUG
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000271 void VerifyCall();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000272#endif
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000273
274 private:
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000275 // Iterator interface.
276 friend class InputIterator;
277 virtual int InputCount() = 0;
278 virtual LOperand* InputAt(int i) = 0;
279
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000280 friend class TempIterator;
281 virtual int TempCount() = 0;
282 virtual LOperand* TempAt(int i) = 0;
283
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000284 LEnvironment* environment_;
285 SetOncePointer<LPointerMap> pointer_map_;
286 HValue* hydrogen_value_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000287 bool is_call_;
288 bool is_save_doubles_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000289};
290
291
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000292// R = number of result operands (0 or 1).
293// I = number of input operands.
294// T = number of temporary operands.
295template<int R, int I, int T>
296class LTemplateInstruction: public LInstruction {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000297 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000298 // Allow 0 or 1 output operands.
299 STATIC_ASSERT(R == 0 || R == 1);
300 virtual bool HasResult() const { return R != 0; }
301 void set_result(LOperand* operand) { results_[0] = operand; }
302 LOperand* result() { return results_[0]; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000303
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000304 protected:
305 EmbeddedContainer<LOperand*, R> results_;
306 EmbeddedContainer<LOperand*, I> inputs_;
307 EmbeddedContainer<LOperand*, T> temps_;
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000308
309 private:
310 virtual int InputCount() { return I; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000311 virtual LOperand* InputAt(int i) { return inputs_[i]; }
312
313 virtual int TempCount() { return T; }
314 virtual LOperand* TempAt(int i) { return temps_[i]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000315};
316
317
318class LGap: public LTemplateInstruction<0, 0, 0> {
319 public:
320 explicit LGap(HBasicBlock* block)
321 : block_(block) {
322 parallel_moves_[BEFORE] = NULL;
323 parallel_moves_[START] = NULL;
324 parallel_moves_[END] = NULL;
325 parallel_moves_[AFTER] = NULL;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000326 }
327
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000328 // Can't use the DECLARE-macro here because of sub-classes.
329 virtual bool IsGap() const { return true; }
330 virtual void PrintDataTo(StringStream* stream);
331 static LGap* cast(LInstruction* instr) {
332 ASSERT(instr->IsGap());
333 return reinterpret_cast<LGap*>(instr);
334 }
335
336 bool IsRedundant() const;
337
338 HBasicBlock* block() const { return block_; }
339
lrn@chromium.org7516f052011-03-30 08:52:27 +0000340 enum InnerPosition {
341 BEFORE,
342 START,
343 END,
344 AFTER,
345 FIRST_INNER_POSITION = BEFORE,
346 LAST_INNER_POSITION = AFTER
347 };
348
mmassi@chromium.org7028c052012-06-13 11:51:58 +0000349 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
350 if (parallel_moves_[pos] == NULL) {
351 parallel_moves_[pos] = new(zone) LParallelMove(zone);
352 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000353 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000354 }
355
356 LParallelMove* GetParallelMove(InnerPosition pos) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000357 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000358 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000359
360 private:
361 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
362 HBasicBlock* block_;
363};
364
365
366class LInstructionGap: public LGap {
367 public:
368 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
369
370 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
371};
372
373
374class LGoto: public LTemplateInstruction<0, 0, 0> {
375 public:
376 explicit LGoto(int block_id) : block_id_(block_id) { }
377
378 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
379 virtual void PrintDataTo(StringStream* stream);
380 virtual bool IsControl() const { return true; }
381
382 int block_id() const { return block_id_; }
383
384 private:
385 int block_id_;
386};
387
388
389class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
390 public:
391 LLazyBailout() : gap_instructions_size_(0) { }
392
393 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
394
395 void set_gap_instructions_size(int gap_instructions_size) {
396 gap_instructions_size_ = gap_instructions_size;
397 }
398 int gap_instructions_size() { return gap_instructions_size_; }
399
400 private:
401 int gap_instructions_size_;
402};
403
404
yangguo@chromium.org46a2a512013-01-18 16:29:40 +0000405class LDummyUse: public LTemplateInstruction<1, 1, 0> {
406 public:
407 explicit LDummyUse(LOperand* value) {
408 inputs_[0] = value;
409 }
410 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
411};
412
413
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000414class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
415 public:
416 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
lrn@chromium.org7516f052011-03-30 08:52:27 +0000417};
418
419
420class LLabel: public LGap {
421 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000422 explicit LLabel(HBasicBlock* block)
423 : LGap(block), replacement_(NULL) { }
424
425 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
426
427 virtual void PrintDataTo(StringStream* stream);
428
429 int block_id() const { return block()->block_id(); }
430 bool is_loop_header() const { return block()->IsLoopHeader(); }
431 Label* label() { return &label_; }
432 LLabel* replacement() const { return replacement_; }
433 void set_replacement(LLabel* label) { replacement_ = label; }
434 bool HasReplacement() const { return replacement_ != NULL; }
435
436 private:
437 Label label_;
438 LLabel* replacement_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000439};
440
441
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000442class LParameter: public LTemplateInstruction<1, 0, 0> {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000443 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000444 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
445};
lrn@chromium.org7516f052011-03-30 08:52:27 +0000446
lrn@chromium.org7516f052011-03-30 08:52:27 +0000447
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000448class LCallStub: public LTemplateInstruction<1, 0, 0> {
449 public:
450 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
451 DECLARE_HYDROGEN_ACCESSOR(CallStub)
452
453 TranscendentalCache::Type transcendental_type() {
454 return hydrogen()->transcendental_type();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000455 }
456};
457
458
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000459class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
460 public:
461 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
462};
463
464
465template<int I, int T>
466class LControlInstruction: public LTemplateInstruction<0, I, T> {
467 public:
468 virtual bool IsControl() const { return true; }
469
470 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
471 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
472 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
473 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
474
475 private:
476 HControlInstruction* hydrogen() {
477 return HControlInstruction::cast(this->hydrogen_value());
478 }
479};
480
481
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000482class LWrapReceiver: public LTemplateInstruction<1, 2, 0> {
483 public:
484 LWrapReceiver(LOperand* receiver, LOperand* function) {
485 inputs_[0] = receiver;
486 inputs_[1] = function;
487 }
488
489 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
490
491 LOperand* receiver() { return inputs_[0]; }
492 LOperand* function() { return inputs_[1]; }
493};
494
495
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000496class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
497 public:
498 LApplyArguments(LOperand* function,
499 LOperand* receiver,
500 LOperand* length,
501 LOperand* elements) {
502 inputs_[0] = function;
503 inputs_[1] = receiver;
504 inputs_[2] = length;
505 inputs_[3] = elements;
506 }
507
508 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
509
510 LOperand* function() { return inputs_[0]; }
511 LOperand* receiver() { return inputs_[1]; }
512 LOperand* length() { return inputs_[2]; }
513 LOperand* elements() { return inputs_[3]; }
514};
515
516
517class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
518 public:
519 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
520 inputs_[0] = arguments;
521 inputs_[1] = length;
522 inputs_[2] = index;
523 }
524
525 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
526
527 LOperand* arguments() { return inputs_[0]; }
528 LOperand* length() { return inputs_[1]; }
529 LOperand* index() { return inputs_[2]; }
530
531 virtual void PrintDataTo(StringStream* stream);
532};
533
534
535class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
536 public:
537 explicit LArgumentsLength(LOperand* elements) {
538 inputs_[0] = elements;
539 }
540
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000541 LOperand* elements() { return inputs_[0]; }
542
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000543 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
544};
545
546
547class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
548 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000549 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000550 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000551};
552
553
554class LModI: public LTemplateInstruction<1, 2, 3> {
555 public:
556 // Used when the right hand is a constant power of 2.
557 LModI(LOperand* left,
558 LOperand* right) {
559 inputs_[0] = left;
560 inputs_[1] = right;
561 temps_[0] = NULL;
562 temps_[1] = NULL;
563 temps_[2] = NULL;
564 }
565
566 // Used for the standard case.
567 LModI(LOperand* left,
568 LOperand* right,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000569 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000570 LOperand* temp2,
571 LOperand* temp3) {
572 inputs_[0] = left;
573 inputs_[1] = right;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000574 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000575 temps_[1] = temp2;
576 temps_[2] = temp3;
577 }
578
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000579 LOperand* left() { return inputs_[0]; }
580 LOperand* right() { return inputs_[1]; }
581 LOperand* temp() { return temps_[0]; }
582 LOperand* temp2() { return temps_[1]; }
583 LOperand* temp3() { return temps_[2]; }
584
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000585 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
586 DECLARE_HYDROGEN_ACCESSOR(Mod)
587};
588
589
590class LDivI: public LTemplateInstruction<1, 2, 0> {
591 public:
592 LDivI(LOperand* left, LOperand* right) {
593 inputs_[0] = left;
594 inputs_[1] = right;
595 }
596
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000597 LOperand* left() { return inputs_[0]; }
598 LOperand* right() { return inputs_[1]; }
599
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000600 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
601 DECLARE_HYDROGEN_ACCESSOR(Div)
602};
603
604
605class LMulI: public LTemplateInstruction<1, 2, 1> {
606 public:
607 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
608 inputs_[0] = left;
609 inputs_[1] = right;
610 temps_[0] = temp;
611 }
612
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000613 LOperand* left() { return inputs_[0]; }
614 LOperand* right() { return inputs_[1]; }
615 LOperand* temp() { return temps_[0]; }
616
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000617 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
618 DECLARE_HYDROGEN_ACCESSOR(Mul)
619};
620
621
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000622// Instruction for computing multiplier * multiplicand + addend.
623class LMultiplyAddD: public LTemplateInstruction<1, 3, 0> {
624 public:
625 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
626 LOperand* multiplicand) {
627 inputs_[0] = addend;
628 inputs_[1] = multiplier;
629 inputs_[2] = multiplicand;
630 }
631
632 LOperand* addend() { return inputs_[0]; }
633 LOperand* multiplier() { return inputs_[1]; }
634 LOperand* multiplicand() { return inputs_[2]; }
635
636 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
637};
638
639
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000640class LCmpIDAndBranch: public LControlInstruction<2, 0> {
641 public:
642 LCmpIDAndBranch(LOperand* left, LOperand* right) {
643 inputs_[0] = left;
644 inputs_[1] = right;
645 }
646
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000647 LOperand* left() { return inputs_[0]; }
648 LOperand* right() { return inputs_[1]; }
649
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000650 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
651 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
652
653 Token::Value op() const { return hydrogen()->token(); }
654 bool is_double() const {
ulan@chromium.org8e8d8822012-11-23 14:36:46 +0000655 return hydrogen()->representation().IsDouble();
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000656 }
657
658 virtual void PrintDataTo(StringStream* stream);
659};
660
661
662class LUnaryMathOperation: public LTemplateInstruction<1, 1, 1> {
663 public:
664 LUnaryMathOperation(LOperand* value, LOperand* temp) {
665 inputs_[0] = value;
666 temps_[0] = temp;
667 }
668
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000669 LOperand* value() { return inputs_[0]; }
670 LOperand* temp() { return temps_[0]; }
671
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000672 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
673 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
674
675 virtual void PrintDataTo(StringStream* stream);
676 BuiltinFunctionId op() const { return hydrogen()->op(); }
677};
678
679
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000680class LMathExp: public LTemplateInstruction<1, 1, 3> {
681 public:
682 LMathExp(LOperand* value,
683 LOperand* double_temp,
684 LOperand* temp1,
685 LOperand* temp2) {
686 inputs_[0] = value;
687 temps_[0] = temp1;
688 temps_[1] = temp2;
689 temps_[2] = double_temp;
690 ExternalReference::InitializeMathExpData();
691 }
692
693 LOperand* value() { return inputs_[0]; }
694 LOperand* temp1() { return temps_[0]; }
695 LOperand* temp2() { return temps_[1]; }
696 LOperand* double_temp() { return temps_[2]; }
697
698 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
699
700 virtual void PrintDataTo(StringStream* stream);
701};
702
703
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000704class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
705 public:
706 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
707 inputs_[0] = left;
708 inputs_[1] = right;
709 }
710
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000711 LOperand* left() { return inputs_[0]; }
712 LOperand* right() { return inputs_[1]; }
713
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000714 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
715 "cmp-object-eq-and-branch")
716 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
717};
718
719
720class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
721 public:
722 explicit LCmpConstantEqAndBranch(LOperand* left) {
723 inputs_[0] = left;
724 }
725
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000726 LOperand* left() { return inputs_[0]; }
727
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000728 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
729 "cmp-constant-eq-and-branch")
730 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
731};
732
733
734class LIsNilAndBranch: public LControlInstruction<1, 0> {
735 public:
736 explicit LIsNilAndBranch(LOperand* value) {
737 inputs_[0] = value;
738 }
739
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000740 LOperand* value() { return inputs_[0]; }
741
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000742 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
743 DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
744
745 EqualityKind kind() const { return hydrogen()->kind(); }
746 NilValue nil() const { return hydrogen()->nil(); }
747
748 virtual void PrintDataTo(StringStream* stream);
749};
750
751
752class LIsObjectAndBranch: public LControlInstruction<1, 1> {
753 public:
754 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
755 inputs_[0] = value;
756 temps_[0] = temp;
757 }
758
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000759 LOperand* value() { return inputs_[0]; }
760 LOperand* temp() { return temps_[0]; }
761
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000762 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
763 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
764
765 virtual void PrintDataTo(StringStream* stream);
766};
767
768
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000769class LIsStringAndBranch: public LControlInstruction<1, 1> {
770 public:
771 LIsStringAndBranch(LOperand* value, LOperand* temp) {
772 inputs_[0] = value;
773 temps_[0] = temp;
774 }
775
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000776 LOperand* value() { return inputs_[0]; }
777 LOperand* temp() { return temps_[0]; }
778
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000779 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
780 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
781
782 virtual void PrintDataTo(StringStream* stream);
783};
784
785
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000786class LIsSmiAndBranch: public LControlInstruction<1, 0> {
787 public:
788 explicit LIsSmiAndBranch(LOperand* value) {
789 inputs_[0] = value;
790 }
791
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000792 LOperand* value() { return inputs_[0]; }
793
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000794 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
795 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
796
797 virtual void PrintDataTo(StringStream* stream);
798};
799
800
801class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
802 public:
803 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
804 inputs_[0] = value;
805 temps_[0] = temp;
806 }
807
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000808 LOperand* value() { return inputs_[0]; }
809 LOperand* temp() { return temps_[0]; }
810
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000811 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
812 "is-undetectable-and-branch")
813 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
814
815 virtual void PrintDataTo(StringStream* stream);
816};
817
818
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000819class LStringCompareAndBranch: public LControlInstruction<2, 0> {
820 public:
821 LStringCompareAndBranch(LOperand* left, LOperand* right) {
822 inputs_[0] = left;
823 inputs_[1] = right;
824 }
825
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000826 LOperand* left() { return inputs_[0]; }
827 LOperand* right() { return inputs_[1]; }
828
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000829 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
830 "string-compare-and-branch")
831 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
832
833 Token::Value op() const { return hydrogen()->token(); }
834
835 virtual void PrintDataTo(StringStream* stream);
836};
837
838
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000839class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
840 public:
841 explicit LHasInstanceTypeAndBranch(LOperand* value) {
842 inputs_[0] = value;
843 }
844
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000845 LOperand* value() { return inputs_[0]; }
846
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000847 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
848 "has-instance-type-and-branch")
849 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
850
851 virtual void PrintDataTo(StringStream* stream);
852};
853
854
855class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
856 public:
857 explicit LGetCachedArrayIndex(LOperand* value) {
858 inputs_[0] = value;
859 }
860
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000861 LOperand* value() { return inputs_[0]; }
862
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000863 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
864 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
865};
866
867
868class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
869 public:
870 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
871 inputs_[0] = value;
872 }
873
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000874 LOperand* value() { return inputs_[0]; }
875
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000876 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
877 "has-cached-array-index-and-branch")
878 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
879
880 virtual void PrintDataTo(StringStream* stream);
881};
882
883
884class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
885 public:
886 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
887 inputs_[0] = value;
888 temps_[0] = temp;
889 }
890
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000891 LOperand* value() { return inputs_[0]; }
892 LOperand* temp() { return temps_[0]; }
893
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000894 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
895 "class-of-test-and-branch")
896 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
897
898 virtual void PrintDataTo(StringStream* stream);
899};
900
901
902class LCmpT: public LTemplateInstruction<1, 2, 0> {
903 public:
904 LCmpT(LOperand* left, LOperand* right) {
905 inputs_[0] = left;
906 inputs_[1] = right;
907 }
908
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000909 LOperand* left() { return inputs_[0]; }
910 LOperand* right() { return inputs_[1]; }
911
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000912 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
913 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
914
915 Token::Value op() const { return hydrogen()->token(); }
916};
917
918
919class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
920 public:
921 LInstanceOf(LOperand* left, LOperand* right) {
922 inputs_[0] = left;
923 inputs_[1] = right;
924 }
925
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000926 LOperand* left() { return inputs_[0]; }
927 LOperand* right() { return inputs_[1]; }
928
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000929 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
930};
931
932
933class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
934 public:
935 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
936 inputs_[0] = value;
937 temps_[0] = temp;
938 }
939
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000940 LOperand* value() { return inputs_[0]; }
941 LOperand* temp() { return temps_[0]; }
942
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000943 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
944 "instance-of-known-global")
945 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
946
947 Handle<JSFunction> function() const { return hydrogen()->function(); }
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000948 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
949 return lazy_deopt_env_;
950 }
951 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {
952 lazy_deopt_env_ = env;
953 }
954
955 private:
956 LEnvironment* lazy_deopt_env_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000957};
958
959
960class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
961 public:
962 LBoundsCheck(LOperand* index, LOperand* length) {
963 inputs_[0] = index;
964 inputs_[1] = length;
965 }
966
967 LOperand* index() { return inputs_[0]; }
968 LOperand* length() { return inputs_[1]; }
969
970 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
danno@chromium.org129d3982012-07-25 15:01:47 +0000971 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000972};
973
974
975class LBitI: public LTemplateInstruction<1, 2, 0> {
976 public:
977 LBitI(LOperand* left, LOperand* right) {
978 inputs_[0] = left;
979 inputs_[1] = right;
980 }
981
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000982 LOperand* left() { return inputs_[0]; }
983 LOperand* right() { return inputs_[1]; }
984
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000985 Token::Value op() const { return hydrogen()->op(); }
986
987 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
988 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
989};
990
991
992class LShiftI: public LTemplateInstruction<1, 2, 0> {
993 public:
994 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
995 : op_(op), can_deopt_(can_deopt) {
996 inputs_[0] = left;
997 inputs_[1] = right;
998 }
999
1000 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001001 LOperand* left() { return inputs_[0]; }
1002 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001003 bool can_deopt() const { return can_deopt_; }
1004
1005 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1006
1007 private:
1008 Token::Value op_;
1009 bool can_deopt_;
1010};
1011
1012
1013class LSubI: public LTemplateInstruction<1, 2, 0> {
1014 public:
1015 LSubI(LOperand* left, LOperand* right) {
1016 inputs_[0] = left;
1017 inputs_[1] = right;
1018 }
1019
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001020 LOperand* left() { return inputs_[0]; }
1021 LOperand* right() { return inputs_[1]; }
1022
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001023 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1024 DECLARE_HYDROGEN_ACCESSOR(Sub)
1025};
1026
1027
1028class LConstantI: public LTemplateInstruction<1, 0, 0> {
1029 public:
1030 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1031 DECLARE_HYDROGEN_ACCESSOR(Constant)
1032
1033 int32_t value() const { return hydrogen()->Integer32Value(); }
1034};
1035
1036
1037class LConstantD: public LTemplateInstruction<1, 0, 0> {
1038 public:
1039 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1040 DECLARE_HYDROGEN_ACCESSOR(Constant)
1041
1042 double value() const { return hydrogen()->DoubleValue(); }
1043};
1044
1045
1046class LConstantT: public LTemplateInstruction<1, 0, 0> {
1047 public:
1048 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1049 DECLARE_HYDROGEN_ACCESSOR(Constant)
1050
1051 Handle<Object> value() const { return hydrogen()->handle(); }
1052};
1053
1054
1055class LBranch: public LControlInstruction<1, 0> {
1056 public:
1057 explicit LBranch(LOperand* value) {
1058 inputs_[0] = value;
1059 }
1060
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001061 LOperand* value() { return inputs_[0]; }
1062
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001063 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1064 DECLARE_HYDROGEN_ACCESSOR(Branch)
1065
1066 virtual void PrintDataTo(StringStream* stream);
1067};
1068
1069
1070class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
1071 public:
1072 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1073 inputs_[0] = value;
1074 temps_[0] = temp;
1075 }
1076
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001077 LOperand* value() { return inputs_[0]; }
1078 LOperand* temp() { return temps_[0]; }
1079
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001080 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1081 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1082
1083 virtual bool IsControl() const { return true; }
1084
1085 Handle<Map> map() const { return hydrogen()->map(); }
1086 int true_block_id() const {
1087 return hydrogen()->FirstSuccessor()->block_id();
1088 }
1089 int false_block_id() const {
1090 return hydrogen()->SecondSuccessor()->block_id();
1091 }
1092};
1093
1094
1095class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
1096 public:
1097 explicit LJSArrayLength(LOperand* value) {
1098 inputs_[0] = value;
1099 }
1100
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001101 LOperand* value() { return inputs_[0]; }
1102
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001103 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
1104 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
1105};
1106
1107
1108class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
1109 public:
1110 explicit LFixedArrayBaseLength(LOperand* value) {
1111 inputs_[0] = value;
1112 }
1113
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001114 LOperand* value() { return inputs_[0]; }
1115
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001116 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
1117 "fixed-array-base-length")
1118 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
1119};
1120
1121
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001122class LMapEnumLength: public LTemplateInstruction<1, 1, 0> {
1123 public:
1124 explicit LMapEnumLength(LOperand* value) {
1125 inputs_[0] = value;
1126 }
1127
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001128 LOperand* value() { return inputs_[0]; }
1129
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001130 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1131};
1132
1133
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001134class LElementsKind: public LTemplateInstruction<1, 1, 0> {
1135 public:
1136 explicit LElementsKind(LOperand* value) {
1137 inputs_[0] = value;
1138 }
1139
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001140 LOperand* value() { return inputs_[0]; }
1141
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001142 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1143 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1144};
1145
1146
1147class LValueOf: public LTemplateInstruction<1, 1, 1> {
1148 public:
1149 LValueOf(LOperand* value, LOperand* temp) {
1150 inputs_[0] = value;
1151 temps_[0] = temp;
1152 }
1153
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001154 LOperand* value() { return inputs_[0]; }
1155 LOperand* temp() { return temps_[0]; }
1156
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001157 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1158 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1159};
1160
1161
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001162class LDateField: public LTemplateInstruction<1, 1, 1> {
1163 public:
1164 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1165 inputs_[0] = date;
1166 temps_[0] = temp;
1167 }
1168
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001169 LOperand* date() { return inputs_[0]; }
1170 LOperand* temp() { return temps_[0]; }
1171 Smi* index() const { return index_; }
1172
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001173 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
1174 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001175
1176 private:
1177 Smi* index_;
1178};
1179
1180
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +00001181class LSeqStringSetChar: public LTemplateInstruction<1, 3, 0> {
1182 public:
1183 LSeqStringSetChar(String::Encoding encoding,
1184 LOperand* string,
1185 LOperand* index,
1186 LOperand* value) : encoding_(encoding) {
1187 inputs_[0] = string;
1188 inputs_[1] = index;
1189 inputs_[2] = value;
1190 }
1191
1192 String::Encoding encoding() { return encoding_; }
1193 LOperand* string() { return inputs_[0]; }
1194 LOperand* index() { return inputs_[1]; }
1195 LOperand* value() { return inputs_[2]; }
1196
1197 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1198 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1199
1200 private:
1201 String::Encoding encoding_;
1202};
1203
1204
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001205class LThrow: public LTemplateInstruction<0, 1, 0> {
1206 public:
1207 explicit LThrow(LOperand* value) {
1208 inputs_[0] = value;
1209 }
1210
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001211 LOperand* value() { return inputs_[0]; }
1212
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001213 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1214};
1215
1216
1217class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1218 public:
1219 explicit LBitNotI(LOperand* value) {
1220 inputs_[0] = value;
1221 }
1222
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001223 LOperand* value() { return inputs_[0]; }
1224
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001225 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1226};
1227
1228
1229class LAddI: public LTemplateInstruction<1, 2, 0> {
1230 public:
1231 LAddI(LOperand* left, LOperand* right) {
1232 inputs_[0] = left;
1233 inputs_[1] = right;
1234 }
1235
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001236 LOperand* left() { return inputs_[0]; }
1237 LOperand* right() { return inputs_[1]; }
1238
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001239 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1240 DECLARE_HYDROGEN_ACCESSOR(Add)
1241};
1242
1243
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001244class LMathMinMax: public LTemplateInstruction<1, 2, 0> {
1245 public:
1246 LMathMinMax(LOperand* left, LOperand* right) {
1247 inputs_[0] = left;
1248 inputs_[1] = right;
1249 }
1250
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001251 LOperand* left() { return inputs_[0]; }
1252 LOperand* right() { return inputs_[1]; }
1253
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001254 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "min-max")
1255 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1256};
1257
1258
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001259class LPower: public LTemplateInstruction<1, 2, 0> {
1260 public:
1261 LPower(LOperand* left, LOperand* right) {
1262 inputs_[0] = left;
1263 inputs_[1] = right;
1264 }
1265
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001266 LOperand* left() { return inputs_[0]; }
1267 LOperand* right() { return inputs_[1]; }
1268
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001269 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1270 DECLARE_HYDROGEN_ACCESSOR(Power)
1271};
1272
1273
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001274class LRandom: public LTemplateInstruction<1, 1, 0> {
1275 public:
1276 explicit LRandom(LOperand* global_object) {
1277 inputs_[0] = global_object;
1278 }
1279
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001280 LOperand* global_object() { return inputs_[0]; }
1281
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001282 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1283 DECLARE_HYDROGEN_ACCESSOR(Random)
1284};
1285
1286
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001287class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1288 public:
1289 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1290 : op_(op) {
1291 inputs_[0] = left;
1292 inputs_[1] = right;
1293 }
1294
1295 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001296 LOperand* left() { return inputs_[0]; }
1297 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001298
1299 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1300 virtual void CompileToNative(LCodeGen* generator);
1301 virtual const char* Mnemonic() const;
1302
1303 private:
1304 Token::Value op_;
1305};
1306
1307
1308class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1309 public:
1310 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1311 : op_(op) {
1312 inputs_[0] = left;
1313 inputs_[1] = right;
1314 }
1315
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001316 LOperand* left() { return inputs_[0]; }
1317 LOperand* right() { return inputs_[1]; }
1318 Token::Value op() const { return op_; }
1319
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001320 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1321 virtual void CompileToNative(LCodeGen* generator);
1322 virtual const char* Mnemonic() const;
1323
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001324 private:
1325 Token::Value op_;
1326};
1327
1328
1329class LReturn: public LTemplateInstruction<0, 1, 0> {
1330 public:
1331 explicit LReturn(LOperand* value) {
1332 inputs_[0] = value;
1333 }
1334
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001335 LOperand* value() { return inputs_[0]; }
1336
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001337 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1338};
1339
1340
1341class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1342 public:
1343 explicit LLoadNamedField(LOperand* object) {
1344 inputs_[0] = object;
1345 }
1346
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001347 LOperand* object() { return inputs_[0]; }
1348
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001349 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1350 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1351};
1352
1353
1354class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1355 public:
1356 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1357 inputs_[0] = object;
1358 }
1359
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001360 LOperand* object() { return inputs_[0]; }
1361
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001362 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1363 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001364};
1365
1366
1367class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1368 public:
1369 explicit LLoadNamedGeneric(LOperand* object) {
1370 inputs_[0] = object;
1371 }
1372
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001373 LOperand* object() { return inputs_[0]; }
1374
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001375 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1376 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1377
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001378 Handle<Object> name() const { return hydrogen()->name(); }
1379};
1380
1381
1382class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1383 public:
1384 explicit LLoadFunctionPrototype(LOperand* function) {
1385 inputs_[0] = function;
1386 }
1387
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001388 LOperand* function() { return inputs_[0]; }
1389
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001390 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1391 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001392};
1393
1394
1395class LLoadElements: public LTemplateInstruction<1, 1, 0> {
1396 public:
1397 explicit LLoadElements(LOperand* object) {
1398 inputs_[0] = object;
1399 }
1400
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001401 LOperand* object() { return inputs_[0]; }
1402
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001403 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1404};
1405
1406
1407class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1408 public:
1409 explicit LLoadExternalArrayPointer(LOperand* object) {
1410 inputs_[0] = object;
1411 }
1412
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001413 LOperand* object() { return inputs_[0]; }
1414
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001415 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1416 "load-external-array-pointer")
1417};
1418
1419
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001420class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001421 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001422 LLoadKeyed(LOperand* elements, LOperand* key) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001423 inputs_[0] = elements;
1424 inputs_[1] = key;
1425 }
1426
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001427 LOperand* elements() { return inputs_[0]; }
1428 LOperand* key() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001429 ElementsKind elements_kind() const {
1430 return hydrogen()->elements_kind();
1431 }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001432 bool is_external() const {
1433 return hydrogen()->is_external();
1434 }
1435
1436 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1437 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1438
ulan@chromium.org8e8d8822012-11-23 14:36:46 +00001439 virtual void PrintDataTo(StringStream* stream);
jkummerow@chromium.org777db6f2012-05-24 09:33:09 +00001440 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001441};
1442
1443
1444class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1445 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001446 LLoadKeyedGeneric(LOperand* object, LOperand* key) {
1447 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001448 inputs_[1] = key;
1449 }
1450
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001451 LOperand* object() { return inputs_[0]; }
1452 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001453
1454 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001455};
1456
1457
1458class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1459 public:
1460 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1461 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1462};
1463
1464
1465class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1466 public:
1467 explicit LLoadGlobalGeneric(LOperand* global_object) {
1468 inputs_[0] = global_object;
1469 }
1470
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001471 LOperand* global_object() { return inputs_[0]; }
1472
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001473 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1474 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1475
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001476 Handle<Object> name() const { return hydrogen()->name(); }
1477 bool for_typeof() const { return hydrogen()->for_typeof(); }
1478};
1479
1480
1481class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1482 public:
1483 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1484 inputs_[0] = value;
1485 temps_[0] = temp;
1486 }
1487
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001488 LOperand* value() { return inputs_[0]; }
1489 LOperand* temp() { return temps_[0]; }
1490
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001491 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1492 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1493};
1494
1495
1496class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1497 public:
1498 explicit LStoreGlobalGeneric(LOperand* global_object,
1499 LOperand* value) {
1500 inputs_[0] = global_object;
1501 inputs_[1] = value;
1502 }
1503
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001504 LOperand* global_object() { return inputs_[0]; }
1505 LOperand* value() { return inputs_[1]; }
1506
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001507 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1508 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1509
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001510 Handle<Object> name() const { return hydrogen()->name(); }
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001511 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001512};
1513
1514
1515class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1516 public:
1517 explicit LLoadContextSlot(LOperand* context) {
1518 inputs_[0] = context;
1519 }
1520
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001521 LOperand* context() { return inputs_[0]; }
1522
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001523 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1524 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1525
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001526 int slot_index() { return hydrogen()->slot_index(); }
1527
1528 virtual void PrintDataTo(StringStream* stream);
1529};
1530
1531
1532class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1533 public:
1534 LStoreContextSlot(LOperand* context, LOperand* value) {
1535 inputs_[0] = context;
1536 inputs_[1] = value;
1537 }
1538
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001539 LOperand* context() { return inputs_[0]; }
1540 LOperand* value() { return inputs_[1]; }
1541
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001542 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1543 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1544
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001545 int slot_index() { return hydrogen()->slot_index(); }
1546
1547 virtual void PrintDataTo(StringStream* stream);
1548};
1549
1550
1551class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1552 public:
1553 explicit LPushArgument(LOperand* value) {
1554 inputs_[0] = value;
1555 }
1556
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001557 LOperand* value() { return inputs_[0]; }
1558
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001559 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1560};
1561
1562
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00001563class LDrop: public LTemplateInstruction<0, 0, 0> {
1564 public:
1565 explicit LDrop(int count) : count_(count) { }
1566
1567 int count() const { return count_; }
1568
1569 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1570
1571 private:
1572 int count_;
1573};
1574
1575
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001576class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1577 public:
1578 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1579 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1580};
1581
1582
1583class LContext: public LTemplateInstruction<1, 0, 0> {
1584 public:
1585 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1586};
1587
1588
1589class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1590 public:
1591 explicit LOuterContext(LOperand* context) {
1592 inputs_[0] = context;
1593 }
1594
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001595 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001596
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001597 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001598};
1599
1600
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001601class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> {
1602 public:
1603 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1604 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1605};
1606
1607
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001608class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1609 public:
1610 explicit LGlobalObject(LOperand* context) {
1611 inputs_[0] = context;
1612 }
1613
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001614 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001615
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001616 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001617};
1618
1619
1620class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1621 public:
1622 explicit LGlobalReceiver(LOperand* global_object) {
1623 inputs_[0] = global_object;
1624 }
1625
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001626 LOperand* global_object() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001627
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001628 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001629};
1630
1631
1632class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1633 public:
1634 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1635 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1636
1637 virtual void PrintDataTo(StringStream* stream);
1638
1639 Handle<JSFunction> function() { return hydrogen()->function(); }
1640 int arity() const { return hydrogen()->argument_count() - 1; }
1641};
1642
1643
1644class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1645 public:
1646 explicit LInvokeFunction(LOperand* function) {
1647 inputs_[0] = function;
1648 }
1649
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001650 LOperand* function() { return inputs_[0]; }
1651
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001652 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1653 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1654
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001655 virtual void PrintDataTo(StringStream* stream);
1656
1657 int arity() const { return hydrogen()->argument_count() - 1; }
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00001658 Handle<JSFunction> known_function() { return hydrogen()->known_function(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001659};
1660
1661
1662class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1663 public:
1664 explicit LCallKeyed(LOperand* key) {
1665 inputs_[0] = key;
1666 }
1667
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001668 LOperand* key() { return inputs_[0]; }
1669
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001670 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1671 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1672
1673 virtual void PrintDataTo(StringStream* stream);
1674
1675 int arity() const { return hydrogen()->argument_count() - 1; }
1676};
1677
1678
1679
1680class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1681 public:
1682 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1683 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1684
1685 virtual void PrintDataTo(StringStream* stream);
1686
1687 Handle<String> name() const { return hydrogen()->name(); }
1688 int arity() const { return hydrogen()->argument_count() - 1; }
1689};
1690
1691
danno@chromium.orgc612e022011-11-10 11:38:15 +00001692class LCallFunction: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001693 public:
danno@chromium.orgc612e022011-11-10 11:38:15 +00001694 explicit LCallFunction(LOperand* function) {
1695 inputs_[0] = function;
1696 }
1697
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001698 LOperand* function() { return inputs_[0]; }
1699
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001700 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1701 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1702
danno@chromium.orgc612e022011-11-10 11:38:15 +00001703 int arity() const { return hydrogen()->argument_count() - 1; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001704};
1705
1706
1707class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1708 public:
1709 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1710 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1711
1712 virtual void PrintDataTo(StringStream* stream);
1713
1714 Handle<String> name() const {return hydrogen()->name(); }
1715 int arity() const { return hydrogen()->argument_count() - 1; }
1716};
1717
1718
1719class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1720 public:
1721 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1722 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1723
1724 virtual void PrintDataTo(StringStream* stream);
1725
1726 Handle<JSFunction> target() const { return hydrogen()->target(); }
1727 int arity() const { return hydrogen()->argument_count() - 1; }
1728};
1729
1730
1731class LCallNew: public LTemplateInstruction<1, 1, 0> {
1732 public:
1733 explicit LCallNew(LOperand* constructor) {
1734 inputs_[0] = constructor;
1735 }
1736
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001737 LOperand* constructor() { return inputs_[0]; }
1738
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001739 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1740 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1741
1742 virtual void PrintDataTo(StringStream* stream);
1743
1744 int arity() const { return hydrogen()->argument_count() - 1; }
1745};
1746
1747
1748class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1749 public:
1750 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1751 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1752
1753 const Runtime::Function* function() const { return hydrogen()->function(); }
1754 int arity() const { return hydrogen()->argument_count(); }
1755};
1756
1757
1758class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1759 public:
1760 explicit LInteger32ToDouble(LOperand* value) {
1761 inputs_[0] = value;
1762 }
1763
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001764 LOperand* value() { return inputs_[0]; }
1765
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001766 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1767};
1768
1769
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001770class LUint32ToDouble: public LTemplateInstruction<1, 1, 0> {
1771 public:
1772 explicit LUint32ToDouble(LOperand* value) {
1773 inputs_[0] = value;
1774 }
1775
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001776 LOperand* value() { return inputs_[0]; }
1777
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001778 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1779};
1780
1781
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001782class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1783 public:
1784 explicit LNumberTagI(LOperand* value) {
1785 inputs_[0] = value;
1786 }
1787
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001788 LOperand* value() { return inputs_[0]; }
1789
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001790 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1791};
1792
1793
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001794class LNumberTagU: public LTemplateInstruction<1, 1, 0> {
1795 public:
1796 explicit LNumberTagU(LOperand* value) {
1797 inputs_[0] = value;
1798 }
1799
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001800 LOperand* value() { return inputs_[0]; }
1801
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001802 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1803};
1804
1805
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001806class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1807 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001808 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001809 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001810 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001811 temps_[1] = temp2;
1812 }
1813
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001814 LOperand* value() { return inputs_[0]; }
1815 LOperand* temp() { return temps_[0]; }
1816 LOperand* temp2() { return temps_[1]; }
1817
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001818 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1819};
1820
1821
1822// Sometimes truncating conversion from a tagged value to an int32.
1823class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1824 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001825 LDoubleToI(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001826 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001827 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001828 temps_[1] = temp2;
1829 }
1830
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001831 LOperand* value() { return inputs_[0]; }
1832 LOperand* temp() { return temps_[0]; }
1833 LOperand* temp2() { return temps_[1]; }
1834
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001835 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1836 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1837
1838 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1839};
1840
1841
1842// Truncating conversion from a tagged value to an int32.
1843class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
1844 public:
1845 LTaggedToI(LOperand* value,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001846 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001847 LOperand* temp2,
1848 LOperand* temp3) {
1849 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001850 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001851 temps_[1] = temp2;
1852 temps_[2] = temp3;
1853 }
1854
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001855 LOperand* value() { return inputs_[0]; }
1856 LOperand* temp() { return temps_[0]; }
1857 LOperand* temp2() { return temps_[1]; }
1858 LOperand* temp3() { return temps_[2]; }
1859
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001860 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1861 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1862
1863 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1864};
1865
1866
1867class LSmiTag: public LTemplateInstruction<1, 1, 0> {
1868 public:
1869 explicit LSmiTag(LOperand* value) {
1870 inputs_[0] = value;
1871 }
1872
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001873 LOperand* value() { return inputs_[0]; }
1874
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001875 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1876};
1877
1878
1879class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
1880 public:
1881 explicit LNumberUntagD(LOperand* value) {
1882 inputs_[0] = value;
1883 }
1884
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001885 LOperand* value() { return inputs_[0]; }
1886
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001887 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1888 DECLARE_HYDROGEN_ACCESSOR(Change)
1889};
1890
1891
1892class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
1893 public:
1894 LSmiUntag(LOperand* value, bool needs_check)
1895 : needs_check_(needs_check) {
1896 inputs_[0] = value;
1897 }
1898
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001899 LOperand* value() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001900 bool needs_check() const { return needs_check_; }
1901
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001902 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1903
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001904 private:
1905 bool needs_check_;
1906};
1907
1908
verwaest@chromium.org37141392012-05-31 13:27:02 +00001909class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001910 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001911 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
1912 inputs_[0] = object;
1913 inputs_[1] = value;
verwaest@chromium.org37141392012-05-31 13:27:02 +00001914 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001915 }
1916
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001917 LOperand* object() { return inputs_[0]; }
1918 LOperand* value() { return inputs_[1]; }
1919 LOperand* temp() { return temps_[0]; }
1920
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001921 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1922 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1923
1924 virtual void PrintDataTo(StringStream* stream);
1925
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001926 Handle<Object> name() const { return hydrogen()->name(); }
1927 bool is_in_object() { return hydrogen()->is_in_object(); }
1928 int offset() { return hydrogen()->offset(); }
1929 Handle<Map> transition() const { return hydrogen()->transition(); }
1930};
1931
1932
1933class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1934 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001935 LStoreNamedGeneric(LOperand* object, LOperand* value) {
1936 inputs_[0] = object;
1937 inputs_[1] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001938 }
1939
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001940 LOperand* object() { return inputs_[0]; }
1941 LOperand* value() { return inputs_[1]; }
1942
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001943 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1944 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1945
1946 virtual void PrintDataTo(StringStream* stream);
1947
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001948 Handle<Object> name() const { return hydrogen()->name(); }
1949 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001950};
1951
1952
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001953class LStoreKeyed: public LTemplateInstruction<0, 3, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001954 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001955 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001956 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001957 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001958 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001959 }
1960
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001961 bool is_external() const { return hydrogen()->is_external(); }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001962 LOperand* elements() { return inputs_[0]; }
1963 LOperand* key() { return inputs_[1]; }
1964 LOperand* value() { return inputs_[2]; }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001965 ElementsKind elements_kind() const {
1966 return hydrogen()->elements_kind();
1967 }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001968
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001969 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
1970 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001971
1972 virtual void PrintDataTo(StringStream* stream);
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00001973 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001974 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001975};
1976
1977
1978class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
1979 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001980 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001981 inputs_[0] = obj;
1982 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001983 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001984 }
1985
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001986 LOperand* object() { return inputs_[0]; }
1987 LOperand* key() { return inputs_[1]; }
1988 LOperand* value() { return inputs_[2]; }
1989
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001990 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1991 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1992
1993 virtual void PrintDataTo(StringStream* stream);
1994
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001995 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001996};
1997
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001998
1999class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
2000 public:
2001 LTransitionElementsKind(LOperand* object,
2002 LOperand* new_map_temp,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002003 LOperand* temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002004 inputs_[0] = object;
2005 temps_[0] = new_map_temp;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002006 temps_[1] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002007 }
2008
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002009 LOperand* object() { return inputs_[0]; }
2010 LOperand* new_map_temp() { return temps_[0]; }
2011 LOperand* temp() { return temps_[1]; }
2012
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002013 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2014 "transition-elements-kind")
2015 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2016
2017 virtual void PrintDataTo(StringStream* stream);
2018
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002019 Handle<Map> original_map() { return hydrogen()->original_map(); }
2020 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002021 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2022 ElementsKind to_kind() { return hydrogen()->to_kind(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002023};
2024
2025
2026class LStringAdd: public LTemplateInstruction<1, 2, 0> {
2027 public:
2028 LStringAdd(LOperand* left, LOperand* right) {
2029 inputs_[0] = left;
2030 inputs_[1] = right;
2031 }
2032
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002033 LOperand* left() { return inputs_[0]; }
2034 LOperand* right() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002035
2036 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2037 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002038};
2039
2040
2041
2042class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
2043 public:
2044 LStringCharCodeAt(LOperand* string, LOperand* index) {
2045 inputs_[0] = string;
2046 inputs_[1] = index;
2047 }
2048
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002049 LOperand* string() { return inputs_[0]; }
2050 LOperand* index() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002051
2052 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2053 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002054};
2055
2056
2057class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
2058 public:
2059 explicit LStringCharFromCode(LOperand* char_code) {
2060 inputs_[0] = char_code;
2061 }
2062
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002063 LOperand* char_code() { return inputs_[0]; }
2064
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002065 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2066 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002067};
2068
2069
2070class LStringLength: public LTemplateInstruction<1, 1, 0> {
2071 public:
2072 explicit LStringLength(LOperand* string) {
2073 inputs_[0] = string;
2074 }
2075
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002076 LOperand* string() { return inputs_[0]; }
2077
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002078 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
2079 DECLARE_HYDROGEN_ACCESSOR(StringLength)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002080};
2081
2082
2083class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
2084 public:
2085 explicit LCheckFunction(LOperand* value) {
2086 inputs_[0] = value;
2087 }
2088
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002089 LOperand* value() { return inputs_[0]; }
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00002090
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002091 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
2092 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
2093};
2094
2095
2096class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
2097 public:
2098 explicit LCheckInstanceType(LOperand* value) {
2099 inputs_[0] = value;
2100 }
2101
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002102 LOperand* value() { return inputs_[0]; }
2103
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002104 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2105 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2106};
2107
2108
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002109class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002110 public:
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002111 explicit LCheckMaps(LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002112 inputs_[0] = value;
2113 }
2114
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002115 LOperand* value() { return inputs_[0]; }
2116
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002117 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2118 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002119};
2120
2121
verwaest@chromium.orge4ee6de2012-11-06 12:13:00 +00002122class LCheckPrototypeMaps: public LTemplateInstruction<1, 0, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002123 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002124 LCheckPrototypeMaps(LOperand* temp, LOperand* temp2) {
2125 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002126 temps_[1] = temp2;
2127 }
2128
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002129 LOperand* temp() { return temps_[0]; }
2130 LOperand* temp2() { return temps_[1]; }
2131
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002132 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
2133 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
2134
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002135 ZoneList<Handle<JSObject> >* prototypes() const {
2136 return hydrogen()->prototypes();
2137 }
2138 ZoneList<Handle<Map> >* maps() const { return hydrogen()->maps(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002139};
2140
2141
2142class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
2143 public:
2144 explicit LCheckSmi(LOperand* value) {
2145 inputs_[0] = value;
2146 }
2147
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002148 LOperand* value() { return inputs_[0]; }
2149
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002150 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2151};
2152
2153
2154class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2155 public:
2156 explicit LCheckNonSmi(LOperand* value) {
2157 inputs_[0] = value;
2158 }
2159
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002160 LOperand* value() { return inputs_[0]; }
2161
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002162 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2163};
2164
2165
2166class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
2167 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002168 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2169 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002170 temps_[0] = temp;
2171 }
2172
2173 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002174 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002175
2176 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2177};
2178
2179
2180class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
2181 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002182 explicit LClampIToUint8(LOperand* unclamped) {
2183 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002184 }
2185
2186 LOperand* unclamped() { return inputs_[0]; }
2187
2188 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2189};
2190
2191
2192class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2193 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002194 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2195 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002196 temps_[0] = temp;
2197 }
2198
2199 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002200 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002201
2202 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2203};
2204
2205
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002206class LAllocateObject: public LTemplateInstruction<1, 0, 2> {
ulan@chromium.org967e2702012-02-28 09:49:15 +00002207 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002208 LAllocateObject(LOperand* temp, LOperand* temp2) {
2209 temps_[0] = temp;
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002210 temps_[1] = temp2;
2211 }
2212
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002213 LOperand* temp() { return temps_[0]; }
2214 LOperand* temp2() { return temps_[1]; }
2215
ulan@chromium.org967e2702012-02-28 09:49:15 +00002216 DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object")
2217 DECLARE_HYDROGEN_ACCESSOR(AllocateObject)
2218};
2219
2220
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002221class LFastLiteral: public LTemplateInstruction<1, 0, 0> {
2222 public:
2223 DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal")
2224 DECLARE_HYDROGEN_ACCESSOR(FastLiteral)
2225};
2226
2227
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002228class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
2229 public:
2230 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
2231 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
2232};
2233
2234
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002235class LObjectLiteral: public LTemplateInstruction<1, 0, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002236 public:
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002237 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
2238 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002239};
2240
2241
2242class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
2243 public:
2244 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2245 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2246};
2247
2248
2249class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
2250 public:
2251 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2252 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2253
2254 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2255};
2256
2257
2258class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2259 public:
2260 explicit LToFastProperties(LOperand* value) {
2261 inputs_[0] = value;
2262 }
2263
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002264 LOperand* value() { return inputs_[0]; }
2265
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002266 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2267 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2268};
2269
2270
2271class LTypeof: public LTemplateInstruction<1, 1, 0> {
2272 public:
2273 explicit LTypeof(LOperand* value) {
2274 inputs_[0] = value;
2275 }
2276
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002277 LOperand* value() { return inputs_[0]; }
2278
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002279 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2280};
2281
2282
2283class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2284 public:
2285 explicit LTypeofIsAndBranch(LOperand* value) {
2286 inputs_[0] = value;
2287 }
2288
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002289 LOperand* value() { return inputs_[0]; }
2290
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002291 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2292 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2293
2294 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2295
2296 virtual void PrintDataTo(StringStream* stream);
2297};
2298
2299
2300class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
2301 public:
2302 explicit LIsConstructCallAndBranch(LOperand* temp) {
2303 temps_[0] = temp;
2304 }
2305
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002306 LOperand* temp() { return temps_[0]; }
2307
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002308 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2309 "is-construct-call-and-branch")
2310};
2311
2312
2313class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
2314 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002315 LDeleteProperty(LOperand* object, LOperand* key) {
2316 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002317 inputs_[1] = key;
2318 }
2319
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002320 LOperand* object() { return inputs_[0]; }
2321 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002322
2323 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002324};
2325
2326
2327class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2328 public:
2329 LOsrEntry();
2330
2331 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2332
2333 LOperand** SpilledRegisterArray() { return register_spills_; }
2334 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2335
2336 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2337 void MarkSpilledDoubleRegister(int allocation_index,
2338 LOperand* spill_operand);
2339
2340 private:
2341 // Arrays of spill slot operands for registers with an assigned spill
2342 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2343 // NULL if the register has no assigned spill slot. Indexed by allocation
2344 // index.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002345 LOperand* register_spills_[Register::kMaxNumAllocatableRegisters];
2346 LOperand* double_register_spills_[
2347 DoubleRegister::kMaxNumAllocatableRegisters];
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002348};
2349
2350
2351class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2352 public:
2353 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2354 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2355
2356 Label* done_label() { return &done_label_; }
2357
2358 private:
2359 Label done_label_;
2360};
2361
2362
2363class LIn: public LTemplateInstruction<1, 2, 0> {
2364 public:
2365 LIn(LOperand* key, LOperand* object) {
2366 inputs_[0] = key;
2367 inputs_[1] = object;
2368 }
2369
2370 LOperand* key() { return inputs_[0]; }
2371 LOperand* object() { return inputs_[1]; }
2372
2373 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2374};
2375
2376
ulan@chromium.org812308e2012-02-29 15:58:45 +00002377class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> {
2378 public:
2379 explicit LForInPrepareMap(LOperand* object) {
2380 inputs_[0] = object;
2381 }
2382
2383 LOperand* object() { return inputs_[0]; }
2384
2385 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2386};
2387
2388
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002389class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002390 public:
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002391 explicit LForInCacheArray(LOperand* map) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002392 inputs_[0] = map;
2393 }
2394
2395 LOperand* map() { return inputs_[0]; }
2396
2397 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2398
2399 int idx() {
2400 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2401 }
2402};
2403
2404
2405class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2406 public:
2407 LCheckMapValue(LOperand* value, LOperand* map) {
2408 inputs_[0] = value;
2409 inputs_[1] = map;
2410 }
2411
2412 LOperand* value() { return inputs_[0]; }
2413 LOperand* map() { return inputs_[1]; }
2414
2415 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2416};
2417
2418
2419class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2420 public:
2421 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2422 inputs_[0] = object;
2423 inputs_[1] = index;
2424 }
2425
2426 LOperand* object() { return inputs_[0]; }
2427 LOperand* index() { return inputs_[1]; }
2428
2429 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2430};
2431
2432
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002433class LChunkBuilder;
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002434class LPlatformChunk: public LChunk {
lrn@chromium.org7516f052011-03-30 08:52:27 +00002435 public:
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002436 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2437 : LChunk(info, graph) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002438
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002439 int GetNextSpillIndex(bool is_double);
2440 LOperand* GetNextSpillSlot(bool is_double);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002441};
2442
2443
2444class LChunkBuilder BASE_EMBEDDED {
2445 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002446 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2447 : chunk_(NULL),
2448 info_(info),
2449 graph_(graph),
mmassi@chromium.org7028c052012-06-13 11:51:58 +00002450 zone_(graph->zone()),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002451 status_(UNUSED),
2452 current_instruction_(NULL),
2453 current_block_(NULL),
2454 next_block_(NULL),
2455 argument_count_(0),
2456 allocator_(allocator),
2457 position_(RelocInfo::kNoPosition),
2458 instruction_pending_deoptimization_environment_(NULL),
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002459 pending_deoptimization_ast_id_(BailoutId::None()) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002460
2461 // Build the sequence for the graph.
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002462 LPlatformChunk* Build();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002463
2464 // Declare methods that deal with the individual node types.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002465#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002466 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2467#undef DECLARE_DO
2468
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002469 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2470
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002471 private:
2472 enum Status {
2473 UNUSED,
2474 BUILDING,
2475 DONE,
2476 ABORTED
2477 };
2478
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002479 LPlatformChunk* chunk() const { return chunk_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002480 CompilationInfo* info() const { return info_; }
2481 HGraph* graph() const { return graph_; }
ulan@chromium.org812308e2012-02-29 15:58:45 +00002482 Zone* zone() const { return zone_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002483
2484 bool is_unused() const { return status_ == UNUSED; }
2485 bool is_building() const { return status_ == BUILDING; }
2486 bool is_done() const { return status_ == DONE; }
2487 bool is_aborted() const { return status_ == ABORTED; }
2488
yangguo@chromium.org46839fb2012-08-28 09:06:19 +00002489 void Abort(const char* reason);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002490
2491 // Methods for getting operands for Use / Define / Temp.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002492 LUnallocated* ToUnallocated(Register reg);
2493 LUnallocated* ToUnallocated(DoubleRegister reg);
2494
2495 // Methods for setting up define-use relationships.
2496 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2497 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2498 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2499 DoubleRegister fixed_register);
2500
2501 // A value that is guaranteed to be allocated to a register.
2502 // Operand created by UseRegister is guaranteed to be live until the end of
2503 // instruction. This means that register allocator will not reuse it's
2504 // register for any other operand inside instruction.
2505 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2506 // instruction start. Register allocator is free to assign the same register
2507 // to some other operand used inside instruction (i.e. temporary or
2508 // output).
2509 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2510 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2511
2512 // An input operand in a register that may be trashed.
2513 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2514
2515 // An input operand in a register or stack slot.
2516 MUST_USE_RESULT LOperand* Use(HValue* value);
2517 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2518
2519 // An input operand in a register, stack slot or a constant operand.
2520 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2521 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2522
2523 // An input operand in a register or a constant operand.
2524 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2525 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2526
2527 // An input operand in register, stack slot or a constant operand.
2528 // Will not be moved to a register even if one is freely available.
2529 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2530
2531 // Temporary operand that must be in a register.
2532 MUST_USE_RESULT LUnallocated* TempRegister();
2533 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2534 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2535
2536 // Methods for setting up define-use relationships.
2537 // Return the same instruction that they are passed.
2538 template<int I, int T>
2539 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2540 LUnallocated* result);
2541 template<int I, int T>
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002542 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2543 template<int I, int T>
2544 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2545 int index);
2546 template<int I, int T>
2547 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2548 template<int I, int T>
2549 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2550 Register reg);
2551 template<int I, int T>
2552 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2553 DoubleRegister reg);
2554 LInstruction* AssignEnvironment(LInstruction* instr);
2555 LInstruction* AssignPointerMap(LInstruction* instr);
2556
2557 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2558
2559 // By default we assume that instruction sequences generated for calls
2560 // cannot deoptimize eagerly and we do not attach environment to this
2561 // instruction.
2562 LInstruction* MarkAsCall(
2563 LInstruction* instr,
2564 HInstruction* hinstr,
2565 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002566
2567 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2568 int* argument_index_accumulator);
2569
2570 void VisitInstruction(HInstruction* current);
2571
2572 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2573 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2574 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2575 LInstruction* DoArithmeticD(Token::Value op,
2576 HArithmeticBinaryOperation* instr);
2577 LInstruction* DoArithmeticT(Token::Value op,
2578 HArithmeticBinaryOperation* instr);
2579
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002580 LPlatformChunk* chunk_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002581 CompilationInfo* info_;
2582 HGraph* const graph_;
ulan@chromium.org812308e2012-02-29 15:58:45 +00002583 Zone* zone_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002584 Status status_;
2585 HInstruction* current_instruction_;
2586 HBasicBlock* current_block_;
2587 HBasicBlock* next_block_;
2588 int argument_count_;
2589 LAllocator* allocator_;
2590 int position_;
2591 LInstruction* instruction_pending_deoptimization_environment_;
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002592 BailoutId pending_deoptimization_ast_id_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002593
lrn@chromium.org7516f052011-03-30 08:52:27 +00002594 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2595};
2596
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002597#undef DECLARE_HYDROGEN_ACCESSOR
2598#undef DECLARE_CONCRETE_INSTRUCTION
lrn@chromium.org7516f052011-03-30 08:52:27 +00002599
2600} } // namespace v8::internal
2601
2602#endif // V8_MIPS_LITHIUM_MIPS_H_