blob: 32db0dd43652096db87b511043463e0854098c6b [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) \
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +000052 V(Allocate) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000053 V(ApplyArguments) \
54 V(ArgumentsElements) \
55 V(ArgumentsLength) \
56 V(ArithmeticD) \
57 V(ArithmeticT) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000058 V(BitI) \
59 V(BitNotI) \
60 V(BoundsCheck) \
61 V(Branch) \
62 V(CallConstantFunction) \
63 V(CallFunction) \
64 V(CallGlobal) \
65 V(CallKeyed) \
66 V(CallKnownGlobal) \
67 V(CallNamed) \
68 V(CallNew) \
ulan@chromium.org750145a2013-03-07 15:14:13 +000069 V(CallNewArray) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000070 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) \
rossberg@chromium.orgb99c7542013-05-31 11:40:45 +000089 V(ConstantS) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000090 V(ConstantT) \
91 V(Context) \
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +000092 V(DebugBreak) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +000093 V(DeclareGlobals) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000094 V(DeleteProperty) \
95 V(Deoptimize) \
96 V(DivI) \
97 V(DoubleToI) \
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +000098 V(DoubleToSmi) \
yangguo@chromium.org46a2a512013-01-18 16:29:40 +000099 V(DummyUse) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000100 V(ElementsKind) \
101 V(FixedArrayBaseLength) \
102 V(FunctionLiteral) \
103 V(GetCachedArrayIndex) \
104 V(GlobalObject) \
105 V(GlobalReceiver) \
106 V(Goto) \
107 V(HasCachedArrayIndexAndBranch) \
108 V(HasInstanceTypeAndBranch) \
109 V(In) \
110 V(InstanceOf) \
111 V(InstanceOfKnownGlobal) \
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000112 V(InstanceSize) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000113 V(InstructionGap) \
114 V(Integer32ToDouble) \
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +0000115 V(Integer32ToSmi) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000116 V(Uint32ToDouble) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000117 V(InvokeFunction) \
118 V(IsConstructCallAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000119 V(IsObjectAndBranch) \
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000120 V(IsStringAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000121 V(IsSmiAndBranch) \
122 V(IsUndetectableAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000123 V(Label) \
124 V(LazyBailout) \
125 V(LoadContextSlot) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000126 V(LoadExternalArrayPointer) \
127 V(LoadFunctionPrototype) \
128 V(LoadGlobalCell) \
129 V(LoadGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000130 V(LoadKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000131 V(LoadKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000132 V(LoadNamedField) \
133 V(LoadNamedFieldPolymorphic) \
134 V(LoadNamedGeneric) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000135 V(MapEnumLength) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000136 V(MathAbs) \
137 V(MathCos) \
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000138 V(MathExp) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000139 V(MathFloor) \
dslomov@chromium.orgb752d402013-06-18 11:54:54 +0000140 V(MathFloorOfDiv) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000141 V(MathLog) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000142 V(MathMinMax) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000143 V(MathPowHalf) \
144 V(MathRound) \
145 V(MathSin) \
146 V(MathSqrt) \
147 V(MathTan) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000148 V(ModI) \
149 V(MulI) \
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000150 V(MultiplyAddD) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000151 V(NumberTagD) \
152 V(NumberTagI) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000153 V(NumberTagU) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000154 V(NumberUntagD) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000155 V(OsrEntry) \
156 V(OuterContext) \
157 V(Parameter) \
158 V(Power) \
159 V(PushArgument) \
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000160 V(Random) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000161 V(RegExpLiteral) \
162 V(Return) \
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000163 V(SeqStringSetChar) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000164 V(ShiftI) \
165 V(SmiTag) \
166 V(SmiUntag) \
167 V(StackCheck) \
168 V(StoreContextSlot) \
169 V(StoreGlobalCell) \
170 V(StoreGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000171 V(StoreKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000172 V(StoreKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000173 V(StoreNamedField) \
174 V(StoreNamedGeneric) \
175 V(StringAdd) \
176 V(StringCharCodeAt) \
177 V(StringCharFromCode) \
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +0000178 V(StringCompareAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000179 V(StringLength) \
180 V(SubI) \
181 V(TaggedToI) \
182 V(ThisFunction) \
183 V(Throw) \
184 V(ToFastProperties) \
185 V(TransitionElementsKind) \
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +0000186 V(TrapAllocationMemento) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000187 V(Typeof) \
188 V(TypeofIsAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000189 V(UnknownOSRValue) \
ulan@chromium.org812308e2012-02-29 15:58:45 +0000190 V(ValueOf) \
191 V(ForInPrepareMap) \
192 V(ForInCacheArray) \
193 V(CheckMapValue) \
yangguo@chromium.org154ff992012-03-13 08:09:54 +0000194 V(LoadFieldByIndex) \
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000195 V(DateField) \
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000196 V(WrapReceiver) \
jkummerow@chromium.org4c54a2a2013-03-19 17:51:30 +0000197 V(Drop) \
198 V(InnerAllocatedObject)
199
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000200
201#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
202 virtual Opcode opcode() const { return LInstruction::k##type; } \
203 virtual void CompileToNative(LCodeGen* generator); \
204 virtual const char* Mnemonic() const { return mnemonic; } \
205 static L##type* cast(LInstruction* instr) { \
206 ASSERT(instr->Is##type()); \
207 return reinterpret_cast<L##type*>(instr); \
208 }
209
210
211#define DECLARE_HYDROGEN_ACCESSOR(type) \
212 H##type* hydrogen() const { \
213 return H##type::cast(hydrogen_value()); \
214 }
215
lrn@chromium.org7516f052011-03-30 08:52:27 +0000216
217class LInstruction: public ZoneObject {
218 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000219 LInstruction()
220 : environment_(NULL),
221 hydrogen_value_(NULL),
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000222 is_call_(false) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000223 virtual ~LInstruction() { }
224
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000225 virtual void CompileToNative(LCodeGen* generator) = 0;
226 virtual const char* Mnemonic() const = 0;
227 virtual void PrintTo(StringStream* stream);
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000228 virtual void PrintDataTo(StringStream* stream);
229 virtual void PrintOutputOperandTo(StringStream* stream);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000230
231 enum Opcode {
232 // Declare a unique enum value for each instruction.
233#define DECLARE_OPCODE(type) k##type,
234 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
235 kNumberOfInstructions
236#undef DECLARE_OPCODE
237 };
238
239 virtual Opcode opcode() const = 0;
240
241 // Declare non-virtual type testers for all leaf IR classes.
242#define DECLARE_PREDICATE(type) \
243 bool Is##type() const { return opcode() == k##type; }
244 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
245#undef DECLARE_PREDICATE
246
247 // Declare virtual predicates for instructions that don't have
248 // an opcode.
249 virtual bool IsGap() const { return false; }
250
251 virtual bool IsControl() const { return false; }
252
253 void set_environment(LEnvironment* env) { environment_ = env; }
254 LEnvironment* environment() const { return environment_; }
255 bool HasEnvironment() const { return environment_ != NULL; }
256
257 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
258 LPointerMap* pointer_map() const { return pointer_map_.get(); }
259 bool HasPointerMap() const { return pointer_map_.is_set(); }
260
261 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
262 HValue* hydrogen_value() const { return hydrogen_value_; }
263
danno@chromium.org1044a4d2012-04-30 12:34:39 +0000264 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000265
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000266 void MarkAsCall() { is_call_ = true; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000267
268 // Interface to the register allocator and iterators.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000269 bool ClobbersTemps() const { return is_call_; }
270 bool ClobbersRegisters() const { return is_call_; }
271 bool ClobbersDoubleRegisters() const { return is_call_; }
272
273 // Interface to the register allocator and iterators.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000274 bool IsMarkedAsCall() const { return is_call_; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000275
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000276 virtual bool HasResult() const = 0;
277 virtual LOperand* result() = 0;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000278
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000279 LOperand* FirstInput() { return InputAt(0); }
280 LOperand* Output() { return HasResult() ? result() : NULL; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000281
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000282 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
283
lrn@chromium.org7516f052011-03-30 08:52:27 +0000284#ifdef DEBUG
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000285 void VerifyCall();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000286#endif
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000287
288 private:
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000289 // Iterator interface.
290 friend class InputIterator;
291 virtual int InputCount() = 0;
292 virtual LOperand* InputAt(int i) = 0;
293
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000294 friend class TempIterator;
295 virtual int TempCount() = 0;
296 virtual LOperand* TempAt(int i) = 0;
297
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000298 LEnvironment* environment_;
299 SetOncePointer<LPointerMap> pointer_map_;
300 HValue* hydrogen_value_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000301 bool is_call_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000302};
303
304
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000305// R = number of result operands (0 or 1).
306// I = number of input operands.
307// T = number of temporary operands.
308template<int R, int I, int T>
309class LTemplateInstruction: public LInstruction {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000310 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000311 // Allow 0 or 1 output operands.
312 STATIC_ASSERT(R == 0 || R == 1);
313 virtual bool HasResult() const { return R != 0; }
314 void set_result(LOperand* operand) { results_[0] = operand; }
315 LOperand* result() { return results_[0]; }
lrn@chromium.org7516f052011-03-30 08:52:27 +0000316
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000317 protected:
318 EmbeddedContainer<LOperand*, R> results_;
319 EmbeddedContainer<LOperand*, I> inputs_;
320 EmbeddedContainer<LOperand*, T> temps_;
yangguo@chromium.org46839fb2012-08-28 09:06:19 +0000321
322 private:
323 virtual int InputCount() { return I; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000324 virtual LOperand* InputAt(int i) { return inputs_[i]; }
325
326 virtual int TempCount() { return T; }
327 virtual LOperand* TempAt(int i) { return temps_[i]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000328};
329
330
331class LGap: public LTemplateInstruction<0, 0, 0> {
332 public:
333 explicit LGap(HBasicBlock* block)
334 : block_(block) {
335 parallel_moves_[BEFORE] = NULL;
336 parallel_moves_[START] = NULL;
337 parallel_moves_[END] = NULL;
338 parallel_moves_[AFTER] = NULL;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000339 }
340
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000341 // Can't use the DECLARE-macro here because of sub-classes.
342 virtual bool IsGap() const { return true; }
343 virtual void PrintDataTo(StringStream* stream);
344 static LGap* cast(LInstruction* instr) {
345 ASSERT(instr->IsGap());
346 return reinterpret_cast<LGap*>(instr);
347 }
348
349 bool IsRedundant() const;
350
351 HBasicBlock* block() const { return block_; }
352
lrn@chromium.org7516f052011-03-30 08:52:27 +0000353 enum InnerPosition {
354 BEFORE,
355 START,
356 END,
357 AFTER,
358 FIRST_INNER_POSITION = BEFORE,
359 LAST_INNER_POSITION = AFTER
360 };
361
mmassi@chromium.org7028c052012-06-13 11:51:58 +0000362 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
363 if (parallel_moves_[pos] == NULL) {
364 parallel_moves_[pos] = new(zone) LParallelMove(zone);
365 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000366 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000367 }
368
369 LParallelMove* GetParallelMove(InnerPosition pos) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000370 return parallel_moves_[pos];
lrn@chromium.org7516f052011-03-30 08:52:27 +0000371 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000372
373 private:
374 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
375 HBasicBlock* block_;
376};
377
378
379class LInstructionGap: public LGap {
380 public:
381 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
382
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000383 virtual bool HasInterestingComment(LCodeGen* gen) const {
384 return !IsRedundant();
385 }
386
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000387 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
388};
389
390
391class LGoto: public LTemplateInstruction<0, 0, 0> {
392 public:
393 explicit LGoto(int block_id) : block_id_(block_id) { }
394
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000395 virtual bool HasInterestingComment(LCodeGen* gen) const;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000396 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
397 virtual void PrintDataTo(StringStream* stream);
398 virtual bool IsControl() const { return true; }
399
400 int block_id() const { return block_id_; }
401
402 private:
403 int block_id_;
404};
405
406
407class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
408 public:
409 LLazyBailout() : gap_instructions_size_(0) { }
410
411 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
412
413 void set_gap_instructions_size(int gap_instructions_size) {
414 gap_instructions_size_ = gap_instructions_size;
415 }
416 int gap_instructions_size() { return gap_instructions_size_; }
417
418 private:
419 int gap_instructions_size_;
420};
421
422
yangguo@chromium.org46a2a512013-01-18 16:29:40 +0000423class LDummyUse: public LTemplateInstruction<1, 1, 0> {
424 public:
425 explicit LDummyUse(LOperand* value) {
426 inputs_[0] = value;
427 }
428 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
429};
430
431
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000432class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
433 public:
434 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
lrn@chromium.org7516f052011-03-30 08:52:27 +0000435};
436
437
438class LLabel: public LGap {
439 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000440 explicit LLabel(HBasicBlock* block)
441 : LGap(block), replacement_(NULL) { }
442
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000443 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000444 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
445
446 virtual void PrintDataTo(StringStream* stream);
447
448 int block_id() const { return block()->block_id(); }
449 bool is_loop_header() const { return block()->IsLoopHeader(); }
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000450 bool is_osr_entry() const { return block()->is_osr_entry(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000451 Label* label() { return &label_; }
452 LLabel* replacement() const { return replacement_; }
453 void set_replacement(LLabel* label) { replacement_ = label; }
454 bool HasReplacement() const { return replacement_ != NULL; }
455
456 private:
457 Label label_;
458 LLabel* replacement_;
lrn@chromium.org7516f052011-03-30 08:52:27 +0000459};
460
461
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000462class LParameter: public LTemplateInstruction<1, 0, 0> {
lrn@chromium.org7516f052011-03-30 08:52:27 +0000463 public:
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000464 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000465 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
466};
lrn@chromium.org7516f052011-03-30 08:52:27 +0000467
lrn@chromium.org7516f052011-03-30 08:52:27 +0000468
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000469class LCallStub: public LTemplateInstruction<1, 0, 0> {
470 public:
471 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
472 DECLARE_HYDROGEN_ACCESSOR(CallStub)
473
474 TranscendentalCache::Type transcendental_type() {
475 return hydrogen()->transcendental_type();
lrn@chromium.org7516f052011-03-30 08:52:27 +0000476 }
477};
478
479
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000480class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
481 public:
ulan@chromium.org32d7dba2013-04-24 10:59:06 +0000482 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000483 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
484};
485
486
487template<int I, int T>
488class LControlInstruction: public LTemplateInstruction<0, I, T> {
489 public:
490 virtual bool IsControl() const { return true; }
491
492 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
493 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
494 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
495 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
496
497 private:
498 HControlInstruction* hydrogen() {
499 return HControlInstruction::cast(this->hydrogen_value());
500 }
501};
502
503
rossberg@chromium.org2c067b12012-03-19 11:01:52 +0000504class LWrapReceiver: public LTemplateInstruction<1, 2, 0> {
505 public:
506 LWrapReceiver(LOperand* receiver, LOperand* function) {
507 inputs_[0] = receiver;
508 inputs_[1] = function;
509 }
510
511 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
512
513 LOperand* receiver() { return inputs_[0]; }
514 LOperand* function() { return inputs_[1]; }
515};
516
517
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000518class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
519 public:
520 LApplyArguments(LOperand* function,
521 LOperand* receiver,
522 LOperand* length,
523 LOperand* elements) {
524 inputs_[0] = function;
525 inputs_[1] = receiver;
526 inputs_[2] = length;
527 inputs_[3] = elements;
528 }
529
530 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
531
532 LOperand* function() { return inputs_[0]; }
533 LOperand* receiver() { return inputs_[1]; }
534 LOperand* length() { return inputs_[2]; }
535 LOperand* elements() { return inputs_[3]; }
536};
537
538
539class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
540 public:
541 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
542 inputs_[0] = arguments;
543 inputs_[1] = length;
544 inputs_[2] = index;
545 }
546
547 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
548
549 LOperand* arguments() { return inputs_[0]; }
550 LOperand* length() { return inputs_[1]; }
551 LOperand* index() { return inputs_[2]; }
552
553 virtual void PrintDataTo(StringStream* stream);
554};
555
556
557class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
558 public:
559 explicit LArgumentsLength(LOperand* elements) {
560 inputs_[0] = elements;
561 }
562
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000563 LOperand* elements() { return inputs_[0]; }
564
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000565 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
566};
567
568
569class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
570 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000571 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000572 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000573};
574
575
576class LModI: public LTemplateInstruction<1, 2, 3> {
577 public:
578 // Used when the right hand is a constant power of 2.
579 LModI(LOperand* left,
580 LOperand* right) {
581 inputs_[0] = left;
582 inputs_[1] = right;
583 temps_[0] = NULL;
584 temps_[1] = NULL;
585 temps_[2] = NULL;
586 }
587
588 // Used for the standard case.
589 LModI(LOperand* left,
590 LOperand* right,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000591 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000592 LOperand* temp2,
593 LOperand* temp3) {
594 inputs_[0] = left;
595 inputs_[1] = right;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000596 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000597 temps_[1] = temp2;
598 temps_[2] = temp3;
599 }
600
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000601 LOperand* left() { return inputs_[0]; }
602 LOperand* right() { return inputs_[1]; }
603 LOperand* temp() { return temps_[0]; }
604 LOperand* temp2() { return temps_[1]; }
605 LOperand* temp3() { return temps_[2]; }
606
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000607 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
608 DECLARE_HYDROGEN_ACCESSOR(Mod)
609};
610
611
612class LDivI: public LTemplateInstruction<1, 2, 0> {
613 public:
614 LDivI(LOperand* left, LOperand* right) {
615 inputs_[0] = left;
616 inputs_[1] = right;
617 }
618
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000619 LOperand* left() { return inputs_[0]; }
620 LOperand* right() { return inputs_[1]; }
621
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000622 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
623 DECLARE_HYDROGEN_ACCESSOR(Div)
624};
625
626
dslomov@chromium.orgb752d402013-06-18 11:54:54 +0000627class LMathFloorOfDiv: public LTemplateInstruction<1, 2, 1> {
628 public:
629 LMathFloorOfDiv(LOperand* left,
630 LOperand* right,
631 LOperand* temp = NULL) {
632 inputs_[0] = left;
633 inputs_[1] = right;
634 temps_[0] = temp;
635 }
636
637 LOperand* left() { return inputs_[0]; }
638 LOperand* right() { return inputs_[1]; }
639 LOperand* temp() { return temps_[0]; }
640
641 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv, "math-floor-of-div")
642 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
643};
644
645
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000646class LMulI: public LTemplateInstruction<1, 2, 1> {
647 public:
648 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
649 inputs_[0] = left;
650 inputs_[1] = right;
651 temps_[0] = temp;
652 }
653
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000654 LOperand* left() { return inputs_[0]; }
655 LOperand* right() { return inputs_[1]; }
656 LOperand* temp() { return temps_[0]; }
657
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000658 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
659 DECLARE_HYDROGEN_ACCESSOR(Mul)
660};
661
662
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000663// Instruction for computing multiplier * multiplicand + addend.
664class LMultiplyAddD: public LTemplateInstruction<1, 3, 0> {
665 public:
666 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
667 LOperand* multiplicand) {
668 inputs_[0] = addend;
669 inputs_[1] = multiplier;
670 inputs_[2] = multiplicand;
671 }
672
673 LOperand* addend() { return inputs_[0]; }
674 LOperand* multiplier() { return inputs_[1]; }
675 LOperand* multiplicand() { return inputs_[2]; }
676
677 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
678};
679
680
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000681class LDebugBreak: public LTemplateInstruction<0, 0, 0> {
682 public:
683 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
684};
685
686
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000687class LCmpIDAndBranch: public LControlInstruction<2, 0> {
688 public:
689 LCmpIDAndBranch(LOperand* left, LOperand* right) {
690 inputs_[0] = left;
691 inputs_[1] = right;
692 }
693
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000694 LOperand* left() { return inputs_[0]; }
695 LOperand* right() { return inputs_[1]; }
696
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000697 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
698 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
699
700 Token::Value op() const { return hydrogen()->token(); }
701 bool is_double() const {
ulan@chromium.org8e8d8822012-11-23 14:36:46 +0000702 return hydrogen()->representation().IsDouble();
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000703 }
704
705 virtual void PrintDataTo(StringStream* stream);
706};
707
708
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000709class LMathFloor: public LTemplateInstruction<1, 1, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000710 public:
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000711 LMathFloor(LOperand* value, LOperand* temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000712 inputs_[0] = value;
713 temps_[0] = temp;
714 }
715
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000716 LOperand* value() { return inputs_[0]; }
717 LOperand* temp() { return temps_[0]; }
718
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000719 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000720 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000721};
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000722
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000723
724class LMathRound: public LTemplateInstruction<1, 1, 1> {
725 public:
726 LMathRound(LOperand* value, LOperand* temp) {
727 inputs_[0] = value;
728 temps_[0] = temp;
729 }
730
731 LOperand* value() { return inputs_[0]; }
732 LOperand* temp() { return temps_[0]; }
733
734 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
735 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
736};
737
738
739class LMathAbs: public LTemplateInstruction<1, 1, 0> {
740 public:
741 explicit LMathAbs(LOperand* value) {
742 inputs_[0] = value;
743 }
744
745 LOperand* value() { return inputs_[0]; }
746
747 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
748 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
749};
750
751
752class LMathLog: public LTemplateInstruction<1, 1, 0> {
753 public:
754 explicit LMathLog(LOperand* value) {
755 inputs_[0] = value;
756 }
757
758 LOperand* value() { return inputs_[0]; }
759
760 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
761};
762
763
764class LMathSin: public LTemplateInstruction<1, 1, 0> {
765 public:
766 explicit LMathSin(LOperand* value) {
767 inputs_[0] = value;
768 }
769
770 LOperand* value() { return inputs_[0]; }
771
772 DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
773};
774
775
776class LMathCos: public LTemplateInstruction<1, 1, 0> {
777 public:
778 explicit LMathCos(LOperand* value) {
779 inputs_[0] = value;
780 }
781
782 LOperand* value() { return inputs_[0]; }
783
784 DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
785};
786
787
788class LMathTan: public LTemplateInstruction<1, 1, 0> {
789 public:
790 explicit LMathTan(LOperand* value) {
791 inputs_[0] = value;
792 }
793
794 LOperand* value() { return inputs_[0]; }
795
796 DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000797};
798
799
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000800class LMathExp: public LTemplateInstruction<1, 1, 3> {
801 public:
802 LMathExp(LOperand* value,
803 LOperand* double_temp,
804 LOperand* temp1,
805 LOperand* temp2) {
806 inputs_[0] = value;
807 temps_[0] = temp1;
808 temps_[1] = temp2;
809 temps_[2] = double_temp;
810 ExternalReference::InitializeMathExpData();
811 }
812
813 LOperand* value() { return inputs_[0]; }
814 LOperand* temp1() { return temps_[0]; }
815 LOperand* temp2() { return temps_[1]; }
816 LOperand* double_temp() { return temps_[2]; }
817
818 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000819};
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000820
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000821
822class LMathSqrt: public LTemplateInstruction<1, 1, 0> {
823 public:
824 explicit LMathSqrt(LOperand* value) {
825 inputs_[0] = value;
826 }
827
828 LOperand* value() { return inputs_[0]; }
829
830 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
831};
832
833
834class LMathPowHalf: public LTemplateInstruction<1, 1, 1> {
835 public:
836 LMathPowHalf(LOperand* value, LOperand* temp) {
837 inputs_[0] = value;
838 temps_[0] = temp;
839 }
840
841 LOperand* value() { return inputs_[0]; }
842 LOperand* temp() { return temps_[0]; }
843
844 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000845};
846
847
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000848class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
849 public:
850 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
851 inputs_[0] = left;
852 inputs_[1] = right;
853 }
854
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000855 LOperand* left() { return inputs_[0]; }
856 LOperand* right() { return inputs_[1]; }
857
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000858 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
859 "cmp-object-eq-and-branch")
860 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
861};
862
863
864class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
865 public:
866 explicit LCmpConstantEqAndBranch(LOperand* left) {
867 inputs_[0] = left;
868 }
869
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000870 LOperand* left() { return inputs_[0]; }
871
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000872 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
873 "cmp-constant-eq-and-branch")
874 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
875};
876
877
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000878class LIsObjectAndBranch: public LControlInstruction<1, 1> {
879 public:
880 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
881 inputs_[0] = value;
882 temps_[0] = temp;
883 }
884
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000885 LOperand* value() { return inputs_[0]; }
886 LOperand* temp() { return temps_[0]; }
887
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000888 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
889 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
890
891 virtual void PrintDataTo(StringStream* stream);
892};
893
894
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000895class LIsStringAndBranch: public LControlInstruction<1, 1> {
896 public:
897 LIsStringAndBranch(LOperand* value, LOperand* temp) {
898 inputs_[0] = value;
899 temps_[0] = temp;
900 }
901
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000902 LOperand* value() { return inputs_[0]; }
903 LOperand* temp() { return temps_[0]; }
904
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000905 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
906 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
907
908 virtual void PrintDataTo(StringStream* stream);
909};
910
911
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000912class LIsSmiAndBranch: public LControlInstruction<1, 0> {
913 public:
914 explicit LIsSmiAndBranch(LOperand* value) {
915 inputs_[0] = value;
916 }
917
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000918 LOperand* value() { return inputs_[0]; }
919
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000920 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
921 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
922
923 virtual void PrintDataTo(StringStream* stream);
924};
925
926
927class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
928 public:
929 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
930 inputs_[0] = value;
931 temps_[0] = temp;
932 }
933
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000934 LOperand* value() { return inputs_[0]; }
935 LOperand* temp() { return temps_[0]; }
936
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000937 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
938 "is-undetectable-and-branch")
939 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
940
941 virtual void PrintDataTo(StringStream* stream);
942};
943
944
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000945class LStringCompareAndBranch: public LControlInstruction<2, 0> {
946 public:
947 LStringCompareAndBranch(LOperand* left, LOperand* right) {
948 inputs_[0] = left;
949 inputs_[1] = right;
950 }
951
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000952 LOperand* left() { return inputs_[0]; }
953 LOperand* right() { return inputs_[1]; }
954
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000955 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
956 "string-compare-and-branch")
957 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
958
959 Token::Value op() const { return hydrogen()->token(); }
960
961 virtual void PrintDataTo(StringStream* stream);
962};
963
964
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000965class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
966 public:
967 explicit LHasInstanceTypeAndBranch(LOperand* value) {
968 inputs_[0] = value;
969 }
970
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000971 LOperand* value() { return inputs_[0]; }
972
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000973 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
974 "has-instance-type-and-branch")
975 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
976
977 virtual void PrintDataTo(StringStream* stream);
978};
979
980
981class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
982 public:
983 explicit LGetCachedArrayIndex(LOperand* value) {
984 inputs_[0] = value;
985 }
986
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000987 LOperand* value() { return inputs_[0]; }
988
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000989 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
990 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
991};
992
993
994class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
995 public:
996 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
997 inputs_[0] = value;
998 }
999
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001000 LOperand* value() { return inputs_[0]; }
1001
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001002 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1003 "has-cached-array-index-and-branch")
1004 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
1005
1006 virtual void PrintDataTo(StringStream* stream);
1007};
1008
1009
1010class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
1011 public:
1012 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
1013 inputs_[0] = value;
1014 temps_[0] = temp;
1015 }
1016
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001017 LOperand* value() { return inputs_[0]; }
1018 LOperand* temp() { return temps_[0]; }
1019
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001020 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1021 "class-of-test-and-branch")
1022 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1023
1024 virtual void PrintDataTo(StringStream* stream);
1025};
1026
1027
1028class LCmpT: public LTemplateInstruction<1, 2, 0> {
1029 public:
1030 LCmpT(LOperand* left, LOperand* right) {
1031 inputs_[0] = left;
1032 inputs_[1] = right;
1033 }
1034
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001035 LOperand* left() { return inputs_[0]; }
1036 LOperand* right() { return inputs_[1]; }
1037
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001038 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1039 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1040
1041 Token::Value op() const { return hydrogen()->token(); }
1042};
1043
1044
1045class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
1046 public:
1047 LInstanceOf(LOperand* left, LOperand* right) {
1048 inputs_[0] = left;
1049 inputs_[1] = right;
1050 }
1051
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001052 LOperand* left() { return inputs_[0]; }
1053 LOperand* right() { return inputs_[1]; }
1054
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001055 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1056};
1057
1058
1059class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
1060 public:
1061 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
1062 inputs_[0] = value;
1063 temps_[0] = temp;
1064 }
1065
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001066 LOperand* value() { return inputs_[0]; }
1067 LOperand* temp() { return temps_[0]; }
1068
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001069 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1070 "instance-of-known-global")
1071 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1072
1073 Handle<JSFunction> function() const { return hydrogen()->function(); }
danno@chromium.org1044a4d2012-04-30 12:34:39 +00001074 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1075 return lazy_deopt_env_;
1076 }
1077 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {
1078 lazy_deopt_env_ = env;
1079 }
1080
1081 private:
1082 LEnvironment* lazy_deopt_env_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001083};
1084
1085
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +00001086class LInstanceSize: public LTemplateInstruction<1, 1, 0> {
1087 public:
1088 explicit LInstanceSize(LOperand* object) {
1089 inputs_[0] = object;
1090 }
1091
1092 LOperand* object() { return inputs_[0]; }
1093
1094 DECLARE_CONCRETE_INSTRUCTION(InstanceSize, "instance-size")
1095 DECLARE_HYDROGEN_ACCESSOR(InstanceSize)
1096};
1097
1098
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001099class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
1100 public:
1101 LBoundsCheck(LOperand* index, LOperand* length) {
1102 inputs_[0] = index;
1103 inputs_[1] = length;
1104 }
1105
1106 LOperand* index() { return inputs_[0]; }
1107 LOperand* length() { return inputs_[1]; }
1108
1109 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
danno@chromium.org129d3982012-07-25 15:01:47 +00001110 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001111};
1112
1113
1114class LBitI: public LTemplateInstruction<1, 2, 0> {
1115 public:
1116 LBitI(LOperand* left, LOperand* right) {
1117 inputs_[0] = left;
1118 inputs_[1] = right;
1119 }
1120
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001121 LOperand* left() { return inputs_[0]; }
1122 LOperand* right() { return inputs_[1]; }
1123
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001124 Token::Value op() const { return hydrogen()->op(); }
1125
1126 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1127 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1128};
1129
1130
1131class LShiftI: public LTemplateInstruction<1, 2, 0> {
1132 public:
1133 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1134 : op_(op), can_deopt_(can_deopt) {
1135 inputs_[0] = left;
1136 inputs_[1] = right;
1137 }
1138
1139 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001140 LOperand* left() { return inputs_[0]; }
1141 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001142 bool can_deopt() const { return can_deopt_; }
1143
1144 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1145
1146 private:
1147 Token::Value op_;
1148 bool can_deopt_;
1149};
1150
1151
1152class LSubI: public LTemplateInstruction<1, 2, 0> {
1153 public:
1154 LSubI(LOperand* left, LOperand* right) {
1155 inputs_[0] = left;
1156 inputs_[1] = right;
1157 }
1158
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001159 LOperand* left() { return inputs_[0]; }
1160 LOperand* right() { return inputs_[1]; }
1161
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001162 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1163 DECLARE_HYDROGEN_ACCESSOR(Sub)
1164};
1165
1166
1167class LConstantI: public LTemplateInstruction<1, 0, 0> {
1168 public:
1169 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1170 DECLARE_HYDROGEN_ACCESSOR(Constant)
1171
1172 int32_t value() const { return hydrogen()->Integer32Value(); }
1173};
1174
1175
rossberg@chromium.orgb99c7542013-05-31 11:40:45 +00001176class LConstantS: public LTemplateInstruction<1, 0, 0> {
1177 public:
1178 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1179 DECLARE_HYDROGEN_ACCESSOR(Constant)
1180
1181 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1182};
1183
1184
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001185class LConstantD: public LTemplateInstruction<1, 0, 0> {
1186 public:
1187 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1188 DECLARE_HYDROGEN_ACCESSOR(Constant)
1189
1190 double value() const { return hydrogen()->DoubleValue(); }
1191};
1192
1193
1194class LConstantT: public LTemplateInstruction<1, 0, 0> {
1195 public:
1196 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1197 DECLARE_HYDROGEN_ACCESSOR(Constant)
1198
1199 Handle<Object> value() const { return hydrogen()->handle(); }
1200};
1201
1202
1203class LBranch: public LControlInstruction<1, 0> {
1204 public:
1205 explicit LBranch(LOperand* value) {
1206 inputs_[0] = value;
1207 }
1208
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001209 LOperand* value() { return inputs_[0]; }
1210
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001211 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1212 DECLARE_HYDROGEN_ACCESSOR(Branch)
1213
1214 virtual void PrintDataTo(StringStream* stream);
1215};
1216
1217
1218class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
1219 public:
1220 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1221 inputs_[0] = value;
1222 temps_[0] = temp;
1223 }
1224
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001225 LOperand* value() { return inputs_[0]; }
1226 LOperand* temp() { return temps_[0]; }
1227
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001228 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1229 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1230
1231 virtual bool IsControl() const { return true; }
1232
1233 Handle<Map> map() const { return hydrogen()->map(); }
1234 int true_block_id() const {
1235 return hydrogen()->FirstSuccessor()->block_id();
1236 }
1237 int false_block_id() const {
1238 return hydrogen()->SecondSuccessor()->block_id();
1239 }
1240};
1241
1242
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001243class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
1244 public:
1245 explicit LFixedArrayBaseLength(LOperand* value) {
1246 inputs_[0] = value;
1247 }
1248
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001249 LOperand* value() { return inputs_[0]; }
1250
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001251 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
1252 "fixed-array-base-length")
1253 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
1254};
1255
1256
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001257class LMapEnumLength: public LTemplateInstruction<1, 1, 0> {
1258 public:
1259 explicit LMapEnumLength(LOperand* value) {
1260 inputs_[0] = value;
1261 }
1262
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001263 LOperand* value() { return inputs_[0]; }
1264
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001265 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1266};
1267
1268
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001269class LElementsKind: public LTemplateInstruction<1, 1, 0> {
1270 public:
1271 explicit LElementsKind(LOperand* value) {
1272 inputs_[0] = value;
1273 }
1274
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001275 LOperand* value() { return inputs_[0]; }
1276
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001277 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1278 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1279};
1280
1281
1282class LValueOf: public LTemplateInstruction<1, 1, 1> {
1283 public:
1284 LValueOf(LOperand* value, LOperand* temp) {
1285 inputs_[0] = value;
1286 temps_[0] = temp;
1287 }
1288
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001289 LOperand* value() { return inputs_[0]; }
1290 LOperand* temp() { return temps_[0]; }
1291
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001292 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1293 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1294};
1295
1296
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001297class LDateField: public LTemplateInstruction<1, 1, 1> {
1298 public:
1299 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1300 inputs_[0] = date;
1301 temps_[0] = temp;
1302 }
1303
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001304 LOperand* date() { return inputs_[0]; }
1305 LOperand* temp() { return temps_[0]; }
1306 Smi* index() const { return index_; }
1307
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001308 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
1309 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001310
1311 private:
1312 Smi* index_;
1313};
1314
1315
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +00001316class LSeqStringSetChar: public LTemplateInstruction<1, 3, 0> {
1317 public:
1318 LSeqStringSetChar(String::Encoding encoding,
1319 LOperand* string,
1320 LOperand* index,
1321 LOperand* value) : encoding_(encoding) {
1322 inputs_[0] = string;
1323 inputs_[1] = index;
1324 inputs_[2] = value;
1325 }
1326
1327 String::Encoding encoding() { return encoding_; }
1328 LOperand* string() { return inputs_[0]; }
1329 LOperand* index() { return inputs_[1]; }
1330 LOperand* value() { return inputs_[2]; }
1331
1332 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1333 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1334
1335 private:
1336 String::Encoding encoding_;
1337};
1338
1339
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001340class LThrow: public LTemplateInstruction<0, 1, 0> {
1341 public:
1342 explicit LThrow(LOperand* value) {
1343 inputs_[0] = value;
1344 }
1345
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001346 LOperand* value() { return inputs_[0]; }
1347
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001348 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1349};
1350
1351
1352class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1353 public:
1354 explicit LBitNotI(LOperand* value) {
1355 inputs_[0] = value;
1356 }
1357
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001358 LOperand* value() { return inputs_[0]; }
1359
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001360 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1361};
1362
1363
1364class LAddI: public LTemplateInstruction<1, 2, 0> {
1365 public:
1366 LAddI(LOperand* left, LOperand* right) {
1367 inputs_[0] = left;
1368 inputs_[1] = right;
1369 }
1370
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001371 LOperand* left() { return inputs_[0]; }
1372 LOperand* right() { return inputs_[1]; }
1373
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001374 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1375 DECLARE_HYDROGEN_ACCESSOR(Add)
1376};
1377
1378
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001379class LMathMinMax: public LTemplateInstruction<1, 2, 0> {
1380 public:
1381 LMathMinMax(LOperand* left, LOperand* right) {
1382 inputs_[0] = left;
1383 inputs_[1] = right;
1384 }
1385
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001386 LOperand* left() { return inputs_[0]; }
1387 LOperand* right() { return inputs_[1]; }
1388
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +00001389 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001390 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1391};
1392
1393
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001394class LPower: public LTemplateInstruction<1, 2, 0> {
1395 public:
1396 LPower(LOperand* left, LOperand* right) {
1397 inputs_[0] = left;
1398 inputs_[1] = right;
1399 }
1400
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001401 LOperand* left() { return inputs_[0]; }
1402 LOperand* right() { return inputs_[1]; }
1403
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001404 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1405 DECLARE_HYDROGEN_ACCESSOR(Power)
1406};
1407
1408
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001409class LRandom: public LTemplateInstruction<1, 1, 0> {
1410 public:
1411 explicit LRandom(LOperand* global_object) {
1412 inputs_[0] = global_object;
1413 }
1414
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001415 LOperand* global_object() { return inputs_[0]; }
1416
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001417 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1418 DECLARE_HYDROGEN_ACCESSOR(Random)
1419};
1420
1421
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001422class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1423 public:
1424 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1425 : op_(op) {
1426 inputs_[0] = left;
1427 inputs_[1] = right;
1428 }
1429
1430 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001431 LOperand* left() { return inputs_[0]; }
1432 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001433
1434 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1435 virtual void CompileToNative(LCodeGen* generator);
1436 virtual const char* Mnemonic() const;
1437
1438 private:
1439 Token::Value op_;
1440};
1441
1442
1443class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1444 public:
1445 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1446 : op_(op) {
1447 inputs_[0] = left;
1448 inputs_[1] = right;
1449 }
1450
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001451 LOperand* left() { return inputs_[0]; }
1452 LOperand* right() { return inputs_[1]; }
1453 Token::Value op() const { return op_; }
1454
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001455 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1456 virtual void CompileToNative(LCodeGen* generator);
1457 virtual const char* Mnemonic() const;
1458
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001459 private:
1460 Token::Value op_;
1461};
1462
1463
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001464class LReturn: public LTemplateInstruction<0, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001465 public:
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001466 explicit LReturn(LOperand* value, LOperand* parameter_count) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001467 inputs_[0] = value;
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001468 inputs_[1] = parameter_count;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001469 }
1470
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001471 LOperand* value() { return inputs_[0]; }
1472
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001473 bool has_constant_parameter_count() {
1474 return parameter_count()->IsConstantOperand();
1475 }
1476 LConstantOperand* constant_parameter_count() {
1477 ASSERT(has_constant_parameter_count());
1478 return LConstantOperand::cast(parameter_count());
1479 }
1480 LOperand* parameter_count() { return inputs_[1]; }
1481
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001482 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1483};
1484
1485
1486class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1487 public:
1488 explicit LLoadNamedField(LOperand* object) {
1489 inputs_[0] = object;
1490 }
1491
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001492 LOperand* object() { return inputs_[0]; }
1493
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001494 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1495 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1496};
1497
1498
1499class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1500 public:
1501 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1502 inputs_[0] = object;
1503 }
1504
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001505 LOperand* object() { return inputs_[0]; }
1506
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001507 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1508 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001509};
1510
1511
1512class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1513 public:
1514 explicit LLoadNamedGeneric(LOperand* object) {
1515 inputs_[0] = object;
1516 }
1517
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001518 LOperand* object() { return inputs_[0]; }
1519
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001520 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1521 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1522
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001523 Handle<Object> name() const { return hydrogen()->name(); }
1524};
1525
1526
1527class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1528 public:
1529 explicit LLoadFunctionPrototype(LOperand* function) {
1530 inputs_[0] = function;
1531 }
1532
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001533 LOperand* function() { return inputs_[0]; }
1534
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001535 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1536 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001537};
1538
1539
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001540class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1541 public:
1542 explicit LLoadExternalArrayPointer(LOperand* object) {
1543 inputs_[0] = object;
1544 }
1545
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001546 LOperand* object() { return inputs_[0]; }
1547
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001548 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1549 "load-external-array-pointer")
1550};
1551
1552
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001553class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001554 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001555 LLoadKeyed(LOperand* elements, LOperand* key) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001556 inputs_[0] = elements;
1557 inputs_[1] = key;
1558 }
1559
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001560 LOperand* elements() { return inputs_[0]; }
1561 LOperand* key() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001562 ElementsKind elements_kind() const {
1563 return hydrogen()->elements_kind();
1564 }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001565 bool is_external() const {
1566 return hydrogen()->is_external();
1567 }
1568
1569 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1570 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1571
ulan@chromium.org8e8d8822012-11-23 14:36:46 +00001572 virtual void PrintDataTo(StringStream* stream);
jkummerow@chromium.org777db6f2012-05-24 09:33:09 +00001573 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001574};
1575
1576
1577class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1578 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001579 LLoadKeyedGeneric(LOperand* object, LOperand* key) {
1580 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001581 inputs_[1] = key;
1582 }
1583
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001584 LOperand* object() { return inputs_[0]; }
1585 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001586
1587 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001588};
1589
1590
1591class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1592 public:
1593 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1594 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1595};
1596
1597
1598class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1599 public:
1600 explicit LLoadGlobalGeneric(LOperand* global_object) {
1601 inputs_[0] = global_object;
1602 }
1603
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001604 LOperand* global_object() { return inputs_[0]; }
1605
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001606 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1607 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1608
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001609 Handle<Object> name() const { return hydrogen()->name(); }
1610 bool for_typeof() const { return hydrogen()->for_typeof(); }
1611};
1612
1613
1614class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1615 public:
1616 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1617 inputs_[0] = value;
1618 temps_[0] = temp;
1619 }
1620
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001621 LOperand* value() { return inputs_[0]; }
1622 LOperand* temp() { return temps_[0]; }
1623
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001624 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1625 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1626};
1627
1628
1629class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1630 public:
1631 explicit LStoreGlobalGeneric(LOperand* global_object,
1632 LOperand* value) {
1633 inputs_[0] = global_object;
1634 inputs_[1] = value;
1635 }
1636
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001637 LOperand* global_object() { return inputs_[0]; }
1638 LOperand* value() { return inputs_[1]; }
1639
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001640 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1641 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1642
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001643 Handle<Object> name() const { return hydrogen()->name(); }
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001644 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001645};
1646
1647
1648class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1649 public:
1650 explicit LLoadContextSlot(LOperand* context) {
1651 inputs_[0] = context;
1652 }
1653
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001654 LOperand* context() { return inputs_[0]; }
1655
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001656 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1657 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1658
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001659 int slot_index() { return hydrogen()->slot_index(); }
1660
1661 virtual void PrintDataTo(StringStream* stream);
1662};
1663
1664
1665class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1666 public:
1667 LStoreContextSlot(LOperand* context, LOperand* value) {
1668 inputs_[0] = context;
1669 inputs_[1] = value;
1670 }
1671
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001672 LOperand* context() { return inputs_[0]; }
1673 LOperand* value() { return inputs_[1]; }
1674
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001675 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1676 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1677
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001678 int slot_index() { return hydrogen()->slot_index(); }
1679
1680 virtual void PrintDataTo(StringStream* stream);
1681};
1682
1683
1684class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1685 public:
1686 explicit LPushArgument(LOperand* value) {
1687 inputs_[0] = value;
1688 }
1689
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001690 LOperand* value() { return inputs_[0]; }
1691
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001692 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1693};
1694
1695
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00001696class LDrop: public LTemplateInstruction<0, 0, 0> {
1697 public:
1698 explicit LDrop(int count) : count_(count) { }
1699
1700 int count() const { return count_; }
1701
1702 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1703
1704 private:
1705 int count_;
1706};
1707
1708
jkummerow@chromium.org4c54a2a2013-03-19 17:51:30 +00001709class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
1710 public:
1711 explicit LInnerAllocatedObject(LOperand* base_object) {
1712 inputs_[0] = base_object;
1713 }
1714
1715 LOperand* base_object() { return inputs_[0]; }
1716 int offset() { return hydrogen()->offset(); }
1717
1718 virtual void PrintDataTo(StringStream* stream);
1719
1720 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
1721 DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
1722};
1723
1724
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001725class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1726 public:
1727 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1728 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1729};
1730
1731
1732class LContext: public LTemplateInstruction<1, 0, 0> {
1733 public:
1734 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00001735 DECLARE_HYDROGEN_ACCESSOR(Context)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001736};
1737
1738
1739class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1740 public:
1741 explicit LOuterContext(LOperand* context) {
1742 inputs_[0] = context;
1743 }
1744
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001745 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001746
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001747 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001748};
1749
1750
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001751class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> {
1752 public:
1753 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1754 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1755};
1756
1757
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001758class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1759 public:
1760 explicit LGlobalObject(LOperand* context) {
1761 inputs_[0] = context;
1762 }
1763
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001764 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001765
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001766 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001767};
1768
1769
1770class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1771 public:
1772 explicit LGlobalReceiver(LOperand* global_object) {
1773 inputs_[0] = global_object;
1774 }
1775
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001776 LOperand* global_object() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001777
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001778 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001779};
1780
1781
1782class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1783 public:
1784 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1785 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1786
1787 virtual void PrintDataTo(StringStream* stream);
1788
1789 Handle<JSFunction> function() { return hydrogen()->function(); }
1790 int arity() const { return hydrogen()->argument_count() - 1; }
1791};
1792
1793
1794class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1795 public:
1796 explicit LInvokeFunction(LOperand* function) {
1797 inputs_[0] = function;
1798 }
1799
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001800 LOperand* function() { return inputs_[0]; }
1801
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001802 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1803 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1804
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001805 virtual void PrintDataTo(StringStream* stream);
1806
1807 int arity() const { return hydrogen()->argument_count() - 1; }
1808};
1809
1810
1811class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1812 public:
1813 explicit LCallKeyed(LOperand* key) {
1814 inputs_[0] = key;
1815 }
1816
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001817 LOperand* key() { return inputs_[0]; }
1818
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001819 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1820 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1821
1822 virtual void PrintDataTo(StringStream* stream);
1823
1824 int arity() const { return hydrogen()->argument_count() - 1; }
1825};
1826
1827
1828
1829class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1830 public:
1831 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1832 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1833
1834 virtual void PrintDataTo(StringStream* stream);
1835
1836 Handle<String> name() const { return hydrogen()->name(); }
1837 int arity() const { return hydrogen()->argument_count() - 1; }
1838};
1839
1840
danno@chromium.orgc612e022011-11-10 11:38:15 +00001841class LCallFunction: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001842 public:
danno@chromium.orgc612e022011-11-10 11:38:15 +00001843 explicit LCallFunction(LOperand* function) {
1844 inputs_[0] = function;
1845 }
1846
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001847 LOperand* function() { return inputs_[0]; }
1848
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001849 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1850 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1851
danno@chromium.orgc612e022011-11-10 11:38:15 +00001852 int arity() const { return hydrogen()->argument_count() - 1; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001853};
1854
1855
1856class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1857 public:
1858 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1859 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1860
1861 virtual void PrintDataTo(StringStream* stream);
1862
1863 Handle<String> name() const {return hydrogen()->name(); }
1864 int arity() const { return hydrogen()->argument_count() - 1; }
1865};
1866
1867
1868class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1869 public:
1870 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1871 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1872
1873 virtual void PrintDataTo(StringStream* stream);
1874
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001875 int arity() const { return hydrogen()->argument_count() - 1; }
1876};
1877
1878
1879class LCallNew: public LTemplateInstruction<1, 1, 0> {
1880 public:
1881 explicit LCallNew(LOperand* constructor) {
1882 inputs_[0] = constructor;
1883 }
1884
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001885 LOperand* constructor() { return inputs_[0]; }
1886
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001887 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1888 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1889
1890 virtual void PrintDataTo(StringStream* stream);
1891
1892 int arity() const { return hydrogen()->argument_count() - 1; }
1893};
1894
1895
ulan@chromium.org750145a2013-03-07 15:14:13 +00001896class LCallNewArray: public LTemplateInstruction<1, 1, 0> {
1897 public:
1898 explicit LCallNewArray(LOperand* constructor) {
1899 inputs_[0] = constructor;
1900 }
1901
1902 LOperand* constructor() { return inputs_[0]; }
1903
1904 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1905 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1906
1907 virtual void PrintDataTo(StringStream* stream);
1908
1909 int arity() const { return hydrogen()->argument_count() - 1; }
1910};
1911
1912
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001913class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1914 public:
1915 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1916 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1917
1918 const Runtime::Function* function() const { return hydrogen()->function(); }
1919 int arity() const { return hydrogen()->argument_count(); }
1920};
1921
1922
1923class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1924 public:
1925 explicit LInteger32ToDouble(LOperand* value) {
1926 inputs_[0] = value;
1927 }
1928
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001929 LOperand* value() { return inputs_[0]; }
1930
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001931 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1932};
1933
1934
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00001935class LInteger32ToSmi: public LTemplateInstruction<1, 1, 0> {
1936 public:
1937 explicit LInteger32ToSmi(LOperand* value) {
1938 inputs_[0] = value;
1939 }
1940
1941 LOperand* value() { return inputs_[0]; }
1942
1943 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1944 DECLARE_HYDROGEN_ACCESSOR(Change)
1945};
1946
1947
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001948class LUint32ToDouble: public LTemplateInstruction<1, 1, 0> {
1949 public:
1950 explicit LUint32ToDouble(LOperand* value) {
1951 inputs_[0] = value;
1952 }
1953
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001954 LOperand* value() { return inputs_[0]; }
1955
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001956 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1957};
1958
1959
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001960class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1961 public:
1962 explicit LNumberTagI(LOperand* value) {
1963 inputs_[0] = value;
1964 }
1965
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001966 LOperand* value() { return inputs_[0]; }
1967
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001968 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1969};
1970
1971
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001972class LNumberTagU: public LTemplateInstruction<1, 1, 0> {
1973 public:
1974 explicit LNumberTagU(LOperand* value) {
1975 inputs_[0] = value;
1976 }
1977
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001978 LOperand* value() { return inputs_[0]; }
1979
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001980 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1981};
1982
1983
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001984class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1985 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001986 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001987 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001988 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001989 temps_[1] = temp2;
1990 }
1991
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001992 LOperand* value() { return inputs_[0]; }
1993 LOperand* temp() { return temps_[0]; }
1994 LOperand* temp2() { return temps_[1]; }
1995
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001996 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00001997 DECLARE_HYDROGEN_ACCESSOR(Change)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001998};
1999
2000
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00002001class LDoubleToSmi: public LTemplateInstruction<1, 1, 2> {
2002 public:
2003 LDoubleToSmi(LOperand* value, LOperand* temp, LOperand* temp2) {
2004 inputs_[0] = value;
2005 temps_[0] = temp;
2006 temps_[1] = temp2;
2007 }
2008
2009 LOperand* value() { return inputs_[0]; }
2010 LOperand* temp() { return temps_[0]; }
2011 LOperand* temp2() { return temps_[1]; }
2012
2013 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2014 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2015
2016 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2017};
2018
2019
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002020// Sometimes truncating conversion from a tagged value to an int32.
2021class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
2022 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002023 LDoubleToI(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002024 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002025 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002026 temps_[1] = temp2;
2027 }
2028
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002029 LOperand* value() { return inputs_[0]; }
2030 LOperand* temp() { return temps_[0]; }
2031 LOperand* temp2() { return temps_[1]; }
2032
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002033 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2034 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2035
2036 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2037};
2038
2039
2040// Truncating conversion from a tagged value to an int32.
2041class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
2042 public:
2043 LTaggedToI(LOperand* value,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002044 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002045 LOperand* temp2,
2046 LOperand* temp3) {
2047 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002048 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002049 temps_[1] = temp2;
2050 temps_[2] = temp3;
2051 }
2052
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002053 LOperand* value() { return inputs_[0]; }
2054 LOperand* temp() { return temps_[0]; }
2055 LOperand* temp2() { return temps_[1]; }
2056 LOperand* temp3() { return temps_[2]; }
2057
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002058 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2059 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2060
2061 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2062};
2063
2064
2065class LSmiTag: public LTemplateInstruction<1, 1, 0> {
2066 public:
2067 explicit LSmiTag(LOperand* value) {
2068 inputs_[0] = value;
2069 }
2070
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002071 LOperand* value() { return inputs_[0]; }
2072
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002073 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2074};
2075
2076
2077class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
2078 public:
2079 explicit LNumberUntagD(LOperand* value) {
2080 inputs_[0] = value;
2081 }
2082
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002083 LOperand* value() { return inputs_[0]; }
2084
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002085 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2086 DECLARE_HYDROGEN_ACCESSOR(Change)
2087};
2088
2089
2090class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
2091 public:
2092 LSmiUntag(LOperand* value, bool needs_check)
2093 : needs_check_(needs_check) {
2094 inputs_[0] = value;
2095 }
2096
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002097 LOperand* value() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002098 bool needs_check() const { return needs_check_; }
2099
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002100 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2101
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002102 private:
2103 bool needs_check_;
2104};
2105
2106
verwaest@chromium.org37141392012-05-31 13:27:02 +00002107class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002108 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002109 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2110 inputs_[0] = object;
2111 inputs_[1] = value;
verwaest@chromium.org37141392012-05-31 13:27:02 +00002112 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002113 }
2114
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002115 LOperand* object() { return inputs_[0]; }
2116 LOperand* value() { return inputs_[1]; }
2117 LOperand* temp() { return temps_[0]; }
2118
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002119 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2120 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2121
2122 virtual void PrintDataTo(StringStream* stream);
2123
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002124 Handle<Map> transition() const { return hydrogen()->transition(); }
danno@chromium.orgf005df62013-04-30 16:36:45 +00002125 Representation representation() const {
2126 return hydrogen()->field_representation();
2127 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002128};
2129
2130
2131class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
2132 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002133 LStoreNamedGeneric(LOperand* object, LOperand* value) {
2134 inputs_[0] = object;
2135 inputs_[1] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002136 }
2137
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002138 LOperand* object() { return inputs_[0]; }
2139 LOperand* value() { return inputs_[1]; }
2140
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002141 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2142 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2143
2144 virtual void PrintDataTo(StringStream* stream);
2145
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002146 Handle<Object> name() const { return hydrogen()->name(); }
2147 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002148};
2149
2150
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002151class LStoreKeyed: public LTemplateInstruction<0, 3, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002152 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002153 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002154 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002155 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002156 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002157 }
2158
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002159 bool is_external() const { return hydrogen()->is_external(); }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002160 LOperand* elements() { return inputs_[0]; }
2161 LOperand* key() { return inputs_[1]; }
2162 LOperand* value() { return inputs_[2]; }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002163 ElementsKind elements_kind() const {
2164 return hydrogen()->elements_kind();
2165 }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002166
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002167 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2168 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002169
2170 virtual void PrintDataTo(StringStream* stream);
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00002171 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002172 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002173};
2174
2175
2176class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
2177 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002178 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002179 inputs_[0] = obj;
2180 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002181 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002182 }
2183
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002184 LOperand* object() { return inputs_[0]; }
2185 LOperand* key() { return inputs_[1]; }
2186 LOperand* value() { return inputs_[2]; }
2187
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002188 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2189 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2190
2191 virtual void PrintDataTo(StringStream* stream);
2192
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00002193 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002194};
2195
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002196
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +00002197class LTransitionElementsKind: public LTemplateInstruction<0, 1, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002198 public:
2199 LTransitionElementsKind(LOperand* object,
2200 LOperand* new_map_temp,
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002201 LOperand* fixed_object_temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002202 inputs_[0] = object;
2203 temps_[0] = new_map_temp;
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002204 temps_[1] = fixed_object_temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002205 }
2206
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002207 LOperand* object() { return inputs_[0]; }
2208 LOperand* new_map_temp() { return temps_[0]; }
2209 LOperand* temp() { return temps_[1]; }
2210
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002211 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2212 "transition-elements-kind")
2213 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2214
2215 virtual void PrintDataTo(StringStream* stream);
2216
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002217 Handle<Map> original_map() { return hydrogen()->original_map(); }
2218 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002219 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2220 ElementsKind to_kind() { return hydrogen()->to_kind(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002221};
2222
2223
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002224class LTrapAllocationMemento : public LTemplateInstruction<0, 1, 1> {
2225 public:
2226 LTrapAllocationMemento(LOperand* object,
2227 LOperand* temp) {
2228 inputs_[0] = object;
2229 temps_[0] = temp;
2230 }
2231
2232 LOperand* object() { return inputs_[0]; }
2233 LOperand* temp() { return temps_[0]; }
2234
2235 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2236 "trap-allocation-memento")
2237};
2238
2239
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002240class LStringAdd: public LTemplateInstruction<1, 2, 0> {
2241 public:
2242 LStringAdd(LOperand* left, LOperand* right) {
2243 inputs_[0] = left;
2244 inputs_[1] = right;
2245 }
2246
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002247 LOperand* left() { return inputs_[0]; }
2248 LOperand* right() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002249
2250 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2251 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002252};
2253
2254
2255
2256class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
2257 public:
2258 LStringCharCodeAt(LOperand* string, LOperand* index) {
2259 inputs_[0] = string;
2260 inputs_[1] = index;
2261 }
2262
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002263 LOperand* string() { return inputs_[0]; }
2264 LOperand* index() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002265
2266 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2267 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002268};
2269
2270
2271class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
2272 public:
2273 explicit LStringCharFromCode(LOperand* char_code) {
2274 inputs_[0] = char_code;
2275 }
2276
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002277 LOperand* char_code() { return inputs_[0]; }
2278
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002279 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2280 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002281};
2282
2283
2284class LStringLength: public LTemplateInstruction<1, 1, 0> {
2285 public:
2286 explicit LStringLength(LOperand* string) {
2287 inputs_[0] = string;
2288 }
2289
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002290 LOperand* string() { return inputs_[0]; }
2291
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002292 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
2293 DECLARE_HYDROGEN_ACCESSOR(StringLength)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002294};
2295
2296
2297class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
2298 public:
2299 explicit LCheckFunction(LOperand* value) {
2300 inputs_[0] = value;
2301 }
2302
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002303 LOperand* value() { return inputs_[0]; }
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00002304
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002305 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
2306 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
2307};
2308
2309
2310class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
2311 public:
2312 explicit LCheckInstanceType(LOperand* value) {
2313 inputs_[0] = value;
2314 }
2315
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002316 LOperand* value() { return inputs_[0]; }
2317
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002318 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2319 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2320};
2321
2322
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002323class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002324 public:
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002325 explicit LCheckMaps(LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002326 inputs_[0] = value;
2327 }
2328
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002329 LOperand* value() { return inputs_[0]; }
2330
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002331 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2332 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002333};
2334
2335
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +00002336class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002337 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002338 LCheckPrototypeMaps(LOperand* temp, LOperand* temp2) {
2339 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002340 temps_[1] = temp2;
2341 }
2342
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002343 LOperand* temp() { return temps_[0]; }
2344 LOperand* temp2() { return temps_[1]; }
2345
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002346 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
2347 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
2348
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002349 ZoneList<Handle<JSObject> >* prototypes() const {
2350 return hydrogen()->prototypes();
2351 }
2352 ZoneList<Handle<Map> >* maps() const { return hydrogen()->maps(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002353};
2354
2355
jkummerow@chromium.orgc1184022013-05-28 16:58:15 +00002356class LCheckSmi: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002357 public:
2358 explicit LCheckSmi(LOperand* value) {
2359 inputs_[0] = value;
2360 }
2361
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002362 LOperand* value() { return inputs_[0]; }
2363
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002364 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2365};
2366
2367
2368class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2369 public:
2370 explicit LCheckNonSmi(LOperand* value) {
2371 inputs_[0] = value;
2372 }
2373
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002374 LOperand* value() { return inputs_[0]; }
2375
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002376 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2377};
2378
2379
2380class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
2381 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002382 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2383 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002384 temps_[0] = temp;
2385 }
2386
2387 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002388 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002389
2390 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2391};
2392
2393
2394class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
2395 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002396 explicit LClampIToUint8(LOperand* unclamped) {
2397 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002398 }
2399
2400 LOperand* unclamped() { return inputs_[0]; }
2401
2402 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2403};
2404
2405
2406class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2407 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002408 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2409 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002410 temps_[0] = temp;
2411 }
2412
2413 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002414 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002415
2416 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2417};
2418
2419
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002420class LAllocate: public LTemplateInstruction<1, 2, 2> {
2421 public:
2422 LAllocate(LOperand* size, LOperand* temp1, LOperand* temp2) {
2423 inputs_[1] = size;
2424 temps_[0] = temp1;
2425 temps_[1] = temp2;
2426 }
2427
2428 LOperand* size() { return inputs_[1]; }
2429 LOperand* temp1() { return temps_[0]; }
2430 LOperand* temp2() { return temps_[1]; }
2431
2432 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2433 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2434};
2435
2436
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002437class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
2438 public:
2439 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2440 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2441};
2442
2443
2444class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
2445 public:
2446 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2447 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002448};
2449
2450
2451class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2452 public:
2453 explicit LToFastProperties(LOperand* value) {
2454 inputs_[0] = value;
2455 }
2456
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002457 LOperand* value() { return inputs_[0]; }
2458
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002459 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2460 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2461};
2462
2463
2464class LTypeof: public LTemplateInstruction<1, 1, 0> {
2465 public:
2466 explicit LTypeof(LOperand* value) {
2467 inputs_[0] = value;
2468 }
2469
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002470 LOperand* value() { return inputs_[0]; }
2471
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002472 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2473};
2474
2475
2476class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2477 public:
2478 explicit LTypeofIsAndBranch(LOperand* value) {
2479 inputs_[0] = value;
2480 }
2481
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002482 LOperand* value() { return inputs_[0]; }
2483
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002484 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2485 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2486
2487 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2488
2489 virtual void PrintDataTo(StringStream* stream);
2490};
2491
2492
2493class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
2494 public:
2495 explicit LIsConstructCallAndBranch(LOperand* temp) {
2496 temps_[0] = temp;
2497 }
2498
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002499 LOperand* temp() { return temps_[0]; }
2500
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002501 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2502 "is-construct-call-and-branch")
2503};
2504
2505
2506class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
2507 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002508 LDeleteProperty(LOperand* object, LOperand* key) {
2509 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002510 inputs_[1] = key;
2511 }
2512
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002513 LOperand* object() { return inputs_[0]; }
2514 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002515
2516 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002517};
2518
2519
2520class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2521 public:
2522 LOsrEntry();
2523
ulan@chromium.org32d7dba2013-04-24 10:59:06 +00002524 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002525 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2526
2527 LOperand** SpilledRegisterArray() { return register_spills_; }
2528 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2529
2530 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2531 void MarkSpilledDoubleRegister(int allocation_index,
2532 LOperand* spill_operand);
2533
2534 private:
2535 // Arrays of spill slot operands for registers with an assigned spill
2536 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2537 // NULL if the register has no assigned spill slot. Indexed by allocation
2538 // index.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002539 LOperand* register_spills_[Register::kMaxNumAllocatableRegisters];
2540 LOperand* double_register_spills_[
2541 DoubleRegister::kMaxNumAllocatableRegisters];
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002542};
2543
2544
2545class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2546 public:
2547 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2548 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2549
2550 Label* done_label() { return &done_label_; }
2551
2552 private:
2553 Label done_label_;
2554};
2555
2556
2557class LIn: public LTemplateInstruction<1, 2, 0> {
2558 public:
2559 LIn(LOperand* key, LOperand* object) {
2560 inputs_[0] = key;
2561 inputs_[1] = object;
2562 }
2563
2564 LOperand* key() { return inputs_[0]; }
2565 LOperand* object() { return inputs_[1]; }
2566
2567 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2568};
2569
2570
ulan@chromium.org812308e2012-02-29 15:58:45 +00002571class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> {
2572 public:
2573 explicit LForInPrepareMap(LOperand* object) {
2574 inputs_[0] = object;
2575 }
2576
2577 LOperand* object() { return inputs_[0]; }
2578
2579 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2580};
2581
2582
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002583class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002584 public:
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002585 explicit LForInCacheArray(LOperand* map) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002586 inputs_[0] = map;
2587 }
2588
2589 LOperand* map() { return inputs_[0]; }
2590
2591 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2592
2593 int idx() {
2594 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2595 }
2596};
2597
2598
2599class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2600 public:
2601 LCheckMapValue(LOperand* value, LOperand* map) {
2602 inputs_[0] = value;
2603 inputs_[1] = map;
2604 }
2605
2606 LOperand* value() { return inputs_[0]; }
2607 LOperand* map() { return inputs_[1]; }
2608
2609 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2610};
2611
2612
2613class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2614 public:
2615 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2616 inputs_[0] = object;
2617 inputs_[1] = index;
2618 }
2619
2620 LOperand* object() { return inputs_[0]; }
2621 LOperand* index() { return inputs_[1]; }
2622
2623 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2624};
2625
2626
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002627class LChunkBuilder;
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002628class LPlatformChunk: public LChunk {
lrn@chromium.org7516f052011-03-30 08:52:27 +00002629 public:
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002630 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2631 : LChunk(info, graph) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002632
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002633 int GetNextSpillIndex(bool is_double);
2634 LOperand* GetNextSpillSlot(bool is_double);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002635};
2636
2637
2638class LChunkBuilder BASE_EMBEDDED {
2639 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002640 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2641 : chunk_(NULL),
2642 info_(info),
2643 graph_(graph),
mmassi@chromium.org7028c052012-06-13 11:51:58 +00002644 zone_(graph->zone()),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002645 status_(UNUSED),
2646 current_instruction_(NULL),
2647 current_block_(NULL),
2648 next_block_(NULL),
2649 argument_count_(0),
2650 allocator_(allocator),
2651 position_(RelocInfo::kNoPosition),
2652 instruction_pending_deoptimization_environment_(NULL),
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002653 pending_deoptimization_ast_id_(BailoutId::None()) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002654
2655 // Build the sequence for the graph.
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002656 LPlatformChunk* Build();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002657
2658 // Declare methods that deal with the individual node types.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002659#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002660 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2661#undef DECLARE_DO
2662
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002663 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2664
dslomov@chromium.orgb752d402013-06-18 11:54:54 +00002665 static bool HasMagicNumberForDivisor(int32_t divisor);
2666 static HValue* SimplifiedDivisorForMathFloorOfDiv(HValue* val);
2667
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +00002668 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2669 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2670 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2671 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2672 LInstruction* DoMathSin(HUnaryMathOperation* instr);
2673 LInstruction* DoMathCos(HUnaryMathOperation* instr);
2674 LInstruction* DoMathTan(HUnaryMathOperation* instr);
2675 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2676 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2677 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2678
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002679 private:
2680 enum Status {
2681 UNUSED,
2682 BUILDING,
2683 DONE,
2684 ABORTED
2685 };
2686
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002687 LPlatformChunk* chunk() const { return chunk_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002688 CompilationInfo* info() const { return info_; }
2689 HGraph* graph() const { return graph_; }
ulan@chromium.org812308e2012-02-29 15:58:45 +00002690 Zone* zone() const { return zone_; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002691
2692 bool is_unused() const { return status_ == UNUSED; }
2693 bool is_building() const { return status_ == BUILDING; }
2694 bool is_done() const { return status_ == DONE; }
2695 bool is_aborted() const { return status_ == ABORTED; }
2696
yangguo@chromium.org46839fb2012-08-28 09:06:19 +00002697 void Abort(const char* reason);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002698
2699 // Methods for getting operands for Use / Define / Temp.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002700 LUnallocated* ToUnallocated(Register reg);
2701 LUnallocated* ToUnallocated(DoubleRegister reg);
2702
2703 // Methods for setting up define-use relationships.
2704 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2705 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2706 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2707 DoubleRegister fixed_register);
2708
2709 // A value that is guaranteed to be allocated to a register.
2710 // Operand created by UseRegister is guaranteed to be live until the end of
2711 // instruction. This means that register allocator will not reuse it's
2712 // register for any other operand inside instruction.
2713 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2714 // instruction start. Register allocator is free to assign the same register
2715 // to some other operand used inside instruction (i.e. temporary or
2716 // output).
2717 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2718 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2719
2720 // An input operand in a register that may be trashed.
2721 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2722
2723 // An input operand in a register or stack slot.
2724 MUST_USE_RESULT LOperand* Use(HValue* value);
2725 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2726
2727 // An input operand in a register, stack slot or a constant operand.
2728 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2729 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2730
2731 // An input operand in a register or a constant operand.
2732 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2733 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2734
danno@chromium.orgf005df62013-04-30 16:36:45 +00002735 // An input operand in a constant operand.
2736 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2737
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002738 // An input operand in register, stack slot or a constant operand.
2739 // Will not be moved to a register even if one is freely available.
2740 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2741
2742 // Temporary operand that must be in a register.
2743 MUST_USE_RESULT LUnallocated* TempRegister();
2744 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2745 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2746
2747 // Methods for setting up define-use relationships.
2748 // Return the same instruction that they are passed.
2749 template<int I, int T>
2750 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2751 LUnallocated* result);
2752 template<int I, int T>
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002753 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2754 template<int I, int T>
2755 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2756 int index);
2757 template<int I, int T>
2758 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2759 template<int I, int T>
2760 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2761 Register reg);
2762 template<int I, int T>
2763 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2764 DoubleRegister reg);
2765 LInstruction* AssignEnvironment(LInstruction* instr);
2766 LInstruction* AssignPointerMap(LInstruction* instr);
2767
2768 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2769
2770 // By default we assume that instruction sequences generated for calls
2771 // cannot deoptimize eagerly and we do not attach environment to this
2772 // instruction.
2773 LInstruction* MarkAsCall(
2774 LInstruction* instr,
2775 HInstruction* hinstr,
2776 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002777
2778 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2779 int* argument_index_accumulator);
2780
2781 void VisitInstruction(HInstruction* current);
2782
2783 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2784 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2785 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2786 LInstruction* DoArithmeticD(Token::Value op,
2787 HArithmeticBinaryOperation* instr);
2788 LInstruction* DoArithmeticT(Token::Value op,
2789 HArithmeticBinaryOperation* instr);
2790
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002791 LPlatformChunk* chunk_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002792 CompilationInfo* info_;
2793 HGraph* const graph_;
ulan@chromium.org812308e2012-02-29 15:58:45 +00002794 Zone* zone_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002795 Status status_;
2796 HInstruction* current_instruction_;
2797 HBasicBlock* current_block_;
2798 HBasicBlock* next_block_;
2799 int argument_count_;
2800 LAllocator* allocator_;
2801 int position_;
2802 LInstruction* instruction_pending_deoptimization_environment_;
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002803 BailoutId pending_deoptimization_ast_id_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002804
lrn@chromium.org7516f052011-03-30 08:52:27 +00002805 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2806};
2807
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002808#undef DECLARE_HYDROGEN_ACCESSOR
2809#undef DECLARE_CONCRETE_INSTRUCTION
lrn@chromium.org7516f052011-03-30 08:52:27 +00002810
2811} } // namespace v8::internal
2812
2813#endif // V8_MIPS_LITHIUM_MIPS_H_