blob: 67bf9376c71b38e86e7d206e6d7a92c0d6b9fdd4 [file] [log] [blame]
Ben Murdochc7cc0282012-03-05 14:35:55 +00001// Copyright 2012 the V8 project authors. All rights reserved.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002// 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_IA32_LITHIUM_IA32_H_
29#define V8_IA32_LITHIUM_IA32_H_
30
31#include "hydrogen.h"
32#include "lithium-allocator.h"
Ben Murdoch086aeea2011-05-13 15:57:08 +010033#include "lithium.h"
Ben Murdochb0fe1622011-05-05 13:52:32 +010034#include "safepoint-table.h"
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000035#include "utils.h"
Ben Murdochb0fe1622011-05-05 13:52:32 +010036
37namespace v8 {
38namespace internal {
39
40// Forward declarations.
41class LCodeGen;
Ben Murdochb0fe1622011-05-05 13:52:32 +010042
Ben Murdochb0fe1622011-05-05 13:52:32 +010043#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
44 V(AccessArgumentsAt) \
45 V(AddI) \
46 V(ApplyArguments) \
47 V(ArgumentsElements) \
48 V(ArgumentsLength) \
49 V(ArithmeticD) \
50 V(ArithmeticT) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010051 V(ArrayLiteral) \
52 V(BitI) \
53 V(BitNotI) \
54 V(BoundsCheck) \
55 V(Branch) \
56 V(CallConstantFunction) \
57 V(CallFunction) \
58 V(CallGlobal) \
59 V(CallKeyed) \
60 V(CallKnownGlobal) \
61 V(CallNamed) \
62 V(CallNew) \
63 V(CallRuntime) \
64 V(CallStub) \
65 V(CheckFunction) \
66 V(CheckInstanceType) \
67 V(CheckMap) \
Steve Block44f0eee2011-05-26 01:26:41 +010068 V(CheckNonSmi) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010069 V(CheckPrototypeMaps) \
70 V(CheckSmi) \
Ben Murdoch257744e2011-11-30 15:57:28 +000071 V(ClampDToUint8) \
72 V(ClampIToUint8) \
73 V(ClampTToUint8) \
Steve Block1e0659c2011-05-24 12:43:12 +010074 V(ClassOfTestAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010075 V(CmpIDAndBranch) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000076 V(CmpObjectEqAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010077 V(CmpMapAndBranch) \
78 V(CmpT) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000079 V(CmpConstantEqAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010080 V(ConstantD) \
81 V(ConstantI) \
82 V(ConstantT) \
Steve Block1e0659c2011-05-24 12:43:12 +010083 V(Context) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010084 V(DeleteProperty) \
85 V(Deoptimize) \
86 V(DivI) \
87 V(DoubleToI) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000088 V(ElementsKind) \
Ben Murdoch69a99ed2011-11-30 16:03:39 +000089 V(FixedArrayBaseLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010090 V(FunctionLiteral) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +010091 V(GetCachedArrayIndex) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010092 V(GlobalObject) \
93 V(GlobalReceiver) \
94 V(Goto) \
Steve Block1e0659c2011-05-24 12:43:12 +010095 V(HasCachedArrayIndexAndBranch) \
Steve Block1e0659c2011-05-24 12:43:12 +010096 V(HasInstanceTypeAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +000097 V(In) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010098 V(InstanceOf) \
Ben Murdoch086aeea2011-05-13 15:57:08 +010099 V(InstanceOfKnownGlobal) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000100 V(InstructionGap) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100101 V(Integer32ToDouble) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000102 V(InvokeFunction) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000103 V(IsConstructCallAndBranch) \
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000104 V(IsNilAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100105 V(IsObjectAndBranch) \
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000106 V(IsStringAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100107 V(IsSmiAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000108 V(IsUndetectableAndBranch) \
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000109 V(StringCompareAndBranch) \
Steve Block9fac8402011-05-12 15:51:54 +0100110 V(JSArrayLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100111 V(Label) \
112 V(LazyBailout) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100113 V(LoadContextSlot) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100114 V(LoadElements) \
Steve Block44f0eee2011-05-26 01:26:41 +0100115 V(LoadExternalArrayPointer) \
Steve Block1e0659c2011-05-24 12:43:12 +0100116 V(LoadFunctionPrototype) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100117 V(LoadGlobalCell) \
118 V(LoadGlobalGeneric) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100119 V(LoadKeyedFastElement) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000120 V(LoadKeyedFastDoubleElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100121 V(LoadKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100122 V(LoadKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100123 V(LoadNamedField) \
Steve Block44f0eee2011-05-26 01:26:41 +0100124 V(LoadNamedFieldPolymorphic) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100125 V(LoadNamedGeneric) \
Ben Murdochc7cc0282012-03-05 14:35:55 +0000126 V(MathPowHalf) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100127 V(ModI) \
128 V(MulI) \
129 V(NumberTagD) \
130 V(NumberTagI) \
131 V(NumberUntagD) \
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000132 V(ObjectLiteralFast) \
133 V(ObjectLiteralGeneric) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100134 V(OsrEntry) \
Steve Block1e0659c2011-05-24 12:43:12 +0100135 V(OuterContext) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100136 V(Parameter) \
137 V(Power) \
Ben Murdochc7cc0282012-03-05 14:35:55 +0000138 V(Random) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100139 V(PushArgument) \
140 V(RegExpLiteral) \
141 V(Return) \
142 V(ShiftI) \
143 V(SmiTag) \
144 V(SmiUntag) \
145 V(StackCheck) \
Steve Block1e0659c2011-05-24 12:43:12 +0100146 V(StoreContextSlot) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100147 V(StoreGlobalCell) \
148 V(StoreGlobalGeneric) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000149 V(StoreKeyedFastDoubleElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100150 V(StoreKeyedFastElement) \
151 V(StoreKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100152 V(StoreKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100153 V(StoreNamedField) \
154 V(StoreNamedGeneric) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000155 V(StringAdd) \
Steve Block1e0659c2011-05-24 12:43:12 +0100156 V(StringCharCodeAt) \
Steve Block44f0eee2011-05-26 01:26:41 +0100157 V(StringCharFromCode) \
Steve Block1e0659c2011-05-24 12:43:12 +0100158 V(StringLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100159 V(SubI) \
160 V(TaggedToI) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000161 V(ThisFunction) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100162 V(Throw) \
Steve Block44f0eee2011-05-26 01:26:41 +0100163 V(ToFastProperties) \
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000164 V(TransitionElementsKind) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100165 V(Typeof) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100166 V(TypeofIsAndBranch) \
167 V(UnaryMathOperation) \
168 V(UnknownOSRValue) \
169 V(ValueOf)
170
171
Ben Murdoch257744e2011-11-30 15:57:28 +0000172#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
173 virtual Opcode opcode() const { return LInstruction::k##type; } \
174 virtual void CompileToNative(LCodeGen* generator); \
175 virtual const char* Mnemonic() const { return mnemonic; } \
176 static L##type* cast(LInstruction* instr) { \
177 ASSERT(instr->Is##type()); \
178 return reinterpret_cast<L##type*>(instr); \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100179 }
180
181
Ben Murdochb0fe1622011-05-05 13:52:32 +0100182#define DECLARE_HYDROGEN_ACCESSOR(type) \
183 H##type* hydrogen() const { \
184 return H##type::cast(hydrogen_value()); \
185 }
186
187
188class LInstruction: public ZoneObject {
189 public:
190 LInstruction()
Steve Block1e0659c2011-05-24 12:43:12 +0100191 : environment_(NULL),
192 hydrogen_value_(NULL),
193 is_call_(false),
194 is_save_doubles_(false) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100195 virtual ~LInstruction() { }
196
197 virtual void CompileToNative(LCodeGen* generator) = 0;
198 virtual const char* Mnemonic() const = 0;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100199 virtual void PrintTo(StringStream* stream);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000200 virtual void PrintDataTo(StringStream* stream);
201 virtual void PrintOutputOperandTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100202
Ben Murdoch257744e2011-11-30 15:57:28 +0000203 enum Opcode {
204 // Declare a unique enum value for each instruction.
205#define DECLARE_OPCODE(type) k##type,
206 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
207 kNumberOfInstructions
208#undef DECLARE_OPCODE
209 };
210
211 virtual Opcode opcode() const = 0;
212
213 // Declare non-virtual type testers for all leaf IR classes.
214#define DECLARE_PREDICATE(type) \
215 bool Is##type() const { return opcode() == k##type; }
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
217#undef DECLARE_PREDICATE
218
219 // Declare virtual predicates for instructions that don't have
220 // an opcode.
221 virtual bool IsGap() const { return false; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100222
Ben Murdochb0fe1622011-05-05 13:52:32 +0100223 virtual bool IsControl() const { return false; }
224
Steve Block1e0659c2011-05-24 12:43:12 +0100225 void set_environment(LEnvironment* env) { environment_ = env; }
226 LEnvironment* environment() const { return environment_; }
227 bool HasEnvironment() const { return environment_ != NULL; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100228
229 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
230 LPointerMap* pointer_map() const { return pointer_map_.get(); }
231 bool HasPointerMap() const { return pointer_map_.is_set(); }
232
Ben Murdochb0fe1622011-05-05 13:52:32 +0100233
234 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
235 HValue* hydrogen_value() const { return hydrogen_value_; }
236
237 void set_deoptimization_environment(LEnvironment* env) {
238 deoptimization_environment_.set(env);
239 }
240 LEnvironment* deoptimization_environment() const {
241 return deoptimization_environment_.get();
242 }
243 bool HasDeoptimizationEnvironment() const {
244 return deoptimization_environment_.is_set();
245 }
246
Steve Block1e0659c2011-05-24 12:43:12 +0100247 void MarkAsCall() { is_call_ = true; }
248 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
249
250 // Interface to the register allocator and iterators.
251 bool IsMarkedAsCall() const { return is_call_; }
252 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
253
254 virtual bool HasResult() const = 0;
255 virtual LOperand* result() = 0;
256
257 virtual int InputCount() = 0;
258 virtual LOperand* InputAt(int i) = 0;
259 virtual int TempCount() = 0;
260 virtual LOperand* TempAt(int i) = 0;
261
262 LOperand* FirstInput() { return InputAt(0); }
263 LOperand* Output() { return HasResult() ? result() : NULL; }
264
265#ifdef DEBUG
266 void VerifyCall();
267#endif
268
Ben Murdochb0fe1622011-05-05 13:52:32 +0100269 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100270 LEnvironment* environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100271 SetOncePointer<LPointerMap> pointer_map_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100272 HValue* hydrogen_value_;
273 SetOncePointer<LEnvironment> deoptimization_environment_;
Steve Block1e0659c2011-05-24 12:43:12 +0100274 bool is_call_;
275 bool is_save_doubles_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100276};
277
278
Steve Block1e0659c2011-05-24 12:43:12 +0100279// R = number of result operands (0 or 1).
280// I = number of input operands.
281// T = number of temporary operands.
282template<int R, int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100283class LTemplateInstruction: public LInstruction {
284 public:
285 // Allow 0 or 1 output operands.
286 STATIC_ASSERT(R == 0 || R == 1);
287 virtual bool HasResult() const { return R != 0; }
288 void set_result(LOperand* operand) { results_[0] = operand; }
289 LOperand* result() { return results_[0]; }
290
291 int InputCount() { return I; }
292 LOperand* InputAt(int i) { return inputs_[i]; }
293
294 int TempCount() { return T; }
295 LOperand* TempAt(int i) { return temps_[i]; }
296
Ben Murdochb8e0da22011-05-16 14:20:40 +0100297 protected:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000298 EmbeddedContainer<LOperand*, R> results_;
299 EmbeddedContainer<LOperand*, I> inputs_;
300 EmbeddedContainer<LOperand*, T> temps_;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100301};
302
303
304class LGap: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100305 public:
Ben Murdoch257744e2011-11-30 15:57:28 +0000306 explicit LGap(HBasicBlock* block) : block_(block) {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100307 parallel_moves_[BEFORE] = NULL;
308 parallel_moves_[START] = NULL;
309 parallel_moves_[END] = NULL;
310 parallel_moves_[AFTER] = NULL;
311 }
312
Ben Murdoch257744e2011-11-30 15:57:28 +0000313 // Can't use the DECLARE-macro here because of sub-classes.
314 virtual bool IsGap() const { return true; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100315 virtual void PrintDataTo(StringStream* stream);
Ben Murdoch257744e2011-11-30 15:57:28 +0000316 static LGap* cast(LInstruction* instr) {
317 ASSERT(instr->IsGap());
318 return reinterpret_cast<LGap*>(instr);
319 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100320
321 bool IsRedundant() const;
322
323 HBasicBlock* block() const { return block_; }
324
325 enum InnerPosition {
326 BEFORE,
327 START,
328 END,
329 AFTER,
330 FIRST_INNER_POSITION = BEFORE,
331 LAST_INNER_POSITION = AFTER
332 };
333
334 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
335 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
336 return parallel_moves_[pos];
337 }
338
339 LParallelMove* GetParallelMove(InnerPosition pos) {
340 return parallel_moves_[pos];
341 }
342
343 private:
344 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
345 HBasicBlock* block_;
346};
347
348
Ben Murdoch257744e2011-11-30 15:57:28 +0000349class LInstructionGap: public LGap {
350 public:
351 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
352
353 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
354};
355
356
Ben Murdochb8e0da22011-05-16 14:20:40 +0100357class LGoto: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100358 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000359 explicit LGoto(int block_id) : block_id_(block_id) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100360
361 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100362 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100363 virtual bool IsControl() const { return true; }
364
365 int block_id() const { return block_id_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100366
367 private:
368 int block_id_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100369};
370
371
Ben Murdochb8e0da22011-05-16 14:20:40 +0100372class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100373 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +0100374 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100375};
376
377
Ben Murdochb8e0da22011-05-16 14:20:40 +0100378class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100379 public:
380 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
381};
382
383
384class LLabel: public LGap {
385 public:
386 explicit LLabel(HBasicBlock* block)
387 : LGap(block), replacement_(NULL) { }
388
389 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
390
Ben Murdochb8e0da22011-05-16 14:20:40 +0100391 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100392
393 int block_id() const { return block()->block_id(); }
394 bool is_loop_header() const { return block()->IsLoopHeader(); }
395 Label* label() { return &label_; }
396 LLabel* replacement() const { return replacement_; }
397 void set_replacement(LLabel* label) { replacement_ = label; }
398 bool HasReplacement() const { return replacement_ != NULL; }
399
400 private:
401 Label label_;
402 LLabel* replacement_;
403};
404
405
Ben Murdochb8e0da22011-05-16 14:20:40 +0100406class LParameter: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100407 public:
408 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
409};
410
411
Steve Block1e0659c2011-05-24 12:43:12 +0100412class LCallStub: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100413 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100414 explicit LCallStub(LOperand* context) {
415 inputs_[0] = context;
416 }
417
Ben Murdochb0fe1622011-05-05 13:52:32 +0100418 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
419 DECLARE_HYDROGEN_ACCESSOR(CallStub)
420
Steve Block1e0659c2011-05-24 12:43:12 +0100421 LOperand* context() { return inputs_[0]; }
422
Ben Murdochb0fe1622011-05-05 13:52:32 +0100423 TranscendentalCache::Type transcendental_type() {
424 return hydrogen()->transcendental_type();
425 }
426};
427
428
Ben Murdochb8e0da22011-05-16 14:20:40 +0100429class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100430 public:
431 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
432};
433
434
Steve Block1e0659c2011-05-24 12:43:12 +0100435template<int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100436class LControlInstruction: public LTemplateInstruction<0, I, T> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100437 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100438 virtual bool IsControl() const { return true; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100439
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000440 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
441 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
442 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
443 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100444
445 private:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000446 HControlInstruction* hydrogen() {
447 return HControlInstruction::cast(this->hydrogen_value());
448 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100449};
450
451
Steve Block1e0659c2011-05-24 12:43:12 +0100452class LApplyArguments: public LTemplateInstruction<1, 4, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100453 public:
454 LApplyArguments(LOperand* function,
455 LOperand* receiver,
456 LOperand* length,
Steve Block1e0659c2011-05-24 12:43:12 +0100457 LOperand* elements,
458 LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100459 inputs_[0] = function;
460 inputs_[1] = receiver;
461 inputs_[2] = length;
462 inputs_[3] = elements;
Steve Block1e0659c2011-05-24 12:43:12 +0100463 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100464 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100465
466 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
467
Ben Murdochb8e0da22011-05-16 14:20:40 +0100468 LOperand* function() { return inputs_[0]; }
469 LOperand* receiver() { return inputs_[1]; }
470 LOperand* length() { return inputs_[2]; }
471 LOperand* elements() { return inputs_[3]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100472};
473
474
Ben Murdochb8e0da22011-05-16 14:20:40 +0100475class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100476 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100477 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
478 inputs_[0] = arguments;
479 inputs_[1] = length;
480 inputs_[2] = index;
481 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100482
483 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
484
Ben Murdochb8e0da22011-05-16 14:20:40 +0100485 LOperand* arguments() { return inputs_[0]; }
486 LOperand* length() { return inputs_[1]; }
487 LOperand* index() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100488
Ben Murdochb8e0da22011-05-16 14:20:40 +0100489 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100490};
491
492
Steve Block1e0659c2011-05-24 12:43:12 +0100493class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100494 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100495 explicit LArgumentsLength(LOperand* elements) {
496 inputs_[0] = elements;
497 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100498
499 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
500};
501
502
Ben Murdochb8e0da22011-05-16 14:20:40 +0100503class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100504 public:
505 LArgumentsElements() { }
506
507 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
508};
509
510
Ben Murdochb8e0da22011-05-16 14:20:40 +0100511class LModI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100512 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100513 LModI(LOperand* left, LOperand* right, LOperand* temp) {
514 inputs_[0] = left;
515 inputs_[1] = right;
516 temps_[0] = temp;
517 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100518
519 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
520 DECLARE_HYDROGEN_ACCESSOR(Mod)
521};
522
523
Ben Murdochb8e0da22011-05-16 14:20:40 +0100524class LDivI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100525 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100526 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
527 inputs_[0] = left;
528 inputs_[1] = right;
529 temps_[0] = temp;
530 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100531
532 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
533 DECLARE_HYDROGEN_ACCESSOR(Div)
534};
535
536
Ben Murdochb8e0da22011-05-16 14:20:40 +0100537class LMulI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100538 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100539 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
540 inputs_[0] = left;
541 inputs_[1] = right;
542 temps_[0] = temp;
543 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100544
545 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
546 DECLARE_HYDROGEN_ACCESSOR(Mul)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100547};
548
549
Steve Block1e0659c2011-05-24 12:43:12 +0100550class LCmpIDAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100551 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100552 LCmpIDAndBranch(LOperand* left, LOperand* right) {
553 inputs_[0] = left;
554 inputs_[1] = right;
555 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100556
557 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000558 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100559
Ben Murdochb8e0da22011-05-16 14:20:40 +0100560 Token::Value op() const { return hydrogen()->token(); }
561 bool is_double() const {
562 return hydrogen()->GetInputRepresentation().IsDouble();
563 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100564
Ben Murdochb8e0da22011-05-16 14:20:40 +0100565 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100566};
567
568
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000569class LUnaryMathOperation: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100570 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000571 LUnaryMathOperation(LOperand* context, LOperand* value) {
572 inputs_[1] = context;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100573 inputs_[0] = value;
574 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100575
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000576 LOperand* context() { return inputs_[1]; }
577 LOperand* value() { return inputs_[0]; }
578
Ben Murdochb0fe1622011-05-05 13:52:32 +0100579 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
580 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
581
Ben Murdochb8e0da22011-05-16 14:20:40 +0100582 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100583 BuiltinFunctionId op() const { return hydrogen()->op(); }
584};
585
586
Ben Murdochc7cc0282012-03-05 14:35:55 +0000587class LMathPowHalf: public LTemplateInstruction<1, 2, 1> {
588 public:
589 LMathPowHalf(LOperand* context, LOperand* value, LOperand* temp) {
590 inputs_[1] = context;
591 inputs_[0] = value;
592 temps_[0] = temp;
593 }
594
595 LOperand* context() { return inputs_[1]; }
596 LOperand* value() { return inputs_[0]; }
597 LOperand* temp() { return temps_[0]; }
598
599 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
600
601 virtual void PrintDataTo(StringStream* stream);
602};
603
604
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000605class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100606 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000607 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100608 inputs_[0] = left;
609 inputs_[1] = right;
610 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100611
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000612 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
613 "cmp-object-eq-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100614};
615
616
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000617class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100618 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000619 explicit LCmpConstantEqAndBranch(LOperand* left) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100620 inputs_[0] = left;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100621 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100622
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000623 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
624 "cmp-constant-eq-and-branch")
625 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100626};
627
628
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000629class LIsNilAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100630 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000631 LIsNilAndBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100632 inputs_[0] = value;
633 temps_[0] = temp;
634 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100635
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000636 DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch")
637 DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100638
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000639 EqualityKind kind() const { return hydrogen()->kind(); }
640 NilValue nil() const { return hydrogen()->nil(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100641
Ben Murdochb8e0da22011-05-16 14:20:40 +0100642 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100643};
644
645
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000646class LIsObjectAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100647 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000648 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100649 inputs_[0] = value;
650 temps_[0] = temp;
651 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100652
Ben Murdochb0fe1622011-05-05 13:52:32 +0100653 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100654
Ben Murdochb8e0da22011-05-16 14:20:40 +0100655 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100656};
657
658
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000659class LIsStringAndBranch: public LControlInstruction<1, 1> {
660 public:
661 LIsStringAndBranch(LOperand* value, LOperand* temp) {
662 inputs_[0] = value;
663 temps_[0] = temp;
664 }
665
666 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
667
668 virtual void PrintDataTo(StringStream* stream);
669};
670
671
Steve Block1e0659c2011-05-24 12:43:12 +0100672class LIsSmiAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100673 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100674 explicit LIsSmiAndBranch(LOperand* value) {
675 inputs_[0] = value;
676 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100677
678 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000679 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100680
Ben Murdochb8e0da22011-05-16 14:20:40 +0100681 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100682};
683
684
Ben Murdoch257744e2011-11-30 15:57:28 +0000685class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
686 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000687 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
Ben Murdoch257744e2011-11-30 15:57:28 +0000688 inputs_[0] = value;
689 temps_[0] = temp;
690 }
691
692 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
693 "is-undetectable-and-branch")
694
695 virtual void PrintDataTo(StringStream* stream);
696};
697
698
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000699class LStringCompareAndBranch: public LControlInstruction<3, 0> {
700 public:
701 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
702 inputs_[0] = context;
703 inputs_[1] = left;
704 inputs_[2] = right;
705 }
706
707 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
708 "string-compare-and-branch")
709 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
710
711 virtual void PrintDataTo(StringStream* stream);
712
713 Token::Value op() const { return hydrogen()->token(); }
714};
715
716
Ben Murdochb8e0da22011-05-16 14:20:40 +0100717class LHasInstanceTypeAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100718 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100719 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
720 inputs_[0] = value;
721 temps_[0] = temp;
722 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100723
724 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
725 "has-instance-type-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000726 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100727
Ben Murdochb8e0da22011-05-16 14:20:40 +0100728 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100729};
730
731
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100732class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
733 public:
734 explicit LGetCachedArrayIndex(LOperand* value) {
735 inputs_[0] = value;
736 }
737
738 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
739 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
740};
741
742
Steve Block1e0659c2011-05-24 12:43:12 +0100743class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100744 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100745 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
746 inputs_[0] = value;
747 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100748
749 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
750 "has-cached-array-index-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100751 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100752};
753
754
Steve Block1e0659c2011-05-24 12:43:12 +0100755class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
756 public:
757 explicit LIsConstructCallAndBranch(LOperand* temp) {
758 temps_[0] = temp;
759 }
760
761 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
762 "is-construct-call-and-branch")
763};
764
765
Ben Murdochb8e0da22011-05-16 14:20:40 +0100766class LClassOfTestAndBranch: public LControlInstruction<1, 2> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100767 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100768 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
769 inputs_[0] = value;
770 temps_[0] = temp;
771 temps_[1] = temp2;
772 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100773
774 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
775 "class-of-test-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000776 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100777
Ben Murdochb8e0da22011-05-16 14:20:40 +0100778 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100779};
780
781
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000782class LCmpT: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100783 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000784 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
785 inputs_[0] = context;
786 inputs_[1] = left;
787 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100788 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100789
790 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000791 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100792
Ben Murdochb8e0da22011-05-16 14:20:40 +0100793 Token::Value op() const { return hydrogen()->token(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100794};
795
796
Steve Block1e0659c2011-05-24 12:43:12 +0100797class LInstanceOf: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100798 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100799 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
800 inputs_[0] = context;
801 inputs_[1] = left;
802 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100803 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100804
805 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
Steve Block1e0659c2011-05-24 12:43:12 +0100806
807 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100808};
809
810
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000811class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100812 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000813 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
Steve Block1e0659c2011-05-24 12:43:12 +0100814 inputs_[0] = context;
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000815 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100816 temps_[0] = temp;
817 }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100818
819 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
820 "instance-of-known-global")
821 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
822
823 Handle<JSFunction> function() const { return hydrogen()->function(); }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100824};
825
826
Ben Murdochb8e0da22011-05-16 14:20:40 +0100827class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100828 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100829 LBoundsCheck(LOperand* index, LOperand* length) {
830 inputs_[0] = index;
831 inputs_[1] = length;
832 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100833
Ben Murdochb8e0da22011-05-16 14:20:40 +0100834 LOperand* index() { return inputs_[0]; }
835 LOperand* length() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100836
837 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
838};
839
840
Steve Block1e0659c2011-05-24 12:43:12 +0100841class LBitI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100842 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000843 LBitI(LOperand* left, LOperand* right) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100844 inputs_[0] = left;
845 inputs_[1] = right;
846 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100847
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000848 Token::Value op() const { return hydrogen()->op(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100849
850 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000851 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100852};
853
854
Steve Block1e0659c2011-05-24 12:43:12 +0100855class LShiftI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100856 public:
857 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100858 : op_(op), can_deopt_(can_deopt) {
859 inputs_[0] = left;
860 inputs_[1] = right;
861 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100862
863 Token::Value op() const { return op_; }
864
865 bool can_deopt() const { return can_deopt_; }
866
867 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
868
869 private:
870 Token::Value op_;
871 bool can_deopt_;
872};
873
874
Steve Block1e0659c2011-05-24 12:43:12 +0100875class LSubI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100876 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100877 LSubI(LOperand* left, LOperand* right) {
878 inputs_[0] = left;
879 inputs_[1] = right;
880 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100881
882 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
883 DECLARE_HYDROGEN_ACCESSOR(Sub)
884};
885
886
Steve Block1e0659c2011-05-24 12:43:12 +0100887class LConstantI: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100888 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +0100889 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
Steve Block1e0659c2011-05-24 12:43:12 +0100890 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100891
Steve Block1e0659c2011-05-24 12:43:12 +0100892 int32_t value() const { return hydrogen()->Integer32Value(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100893};
894
895
Steve Block1e0659c2011-05-24 12:43:12 +0100896class LConstantD: public LTemplateInstruction<1, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100897 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100898 explicit LConstantD(LOperand* temp) {
899 temps_[0] = temp;
900 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100901
902 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
Steve Block1e0659c2011-05-24 12:43:12 +0100903 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100904
Steve Block1e0659c2011-05-24 12:43:12 +0100905 double value() const { return hydrogen()->DoubleValue(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100906};
907
908
Steve Block1e0659c2011-05-24 12:43:12 +0100909class LConstantT: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100910 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +0100911 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
Steve Block1e0659c2011-05-24 12:43:12 +0100912 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100913
Steve Block1e0659c2011-05-24 12:43:12 +0100914 Handle<Object> value() const { return hydrogen()->handle(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100915};
916
917
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000918class LBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100919 public:
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000920 explicit LBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100921 inputs_[0] = value;
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000922 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100923 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100924
925 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000926 DECLARE_HYDROGEN_ACCESSOR(Branch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100927
Ben Murdochb8e0da22011-05-16 14:20:40 +0100928 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100929};
930
931
Steve Block1e0659c2011-05-24 12:43:12 +0100932class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100933 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100934 explicit LCmpMapAndBranch(LOperand* value) {
935 inputs_[0] = value;
936 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100937
938 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
Steve Block1e0659c2011-05-24 12:43:12 +0100939 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100940
941 virtual bool IsControl() const { return true; }
942
Ben Murdoch086aeea2011-05-13 15:57:08 +0100943 Handle<Map> map() const { return hydrogen()->map(); }
944 int true_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100945 return hydrogen()->FirstSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +0100946 }
947 int false_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100948 return hydrogen()->SecondSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +0100949 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100950};
951
952
Steve Block1e0659c2011-05-24 12:43:12 +0100953class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100954 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100955 explicit LJSArrayLength(LOperand* value) {
956 inputs_[0] = value;
957 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100958
Steve Block9fac8402011-05-12 15:51:54 +0100959 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
960 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
961};
Ben Murdochb0fe1622011-05-05 13:52:32 +0100962
Ben Murdochb0fe1622011-05-05 13:52:32 +0100963
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000964class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +0100965 public:
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000966 explicit LFixedArrayBaseLength(LOperand* value) {
Steve Block1e0659c2011-05-24 12:43:12 +0100967 inputs_[0] = value;
968 }
969
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000970 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
971 "fixed-array-base-length")
972 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100973};
974
975
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000976class LElementsKind: public LTemplateInstruction<1, 1, 0> {
977 public:
978 explicit LElementsKind(LOperand* value) {
979 inputs_[0] = value;
980 }
981
982 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
983 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
984};
985
986
Ben Murdochb8e0da22011-05-16 14:20:40 +0100987class LValueOf: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100988 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100989 LValueOf(LOperand* value, LOperand* temp) {
990 inputs_[0] = value;
991 temps_[0] = temp;
992 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100993
994 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
995 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100996};
997
998
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000999class LThrow: public LTemplateInstruction<0, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001000 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001001 LThrow(LOperand* context, LOperand* value) {
1002 inputs_[0] = context;
1003 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001004 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001005
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001006 LOperand* context() { return inputs_[0]; }
1007 LOperand* value() { return inputs_[1]; }
1008
Ben Murdochb0fe1622011-05-05 13:52:32 +01001009 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1010};
1011
1012
Steve Block1e0659c2011-05-24 12:43:12 +01001013class LBitNotI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001014 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001015 explicit LBitNotI(LOperand* value) {
1016 inputs_[0] = value;
1017 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001018
1019 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1020};
1021
1022
Steve Block1e0659c2011-05-24 12:43:12 +01001023class LAddI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001024 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001025 LAddI(LOperand* left, LOperand* right) {
1026 inputs_[0] = left;
1027 inputs_[1] = right;
1028 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001029
1030 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1031 DECLARE_HYDROGEN_ACCESSOR(Add)
1032};
1033
1034
Steve Block1e0659c2011-05-24 12:43:12 +01001035class LPower: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001036 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001037 LPower(LOperand* left, LOperand* right) {
1038 inputs_[0] = left;
1039 inputs_[1] = right;
1040 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001041
1042 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1043 DECLARE_HYDROGEN_ACCESSOR(Power)
1044};
1045
1046
Ben Murdochc7cc0282012-03-05 14:35:55 +00001047class LRandom: public LTemplateInstruction<1, 1, 0> {
1048 public:
1049 explicit LRandom(LOperand* global_object) {
1050 inputs_[0] = global_object;
1051 }
1052
1053 DECLARE_CONCRETE_INSTRUCTION(Random, "random")
1054 DECLARE_HYDROGEN_ACCESSOR(Random)
1055};
1056
1057
Steve Block1e0659c2011-05-24 12:43:12 +01001058class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001059 public:
1060 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001061 : op_(op) {
1062 inputs_[0] = left;
1063 inputs_[1] = right;
1064 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001065
1066 Token::Value op() const { return op_; }
1067
Ben Murdoch257744e2011-11-30 15:57:28 +00001068 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001069 virtual void CompileToNative(LCodeGen* generator);
1070 virtual const char* Mnemonic() const;
1071
1072 private:
1073 Token::Value op_;
1074};
1075
1076
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001077class LArithmeticT: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001078 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001079 LArithmeticT(Token::Value op,
1080 LOperand* context,
1081 LOperand* left,
1082 LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001083 : op_(op) {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001084 inputs_[0] = context;
1085 inputs_[1] = left;
1086 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001087 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001088
Ben Murdoch257744e2011-11-30 15:57:28 +00001089 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001090 virtual void CompileToNative(LCodeGen* generator);
1091 virtual const char* Mnemonic() const;
1092
1093 Token::Value op() const { return op_; }
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001094 LOperand* context() { return inputs_[0]; }
1095 LOperand* left() { return inputs_[1]; }
1096 LOperand* right() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001097
1098 private:
1099 Token::Value op_;
1100};
1101
1102
Steve Block1e0659c2011-05-24 12:43:12 +01001103class LReturn: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001104 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001105 explicit LReturn(LOperand* value) {
1106 inputs_[0] = value;
1107 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001108
1109 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1110};
1111
1112
Steve Block1e0659c2011-05-24 12:43:12 +01001113class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001114 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001115 explicit LLoadNamedField(LOperand* object) {
1116 inputs_[0] = object;
1117 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001118
1119 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1120 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
Steve Block44f0eee2011-05-26 01:26:41 +01001121
1122 LOperand* object() { return inputs_[0]; }
1123};
1124
1125
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001126class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 2, 0> {
Steve Block44f0eee2011-05-26 01:26:41 +01001127 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001128 LLoadNamedFieldPolymorphic(LOperand* context, LOperand* object) {
1129 inputs_[0] = context;
1130 inputs_[1] = object;
Steve Block44f0eee2011-05-26 01:26:41 +01001131 }
1132
1133 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1134 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1135
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001136 LOperand* context() { return inputs_[0]; }
1137 LOperand* object() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001138};
1139
1140
Steve Block1e0659c2011-05-24 12:43:12 +01001141class LLoadNamedGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001142 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001143 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1144 inputs_[0] = context;
1145 inputs_[1] = object;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001146 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001147
1148 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1149 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1150
Steve Block1e0659c2011-05-24 12:43:12 +01001151 LOperand* context() { return inputs_[0]; }
1152 LOperand* object() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001153 Handle<Object> name() const { return hydrogen()->name(); }
1154};
1155
1156
Ben Murdochb8e0da22011-05-16 14:20:40 +01001157class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 1> {
Steve Block9fac8402011-05-12 15:51:54 +01001158 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001159 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1160 inputs_[0] = function;
1161 temps_[0] = temp;
1162 }
Steve Block9fac8402011-05-12 15:51:54 +01001163
1164 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1165 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1166
Ben Murdochb8e0da22011-05-16 14:20:40 +01001167 LOperand* function() { return inputs_[0]; }
Steve Block9fac8402011-05-12 15:51:54 +01001168};
1169
1170
Steve Block1e0659c2011-05-24 12:43:12 +01001171class LLoadElements: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001172 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001173 explicit LLoadElements(LOperand* object) {
1174 inputs_[0] = object;
1175 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001176
1177 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1178};
1179
1180
Steve Block44f0eee2011-05-26 01:26:41 +01001181class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001182 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001183 explicit LLoadExternalArrayPointer(LOperand* object) {
Steve Block1e0659c2011-05-24 12:43:12 +01001184 inputs_[0] = object;
1185 }
1186
Steve Block44f0eee2011-05-26 01:26:41 +01001187 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1188 "load-external-array-pointer")
Steve Block1e0659c2011-05-24 12:43:12 +01001189};
1190
1191
1192class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001193 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001194 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1195 inputs_[0] = elements;
1196 inputs_[1] = key;
1197 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001198
1199 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1200 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1201
Ben Murdochb8e0da22011-05-16 14:20:40 +01001202 LOperand* elements() { return inputs_[0]; }
1203 LOperand* key() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001204};
1205
1206
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001207class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> {
1208 public:
1209 LLoadKeyedFastDoubleElement(LOperand* elements,
1210 LOperand* key) {
1211 inputs_[0] = elements;
1212 inputs_[1] = key;
1213 }
1214
1215 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement,
1216 "load-keyed-fast-double-element")
1217 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement)
1218
1219 LOperand* elements() { return inputs_[0]; }
1220 LOperand* key() { return inputs_[1]; }
1221};
1222
1223
Steve Block44f0eee2011-05-26 01:26:41 +01001224class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001225 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001226 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1227 LOperand* key) {
Steve Block1e0659c2011-05-24 12:43:12 +01001228 inputs_[0] = external_pointer;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001229 inputs_[1] = key;
1230 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001231
Steve Block44f0eee2011-05-26 01:26:41 +01001232 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1233 "load-keyed-specialized-array-element")
1234 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
Steve Block1e0659c2011-05-24 12:43:12 +01001235
1236 LOperand* external_pointer() { return inputs_[0]; }
1237 LOperand* key() { return inputs_[1]; }
Ben Murdoch589d6972011-11-30 16:04:58 +00001238 ElementsKind elements_kind() const {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001239 return hydrogen()->elements_kind();
Steve Block44f0eee2011-05-26 01:26:41 +01001240 }
Steve Block1e0659c2011-05-24 12:43:12 +01001241};
1242
1243
1244class LLoadKeyedGeneric: public LTemplateInstruction<1, 3, 0> {
1245 public:
1246 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1247 inputs_[0] = context;
1248 inputs_[1] = obj;
1249 inputs_[2] = key;
1250 }
1251
Ben Murdochb0fe1622011-05-05 13:52:32 +01001252 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1253
Steve Block1e0659c2011-05-24 12:43:12 +01001254 LOperand* context() { return inputs_[0]; }
1255 LOperand* object() { return inputs_[1]; }
1256 LOperand* key() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001257};
1258
1259
Ben Murdoch8b112d22011-06-08 16:22:53 +01001260class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001261 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001262 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1263 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001264};
1265
1266
Ben Murdoch8b112d22011-06-08 16:22:53 +01001267class LLoadGlobalGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001268 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001269 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1270 inputs_[0] = context;
1271 inputs_[1] = global_object;
1272 }
1273
1274 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1275 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1276
1277 LOperand* context() { return inputs_[0]; }
1278 LOperand* global_object() { return inputs_[1]; }
1279 Handle<Object> name() const { return hydrogen()->name(); }
1280 bool for_typeof() const { return hydrogen()->for_typeof(); }
1281};
1282
1283
Ben Murdochc7cc0282012-03-05 14:35:55 +00001284class LStoreGlobalCell: public LTemplateInstruction<0, 1, 0> {
Ben Murdoch8b112d22011-06-08 16:22:53 +01001285 public:
Ben Murdochc7cc0282012-03-05 14:35:55 +00001286 explicit LStoreGlobalCell(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001287 inputs_[0] = value;
1288 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001289
Ben Murdoch8b112d22011-06-08 16:22:53 +01001290 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1291 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
Ben Murdochc7cc0282012-03-05 14:35:55 +00001292
1293 LOperand* value() { return inputs_[0]; }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001294};
1295
1296
1297class LStoreGlobalGeneric: public LTemplateInstruction<0, 3, 0> {
1298 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001299 LStoreGlobalGeneric(LOperand* context,
1300 LOperand* global_object,
1301 LOperand* value) {
Ben Murdoch8b112d22011-06-08 16:22:53 +01001302 inputs_[0] = context;
1303 inputs_[1] = global_object;
1304 inputs_[2] = value;
1305 }
1306
1307 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1308 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1309
1310 LOperand* context() { return InputAt(0); }
1311 LOperand* global_object() { return InputAt(1); }
1312 Handle<Object> name() const { return hydrogen()->name(); }
1313 LOperand* value() { return InputAt(2); }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001314 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001315};
1316
1317
Steve Block1e0659c2011-05-24 12:43:12 +01001318class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001319 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001320 explicit LLoadContextSlot(LOperand* context) {
1321 inputs_[0] = context;
1322 }
1323
Ben Murdochb8e0da22011-05-16 14:20:40 +01001324 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1325 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1326
Steve Block1e0659c2011-05-24 12:43:12 +01001327 LOperand* context() { return InputAt(0); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001328 int slot_index() { return hydrogen()->slot_index(); }
1329
1330 virtual void PrintDataTo(StringStream* stream);
1331};
1332
1333
Steve Block1e0659c2011-05-24 12:43:12 +01001334class LStoreContextSlot: public LTemplateInstruction<0, 2, 1> {
1335 public:
1336 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1337 inputs_[0] = context;
1338 inputs_[1] = value;
1339 temps_[0] = temp;
1340 }
1341
1342 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1343 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1344
1345 LOperand* context() { return InputAt(0); }
1346 LOperand* value() { return InputAt(1); }
1347 int slot_index() { return hydrogen()->slot_index(); }
Steve Block1e0659c2011-05-24 12:43:12 +01001348
1349 virtual void PrintDataTo(StringStream* stream);
1350};
1351
1352
1353class LPushArgument: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001354 public:
1355 explicit LPushArgument(LOperand* value) {
1356 inputs_[0] = value;
1357 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001358
1359 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1360};
1361
1362
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001363class LThisFunction: public LTemplateInstruction<1, 0, 0> {
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001364 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001365 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001366 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001367};
1368
1369
Steve Block1e0659c2011-05-24 12:43:12 +01001370class LContext: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001371 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001372 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001373};
1374
1375
Steve Block1e0659c2011-05-24 12:43:12 +01001376class LOuterContext: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001377 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001378 explicit LOuterContext(LOperand* context) {
1379 inputs_[0] = context;
1380 }
1381
1382 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1383
1384 LOperand* context() { return InputAt(0); }
1385};
1386
1387
1388class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1389 public:
1390 explicit LGlobalObject(LOperand* context) {
1391 inputs_[0] = context;
1392 }
1393
1394 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1395
1396 LOperand* context() { return InputAt(0); }
1397};
1398
1399
1400class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1401 public:
1402 explicit LGlobalReceiver(LOperand* global_object) {
1403 inputs_[0] = global_object;
1404 }
1405
Ben Murdochb0fe1622011-05-05 13:52:32 +01001406 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
Steve Block1e0659c2011-05-24 12:43:12 +01001407
1408 LOperand* global() { return InputAt(0); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001409};
1410
1411
Ben Murdochb8e0da22011-05-16 14:20:40 +01001412class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001413 public:
1414 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1415 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1416
Ben Murdochb8e0da22011-05-16 14:20:40 +01001417 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001418
Ben Murdochb8e0da22011-05-16 14:20:40 +01001419 Handle<JSFunction> function() { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001420 int arity() const { return hydrogen()->argument_count() - 1; }
1421};
1422
1423
Ben Murdoch257744e2011-11-30 15:57:28 +00001424class LInvokeFunction: public LTemplateInstruction<1, 2, 0> {
1425 public:
1426 LInvokeFunction(LOperand* context, LOperand* function) {
1427 inputs_[0] = context;
1428 inputs_[1] = function;
1429 }
1430
1431 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1432 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1433
1434 LOperand* context() { return inputs_[0]; }
1435 LOperand* function() { return inputs_[1]; }
1436
1437 virtual void PrintDataTo(StringStream* stream);
1438
1439 int arity() const { return hydrogen()->argument_count() - 1; }
1440};
1441
1442
Steve Block1e0659c2011-05-24 12:43:12 +01001443class LCallKeyed: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001444 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001445 LCallKeyed(LOperand* context, LOperand* key) {
1446 inputs_[0] = context;
1447 inputs_[1] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001448 }
1449
Ben Murdochb0fe1622011-05-05 13:52:32 +01001450 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1451 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1452
Steve Block1e0659c2011-05-24 12:43:12 +01001453 LOperand* context() { return inputs_[0]; }
1454 LOperand* key() { return inputs_[1]; }
1455
Ben Murdochb8e0da22011-05-16 14:20:40 +01001456 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001457
1458 int arity() const { return hydrogen()->argument_count() - 1; }
1459};
1460
1461
Steve Block1e0659c2011-05-24 12:43:12 +01001462class LCallNamed: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001463 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001464 explicit LCallNamed(LOperand* context) {
1465 inputs_[0] = context;
1466 }
1467
Ben Murdochb0fe1622011-05-05 13:52:32 +01001468 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1469 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1470
Ben Murdochb8e0da22011-05-16 14:20:40 +01001471 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001472
Steve Block1e0659c2011-05-24 12:43:12 +01001473 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001474 Handle<String> name() const { return hydrogen()->name(); }
1475 int arity() const { return hydrogen()->argument_count() - 1; }
1476};
1477
1478
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001479class LCallFunction: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001480 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001481 explicit LCallFunction(LOperand* context, LOperand* function) {
Steve Block1e0659c2011-05-24 12:43:12 +01001482 inputs_[0] = context;
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001483 inputs_[1] = function;
Steve Block1e0659c2011-05-24 12:43:12 +01001484 }
1485
Ben Murdochb0fe1622011-05-05 13:52:32 +01001486 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1487 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1488
Steve Block1e0659c2011-05-24 12:43:12 +01001489 LOperand* context() { return inputs_[0]; }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001490 LOperand* function() { return inputs_[1]; }
1491 int arity() const { return hydrogen()->argument_count() - 1; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001492};
1493
1494
Steve Block1e0659c2011-05-24 12:43:12 +01001495class LCallGlobal: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001496 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001497 explicit LCallGlobal(LOperand* context) {
1498 inputs_[0] = context;
1499 }
1500
Ben Murdochb0fe1622011-05-05 13:52:32 +01001501 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1502 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1503
Ben Murdochb8e0da22011-05-16 14:20:40 +01001504 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001505
Steve Block1e0659c2011-05-24 12:43:12 +01001506 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001507 Handle<String> name() const {return hydrogen()->name(); }
1508 int arity() const { return hydrogen()->argument_count() - 1; }
1509};
1510
1511
Ben Murdochb8e0da22011-05-16 14:20:40 +01001512class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001513 public:
1514 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1515 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1516
Ben Murdochb8e0da22011-05-16 14:20:40 +01001517 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001518
1519 Handle<JSFunction> target() const { return hydrogen()->target(); }
1520 int arity() const { return hydrogen()->argument_count() - 1; }
1521};
1522
1523
Steve Block1e0659c2011-05-24 12:43:12 +01001524class LCallNew: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001525 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001526 LCallNew(LOperand* context, LOperand* constructor) {
1527 inputs_[0] = context;
1528 inputs_[1] = constructor;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001529 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001530
1531 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1532 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1533
Ben Murdochb8e0da22011-05-16 14:20:40 +01001534 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001535
Steve Block1e0659c2011-05-24 12:43:12 +01001536 LOperand* context() { return inputs_[0]; }
1537 LOperand* constructor() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001538 int arity() const { return hydrogen()->argument_count() - 1; }
1539};
1540
1541
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001542class LCallRuntime: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001543 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001544 explicit LCallRuntime(LOperand* context) {
1545 inputs_[0] = context;
1546 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001547 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1548 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1549
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001550 LOperand* context() { return inputs_[0]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001551 const Runtime::Function* function() const { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001552 int arity() const { return hydrogen()->argument_count(); }
1553};
1554
1555
Steve Block1e0659c2011-05-24 12:43:12 +01001556class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001557 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001558 explicit LInteger32ToDouble(LOperand* value) {
1559 inputs_[0] = value;
1560 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001561
1562 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1563};
1564
1565
Steve Block1e0659c2011-05-24 12:43:12 +01001566class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001567 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001568 explicit LNumberTagI(LOperand* value) {
1569 inputs_[0] = value;
1570 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001571
1572 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1573};
1574
1575
Ben Murdochb8e0da22011-05-16 14:20:40 +01001576class LNumberTagD: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001577 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001578 LNumberTagD(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001579 inputs_[0] = value;
1580 temps_[0] = temp;
1581 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001582
1583 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001584};
1585
1586
1587// Sometimes truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001588class LDoubleToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001589 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001590 LDoubleToI(LOperand* value, LOperand* temp) {
1591 inputs_[0] = value;
1592 temps_[0] = temp;
1593 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001594
1595 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001596 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001597
1598 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1599};
1600
1601
1602// Truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001603class LTaggedToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001604 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001605 LTaggedToI(LOperand* value, LOperand* temp) {
1606 inputs_[0] = value;
1607 temps_[0] = temp;
1608 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001609
1610 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001611 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001612
1613 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001614};
1615
1616
Steve Block1e0659c2011-05-24 12:43:12 +01001617class LSmiTag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001618 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001619 explicit LSmiTag(LOperand* value) {
1620 inputs_[0] = value;
1621 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001622
1623 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1624};
1625
1626
Ben Murdochc7cc0282012-03-05 14:35:55 +00001627class LNumberUntagD: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001628 public:
Ben Murdochc7cc0282012-03-05 14:35:55 +00001629 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001630 inputs_[0] = value;
Ben Murdochc7cc0282012-03-05 14:35:55 +00001631 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001632 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001633
1634 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +01001635 DECLARE_HYDROGEN_ACCESSOR(Change);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001636};
1637
1638
Steve Block1e0659c2011-05-24 12:43:12 +01001639class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001640 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001641 LSmiUntag(LOperand* value, bool needs_check)
1642 : needs_check_(needs_check) {
1643 inputs_[0] = value;
1644 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001645
1646 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1647
1648 bool needs_check() const { return needs_check_; }
1649
1650 private:
1651 bool needs_check_;
1652};
1653
1654
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001655class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001656 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001657 LStoreNamedField(LOperand* obj, LOperand* val, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001658 inputs_[0] = obj;
1659 inputs_[1] = val;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001660 temps_[0] = temp;
1661 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001662
1663 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001664 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001665
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001666 virtual void PrintDataTo(StringStream* stream);
1667
1668 LOperand* object() { return inputs_[0]; }
1669 LOperand* value() { return inputs_[1]; }
1670
1671 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001672 bool is_in_object() { return hydrogen()->is_in_object(); }
1673 int offset() { return hydrogen()->offset(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001674 Handle<Map> transition() const { return hydrogen()->transition(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001675};
1676
1677
Steve Block1e0659c2011-05-24 12:43:12 +01001678class LStoreNamedGeneric: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001679 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001680 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
1681 inputs_[0] = context;
1682 inputs_[1] = object;
1683 inputs_[2] = value;
1684 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001685
1686 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001687 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001688
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001689 virtual void PrintDataTo(StringStream* stream);
1690
Steve Block1e0659c2011-05-24 12:43:12 +01001691 LOperand* context() { return inputs_[0]; }
1692 LOperand* object() { return inputs_[1]; }
1693 LOperand* value() { return inputs_[2]; }
1694 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001695 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001696};
1697
1698
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001699class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001700 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001701 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001702 inputs_[0] = obj;
1703 inputs_[1] = key;
1704 inputs_[2] = val;
1705 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001706
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001707 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1708 "store-keyed-fast-element")
1709 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001710
Ben Murdochb8e0da22011-05-16 14:20:40 +01001711 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001712
Ben Murdochb8e0da22011-05-16 14:20:40 +01001713 LOperand* object() { return inputs_[0]; }
1714 LOperand* key() { return inputs_[1]; }
1715 LOperand* value() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001716};
1717
1718
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001719class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1720 public:
1721 LStoreKeyedFastDoubleElement(LOperand* elements,
1722 LOperand* key,
1723 LOperand* val) {
1724 inputs_[0] = elements;
1725 inputs_[1] = key;
1726 inputs_[2] = val;
1727 }
1728
1729 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1730 "store-keyed-fast-double-element")
1731 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1732
1733 virtual void PrintDataTo(StringStream* stream);
1734
1735 LOperand* elements() { return inputs_[0]; }
1736 LOperand* key() { return inputs_[1]; }
1737 LOperand* value() { return inputs_[2]; }
1738};
1739
1740
Ben Murdoch257744e2011-11-30 15:57:28 +00001741class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001742 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001743 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1744 LOperand* key,
Ben Murdoch257744e2011-11-30 15:57:28 +00001745 LOperand* val) {
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001746 inputs_[0] = external_pointer;
1747 inputs_[1] = key;
1748 inputs_[2] = val;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001749 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001750
Steve Block44f0eee2011-05-26 01:26:41 +01001751 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1752 "store-keyed-specialized-array-element")
1753 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001754
1755 LOperand* external_pointer() { return inputs_[0]; }
1756 LOperand* key() { return inputs_[1]; }
1757 LOperand* value() { return inputs_[2]; }
Ben Murdoch589d6972011-11-30 16:04:58 +00001758 ElementsKind elements_kind() const {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001759 return hydrogen()->elements_kind();
Steve Block44f0eee2011-05-26 01:26:41 +01001760 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001761};
1762
1763
Steve Block1e0659c2011-05-24 12:43:12 +01001764class LStoreKeyedGeneric: public LTemplateInstruction<0, 4, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001765 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001766 LStoreKeyedGeneric(LOperand* context,
1767 LOperand* object,
1768 LOperand* key,
1769 LOperand* value) {
1770 inputs_[0] = context;
1771 inputs_[1] = object;
1772 inputs_[2] = key;
1773 inputs_[3] = value;
1774 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001775
1776 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
Ben Murdoch8b112d22011-06-08 16:22:53 +01001777 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001778
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001779 virtual void PrintDataTo(StringStream* stream);
1780
Steve Block1e0659c2011-05-24 12:43:12 +01001781 LOperand* context() { return inputs_[0]; }
1782 LOperand* object() { return inputs_[1]; }
1783 LOperand* key() { return inputs_[2]; }
1784 LOperand* value() { return inputs_[3]; }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001785 StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); }
1786};
1787
1788
1789class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> {
1790 public:
1791 LTransitionElementsKind(LOperand* object,
1792 LOperand* new_map_temp,
1793 LOperand* temp_reg) {
1794 inputs_[0] = object;
1795 temps_[0] = new_map_temp;
1796 temps_[1] = temp_reg;
1797 }
1798
1799 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1800 "transition-elements-kind")
1801 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1802
1803 virtual void PrintDataTo(StringStream* stream);
1804
1805 LOperand* object() { return inputs_[0]; }
1806 LOperand* new_map_reg() { return temps_[0]; }
1807 LOperand* temp_reg() { return temps_[1]; }
1808 Handle<Map> original_map() { return hydrogen()->original_map(); }
1809 Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001810};
1811
1812
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001813class LStringAdd: public LTemplateInstruction<1, 3, 0> {
Ben Murdoch257744e2011-11-30 15:57:28 +00001814 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001815 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
1816 inputs_[0] = context;
1817 inputs_[1] = left;
1818 inputs_[2] = right;
Ben Murdoch257744e2011-11-30 15:57:28 +00001819 }
1820
1821 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1822 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1823
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001824 LOperand* context() { return inputs_[0]; }
1825 LOperand* left() { return inputs_[1]; }
1826 LOperand* right() { return inputs_[2]; }
Ben Murdoch257744e2011-11-30 15:57:28 +00001827};
1828
1829
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001830class LStringCharCodeAt: public LTemplateInstruction<1, 3, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001831 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001832 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
1833 inputs_[0] = context;
1834 inputs_[1] = string;
1835 inputs_[2] = index;
Steve Block1e0659c2011-05-24 12:43:12 +01001836 }
1837
1838 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1839 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1840
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001841 LOperand* context() { return inputs_[0]; }
1842 LOperand* string() { return inputs_[1]; }
1843 LOperand* index() { return inputs_[2]; }
Steve Block1e0659c2011-05-24 12:43:12 +01001844};
1845
1846
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001847class LStringCharFromCode: public LTemplateInstruction<1, 2, 0> {
Steve Block44f0eee2011-05-26 01:26:41 +01001848 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001849 LStringCharFromCode(LOperand* context, LOperand* char_code) {
1850 inputs_[0] = context;
1851 inputs_[1] = char_code;
Steve Block44f0eee2011-05-26 01:26:41 +01001852 }
1853
1854 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1855 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1856
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001857 LOperand* context() { return inputs_[0]; }
1858 LOperand* char_code() { return inputs_[1]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001859};
1860
1861
Steve Block1e0659c2011-05-24 12:43:12 +01001862class LStringLength: public LTemplateInstruction<1, 1, 0> {
1863 public:
1864 explicit LStringLength(LOperand* string) {
1865 inputs_[0] = string;
1866 }
1867
1868 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1869 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1870
1871 LOperand* string() { return inputs_[0]; }
1872};
1873
1874
1875class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001876 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001877 explicit LCheckFunction(LOperand* value) {
1878 inputs_[0] = value;
1879 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001880
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001881 LOperand* value() { return inputs_[0]; }
1882
Ben Murdochb0fe1622011-05-05 13:52:32 +01001883 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1884 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1885};
1886
1887
Ben Murdochb8e0da22011-05-16 14:20:40 +01001888class LCheckInstanceType: public LTemplateInstruction<0, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001889 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001890 LCheckInstanceType(LOperand* value, LOperand* temp) {
1891 inputs_[0] = value;
1892 temps_[0] = temp;
1893 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001894
1895 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1896 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001897};
1898
1899
Steve Block1e0659c2011-05-24 12:43:12 +01001900class LCheckMap: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001901 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001902 explicit LCheckMap(LOperand* value) {
1903 inputs_[0] = value;
1904 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001905
1906 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1907 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1908};
1909
1910
Ben Murdochb8e0da22011-05-16 14:20:40 +01001911class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001912 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001913 explicit LCheckPrototypeMaps(LOperand* temp) {
1914 temps_[0] = temp;
1915 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001916
1917 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001918 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001919
Ben Murdochb8e0da22011-05-16 14:20:40 +01001920 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1921 Handle<JSObject> holder() const { return hydrogen()->holder(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001922};
1923
1924
Steve Block1e0659c2011-05-24 12:43:12 +01001925class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001926 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001927 explicit LCheckSmi(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001928 inputs_[0] = value;
1929 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001930
Steve Block44f0eee2011-05-26 01:26:41 +01001931 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1932};
Ben Murdochb0fe1622011-05-05 13:52:32 +01001933
Steve Block44f0eee2011-05-26 01:26:41 +01001934
Ben Murdoch257744e2011-11-30 15:57:28 +00001935class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
1936 public:
1937 explicit LClampDToUint8(LOperand* value) {
1938 inputs_[0] = value;
1939 }
1940
1941 LOperand* unclamped() { return inputs_[0]; }
1942
1943 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1944};
1945
1946
1947class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1948 public:
1949 explicit LClampIToUint8(LOperand* value) {
1950 inputs_[0] = value;
1951 }
1952
1953 LOperand* unclamped() { return inputs_[0]; }
1954
1955 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1956};
1957
1958
1959class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
1960 public:
1961 LClampTToUint8(LOperand* value, LOperand* temp) {
1962 inputs_[0] = value;
1963 temps_[0] = temp;
1964 }
1965
1966 LOperand* unclamped() { return inputs_[0]; }
1967
1968 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1969};
1970
1971
Steve Block44f0eee2011-05-26 01:26:41 +01001972class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1973 public:
1974 explicit LCheckNonSmi(LOperand* value) {
1975 inputs_[0] = value;
Ben Murdochb0fe1622011-05-05 13:52:32 +01001976 }
1977
Steve Block44f0eee2011-05-26 01:26:41 +01001978 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001979};
1980
1981
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001982class LArrayLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001983 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001984 explicit LArrayLiteral(LOperand* context) {
1985 inputs_[0] = context;
1986 }
1987
1988 LOperand* context() { return inputs_[0]; }
1989
Ben Murdochb0fe1622011-05-05 13:52:32 +01001990 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1991 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1992};
1993
1994
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001995class LObjectLiteralFast: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001996 public:
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001997 explicit LObjectLiteralFast(LOperand* context) {
Steve Block1e0659c2011-05-24 12:43:12 +01001998 inputs_[0] = context;
1999 }
2000
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002001 LOperand* context() { return inputs_[0]; }
2002
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002003 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteralFast, "object-literal-fast")
2004 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteralFast)
2005};
2006
2007
2008class LObjectLiteralGeneric: public LTemplateInstruction<1, 1, 0> {
2009 public:
2010 explicit LObjectLiteralGeneric(LOperand* context) {
2011 inputs_[0] = context;
2012 }
2013
2014 LOperand* context() { return inputs_[0]; }
2015
2016 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteralGeneric, "object-literal-generic")
2017 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteralGeneric)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002018};
2019
2020
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002021class LRegExpLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002022 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002023 explicit LRegExpLiteral(LOperand* context) {
2024 inputs_[0] = context;
2025 }
2026
2027 LOperand* context() { return inputs_[0]; }
2028
Ben Murdochb0fe1622011-05-05 13:52:32 +01002029 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2030 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2031};
2032
2033
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002034class LFunctionLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002035 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002036 explicit LFunctionLiteral(LOperand* context) {
2037 inputs_[0] = context;
2038 }
2039
2040 LOperand* context() { return inputs_[0]; }
2041
Ben Murdochb0fe1622011-05-05 13:52:32 +01002042 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2043 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2044
2045 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2046};
2047
2048
Steve Block44f0eee2011-05-26 01:26:41 +01002049class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2050 public:
2051 explicit LToFastProperties(LOperand* value) {
2052 inputs_[0] = value;
2053 }
2054
2055 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2056 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2057};
2058
2059
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002060class LTypeof: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002061 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002062 LTypeof(LOperand* context, LOperand* value) {
2063 inputs_[0] = context;
2064 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01002065 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002066
2067 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2068};
2069
2070
Steve Block1e0659c2011-05-24 12:43:12 +01002071class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002072 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01002073 explicit LTypeofIsAndBranch(LOperand* value) {
2074 inputs_[0] = value;
2075 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002076
2077 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002078 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002079
Ben Murdochb8e0da22011-05-16 14:20:40 +01002080 Handle<String> type_literal() { return hydrogen()->type_literal(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002081
Ben Murdochb8e0da22011-05-16 14:20:40 +01002082 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002083};
2084
2085
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002086class LDeleteProperty: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002087 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002088 LDeleteProperty(LOperand* context, LOperand* obj, LOperand* key) {
2089 inputs_[0] = context;
2090 inputs_[1] = obj;
2091 inputs_[2] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01002092 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002093
2094 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
2095
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002096 LOperand* context() { return inputs_[0]; }
2097 LOperand* object() { return inputs_[1]; }
2098 LOperand* key() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002099};
2100
2101
Ben Murdochb8e0da22011-05-16 14:20:40 +01002102class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002103 public:
2104 LOsrEntry();
2105
2106 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2107
2108 LOperand** SpilledRegisterArray() { return register_spills_; }
2109 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2110
2111 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2112 void MarkSpilledDoubleRegister(int allocation_index,
2113 LOperand* spill_operand);
2114
2115 private:
2116 // Arrays of spill slot operands for registers with an assigned spill
2117 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2118 // NULL if the register has no assigned spill slot. Indexed by allocation
2119 // index.
2120 LOperand* register_spills_[Register::kNumAllocatableRegisters];
2121 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2122};
2123
2124
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002125class LStackCheck: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002126 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002127 explicit LStackCheck(LOperand* context) {
2128 inputs_[0] = context;
2129 }
2130
2131 LOperand* context() { return inputs_[0]; }
2132
Ben Murdochb0fe1622011-05-05 13:52:32 +01002133 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002134 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2135
2136 Label* done_label() { return &done_label_; }
2137
2138 private:
2139 Label done_label_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002140};
2141
2142
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002143class LIn: public LTemplateInstruction<1, 3, 0> {
Ben Murdoch257744e2011-11-30 15:57:28 +00002144 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002145 LIn(LOperand* context, LOperand* key, LOperand* object) {
2146 inputs_[0] = context;
2147 inputs_[1] = key;
2148 inputs_[2] = object;
Ben Murdoch257744e2011-11-30 15:57:28 +00002149 }
2150
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002151 LOperand* context() { return inputs_[0]; }
2152 LOperand* key() { return inputs_[1]; }
2153 LOperand* object() { return inputs_[2]; }
Ben Murdoch257744e2011-11-30 15:57:28 +00002154
2155 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2156};
2157
2158
Ben Murdochb0fe1622011-05-05 13:52:32 +01002159class LChunkBuilder;
2160class LChunk: public ZoneObject {
2161 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002162 LChunk(CompilationInfo* info, HGraph* graph)
Ben Murdoch086aeea2011-05-13 15:57:08 +01002163 : spill_slot_count_(0),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002164 info_(info),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002165 graph_(graph),
2166 instructions_(32),
2167 pointer_maps_(8),
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002168 num_double_slots_(0),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002169 inlined_closures_(1) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002170
Steve Block1e0659c2011-05-24 12:43:12 +01002171 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002172 LConstantOperand* DefineConstantOperand(HConstant* constant);
2173 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2174 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
2175
2176 int GetNextSpillIndex(bool is_double);
2177 LOperand* GetNextSpillSlot(bool is_double);
2178
2179 int ParameterAt(int index);
2180 int GetParameterStackSlot(int index) const;
2181 int spill_slot_count() const { return spill_slot_count_; }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002182 int num_double_slots() const { return num_double_slots_; }
2183
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002184 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002185 HGraph* graph() const { return graph_; }
2186 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2187 void AddGapMove(int index, LOperand* from, LOperand* to);
2188 LGap* GetGapAt(int index) const;
2189 bool IsGapAt(int index) const;
2190 int NearestGapPos(int index) const;
2191 void MarkEmptyBlocks();
2192 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
2193 LLabel* GetLabel(int block_id) const {
2194 HBasicBlock* block = graph_->blocks()->at(block_id);
2195 int first_instruction = block->first_instruction_index();
2196 return LLabel::cast(instructions_[first_instruction]);
2197 }
2198 int LookupDestination(int block_id) const {
2199 LLabel* cur = GetLabel(block_id);
2200 while (cur->replacement() != NULL) {
2201 cur = cur->replacement();
2202 }
2203 return cur->block_id();
2204 }
2205 Label* GetAssemblyLabel(int block_id) const {
2206 LLabel* label = GetLabel(block_id);
2207 ASSERT(!label->HasReplacement());
2208 return label->label();
2209 }
2210
2211 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2212 return &inlined_closures_;
2213 }
2214
2215 void AddInlinedClosure(Handle<JSFunction> closure) {
2216 inlined_closures_.Add(closure);
2217 }
2218
Ben Murdochb0fe1622011-05-05 13:52:32 +01002219 private:
2220 int spill_slot_count_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002221 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002222 HGraph* const graph_;
2223 ZoneList<LInstruction*> instructions_;
2224 ZoneList<LPointerMap*> pointer_maps_;
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002225 int num_double_slots_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002226 ZoneList<Handle<JSFunction> > inlined_closures_;
2227};
2228
2229
2230class LChunkBuilder BASE_EMBEDDED {
2231 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002232 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002233 : chunk_(NULL),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002234 info_(info),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002235 graph_(graph),
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002236 isolate_(graph->isolate()),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002237 status_(UNUSED),
2238 current_instruction_(NULL),
2239 current_block_(NULL),
2240 next_block_(NULL),
2241 argument_count_(0),
2242 allocator_(allocator),
2243 position_(RelocInfo::kNoPosition),
Steve Block1e0659c2011-05-24 12:43:12 +01002244 instruction_pending_deoptimization_environment_(NULL),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002245 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
2246
2247 // Build the sequence for the graph.
2248 LChunk* Build();
2249
2250 // Declare methods that deal with the individual node types.
2251#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2252 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2253#undef DECLARE_DO
2254
2255 private:
2256 enum Status {
2257 UNUSED,
2258 BUILDING,
2259 DONE,
2260 ABORTED
2261 };
2262
2263 LChunk* chunk() const { return chunk_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002264 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002265 HGraph* graph() const { return graph_; }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002266 Zone* zone() { return isolate_->zone(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002267
2268 bool is_unused() const { return status_ == UNUSED; }
2269 bool is_building() const { return status_ == BUILDING; }
2270 bool is_done() const { return status_ == DONE; }
2271 bool is_aborted() const { return status_ == ABORTED; }
2272
2273 void Abort(const char* format, ...);
2274
2275 // Methods for getting operands for Use / Define / Temp.
2276 LRegister* ToOperand(Register reg);
2277 LUnallocated* ToUnallocated(Register reg);
2278 LUnallocated* ToUnallocated(XMMRegister reg);
2279
2280 // Methods for setting up define-use relationships.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002281 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2282 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2283 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2284 XMMRegister fixed_register);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002285
2286 // A value that is guaranteed to be allocated to a register.
2287 // Operand created by UseRegister is guaranteed to be live until the end of
2288 // instruction. This means that register allocator will not reuse it's
2289 // register for any other operand inside instruction.
2290 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2291 // instruction start. Register allocator is free to assign the same register
2292 // to some other operand used inside instruction (i.e. temporary or
2293 // output).
Ben Murdochb8e0da22011-05-16 14:20:40 +01002294 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2295 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002296
Ben Murdochb8e0da22011-05-16 14:20:40 +01002297 // An input operand in a register that may be trashed.
2298 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2299
2300 // An input operand in a register or stack slot.
2301 MUST_USE_RESULT LOperand* Use(HValue* value);
2302 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2303
2304 // An input operand in a register, stack slot or a constant operand.
2305 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2306 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2307
2308 // An input operand in a register or a constant operand.
2309 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2310 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2311
2312 // An input operand in register, stack slot or a constant operand.
2313 // Will not be moved to a register even if one is freely available.
2314 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2315
2316 // Temporary operand that must be in a register.
2317 MUST_USE_RESULT LUnallocated* TempRegister();
2318 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2319 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002320
2321 // Methods for setting up define-use relationships.
2322 // Return the same instruction that they are passed.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002323 template<int I, int T>
2324 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2325 LUnallocated* result);
2326 template<int I, int T>
2327 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2328 template<int I, int T>
2329 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2330 template<int I, int T>
2331 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2332 int index);
2333 template<int I, int T>
2334 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2335 template<int I, int T>
2336 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2337 Register reg);
2338 template<int I, int T>
2339 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2340 XMMRegister reg);
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002341 // Assigns an environment to an instruction. An instruction which can
2342 // deoptimize must have an environment.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002343 LInstruction* AssignEnvironment(LInstruction* instr);
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002344 // Assigns a pointer map to an instruction. An instruction which can
2345 // trigger a GC or a lazy deoptimization must have a pointer map.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002346 LInstruction* AssignPointerMap(LInstruction* instr);
2347
2348 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2349
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002350 // Marks a call for the register allocator. Assigns a pointer map to
2351 // support GC and lazy deoptimization. Assigns an environment to support
2352 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002353 LInstruction* MarkAsCall(
2354 LInstruction* instr,
2355 HInstruction* hinstr,
2356 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
Ben Murdoch086aeea2011-05-13 15:57:08 +01002357 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002358
2359 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2360 LInstruction* instr, int ast_id);
2361 void ClearInstructionPendingDeoptimizationEnvironment();
2362
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002363 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env,
2364 int* argument_index_accumulator);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002365
Ben Murdochb0fe1622011-05-05 13:52:32 +01002366 void VisitInstruction(HInstruction* current);
2367
2368 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002369 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2370 LInstruction* DoArithmeticD(Token::Value op,
2371 HArithmeticBinaryOperation* instr);
2372 LInstruction* DoArithmeticT(Token::Value op,
2373 HArithmeticBinaryOperation* instr);
2374
2375 LChunk* chunk_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002376 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002377 HGraph* const graph_;
Ben Murdoch592a9fc2012-03-05 11:04:45 +00002378 Isolate* isolate_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002379 Status status_;
2380 HInstruction* current_instruction_;
2381 HBasicBlock* current_block_;
2382 HBasicBlock* next_block_;
2383 int argument_count_;
2384 LAllocator* allocator_;
2385 int position_;
Steve Block1e0659c2011-05-24 12:43:12 +01002386 LInstruction* instruction_pending_deoptimization_environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002387 int pending_deoptimization_ast_id_;
2388
2389 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2390};
2391
2392#undef DECLARE_HYDROGEN_ACCESSOR
Ben Murdochb0fe1622011-05-05 13:52:32 +01002393#undef DECLARE_CONCRETE_INSTRUCTION
2394
2395} } // namespace v8::internal
2396
2397#endif // V8_IA32_LITHIUM_IA32_H_