blob: 3156722d869200baefb68cfe75dce9a6dfc672ff [file] [log] [blame]
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001// Copyright 2012 the V8 project authors. All rights reserved.
lrn@chromium.org7516f052011-03-30 08:52:27 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_MIPS_LITHIUM_MIPS_H_
29#define V8_MIPS_LITHIUM_MIPS_H_
30
31#include "hydrogen.h"
32#include "lithium-allocator.h"
33#include "lithium.h"
34#include "safepoint-table.h"
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000035#include "utils.h"
lrn@chromium.org7516f052011-03-30 08:52:27 +000036
37namespace v8 {
38namespace internal {
39
40// Forward declarations.
41class LCodeGen;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000042
43#define LITHIUM_ALL_INSTRUCTION_LIST(V) \
44 V(ControlInstruction) \
45 V(Call) \
46 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
47
48
49#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
50 V(AccessArgumentsAt) \
51 V(AddI) \
ulan@chromium.org967e2702012-02-28 09:49:15 +000052 V(AllocateObject) \
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +000053 V(Allocate) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000054 V(ApplyArguments) \
55 V(ArgumentsElements) \
56 V(ArgumentsLength) \
57 V(ArithmeticD) \
58 V(ArithmeticT) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000059 V(BitI) \
60 V(BitNotI) \
61 V(BoundsCheck) \
62 V(Branch) \
63 V(CallConstantFunction) \
64 V(CallFunction) \
65 V(CallGlobal) \
66 V(CallKeyed) \
67 V(CallKnownGlobal) \
68 V(CallNamed) \
69 V(CallNew) \
ulan@chromium.org750145a2013-03-07 15:14:13 +000070 V(CallNewArray) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000071 V(CallRuntime) \
72 V(CallStub) \
73 V(CheckFunction) \
74 V(CheckInstanceType) \
jkummerow@chromium.org1456e702012-03-30 08:38:13 +000075 V(CheckMaps) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000076 V(CheckNonSmi) \
77 V(CheckPrototypeMaps) \
78 V(CheckSmi) \
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +000079 V(CheckSmiAndReturn) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000080 V(ClampDToUint8) \
81 V(ClampIToUint8) \
82 V(ClampTToUint8) \
83 V(ClassOfTestAndBranch) \
84 V(CmpConstantEqAndBranch) \
85 V(CmpIDAndBranch) \
86 V(CmpObjectEqAndBranch) \
87 V(CmpMapAndBranch) \
88 V(CmpT) \
89 V(ConstantD) \
90 V(ConstantI) \
91 V(ConstantT) \
92 V(Context) \
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +000093 V(DebugBreak) \
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +000094 V(DeclareGlobals) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +000095 V(DeleteProperty) \
96 V(Deoptimize) \
97 V(DivI) \
98 V(DoubleToI) \
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +000099 V(DoubleToSmi) \
yangguo@chromium.org46a2a512013-01-18 16:29:40 +0000100 V(DummyUse) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000101 V(ElementsKind) \
102 V(FixedArrayBaseLength) \
103 V(FunctionLiteral) \
104 V(GetCachedArrayIndex) \
105 V(GlobalObject) \
106 V(GlobalReceiver) \
107 V(Goto) \
108 V(HasCachedArrayIndexAndBranch) \
109 V(HasInstanceTypeAndBranch) \
110 V(In) \
111 V(InstanceOf) \
112 V(InstanceOfKnownGlobal) \
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000113 V(InstanceSize) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000114 V(InstructionGap) \
115 V(Integer32ToDouble) \
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +0000116 V(Integer32ToSmi) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000117 V(Uint32ToDouble) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000118 V(InvokeFunction) \
119 V(IsConstructCallAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000120 V(IsObjectAndBranch) \
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000121 V(IsStringAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000122 V(IsSmiAndBranch) \
123 V(IsUndetectableAndBranch) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000124 V(Label) \
125 V(LazyBailout) \
126 V(LoadContextSlot) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000127 V(LoadExternalArrayPointer) \
128 V(LoadFunctionPrototype) \
129 V(LoadGlobalCell) \
130 V(LoadGlobalGeneric) \
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +0000131 V(LoadKeyed) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000132 V(LoadKeyedGeneric) \
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000133 V(LoadNamedField) \
134 V(LoadNamedFieldPolymorphic) \
135 V(LoadNamedGeneric) \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +0000136 V(MapEnumLength) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000137 V(MathAbs) \
138 V(MathCos) \
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000139 V(MathExp) \
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000140 V(MathFloor) \
141 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
627class LMulI: public LTemplateInstruction<1, 2, 1> {
628 public:
629 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
630 inputs_[0] = left;
631 inputs_[1] = right;
632 temps_[0] = temp;
633 }
634
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000635 LOperand* left() { return inputs_[0]; }
636 LOperand* right() { return inputs_[1]; }
637 LOperand* temp() { return temps_[0]; }
638
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000639 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
640 DECLARE_HYDROGEN_ACCESSOR(Mul)
641};
642
643
jkummerow@chromium.org59297c72013-01-09 16:32:23 +0000644// Instruction for computing multiplier * multiplicand + addend.
645class LMultiplyAddD: public LTemplateInstruction<1, 3, 0> {
646 public:
647 LMultiplyAddD(LOperand* addend, LOperand* multiplier,
648 LOperand* multiplicand) {
649 inputs_[0] = addend;
650 inputs_[1] = multiplier;
651 inputs_[2] = multiplicand;
652 }
653
654 LOperand* addend() { return inputs_[0]; }
655 LOperand* multiplier() { return inputs_[1]; }
656 LOperand* multiplicand() { return inputs_[2]; }
657
658 DECLARE_CONCRETE_INSTRUCTION(MultiplyAddD, "multiply-add-d")
659};
660
661
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000662class LDebugBreak: public LTemplateInstruction<0, 0, 0> {
663 public:
664 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
665};
666
667
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000668class LCmpIDAndBranch: public LControlInstruction<2, 0> {
669 public:
670 LCmpIDAndBranch(LOperand* left, LOperand* right) {
671 inputs_[0] = left;
672 inputs_[1] = right;
673 }
674
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000675 LOperand* left() { return inputs_[0]; }
676 LOperand* right() { return inputs_[1]; }
677
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000678 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
679 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
680
681 Token::Value op() const { return hydrogen()->token(); }
682 bool is_double() const {
ulan@chromium.org8e8d8822012-11-23 14:36:46 +0000683 return hydrogen()->representation().IsDouble();
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000684 }
685
686 virtual void PrintDataTo(StringStream* stream);
687};
688
689
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000690class LMathFloor: public LTemplateInstruction<1, 1, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000691 public:
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000692 LMathFloor(LOperand* value, LOperand* temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000693 inputs_[0] = value;
694 temps_[0] = temp;
695 }
696
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000697 LOperand* value() { return inputs_[0]; }
698 LOperand* temp() { return temps_[0]; }
699
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000700 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000701 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000702};
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000703
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000704
705class LMathRound: public LTemplateInstruction<1, 1, 1> {
706 public:
707 LMathRound(LOperand* value, LOperand* temp) {
708 inputs_[0] = value;
709 temps_[0] = temp;
710 }
711
712 LOperand* value() { return inputs_[0]; }
713 LOperand* temp() { return temps_[0]; }
714
715 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
716 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
717};
718
719
720class LMathAbs: public LTemplateInstruction<1, 1, 0> {
721 public:
722 explicit LMathAbs(LOperand* value) {
723 inputs_[0] = value;
724 }
725
726 LOperand* value() { return inputs_[0]; }
727
728 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
729 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
730};
731
732
733class LMathLog: public LTemplateInstruction<1, 1, 0> {
734 public:
735 explicit LMathLog(LOperand* value) {
736 inputs_[0] = value;
737 }
738
739 LOperand* value() { return inputs_[0]; }
740
741 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
742};
743
744
745class LMathSin: public LTemplateInstruction<1, 1, 0> {
746 public:
747 explicit LMathSin(LOperand* value) {
748 inputs_[0] = value;
749 }
750
751 LOperand* value() { return inputs_[0]; }
752
753 DECLARE_CONCRETE_INSTRUCTION(MathSin, "math-sin")
754};
755
756
757class LMathCos: public LTemplateInstruction<1, 1, 0> {
758 public:
759 explicit LMathCos(LOperand* value) {
760 inputs_[0] = value;
761 }
762
763 LOperand* value() { return inputs_[0]; }
764
765 DECLARE_CONCRETE_INSTRUCTION(MathCos, "math-cos")
766};
767
768
769class LMathTan: public LTemplateInstruction<1, 1, 0> {
770 public:
771 explicit LMathTan(LOperand* value) {
772 inputs_[0] = value;
773 }
774
775 LOperand* value() { return inputs_[0]; }
776
777 DECLARE_CONCRETE_INSTRUCTION(MathTan, "math-tan")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000778};
779
780
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000781class LMathExp: public LTemplateInstruction<1, 1, 3> {
782 public:
783 LMathExp(LOperand* value,
784 LOperand* double_temp,
785 LOperand* temp1,
786 LOperand* temp2) {
787 inputs_[0] = value;
788 temps_[0] = temp1;
789 temps_[1] = temp2;
790 temps_[2] = double_temp;
791 ExternalReference::InitializeMathExpData();
792 }
793
794 LOperand* value() { return inputs_[0]; }
795 LOperand* temp1() { return temps_[0]; }
796 LOperand* temp2() { return temps_[1]; }
797 LOperand* double_temp() { return temps_[2]; }
798
799 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000800};
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000801
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +0000802
803class LMathSqrt: public LTemplateInstruction<1, 1, 0> {
804 public:
805 explicit LMathSqrt(LOperand* value) {
806 inputs_[0] = value;
807 }
808
809 LOperand* value() { return inputs_[0]; }
810
811 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
812};
813
814
815class LMathPowHalf: public LTemplateInstruction<1, 1, 1> {
816 public:
817 LMathPowHalf(LOperand* value, LOperand* temp) {
818 inputs_[0] = value;
819 temps_[0] = temp;
820 }
821
822 LOperand* value() { return inputs_[0]; }
823 LOperand* temp() { return temps_[0]; }
824
825 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
svenpanne@chromium.org83130cf2012-11-30 10:13:25 +0000826};
827
828
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000829class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
830 public:
831 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
832 inputs_[0] = left;
833 inputs_[1] = right;
834 }
835
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000836 LOperand* left() { return inputs_[0]; }
837 LOperand* right() { return inputs_[1]; }
838
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000839 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
840 "cmp-object-eq-and-branch")
841 DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch)
842};
843
844
845class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
846 public:
847 explicit LCmpConstantEqAndBranch(LOperand* left) {
848 inputs_[0] = left;
849 }
850
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000851 LOperand* left() { return inputs_[0]; }
852
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000853 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
854 "cmp-constant-eq-and-branch")
855 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
856};
857
858
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000859class LIsObjectAndBranch: public LControlInstruction<1, 1> {
860 public:
861 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
862 inputs_[0] = value;
863 temps_[0] = temp;
864 }
865
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000866 LOperand* value() { return inputs_[0]; }
867 LOperand* temp() { return temps_[0]; }
868
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000869 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
870 DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch)
871
872 virtual void PrintDataTo(StringStream* stream);
873};
874
875
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000876class LIsStringAndBranch: public LControlInstruction<1, 1> {
877 public:
878 LIsStringAndBranch(LOperand* value, LOperand* temp) {
879 inputs_[0] = value;
880 temps_[0] = temp;
881 }
882
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000883 LOperand* value() { return inputs_[0]; }
884 LOperand* temp() { return temps_[0]; }
885
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000886 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
887 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
888
889 virtual void PrintDataTo(StringStream* stream);
890};
891
892
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000893class LIsSmiAndBranch: public LControlInstruction<1, 0> {
894 public:
895 explicit LIsSmiAndBranch(LOperand* value) {
896 inputs_[0] = value;
897 }
898
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000899 LOperand* value() { return inputs_[0]; }
900
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000901 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
902 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
903
904 virtual void PrintDataTo(StringStream* stream);
905};
906
907
908class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
909 public:
910 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
911 inputs_[0] = value;
912 temps_[0] = temp;
913 }
914
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000915 LOperand* value() { return inputs_[0]; }
916 LOperand* temp() { return temps_[0]; }
917
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000918 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
919 "is-undetectable-and-branch")
920 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
921
922 virtual void PrintDataTo(StringStream* stream);
923};
924
925
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000926class LStringCompareAndBranch: public LControlInstruction<2, 0> {
927 public:
928 LStringCompareAndBranch(LOperand* left, LOperand* right) {
929 inputs_[0] = left;
930 inputs_[1] = right;
931 }
932
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000933 LOperand* left() { return inputs_[0]; }
934 LOperand* right() { return inputs_[1]; }
935
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000936 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
937 "string-compare-and-branch")
938 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
939
940 Token::Value op() const { return hydrogen()->token(); }
941
942 virtual void PrintDataTo(StringStream* stream);
943};
944
945
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000946class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
947 public:
948 explicit LHasInstanceTypeAndBranch(LOperand* value) {
949 inputs_[0] = value;
950 }
951
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000952 LOperand* value() { return inputs_[0]; }
953
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000954 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
955 "has-instance-type-and-branch")
956 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
957
958 virtual void PrintDataTo(StringStream* stream);
959};
960
961
962class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
963 public:
964 explicit LGetCachedArrayIndex(LOperand* value) {
965 inputs_[0] = value;
966 }
967
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000968 LOperand* value() { return inputs_[0]; }
969
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000970 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
971 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
972};
973
974
975class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
976 public:
977 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
978 inputs_[0] = value;
979 }
980
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000981 LOperand* value() { return inputs_[0]; }
982
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000983 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
984 "has-cached-array-index-and-branch")
985 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch)
986
987 virtual void PrintDataTo(StringStream* stream);
988};
989
990
991class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
992 public:
993 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
994 inputs_[0] = value;
995 temps_[0] = temp;
996 }
997
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +0000998 LOperand* value() { return inputs_[0]; }
999 LOperand* temp() { return temps_[0]; }
1000
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001001 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1002 "class-of-test-and-branch")
1003 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1004
1005 virtual void PrintDataTo(StringStream* stream);
1006};
1007
1008
1009class LCmpT: public LTemplateInstruction<1, 2, 0> {
1010 public:
1011 LCmpT(LOperand* left, LOperand* right) {
1012 inputs_[0] = left;
1013 inputs_[1] = right;
1014 }
1015
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001016 LOperand* left() { return inputs_[0]; }
1017 LOperand* right() { return inputs_[1]; }
1018
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001019 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1020 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1021
1022 Token::Value op() const { return hydrogen()->token(); }
1023};
1024
1025
1026class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
1027 public:
1028 LInstanceOf(LOperand* left, LOperand* right) {
1029 inputs_[0] = left;
1030 inputs_[1] = right;
1031 }
1032
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001033 LOperand* left() { return inputs_[0]; }
1034 LOperand* right() { return inputs_[1]; }
1035
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001036 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1037};
1038
1039
1040class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
1041 public:
1042 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
1043 inputs_[0] = value;
1044 temps_[0] = temp;
1045 }
1046
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001047 LOperand* value() { return inputs_[0]; }
1048 LOperand* temp() { return temps_[0]; }
1049
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001050 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1051 "instance-of-known-global")
1052 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1053
1054 Handle<JSFunction> function() const { return hydrogen()->function(); }
danno@chromium.org1044a4d2012-04-30 12:34:39 +00001055 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1056 return lazy_deopt_env_;
1057 }
1058 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) {
1059 lazy_deopt_env_ = env;
1060 }
1061
1062 private:
1063 LEnvironment* lazy_deopt_env_;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001064};
1065
1066
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +00001067class LInstanceSize: public LTemplateInstruction<1, 1, 0> {
1068 public:
1069 explicit LInstanceSize(LOperand* object) {
1070 inputs_[0] = object;
1071 }
1072
1073 LOperand* object() { return inputs_[0]; }
1074
1075 DECLARE_CONCRETE_INSTRUCTION(InstanceSize, "instance-size")
1076 DECLARE_HYDROGEN_ACCESSOR(InstanceSize)
1077};
1078
1079
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001080class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
1081 public:
1082 LBoundsCheck(LOperand* index, LOperand* length) {
1083 inputs_[0] = index;
1084 inputs_[1] = length;
1085 }
1086
1087 LOperand* index() { return inputs_[0]; }
1088 LOperand* length() { return inputs_[1]; }
1089
1090 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
danno@chromium.org129d3982012-07-25 15:01:47 +00001091 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001092};
1093
1094
1095class LBitI: public LTemplateInstruction<1, 2, 0> {
1096 public:
1097 LBitI(LOperand* left, LOperand* right) {
1098 inputs_[0] = left;
1099 inputs_[1] = right;
1100 }
1101
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001102 LOperand* left() { return inputs_[0]; }
1103 LOperand* right() { return inputs_[1]; }
1104
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001105 Token::Value op() const { return hydrogen()->op(); }
1106
1107 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1108 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1109};
1110
1111
1112class LShiftI: public LTemplateInstruction<1, 2, 0> {
1113 public:
1114 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1115 : op_(op), can_deopt_(can_deopt) {
1116 inputs_[0] = left;
1117 inputs_[1] = right;
1118 }
1119
1120 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001121 LOperand* left() { return inputs_[0]; }
1122 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001123 bool can_deopt() const { return can_deopt_; }
1124
1125 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1126
1127 private:
1128 Token::Value op_;
1129 bool can_deopt_;
1130};
1131
1132
1133class LSubI: public LTemplateInstruction<1, 2, 0> {
1134 public:
1135 LSubI(LOperand* left, LOperand* right) {
1136 inputs_[0] = left;
1137 inputs_[1] = right;
1138 }
1139
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001140 LOperand* left() { return inputs_[0]; }
1141 LOperand* right() { return inputs_[1]; }
1142
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001143 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1144 DECLARE_HYDROGEN_ACCESSOR(Sub)
1145};
1146
1147
1148class LConstantI: public LTemplateInstruction<1, 0, 0> {
1149 public:
1150 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1151 DECLARE_HYDROGEN_ACCESSOR(Constant)
1152
1153 int32_t value() const { return hydrogen()->Integer32Value(); }
1154};
1155
1156
1157class LConstantD: public LTemplateInstruction<1, 0, 0> {
1158 public:
1159 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1160 DECLARE_HYDROGEN_ACCESSOR(Constant)
1161
1162 double value() const { return hydrogen()->DoubleValue(); }
1163};
1164
1165
1166class LConstantT: public LTemplateInstruction<1, 0, 0> {
1167 public:
1168 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1169 DECLARE_HYDROGEN_ACCESSOR(Constant)
1170
1171 Handle<Object> value() const { return hydrogen()->handle(); }
1172};
1173
1174
1175class LBranch: public LControlInstruction<1, 0> {
1176 public:
1177 explicit LBranch(LOperand* value) {
1178 inputs_[0] = value;
1179 }
1180
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001181 LOperand* value() { return inputs_[0]; }
1182
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001183 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1184 DECLARE_HYDROGEN_ACCESSOR(Branch)
1185
1186 virtual void PrintDataTo(StringStream* stream);
1187};
1188
1189
1190class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> {
1191 public:
1192 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1193 inputs_[0] = value;
1194 temps_[0] = temp;
1195 }
1196
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001197 LOperand* value() { return inputs_[0]; }
1198 LOperand* temp() { return temps_[0]; }
1199
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001200 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1201 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1202
1203 virtual bool IsControl() const { return true; }
1204
1205 Handle<Map> map() const { return hydrogen()->map(); }
1206 int true_block_id() const {
1207 return hydrogen()->FirstSuccessor()->block_id();
1208 }
1209 int false_block_id() const {
1210 return hydrogen()->SecondSuccessor()->block_id();
1211 }
1212};
1213
1214
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001215class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
1216 public:
1217 explicit LFixedArrayBaseLength(LOperand* value) {
1218 inputs_[0] = value;
1219 }
1220
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001221 LOperand* value() { return inputs_[0]; }
1222
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001223 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
1224 "fixed-array-base-length")
1225 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
1226};
1227
1228
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001229class LMapEnumLength: public LTemplateInstruction<1, 1, 0> {
1230 public:
1231 explicit LMapEnumLength(LOperand* value) {
1232 inputs_[0] = value;
1233 }
1234
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001235 LOperand* value() { return inputs_[0]; }
1236
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001237 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1238};
1239
1240
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001241class LElementsKind: public LTemplateInstruction<1, 1, 0> {
1242 public:
1243 explicit LElementsKind(LOperand* value) {
1244 inputs_[0] = value;
1245 }
1246
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001247 LOperand* value() { return inputs_[0]; }
1248
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001249 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
1250 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
1251};
1252
1253
1254class LValueOf: public LTemplateInstruction<1, 1, 1> {
1255 public:
1256 LValueOf(LOperand* value, LOperand* temp) {
1257 inputs_[0] = value;
1258 temps_[0] = temp;
1259 }
1260
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001261 LOperand* value() { return inputs_[0]; }
1262 LOperand* temp() { return temps_[0]; }
1263
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001264 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1265 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1266};
1267
1268
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001269class LDateField: public LTemplateInstruction<1, 1, 1> {
1270 public:
1271 LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) {
1272 inputs_[0] = date;
1273 temps_[0] = temp;
1274 }
1275
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001276 LOperand* date() { return inputs_[0]; }
1277 LOperand* temp() { return temps_[0]; }
1278 Smi* index() const { return index_; }
1279
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001280 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field")
1281 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001282
1283 private:
1284 Smi* index_;
1285};
1286
1287
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +00001288class LSeqStringSetChar: public LTemplateInstruction<1, 3, 0> {
1289 public:
1290 LSeqStringSetChar(String::Encoding encoding,
1291 LOperand* string,
1292 LOperand* index,
1293 LOperand* value) : encoding_(encoding) {
1294 inputs_[0] = string;
1295 inputs_[1] = index;
1296 inputs_[2] = value;
1297 }
1298
1299 String::Encoding encoding() { return encoding_; }
1300 LOperand* string() { return inputs_[0]; }
1301 LOperand* index() { return inputs_[1]; }
1302 LOperand* value() { return inputs_[2]; }
1303
1304 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1305 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1306
1307 private:
1308 String::Encoding encoding_;
1309};
1310
1311
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001312class LThrow: public LTemplateInstruction<0, 1, 0> {
1313 public:
1314 explicit LThrow(LOperand* value) {
1315 inputs_[0] = value;
1316 }
1317
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001318 LOperand* value() { return inputs_[0]; }
1319
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001320 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1321};
1322
1323
1324class LBitNotI: public LTemplateInstruction<1, 1, 0> {
1325 public:
1326 explicit LBitNotI(LOperand* value) {
1327 inputs_[0] = value;
1328 }
1329
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001330 LOperand* value() { return inputs_[0]; }
1331
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001332 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1333};
1334
1335
1336class LAddI: public LTemplateInstruction<1, 2, 0> {
1337 public:
1338 LAddI(LOperand* left, LOperand* right) {
1339 inputs_[0] = left;
1340 inputs_[1] = right;
1341 }
1342
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001343 LOperand* left() { return inputs_[0]; }
1344 LOperand* right() { return inputs_[1]; }
1345
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001346 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1347 DECLARE_HYDROGEN_ACCESSOR(Add)
1348};
1349
1350
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001351class LMathMinMax: public LTemplateInstruction<1, 2, 0> {
1352 public:
1353 LMathMinMax(LOperand* left, LOperand* right) {
1354 inputs_[0] = left;
1355 inputs_[1] = right;
1356 }
1357
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001358 LOperand* left() { return inputs_[0]; }
1359 LOperand* right() { return inputs_[1]; }
1360
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +00001361 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00001362 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1363};
1364
1365
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001366class LPower: public LTemplateInstruction<1, 2, 0> {
1367 public:
1368 LPower(LOperand* left, LOperand* right) {
1369 inputs_[0] = left;
1370 inputs_[1] = right;
1371 }
1372
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001373 LOperand* left() { return inputs_[0]; }
1374 LOperand* right() { return inputs_[1]; }
1375
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001376 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1377 DECLARE_HYDROGEN_ACCESSOR(Power)
1378};
1379
1380
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001381class LRandom: public LTemplateInstruction<1, 1, 0> {
1382 public:
1383 explicit LRandom(LOperand* global_object) {
1384 inputs_[0] = global_object;
1385 }
1386
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001387 LOperand* global_object() { return inputs_[0]; }
1388
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001389 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1390 DECLARE_HYDROGEN_ACCESSOR(Random)
1391};
1392
1393
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001394class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1395 public:
1396 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1397 : op_(op) {
1398 inputs_[0] = left;
1399 inputs_[1] = right;
1400 }
1401
1402 Token::Value op() const { return op_; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001403 LOperand* left() { return inputs_[0]; }
1404 LOperand* right() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001405
1406 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1407 virtual void CompileToNative(LCodeGen* generator);
1408 virtual const char* Mnemonic() const;
1409
1410 private:
1411 Token::Value op_;
1412};
1413
1414
1415class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1416 public:
1417 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1418 : op_(op) {
1419 inputs_[0] = left;
1420 inputs_[1] = right;
1421 }
1422
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001423 LOperand* left() { return inputs_[0]; }
1424 LOperand* right() { return inputs_[1]; }
1425 Token::Value op() const { return op_; }
1426
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001427 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1428 virtual void CompileToNative(LCodeGen* generator);
1429 virtual const char* Mnemonic() const;
1430
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001431 private:
1432 Token::Value op_;
1433};
1434
1435
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001436class LReturn: public LTemplateInstruction<0, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001437 public:
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001438 explicit LReturn(LOperand* value, LOperand* parameter_count) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001439 inputs_[0] = value;
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001440 inputs_[1] = parameter_count;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001441 }
1442
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001443 LOperand* value() { return inputs_[0]; }
1444
ulan@chromium.org6e196bf2013-03-13 09:38:22 +00001445 bool has_constant_parameter_count() {
1446 return parameter_count()->IsConstantOperand();
1447 }
1448 LConstantOperand* constant_parameter_count() {
1449 ASSERT(has_constant_parameter_count());
1450 return LConstantOperand::cast(parameter_count());
1451 }
1452 LOperand* parameter_count() { return inputs_[1]; }
1453
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001454 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1455};
1456
1457
1458class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
1459 public:
1460 explicit LLoadNamedField(LOperand* object) {
1461 inputs_[0] = object;
1462 }
1463
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001464 LOperand* object() { return inputs_[0]; }
1465
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001466 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1467 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1468};
1469
1470
1471class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1472 public:
1473 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1474 inputs_[0] = object;
1475 }
1476
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001477 LOperand* object() { return inputs_[0]; }
1478
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001479 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1480 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001481};
1482
1483
1484class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
1485 public:
1486 explicit LLoadNamedGeneric(LOperand* object) {
1487 inputs_[0] = object;
1488 }
1489
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001490 LOperand* object() { return inputs_[0]; }
1491
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001492 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1493 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1494
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001495 Handle<Object> name() const { return hydrogen()->name(); }
1496};
1497
1498
1499class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
1500 public:
1501 explicit LLoadFunctionPrototype(LOperand* function) {
1502 inputs_[0] = function;
1503 }
1504
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001505 LOperand* function() { return inputs_[0]; }
1506
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001507 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1508 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001509};
1510
1511
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001512class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
1513 public:
1514 explicit LLoadExternalArrayPointer(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(LoadExternalArrayPointer,
1521 "load-external-array-pointer")
1522};
1523
1524
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001525class LLoadKeyed: public LTemplateInstruction<1, 2, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001526 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001527 LLoadKeyed(LOperand* elements, LOperand* key) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001528 inputs_[0] = elements;
1529 inputs_[1] = key;
1530 }
1531
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001532 LOperand* elements() { return inputs_[0]; }
1533 LOperand* key() { return inputs_[1]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001534 ElementsKind elements_kind() const {
1535 return hydrogen()->elements_kind();
1536 }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00001537 bool is_external() const {
1538 return hydrogen()->is_external();
1539 }
1540
1541 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1542 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1543
ulan@chromium.org8e8d8822012-11-23 14:36:46 +00001544 virtual void PrintDataTo(StringStream* stream);
jkummerow@chromium.org777db6f2012-05-24 09:33:09 +00001545 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001546};
1547
1548
1549class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
1550 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001551 LLoadKeyedGeneric(LOperand* object, LOperand* key) {
1552 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001553 inputs_[1] = key;
1554 }
1555
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001556 LOperand* object() { return inputs_[0]; }
1557 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001558
1559 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001560};
1561
1562
1563class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
1564 public:
1565 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1566 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1567};
1568
1569
1570class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
1571 public:
1572 explicit LLoadGlobalGeneric(LOperand* global_object) {
1573 inputs_[0] = global_object;
1574 }
1575
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001576 LOperand* global_object() { return inputs_[0]; }
1577
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001578 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1579 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1580
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001581 Handle<Object> name() const { return hydrogen()->name(); }
1582 bool for_typeof() const { return hydrogen()->for_typeof(); }
1583};
1584
1585
1586class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1587 public:
1588 LStoreGlobalCell(LOperand* value, LOperand* temp) {
1589 inputs_[0] = value;
1590 temps_[0] = temp;
1591 }
1592
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001593 LOperand* value() { return inputs_[0]; }
1594 LOperand* temp() { return temps_[0]; }
1595
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001596 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1597 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1598};
1599
1600
1601class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1602 public:
1603 explicit LStoreGlobalGeneric(LOperand* global_object,
1604 LOperand* value) {
1605 inputs_[0] = global_object;
1606 inputs_[1] = value;
1607 }
1608
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001609 LOperand* global_object() { return inputs_[0]; }
1610 LOperand* value() { return inputs_[1]; }
1611
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001612 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1613 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1614
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001615 Handle<Object> name() const { return hydrogen()->name(); }
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00001616 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001617};
1618
1619
1620class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
1621 public:
1622 explicit LLoadContextSlot(LOperand* context) {
1623 inputs_[0] = context;
1624 }
1625
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001626 LOperand* context() { return inputs_[0]; }
1627
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001628 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1629 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1630
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001631 int slot_index() { return hydrogen()->slot_index(); }
1632
1633 virtual void PrintDataTo(StringStream* stream);
1634};
1635
1636
1637class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> {
1638 public:
1639 LStoreContextSlot(LOperand* context, LOperand* value) {
1640 inputs_[0] = context;
1641 inputs_[1] = value;
1642 }
1643
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001644 LOperand* context() { return inputs_[0]; }
1645 LOperand* value() { return inputs_[1]; }
1646
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001647 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1648 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1649
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001650 int slot_index() { return hydrogen()->slot_index(); }
1651
1652 virtual void PrintDataTo(StringStream* stream);
1653};
1654
1655
1656class LPushArgument: public LTemplateInstruction<0, 1, 0> {
1657 public:
1658 explicit LPushArgument(LOperand* value) {
1659 inputs_[0] = value;
1660 }
1661
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001662 LOperand* value() { return inputs_[0]; }
1663
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001664 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1665};
1666
1667
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00001668class LDrop: public LTemplateInstruction<0, 0, 0> {
1669 public:
1670 explicit LDrop(int count) : count_(count) { }
1671
1672 int count() const { return count_; }
1673
1674 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1675
1676 private:
1677 int count_;
1678};
1679
1680
jkummerow@chromium.org4c54a2a2013-03-19 17:51:30 +00001681class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
1682 public:
1683 explicit LInnerAllocatedObject(LOperand* base_object) {
1684 inputs_[0] = base_object;
1685 }
1686
1687 LOperand* base_object() { return inputs_[0]; }
1688 int offset() { return hydrogen()->offset(); }
1689
1690 virtual void PrintDataTo(StringStream* stream);
1691
1692 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
1693 DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
1694};
1695
1696
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001697class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1698 public:
1699 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1700 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1701};
1702
1703
1704class LContext: public LTemplateInstruction<1, 0, 0> {
1705 public:
1706 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00001707 DECLARE_HYDROGEN_ACCESSOR(Context)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001708};
1709
1710
1711class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1712 public:
1713 explicit LOuterContext(LOperand* context) {
1714 inputs_[0] = context;
1715 }
1716
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001717 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001718
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001719 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001720};
1721
1722
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001723class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> {
1724 public:
1725 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1726 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1727};
1728
1729
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001730class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1731 public:
1732 explicit LGlobalObject(LOperand* context) {
1733 inputs_[0] = context;
1734 }
1735
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001736 LOperand* context() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001737
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001738 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001739};
1740
1741
1742class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1743 public:
1744 explicit LGlobalReceiver(LOperand* global_object) {
1745 inputs_[0] = global_object;
1746 }
1747
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001748 LOperand* global_object() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001749
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001750 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001751};
1752
1753
1754class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1755 public:
1756 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1757 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1758
1759 virtual void PrintDataTo(StringStream* stream);
1760
1761 Handle<JSFunction> function() { return hydrogen()->function(); }
1762 int arity() const { return hydrogen()->argument_count() - 1; }
1763};
1764
1765
1766class LInvokeFunction: public LTemplateInstruction<1, 1, 0> {
1767 public:
1768 explicit LInvokeFunction(LOperand* function) {
1769 inputs_[0] = function;
1770 }
1771
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001772 LOperand* function() { return inputs_[0]; }
1773
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001774 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1775 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1776
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001777 virtual void PrintDataTo(StringStream* stream);
1778
1779 int arity() const { return hydrogen()->argument_count() - 1; }
1780};
1781
1782
1783class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
1784 public:
1785 explicit LCallKeyed(LOperand* key) {
1786 inputs_[0] = key;
1787 }
1788
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001789 LOperand* key() { return inputs_[0]; }
1790
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001791 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1792 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1793
1794 virtual void PrintDataTo(StringStream* stream);
1795
1796 int arity() const { return hydrogen()->argument_count() - 1; }
1797};
1798
1799
1800
1801class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1802 public:
1803 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1804 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1805
1806 virtual void PrintDataTo(StringStream* stream);
1807
1808 Handle<String> name() const { return hydrogen()->name(); }
1809 int arity() const { return hydrogen()->argument_count() - 1; }
1810};
1811
1812
danno@chromium.orgc612e022011-11-10 11:38:15 +00001813class LCallFunction: public LTemplateInstruction<1, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001814 public:
danno@chromium.orgc612e022011-11-10 11:38:15 +00001815 explicit LCallFunction(LOperand* function) {
1816 inputs_[0] = function;
1817 }
1818
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001819 LOperand* function() { return inputs_[0]; }
1820
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001821 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1822 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1823
danno@chromium.orgc612e022011-11-10 11:38:15 +00001824 int arity() const { return hydrogen()->argument_count() - 1; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001825};
1826
1827
1828class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1829 public:
1830 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1831 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1832
1833 virtual void PrintDataTo(StringStream* stream);
1834
1835 Handle<String> name() const {return hydrogen()->name(); }
1836 int arity() const { return hydrogen()->argument_count() - 1; }
1837};
1838
1839
1840class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1841 public:
1842 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1843 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1844
1845 virtual void PrintDataTo(StringStream* stream);
1846
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001847 int arity() const { return hydrogen()->argument_count() - 1; }
1848};
1849
1850
1851class LCallNew: public LTemplateInstruction<1, 1, 0> {
1852 public:
1853 explicit LCallNew(LOperand* constructor) {
1854 inputs_[0] = constructor;
1855 }
1856
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001857 LOperand* constructor() { return inputs_[0]; }
1858
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001859 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1860 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1861
1862 virtual void PrintDataTo(StringStream* stream);
1863
1864 int arity() const { return hydrogen()->argument_count() - 1; }
1865};
1866
1867
ulan@chromium.org750145a2013-03-07 15:14:13 +00001868class LCallNewArray: public LTemplateInstruction<1, 1, 0> {
1869 public:
1870 explicit LCallNewArray(LOperand* constructor) {
1871 inputs_[0] = constructor;
1872 }
1873
1874 LOperand* constructor() { return inputs_[0]; }
1875
1876 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1877 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1878
1879 virtual void PrintDataTo(StringStream* stream);
1880
1881 int arity() const { return hydrogen()->argument_count() - 1; }
1882};
1883
1884
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001885class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1886 public:
1887 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1888 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1889
1890 const Runtime::Function* function() const { return hydrogen()->function(); }
1891 int arity() const { return hydrogen()->argument_count(); }
1892};
1893
1894
1895class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
1896 public:
1897 explicit LInteger32ToDouble(LOperand* value) {
1898 inputs_[0] = value;
1899 }
1900
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001901 LOperand* value() { return inputs_[0]; }
1902
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001903 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1904};
1905
1906
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00001907class LInteger32ToSmi: public LTemplateInstruction<1, 1, 0> {
1908 public:
1909 explicit LInteger32ToSmi(LOperand* value) {
1910 inputs_[0] = value;
1911 }
1912
1913 LOperand* value() { return inputs_[0]; }
1914
1915 DECLARE_CONCRETE_INSTRUCTION(Integer32ToSmi, "int32-to-smi")
1916 DECLARE_HYDROGEN_ACCESSOR(Change)
1917};
1918
1919
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001920class LUint32ToDouble: public LTemplateInstruction<1, 1, 0> {
1921 public:
1922 explicit LUint32ToDouble(LOperand* value) {
1923 inputs_[0] = value;
1924 }
1925
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001926 LOperand* value() { return inputs_[0]; }
1927
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001928 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1929};
1930
1931
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001932class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
1933 public:
1934 explicit LNumberTagI(LOperand* value) {
1935 inputs_[0] = value;
1936 }
1937
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001938 LOperand* value() { return inputs_[0]; }
1939
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001940 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1941};
1942
1943
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001944class LNumberTagU: public LTemplateInstruction<1, 1, 0> {
1945 public:
1946 explicit LNumberTagU(LOperand* value) {
1947 inputs_[0] = value;
1948 }
1949
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001950 LOperand* value() { return inputs_[0]; }
1951
jkummerow@chromium.org78502a92012-09-06 13:50:42 +00001952 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1953};
1954
1955
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001956class LNumberTagD: public LTemplateInstruction<1, 1, 2> {
1957 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001958 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001959 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001960 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001961 temps_[1] = temp2;
1962 }
1963
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001964 LOperand* value() { return inputs_[0]; }
1965 LOperand* temp() { return temps_[0]; }
1966 LOperand* temp2() { return temps_[1]; }
1967
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001968 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00001969 DECLARE_HYDROGEN_ACCESSOR(Change)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001970};
1971
1972
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00001973class LDoubleToSmi: public LTemplateInstruction<1, 1, 2> {
1974 public:
1975 LDoubleToSmi(LOperand* value, LOperand* temp, LOperand* temp2) {
1976 inputs_[0] = value;
1977 temps_[0] = temp;
1978 temps_[1] = temp2;
1979 }
1980
1981 LOperand* value() { return inputs_[0]; }
1982 LOperand* temp() { return temps_[0]; }
1983 LOperand* temp2() { return temps_[1]; }
1984
1985 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1986 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1987
1988 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1989};
1990
1991
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001992// Sometimes truncating conversion from a tagged value to an int32.
1993class LDoubleToI: public LTemplateInstruction<1, 1, 2> {
1994 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001995 LDoubleToI(LOperand* value, LOperand* temp, LOperand* temp2) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001996 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00001997 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001998 temps_[1] = temp2;
1999 }
2000
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002001 LOperand* value() { return inputs_[0]; }
2002 LOperand* temp() { return temps_[0]; }
2003 LOperand* temp2() { return temps_[1]; }
2004
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002005 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2006 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2007
2008 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2009};
2010
2011
2012// Truncating conversion from a tagged value to an int32.
2013class LTaggedToI: public LTemplateInstruction<1, 1, 3> {
2014 public:
2015 LTaggedToI(LOperand* value,
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002016 LOperand* temp,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002017 LOperand* temp2,
2018 LOperand* temp3) {
2019 inputs_[0] = value;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002020 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002021 temps_[1] = temp2;
2022 temps_[2] = temp3;
2023 }
2024
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002025 LOperand* value() { return inputs_[0]; }
2026 LOperand* temp() { return temps_[0]; }
2027 LOperand* temp2() { return temps_[1]; }
2028 LOperand* temp3() { return temps_[2]; }
2029
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002030 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2031 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2032
2033 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2034};
2035
2036
2037class LSmiTag: public LTemplateInstruction<1, 1, 0> {
2038 public:
2039 explicit LSmiTag(LOperand* value) {
2040 inputs_[0] = value;
2041 }
2042
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002043 LOperand* value() { return inputs_[0]; }
2044
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002045 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2046};
2047
2048
2049class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
2050 public:
2051 explicit LNumberUntagD(LOperand* value) {
2052 inputs_[0] = value;
2053 }
2054
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002055 LOperand* value() { return inputs_[0]; }
2056
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002057 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2058 DECLARE_HYDROGEN_ACCESSOR(Change)
2059};
2060
2061
2062class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
2063 public:
2064 LSmiUntag(LOperand* value, bool needs_check)
2065 : needs_check_(needs_check) {
2066 inputs_[0] = value;
2067 }
2068
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002069 LOperand* value() { return inputs_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002070 bool needs_check() const { return needs_check_; }
2071
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00002072 DECLARE_HYDROGEN_ACCESSOR(Change);
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002073 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2074
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002075 private:
2076 bool needs_check_;
2077};
2078
2079
verwaest@chromium.org37141392012-05-31 13:27:02 +00002080class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002081 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002082 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
2083 inputs_[0] = object;
2084 inputs_[1] = value;
verwaest@chromium.org37141392012-05-31 13:27:02 +00002085 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002086 }
2087
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002088 LOperand* object() { return inputs_[0]; }
2089 LOperand* value() { return inputs_[1]; }
2090 LOperand* temp() { return temps_[0]; }
2091
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002092 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2093 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2094
2095 virtual void PrintDataTo(StringStream* stream);
2096
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002097 Handle<Object> name() const { return hydrogen()->name(); }
2098 bool is_in_object() { return hydrogen()->is_in_object(); }
2099 int offset() { return hydrogen()->offset(); }
2100 Handle<Map> transition() const { return hydrogen()->transition(); }
danno@chromium.orgf005df62013-04-30 16:36:45 +00002101 Representation representation() const {
2102 return hydrogen()->field_representation();
2103 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002104};
2105
2106
2107class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
2108 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002109 LStoreNamedGeneric(LOperand* object, LOperand* value) {
2110 inputs_[0] = object;
2111 inputs_[1] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002112 }
2113
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002114 LOperand* object() { return inputs_[0]; }
2115 LOperand* value() { return inputs_[1]; }
2116
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002117 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2118 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2119
2120 virtual void PrintDataTo(StringStream* stream);
2121
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002122 Handle<Object> name() const { return hydrogen()->name(); }
2123 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002124};
2125
2126
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002127class LStoreKeyed: public LTemplateInstruction<0, 3, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002128 public:
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002129 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value) {
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002130 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002131 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002132 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002133 }
2134
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002135 bool is_external() const { return hydrogen()->is_external(); }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002136 LOperand* elements() { return inputs_[0]; }
2137 LOperand* key() { return inputs_[1]; }
2138 LOperand* value() { return inputs_[2]; }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002139 ElementsKind elements_kind() const {
2140 return hydrogen()->elements_kind();
2141 }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002142
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002143 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2144 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002145
2146 virtual void PrintDataTo(StringStream* stream);
svenpanne@chromium.orgfb046332012-04-19 12:02:44 +00002147 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
mvstanton@chromium.orge4ac3ef2012-11-12 14:53:34 +00002148 uint32_t additional_index() const { return hydrogen()->index_offset(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002149};
2150
2151
2152class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
2153 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002154 LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002155 inputs_[0] = obj;
2156 inputs_[1] = key;
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002157 inputs_[2] = value;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002158 }
2159
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002160 LOperand* object() { return inputs_[0]; }
2161 LOperand* key() { return inputs_[1]; }
2162 LOperand* value() { return inputs_[2]; }
2163
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002164 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2165 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2166
2167 virtual void PrintDataTo(StringStream* stream);
2168
mstarzinger@chromium.org1b3afd12011-11-29 14:28:56 +00002169 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002170};
2171
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002172
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +00002173class LTransitionElementsKind: public LTemplateInstruction<0, 1, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002174 public:
2175 LTransitionElementsKind(LOperand* object,
2176 LOperand* new_map_temp,
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002177 LOperand* fixed_object_temp) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002178 inputs_[0] = object;
2179 temps_[0] = new_map_temp;
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002180 temps_[1] = fixed_object_temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002181 }
2182
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002183 LOperand* object() { return inputs_[0]; }
2184 LOperand* new_map_temp() { return temps_[0]; }
2185 LOperand* temp() { return temps_[1]; }
2186
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002187 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2188 "transition-elements-kind")
2189 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2190
2191 virtual void PrintDataTo(StringStream* stream);
2192
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002193 Handle<Map> original_map() { return hydrogen()->original_map(); }
2194 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002195 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2196 ElementsKind to_kind() { return hydrogen()->to_kind(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002197};
2198
2199
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002200class LTrapAllocationMemento : public LTemplateInstruction<0, 1, 1> {
2201 public:
2202 LTrapAllocationMemento(LOperand* object,
2203 LOperand* temp) {
2204 inputs_[0] = object;
2205 temps_[0] = temp;
2206 }
2207
2208 LOperand* object() { return inputs_[0]; }
2209 LOperand* temp() { return temps_[0]; }
2210
2211 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2212 "trap-allocation-memento")
2213};
2214
2215
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002216class LStringAdd: public LTemplateInstruction<1, 2, 0> {
2217 public:
2218 LStringAdd(LOperand* left, LOperand* right) {
2219 inputs_[0] = left;
2220 inputs_[1] = right;
2221 }
2222
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002223 LOperand* left() { return inputs_[0]; }
2224 LOperand* right() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002225
2226 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2227 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002228};
2229
2230
2231
2232class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
2233 public:
2234 LStringCharCodeAt(LOperand* string, LOperand* index) {
2235 inputs_[0] = string;
2236 inputs_[1] = index;
2237 }
2238
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002239 LOperand* string() { return inputs_[0]; }
2240 LOperand* index() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002241
2242 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2243 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002244};
2245
2246
2247class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
2248 public:
2249 explicit LStringCharFromCode(LOperand* char_code) {
2250 inputs_[0] = char_code;
2251 }
2252
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002253 LOperand* char_code() { return inputs_[0]; }
2254
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002255 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2256 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002257};
2258
2259
2260class LStringLength: public LTemplateInstruction<1, 1, 0> {
2261 public:
2262 explicit LStringLength(LOperand* string) {
2263 inputs_[0] = string;
2264 }
2265
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002266 LOperand* string() { return inputs_[0]; }
2267
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002268 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
2269 DECLARE_HYDROGEN_ACCESSOR(StringLength)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002270};
2271
2272
2273class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
2274 public:
2275 explicit LCheckFunction(LOperand* value) {
2276 inputs_[0] = value;
2277 }
2278
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002279 LOperand* value() { return inputs_[0]; }
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00002280
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002281 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
2282 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
2283};
2284
2285
2286class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
2287 public:
2288 explicit LCheckInstanceType(LOperand* value) {
2289 inputs_[0] = value;
2290 }
2291
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002292 LOperand* value() { return inputs_[0]; }
2293
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002294 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2295 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2296};
2297
2298
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002299class LCheckMaps: public LTemplateInstruction<0, 1, 0> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002300 public:
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002301 explicit LCheckMaps(LOperand* value) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002302 inputs_[0] = value;
2303 }
2304
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002305 LOperand* value() { return inputs_[0]; }
2306
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00002307 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2308 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002309};
2310
2311
mstarzinger@chromium.orge27d6172013-04-17 11:51:44 +00002312class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002313 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002314 LCheckPrototypeMaps(LOperand* temp, LOperand* temp2) {
2315 temps_[0] = temp;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002316 temps_[1] = temp2;
2317 }
2318
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002319 LOperand* temp() { return temps_[0]; }
2320 LOperand* temp2() { return temps_[1]; }
2321
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002322 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
2323 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
2324
yangguo@chromium.org003650e2013-01-24 16:31:08 +00002325 ZoneList<Handle<JSObject> >* prototypes() const {
2326 return hydrogen()->prototypes();
2327 }
2328 ZoneList<Handle<Map> >* maps() const { return hydrogen()->maps(); }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002329};
2330
2331
2332class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
2333 public:
2334 explicit LCheckSmi(LOperand* value) {
2335 inputs_[0] = value;
2336 }
2337
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002338 LOperand* value() { return inputs_[0]; }
2339
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002340 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2341};
2342
2343
svenpanne@chromium.orga53e8e02013-05-24 12:35:50 +00002344class LCheckSmiAndReturn: public LTemplateInstruction<1, 1, 0> {
2345 public:
2346 explicit LCheckSmiAndReturn(LOperand* value) {
2347 inputs_[0] = value;
2348 }
2349
2350 LOperand* value() { return inputs_[0]; }
2351
2352 DECLARE_CONCRETE_INSTRUCTION(CheckSmiAndReturn, "check-smi-and-return")
2353};
2354
2355
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002356class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2357 public:
2358 explicit LCheckNonSmi(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(CheckNonSmi, "check-non-smi")
2365};
2366
2367
2368class LClampDToUint8: public LTemplateInstruction<1, 1, 1> {
2369 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002370 LClampDToUint8(LOperand* unclamped, LOperand* temp) {
2371 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002372 temps_[0] = temp;
2373 }
2374
2375 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002376 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002377
2378 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2379};
2380
2381
2382class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
2383 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002384 explicit LClampIToUint8(LOperand* unclamped) {
2385 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002386 }
2387
2388 LOperand* unclamped() { return inputs_[0]; }
2389
2390 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2391};
2392
2393
2394class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2395 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002396 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2397 inputs_[0] = unclamped;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002398 temps_[0] = temp;
2399 }
2400
2401 LOperand* unclamped() { return inputs_[0]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002402 LOperand* temp() { return temps_[0]; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002403
2404 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2405};
2406
2407
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002408class LAllocateObject: public LTemplateInstruction<1, 1, 2> {
ulan@chromium.org967e2702012-02-28 09:49:15 +00002409 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002410 LAllocateObject(LOperand* temp, LOperand* temp2) {
2411 temps_[0] = temp;
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002412 temps_[1] = temp2;
2413 }
2414
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002415 LOperand* temp() { return temps_[0]; }
2416 LOperand* temp2() { return temps_[1]; }
2417
ulan@chromium.org967e2702012-02-28 09:49:15 +00002418 DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object")
2419 DECLARE_HYDROGEN_ACCESSOR(AllocateObject)
2420};
2421
2422
hpayer@chromium.org7c3372b2013-02-13 17:26:04 +00002423class LAllocate: public LTemplateInstruction<1, 2, 2> {
2424 public:
2425 LAllocate(LOperand* size, LOperand* temp1, LOperand* temp2) {
2426 inputs_[1] = size;
2427 temps_[0] = temp1;
2428 temps_[1] = temp2;
2429 }
2430
2431 LOperand* size() { return inputs_[1]; }
2432 LOperand* temp1() { return temps_[0]; }
2433 LOperand* temp2() { return temps_[1]; }
2434
2435 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2436 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2437};
2438
2439
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002440class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
2441 public:
2442 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2443 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2444};
2445
2446
2447class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
2448 public:
2449 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2450 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002451};
2452
2453
2454class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2455 public:
2456 explicit LToFastProperties(LOperand* value) {
2457 inputs_[0] = value;
2458 }
2459
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002460 LOperand* value() { return inputs_[0]; }
2461
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002462 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2463 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2464};
2465
2466
2467class LTypeof: public LTemplateInstruction<1, 1, 0> {
2468 public:
2469 explicit LTypeof(LOperand* value) {
2470 inputs_[0] = value;
2471 }
2472
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002473 LOperand* value() { return inputs_[0]; }
2474
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002475 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2476};
2477
2478
2479class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
2480 public:
2481 explicit LTypeofIsAndBranch(LOperand* value) {
2482 inputs_[0] = value;
2483 }
2484
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002485 LOperand* value() { return inputs_[0]; }
2486
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002487 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2488 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2489
2490 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2491
2492 virtual void PrintDataTo(StringStream* stream);
2493};
2494
2495
2496class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
2497 public:
2498 explicit LIsConstructCallAndBranch(LOperand* temp) {
2499 temps_[0] = temp;
2500 }
2501
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002502 LOperand* temp() { return temps_[0]; }
2503
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002504 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
2505 "is-construct-call-and-branch")
2506};
2507
2508
2509class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
2510 public:
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002511 LDeleteProperty(LOperand* object, LOperand* key) {
2512 inputs_[0] = object;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002513 inputs_[1] = key;
2514 }
2515
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002516 LOperand* object() { return inputs_[0]; }
2517 LOperand* key() { return inputs_[1]; }
svenpanne@chromium.orgc859c4f2012-10-15 11:51:39 +00002518
2519 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002520};
2521
2522
2523class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
2524 public:
2525 LOsrEntry();
2526
ulan@chromium.org32d7dba2013-04-24 10:59:06 +00002527 virtual bool HasInterestingComment(LCodeGen* gen) const { return false; }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002528 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2529
2530 LOperand** SpilledRegisterArray() { return register_spills_; }
2531 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2532
2533 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2534 void MarkSpilledDoubleRegister(int allocation_index,
2535 LOperand* spill_operand);
2536
2537 private:
2538 // Arrays of spill slot operands for registers with an assigned spill
2539 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2540 // NULL if the register has no assigned spill slot. Indexed by allocation
2541 // index.
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002542 LOperand* register_spills_[Register::kMaxNumAllocatableRegisters];
2543 LOperand* double_register_spills_[
2544 DoubleRegister::kMaxNumAllocatableRegisters];
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002545};
2546
2547
2548class LStackCheck: public LTemplateInstruction<0, 0, 0> {
2549 public:
2550 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2551 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2552
2553 Label* done_label() { return &done_label_; }
2554
2555 private:
2556 Label done_label_;
2557};
2558
2559
2560class LIn: public LTemplateInstruction<1, 2, 0> {
2561 public:
2562 LIn(LOperand* key, LOperand* object) {
2563 inputs_[0] = key;
2564 inputs_[1] = object;
2565 }
2566
2567 LOperand* key() { return inputs_[0]; }
2568 LOperand* object() { return inputs_[1]; }
2569
2570 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2571};
2572
2573
ulan@chromium.org812308e2012-02-29 15:58:45 +00002574class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> {
2575 public:
2576 explicit LForInPrepareMap(LOperand* object) {
2577 inputs_[0] = object;
2578 }
2579
2580 LOperand* object() { return inputs_[0]; }
2581
2582 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2583};
2584
2585
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002586class LForInCacheArray: public LTemplateInstruction<1, 1, 0> {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002587 public:
rossberg@chromium.org89e18f52012-10-22 13:09:53 +00002588 explicit LForInCacheArray(LOperand* map) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002589 inputs_[0] = map;
2590 }
2591
2592 LOperand* map() { return inputs_[0]; }
2593
2594 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2595
2596 int idx() {
2597 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2598 }
2599};
2600
2601
2602class LCheckMapValue: public LTemplateInstruction<0, 2, 0> {
2603 public:
2604 LCheckMapValue(LOperand* value, LOperand* map) {
2605 inputs_[0] = value;
2606 inputs_[1] = map;
2607 }
2608
2609 LOperand* value() { return inputs_[0]; }
2610 LOperand* map() { return inputs_[1]; }
2611
2612 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2613};
2614
2615
2616class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> {
2617 public:
2618 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2619 inputs_[0] = object;
2620 inputs_[1] = index;
2621 }
2622
2623 LOperand* object() { return inputs_[0]; }
2624 LOperand* index() { return inputs_[1]; }
2625
2626 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2627};
2628
2629
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002630class LChunkBuilder;
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002631class LPlatformChunk: public LChunk {
lrn@chromium.org7516f052011-03-30 08:52:27 +00002632 public:
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002633 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2634 : LChunk(info, graph) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002635
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002636 int GetNextSpillIndex(bool is_double);
2637 LOperand* GetNextSpillSlot(bool is_double);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002638};
2639
2640
2641class LChunkBuilder BASE_EMBEDDED {
2642 public:
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002643 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2644 : chunk_(NULL),
2645 info_(info),
2646 graph_(graph),
mmassi@chromium.org7028c052012-06-13 11:51:58 +00002647 zone_(graph->zone()),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002648 status_(UNUSED),
2649 current_instruction_(NULL),
2650 current_block_(NULL),
2651 next_block_(NULL),
2652 argument_count_(0),
2653 allocator_(allocator),
2654 position_(RelocInfo::kNoPosition),
2655 instruction_pending_deoptimization_environment_(NULL),
mstarzinger@chromium.org471f2f12012-08-10 14:46:33 +00002656 pending_deoptimization_ast_id_(BailoutId::None()) { }
lrn@chromium.org7516f052011-03-30 08:52:27 +00002657
2658 // Build the sequence for the graph.
jkummerow@chromium.org28583c92012-07-16 11:31:55 +00002659 LPlatformChunk* Build();
lrn@chromium.org7516f052011-03-30 08:52:27 +00002660
2661 // Declare methods that deal with the individual node types.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002662#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
lrn@chromium.org7516f052011-03-30 08:52:27 +00002663 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2664#undef DECLARE_DO
2665
jkummerow@chromium.org59297c72013-01-09 16:32:23 +00002666 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
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_