blob: 038049ca068bf337c9e409712ac67889441373bf [file] [log] [blame]
Ben Murdoch086aeea2011-05-13 15:57:08 +01001// Copyright 2011 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 Murdochb0fe1622011-05-05 13:52:32 +0100104 V(IsNullAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100105 V(IsObjectAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100106 V(IsSmiAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000107 V(IsUndetectableAndBranch) \
Steve Block9fac8402011-05-12 15:51:54 +0100108 V(JSArrayLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100109 V(Label) \
110 V(LazyBailout) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100111 V(LoadContextSlot) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100112 V(LoadElements) \
Steve Block44f0eee2011-05-26 01:26:41 +0100113 V(LoadExternalArrayPointer) \
Steve Block1e0659c2011-05-24 12:43:12 +0100114 V(LoadFunctionPrototype) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100115 V(LoadGlobalCell) \
116 V(LoadGlobalGeneric) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100117 V(LoadKeyedFastElement) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000118 V(LoadKeyedFastDoubleElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100119 V(LoadKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100120 V(LoadKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100121 V(LoadNamedField) \
Steve Block44f0eee2011-05-26 01:26:41 +0100122 V(LoadNamedFieldPolymorphic) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100123 V(LoadNamedGeneric) \
124 V(ModI) \
125 V(MulI) \
126 V(NumberTagD) \
127 V(NumberTagI) \
128 V(NumberUntagD) \
129 V(ObjectLiteral) \
130 V(OsrEntry) \
Steve Block1e0659c2011-05-24 12:43:12 +0100131 V(OuterContext) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100132 V(Parameter) \
133 V(Power) \
134 V(PushArgument) \
135 V(RegExpLiteral) \
136 V(Return) \
137 V(ShiftI) \
138 V(SmiTag) \
139 V(SmiUntag) \
140 V(StackCheck) \
Steve Block1e0659c2011-05-24 12:43:12 +0100141 V(StoreContextSlot) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100142 V(StoreGlobalCell) \
143 V(StoreGlobalGeneric) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000144 V(StoreKeyedFastDoubleElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100145 V(StoreKeyedFastElement) \
146 V(StoreKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100147 V(StoreKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100148 V(StoreNamedField) \
149 V(StoreNamedGeneric) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000150 V(StringAdd) \
Steve Block1e0659c2011-05-24 12:43:12 +0100151 V(StringCharCodeAt) \
Steve Block44f0eee2011-05-26 01:26:41 +0100152 V(StringCharFromCode) \
Steve Block1e0659c2011-05-24 12:43:12 +0100153 V(StringLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100154 V(SubI) \
155 V(TaggedToI) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000156 V(ThisFunction) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100157 V(Throw) \
Steve Block44f0eee2011-05-26 01:26:41 +0100158 V(ToFastProperties) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100159 V(Typeof) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100160 V(TypeofIsAndBranch) \
161 V(UnaryMathOperation) \
162 V(UnknownOSRValue) \
163 V(ValueOf)
164
165
Ben Murdoch257744e2011-11-30 15:57:28 +0000166#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
167 virtual Opcode opcode() const { return LInstruction::k##type; } \
168 virtual void CompileToNative(LCodeGen* generator); \
169 virtual const char* Mnemonic() const { return mnemonic; } \
170 static L##type* cast(LInstruction* instr) { \
171 ASSERT(instr->Is##type()); \
172 return reinterpret_cast<L##type*>(instr); \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100173 }
174
175
Ben Murdochb0fe1622011-05-05 13:52:32 +0100176#define DECLARE_HYDROGEN_ACCESSOR(type) \
177 H##type* hydrogen() const { \
178 return H##type::cast(hydrogen_value()); \
179 }
180
181
182class LInstruction: public ZoneObject {
183 public:
184 LInstruction()
Steve Block1e0659c2011-05-24 12:43:12 +0100185 : environment_(NULL),
186 hydrogen_value_(NULL),
187 is_call_(false),
188 is_save_doubles_(false) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100189 virtual ~LInstruction() { }
190
191 virtual void CompileToNative(LCodeGen* generator) = 0;
192 virtual const char* Mnemonic() const = 0;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100193 virtual void PrintTo(StringStream* stream);
194 virtual void PrintDataTo(StringStream* stream) = 0;
195 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100196
Ben Murdoch257744e2011-11-30 15:57:28 +0000197 enum Opcode {
198 // Declare a unique enum value for each instruction.
199#define DECLARE_OPCODE(type) k##type,
200 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
201 kNumberOfInstructions
202#undef DECLARE_OPCODE
203 };
204
205 virtual Opcode opcode() const = 0;
206
207 // Declare non-virtual type testers for all leaf IR classes.
208#define DECLARE_PREDICATE(type) \
209 bool Is##type() const { return opcode() == k##type; }
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
211#undef DECLARE_PREDICATE
212
213 // Declare virtual predicates for instructions that don't have
214 // an opcode.
215 virtual bool IsGap() const { return false; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100216
Ben Murdochb0fe1622011-05-05 13:52:32 +0100217 virtual bool IsControl() const { return false; }
218
Steve Block1e0659c2011-05-24 12:43:12 +0100219 void set_environment(LEnvironment* env) { environment_ = env; }
220 LEnvironment* environment() const { return environment_; }
221 bool HasEnvironment() const { return environment_ != NULL; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100222
223 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
224 LPointerMap* pointer_map() const { return pointer_map_.get(); }
225 bool HasPointerMap() const { return pointer_map_.is_set(); }
226
Ben Murdochb0fe1622011-05-05 13:52:32 +0100227
228 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
229 HValue* hydrogen_value() const { return hydrogen_value_; }
230
231 void set_deoptimization_environment(LEnvironment* env) {
232 deoptimization_environment_.set(env);
233 }
234 LEnvironment* deoptimization_environment() const {
235 return deoptimization_environment_.get();
236 }
237 bool HasDeoptimizationEnvironment() const {
238 return deoptimization_environment_.is_set();
239 }
240
Steve Block1e0659c2011-05-24 12:43:12 +0100241 void MarkAsCall() { is_call_ = true; }
242 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
243
244 // Interface to the register allocator and iterators.
245 bool IsMarkedAsCall() const { return is_call_; }
246 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
247
248 virtual bool HasResult() const = 0;
249 virtual LOperand* result() = 0;
250
251 virtual int InputCount() = 0;
252 virtual LOperand* InputAt(int i) = 0;
253 virtual int TempCount() = 0;
254 virtual LOperand* TempAt(int i) = 0;
255
256 LOperand* FirstInput() { return InputAt(0); }
257 LOperand* Output() { return HasResult() ? result() : NULL; }
258
259#ifdef DEBUG
260 void VerifyCall();
261#endif
262
Ben Murdochb0fe1622011-05-05 13:52:32 +0100263 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100264 LEnvironment* environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100265 SetOncePointer<LPointerMap> pointer_map_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100266 HValue* hydrogen_value_;
267 SetOncePointer<LEnvironment> deoptimization_environment_;
Steve Block1e0659c2011-05-24 12:43:12 +0100268 bool is_call_;
269 bool is_save_doubles_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100270};
271
272
Steve Block1e0659c2011-05-24 12:43:12 +0100273// R = number of result operands (0 or 1).
274// I = number of input operands.
275// T = number of temporary operands.
276template<int R, int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100277class LTemplateInstruction: public LInstruction {
278 public:
279 // Allow 0 or 1 output operands.
280 STATIC_ASSERT(R == 0 || R == 1);
281 virtual bool HasResult() const { return R != 0; }
282 void set_result(LOperand* operand) { results_[0] = operand; }
283 LOperand* result() { return results_[0]; }
284
285 int InputCount() { return I; }
286 LOperand* InputAt(int i) { return inputs_[i]; }
287
288 int TempCount() { return T; }
289 LOperand* TempAt(int i) { return temps_[i]; }
290
291 virtual void PrintDataTo(StringStream* stream);
292 virtual void PrintOutputOperandTo(StringStream* stream);
293
294 protected:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000295 EmbeddedContainer<LOperand*, R> results_;
296 EmbeddedContainer<LOperand*, I> inputs_;
297 EmbeddedContainer<LOperand*, T> temps_;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100298};
299
300
301class LGap: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100302 public:
Ben Murdoch257744e2011-11-30 15:57:28 +0000303 explicit LGap(HBasicBlock* block) : block_(block) {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100304 parallel_moves_[BEFORE] = NULL;
305 parallel_moves_[START] = NULL;
306 parallel_moves_[END] = NULL;
307 parallel_moves_[AFTER] = NULL;
308 }
309
Ben Murdoch257744e2011-11-30 15:57:28 +0000310 // Can't use the DECLARE-macro here because of sub-classes.
311 virtual bool IsGap() const { return true; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100312 virtual void PrintDataTo(StringStream* stream);
Ben Murdoch257744e2011-11-30 15:57:28 +0000313 static LGap* cast(LInstruction* instr) {
314 ASSERT(instr->IsGap());
315 return reinterpret_cast<LGap*>(instr);
316 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100317
318 bool IsRedundant() const;
319
320 HBasicBlock* block() const { return block_; }
321
322 enum InnerPosition {
323 BEFORE,
324 START,
325 END,
326 AFTER,
327 FIRST_INNER_POSITION = BEFORE,
328 LAST_INNER_POSITION = AFTER
329 };
330
331 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
332 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
333 return parallel_moves_[pos];
334 }
335
336 LParallelMove* GetParallelMove(InnerPosition pos) {
337 return parallel_moves_[pos];
338 }
339
340 private:
341 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
342 HBasicBlock* block_;
343};
344
345
Ben Murdoch257744e2011-11-30 15:57:28 +0000346class LInstructionGap: public LGap {
347 public:
348 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
349
350 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
351};
352
353
Ben Murdochb8e0da22011-05-16 14:20:40 +0100354class LGoto: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100355 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000356 explicit LGoto(int block_id) : block_id_(block_id) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100357
358 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100359 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100360 virtual bool IsControl() const { return true; }
361
362 int block_id() const { return block_id_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100363
364 private:
365 int block_id_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100366};
367
368
Ben Murdochb8e0da22011-05-16 14:20:40 +0100369class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100370 public:
371 LLazyBailout() : gap_instructions_size_(0) { }
372
373 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
374
375 void set_gap_instructions_size(int gap_instructions_size) {
376 gap_instructions_size_ = gap_instructions_size;
377 }
378 int gap_instructions_size() { return gap_instructions_size_; }
379
380 private:
381 int gap_instructions_size_;
382};
383
384
Ben Murdochb8e0da22011-05-16 14:20:40 +0100385class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100386 public:
387 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
388};
389
390
391class LLabel: public LGap {
392 public:
393 explicit LLabel(HBasicBlock* block)
394 : LGap(block), replacement_(NULL) { }
395
396 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
397
Ben Murdochb8e0da22011-05-16 14:20:40 +0100398 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100399
400 int block_id() const { return block()->block_id(); }
401 bool is_loop_header() const { return block()->IsLoopHeader(); }
402 Label* label() { return &label_; }
403 LLabel* replacement() const { return replacement_; }
404 void set_replacement(LLabel* label) { replacement_ = label; }
405 bool HasReplacement() const { return replacement_ != NULL; }
406
407 private:
408 Label label_;
409 LLabel* replacement_;
410};
411
412
Ben Murdochb8e0da22011-05-16 14:20:40 +0100413class LParameter: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100414 public:
415 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
416};
417
418
Steve Block1e0659c2011-05-24 12:43:12 +0100419class LCallStub: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100420 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100421 explicit LCallStub(LOperand* context) {
422 inputs_[0] = context;
423 }
424
Ben Murdochb0fe1622011-05-05 13:52:32 +0100425 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
426 DECLARE_HYDROGEN_ACCESSOR(CallStub)
427
Steve Block1e0659c2011-05-24 12:43:12 +0100428 LOperand* context() { return inputs_[0]; }
429
Ben Murdochb0fe1622011-05-05 13:52:32 +0100430 TranscendentalCache::Type transcendental_type() {
431 return hydrogen()->transcendental_type();
432 }
433};
434
435
Ben Murdochb8e0da22011-05-16 14:20:40 +0100436class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100437 public:
438 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
439};
440
441
Steve Block1e0659c2011-05-24 12:43:12 +0100442template<int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100443class LControlInstruction: public LTemplateInstruction<0, I, T> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100444 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100445 virtual bool IsControl() const { return true; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100446
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000447 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
448 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
449 int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); }
450 int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100451
452 private:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000453 HControlInstruction* hydrogen() {
454 return HControlInstruction::cast(this->hydrogen_value());
455 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100456};
457
458
Steve Block1e0659c2011-05-24 12:43:12 +0100459class LApplyArguments: public LTemplateInstruction<1, 4, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100460 public:
461 LApplyArguments(LOperand* function,
462 LOperand* receiver,
463 LOperand* length,
Steve Block1e0659c2011-05-24 12:43:12 +0100464 LOperand* elements,
465 LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100466 inputs_[0] = function;
467 inputs_[1] = receiver;
468 inputs_[2] = length;
469 inputs_[3] = elements;
Steve Block1e0659c2011-05-24 12:43:12 +0100470 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100471 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100472
473 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
474
Ben Murdochb8e0da22011-05-16 14:20:40 +0100475 LOperand* function() { return inputs_[0]; }
476 LOperand* receiver() { return inputs_[1]; }
477 LOperand* length() { return inputs_[2]; }
478 LOperand* elements() { return inputs_[3]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100479};
480
481
Ben Murdochb8e0da22011-05-16 14:20:40 +0100482class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100483 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100484 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
485 inputs_[0] = arguments;
486 inputs_[1] = length;
487 inputs_[2] = index;
488 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100489
490 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
491
Ben Murdochb8e0da22011-05-16 14:20:40 +0100492 LOperand* arguments() { return inputs_[0]; }
493 LOperand* length() { return inputs_[1]; }
494 LOperand* index() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100495
Ben Murdochb8e0da22011-05-16 14:20:40 +0100496 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100497};
498
499
Steve Block1e0659c2011-05-24 12:43:12 +0100500class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100501 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100502 explicit LArgumentsLength(LOperand* elements) {
503 inputs_[0] = elements;
504 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100505
506 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
507};
508
509
Ben Murdochb8e0da22011-05-16 14:20:40 +0100510class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100511 public:
512 LArgumentsElements() { }
513
514 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
515};
516
517
Ben Murdochb8e0da22011-05-16 14:20:40 +0100518class LModI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100519 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100520 LModI(LOperand* left, LOperand* right, LOperand* temp) {
521 inputs_[0] = left;
522 inputs_[1] = right;
523 temps_[0] = temp;
524 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100525
526 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
527 DECLARE_HYDROGEN_ACCESSOR(Mod)
528};
529
530
Ben Murdochb8e0da22011-05-16 14:20:40 +0100531class LDivI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100532 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100533 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
534 inputs_[0] = left;
535 inputs_[1] = right;
536 temps_[0] = temp;
537 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100538
539 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
540 DECLARE_HYDROGEN_ACCESSOR(Div)
541};
542
543
Ben Murdochb8e0da22011-05-16 14:20:40 +0100544class LMulI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100545 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100546 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
547 inputs_[0] = left;
548 inputs_[1] = right;
549 temps_[0] = temp;
550 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100551
552 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
553 DECLARE_HYDROGEN_ACCESSOR(Mul)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100554};
555
556
Steve Block1e0659c2011-05-24 12:43:12 +0100557class LCmpIDAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100558 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100559 LCmpIDAndBranch(LOperand* left, LOperand* right) {
560 inputs_[0] = left;
561 inputs_[1] = right;
562 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100563
564 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000565 DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100566
Ben Murdochb8e0da22011-05-16 14:20:40 +0100567 Token::Value op() const { return hydrogen()->token(); }
568 bool is_double() const {
569 return hydrogen()->GetInputRepresentation().IsDouble();
570 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100571
Ben Murdochb8e0da22011-05-16 14:20:40 +0100572 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100573};
574
575
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000576class LUnaryMathOperation: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100577 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000578 LUnaryMathOperation(LOperand* context, LOperand* value) {
579 inputs_[1] = context;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100580 inputs_[0] = value;
581 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100582
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000583 LOperand* context() { return inputs_[1]; }
584 LOperand* value() { return inputs_[0]; }
585
Ben Murdochb0fe1622011-05-05 13:52:32 +0100586 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
587 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
588
Ben Murdochb8e0da22011-05-16 14:20:40 +0100589 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100590 BuiltinFunctionId op() const { return hydrogen()->op(); }
591};
592
593
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000594class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100595 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000596 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100597 inputs_[0] = left;
598 inputs_[1] = right;
599 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100600
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000601 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch,
602 "cmp-object-eq-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100603};
604
605
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000606class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100607 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000608 explicit LCmpConstantEqAndBranch(LOperand* left) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100609 inputs_[0] = left;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100610 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100611
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000612 DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch,
613 "cmp-constant-eq-and-branch")
614 DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100615};
616
617
Ben Murdochb8e0da22011-05-16 14:20:40 +0100618class LIsNullAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100619 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100620 LIsNullAndBranch(LOperand* value, LOperand* temp) {
621 inputs_[0] = value;
622 temps_[0] = temp;
623 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100624
625 DECLARE_CONCRETE_INSTRUCTION(IsNullAndBranch, "is-null-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000626 DECLARE_HYDROGEN_ACCESSOR(IsNullAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100627
Ben Murdochb8e0da22011-05-16 14:20:40 +0100628 bool is_strict() const { return hydrogen()->is_strict(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100629
Ben Murdochb8e0da22011-05-16 14:20:40 +0100630 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100631};
632
633
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000634class LIsObjectAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100635 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000636 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100637 inputs_[0] = value;
638 temps_[0] = temp;
639 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100640
Ben Murdochb0fe1622011-05-05 13:52:32 +0100641 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100642
Ben Murdochb8e0da22011-05-16 14:20:40 +0100643 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100644};
645
646
Steve Block1e0659c2011-05-24 12:43:12 +0100647class LIsSmiAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100648 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100649 explicit LIsSmiAndBranch(LOperand* value) {
650 inputs_[0] = value;
651 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100652
653 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000654 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100655
Ben Murdochb8e0da22011-05-16 14:20:40 +0100656 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100657};
658
659
Ben Murdoch257744e2011-11-30 15:57:28 +0000660class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
661 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000662 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
Ben Murdoch257744e2011-11-30 15:57:28 +0000663 inputs_[0] = value;
664 temps_[0] = temp;
665 }
666
667 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
668 "is-undetectable-and-branch")
669
670 virtual void PrintDataTo(StringStream* stream);
671};
672
673
Ben Murdochb8e0da22011-05-16 14:20:40 +0100674class LHasInstanceTypeAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100675 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100676 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
677 inputs_[0] = value;
678 temps_[0] = temp;
679 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100680
681 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
682 "has-instance-type-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000683 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100684
Ben Murdochb8e0da22011-05-16 14:20:40 +0100685 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100686};
687
688
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100689class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
690 public:
691 explicit LGetCachedArrayIndex(LOperand* value) {
692 inputs_[0] = value;
693 }
694
695 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
696 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
697};
698
699
Steve Block1e0659c2011-05-24 12:43:12 +0100700class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100701 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100702 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
703 inputs_[0] = value;
704 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100705
706 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
707 "has-cached-array-index-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100708 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100709};
710
711
Steve Block1e0659c2011-05-24 12:43:12 +0100712class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
713 public:
714 explicit LIsConstructCallAndBranch(LOperand* temp) {
715 temps_[0] = temp;
716 }
717
718 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
719 "is-construct-call-and-branch")
720};
721
722
Ben Murdochb8e0da22011-05-16 14:20:40 +0100723class LClassOfTestAndBranch: public LControlInstruction<1, 2> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100724 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100725 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
726 inputs_[0] = value;
727 temps_[0] = temp;
728 temps_[1] = temp2;
729 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100730
731 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
732 "class-of-test-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000733 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100734
Ben Murdochb8e0da22011-05-16 14:20:40 +0100735 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100736};
737
738
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000739class LCmpT: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100740 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000741 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
742 inputs_[0] = context;
743 inputs_[1] = left;
744 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100745 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100746
747 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000748 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100749
Ben Murdochb8e0da22011-05-16 14:20:40 +0100750 Token::Value op() const { return hydrogen()->token(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100751};
752
753
Steve Block1e0659c2011-05-24 12:43:12 +0100754class LInstanceOf: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100755 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100756 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
757 inputs_[0] = context;
758 inputs_[1] = left;
759 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100760 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100761
762 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
Steve Block1e0659c2011-05-24 12:43:12 +0100763
764 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100765};
766
767
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000768class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100769 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000770 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
Steve Block1e0659c2011-05-24 12:43:12 +0100771 inputs_[0] = context;
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000772 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100773 temps_[0] = temp;
774 }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100775
776 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
777 "instance-of-known-global")
778 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
779
780 Handle<JSFunction> function() const { return hydrogen()->function(); }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100781};
782
783
Ben Murdochb8e0da22011-05-16 14:20:40 +0100784class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100785 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100786 LBoundsCheck(LOperand* index, LOperand* length) {
787 inputs_[0] = index;
788 inputs_[1] = length;
789 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100790
Ben Murdochb8e0da22011-05-16 14:20:40 +0100791 LOperand* index() { return inputs_[0]; }
792 LOperand* length() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100793
794 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
795};
796
797
Steve Block1e0659c2011-05-24 12:43:12 +0100798class LBitI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100799 public:
800 LBitI(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100801 : op_(op) {
802 inputs_[0] = left;
803 inputs_[1] = right;
804 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100805
806 Token::Value op() const { return op_; }
807
808 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
809
810 private:
811 Token::Value op_;
812};
813
814
Steve Block1e0659c2011-05-24 12:43:12 +0100815class LShiftI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100816 public:
817 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100818 : op_(op), can_deopt_(can_deopt) {
819 inputs_[0] = left;
820 inputs_[1] = right;
821 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100822
823 Token::Value op() const { return op_; }
824
825 bool can_deopt() const { return can_deopt_; }
826
827 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
828
829 private:
830 Token::Value op_;
831 bool can_deopt_;
832};
833
834
Steve Block1e0659c2011-05-24 12:43:12 +0100835class LSubI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100836 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100837 LSubI(LOperand* left, LOperand* right) {
838 inputs_[0] = left;
839 inputs_[1] = right;
840 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100841
842 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
843 DECLARE_HYDROGEN_ACCESSOR(Sub)
844};
845
846
Steve Block1e0659c2011-05-24 12:43:12 +0100847class LConstantI: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100848 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +0100849 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
Steve Block1e0659c2011-05-24 12:43:12 +0100850 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100851
Steve Block1e0659c2011-05-24 12:43:12 +0100852 int32_t value() const { return hydrogen()->Integer32Value(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100853};
854
855
Steve Block1e0659c2011-05-24 12:43:12 +0100856class LConstantD: public LTemplateInstruction<1, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100857 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100858 explicit LConstantD(LOperand* temp) {
859 temps_[0] = temp;
860 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100861
862 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
Steve Block1e0659c2011-05-24 12:43:12 +0100863 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100864
Steve Block1e0659c2011-05-24 12:43:12 +0100865 double value() const { return hydrogen()->DoubleValue(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100866};
867
868
Steve Block1e0659c2011-05-24 12:43:12 +0100869class LConstantT: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100870 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +0100871 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
Steve Block1e0659c2011-05-24 12:43:12 +0100872 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100873
Steve Block1e0659c2011-05-24 12:43:12 +0100874 Handle<Object> value() const { return hydrogen()->handle(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100875};
876
877
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000878class LBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100879 public:
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000880 explicit LBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100881 inputs_[0] = value;
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000882 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100883 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100884
885 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000886 DECLARE_HYDROGEN_ACCESSOR(Branch)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100887
Ben Murdochb8e0da22011-05-16 14:20:40 +0100888 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100889};
890
891
Steve Block1e0659c2011-05-24 12:43:12 +0100892class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100893 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100894 explicit LCmpMapAndBranch(LOperand* value) {
895 inputs_[0] = value;
896 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100897
898 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
Steve Block1e0659c2011-05-24 12:43:12 +0100899 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100900
901 virtual bool IsControl() const { return true; }
902
Ben Murdoch086aeea2011-05-13 15:57:08 +0100903 Handle<Map> map() const { return hydrogen()->map(); }
904 int true_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100905 return hydrogen()->FirstSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +0100906 }
907 int false_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100908 return hydrogen()->SecondSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +0100909 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100910};
911
912
Steve Block1e0659c2011-05-24 12:43:12 +0100913class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100914 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100915 explicit LJSArrayLength(LOperand* value) {
916 inputs_[0] = value;
917 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100918
Steve Block9fac8402011-05-12 15:51:54 +0100919 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
920 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
921};
Ben Murdochb0fe1622011-05-05 13:52:32 +0100922
Ben Murdochb0fe1622011-05-05 13:52:32 +0100923
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000924class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +0100925 public:
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000926 explicit LFixedArrayBaseLength(LOperand* value) {
Steve Block1e0659c2011-05-24 12:43:12 +0100927 inputs_[0] = value;
928 }
929
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000930 DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength,
931 "fixed-array-base-length")
932 DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100933};
934
935
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000936class LElementsKind: public LTemplateInstruction<1, 1, 0> {
937 public:
938 explicit LElementsKind(LOperand* value) {
939 inputs_[0] = value;
940 }
941
942 DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind")
943 DECLARE_HYDROGEN_ACCESSOR(ElementsKind)
944};
945
946
Ben Murdochb8e0da22011-05-16 14:20:40 +0100947class LValueOf: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100948 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100949 LValueOf(LOperand* value, LOperand* temp) {
950 inputs_[0] = value;
951 temps_[0] = temp;
952 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100953
954 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
955 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100956};
957
958
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000959class LThrow: public LTemplateInstruction<0, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100960 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000961 LThrow(LOperand* context, LOperand* value) {
962 inputs_[0] = context;
963 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100964 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100965
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000966 LOperand* context() { return inputs_[0]; }
967 LOperand* value() { return inputs_[1]; }
968
Ben Murdochb0fe1622011-05-05 13:52:32 +0100969 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
970};
971
972
Steve Block1e0659c2011-05-24 12:43:12 +0100973class LBitNotI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100974 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100975 explicit LBitNotI(LOperand* value) {
976 inputs_[0] = value;
977 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100978
979 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
980};
981
982
Steve Block1e0659c2011-05-24 12:43:12 +0100983class LAddI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100984 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100985 LAddI(LOperand* left, LOperand* right) {
986 inputs_[0] = left;
987 inputs_[1] = right;
988 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100989
990 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
991 DECLARE_HYDROGEN_ACCESSOR(Add)
992};
993
994
Steve Block1e0659c2011-05-24 12:43:12 +0100995class LPower: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100996 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100997 LPower(LOperand* left, LOperand* right) {
998 inputs_[0] = left;
999 inputs_[1] = right;
1000 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001001
1002 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1003 DECLARE_HYDROGEN_ACCESSOR(Power)
1004};
1005
1006
Steve Block1e0659c2011-05-24 12:43:12 +01001007class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001008 public:
1009 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001010 : op_(op) {
1011 inputs_[0] = left;
1012 inputs_[1] = right;
1013 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001014
1015 Token::Value op() const { return op_; }
1016
Ben Murdoch257744e2011-11-30 15:57:28 +00001017 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001018 virtual void CompileToNative(LCodeGen* generator);
1019 virtual const char* Mnemonic() const;
1020
1021 private:
1022 Token::Value op_;
1023};
1024
1025
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001026class LArithmeticT: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001027 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001028 LArithmeticT(Token::Value op,
1029 LOperand* context,
1030 LOperand* left,
1031 LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001032 : op_(op) {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001033 inputs_[0] = context;
1034 inputs_[1] = left;
1035 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001036 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001037
Ben Murdoch257744e2011-11-30 15:57:28 +00001038 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001039 virtual void CompileToNative(LCodeGen* generator);
1040 virtual const char* Mnemonic() const;
1041
1042 Token::Value op() const { return op_; }
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001043 LOperand* context() { return inputs_[0]; }
1044 LOperand* left() { return inputs_[1]; }
1045 LOperand* right() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001046
1047 private:
1048 Token::Value op_;
1049};
1050
1051
Steve Block1e0659c2011-05-24 12:43:12 +01001052class LReturn: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001053 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001054 explicit LReturn(LOperand* value) {
1055 inputs_[0] = value;
1056 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001057
1058 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1059};
1060
1061
Steve Block1e0659c2011-05-24 12:43:12 +01001062class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001063 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001064 explicit LLoadNamedField(LOperand* object) {
1065 inputs_[0] = object;
1066 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001067
1068 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1069 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
Steve Block44f0eee2011-05-26 01:26:41 +01001070
1071 LOperand* object() { return inputs_[0]; }
1072};
1073
1074
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001075class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 2, 0> {
Steve Block44f0eee2011-05-26 01:26:41 +01001076 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001077 LLoadNamedFieldPolymorphic(LOperand* context, LOperand* object) {
1078 inputs_[0] = context;
1079 inputs_[1] = object;
Steve Block44f0eee2011-05-26 01:26:41 +01001080 }
1081
1082 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1083 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1084
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001085 LOperand* context() { return inputs_[0]; }
1086 LOperand* object() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001087};
1088
1089
Steve Block1e0659c2011-05-24 12:43:12 +01001090class LLoadNamedGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001091 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001092 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1093 inputs_[0] = context;
1094 inputs_[1] = object;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001095 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001096
1097 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1098 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1099
Steve Block1e0659c2011-05-24 12:43:12 +01001100 LOperand* context() { return inputs_[0]; }
1101 LOperand* object() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001102 Handle<Object> name() const { return hydrogen()->name(); }
1103};
1104
1105
Ben Murdochb8e0da22011-05-16 14:20:40 +01001106class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 1> {
Steve Block9fac8402011-05-12 15:51:54 +01001107 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001108 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1109 inputs_[0] = function;
1110 temps_[0] = temp;
1111 }
Steve Block9fac8402011-05-12 15:51:54 +01001112
1113 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1114 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1115
Ben Murdochb8e0da22011-05-16 14:20:40 +01001116 LOperand* function() { return inputs_[0]; }
Steve Block9fac8402011-05-12 15:51:54 +01001117};
1118
1119
Steve Block1e0659c2011-05-24 12:43:12 +01001120class LLoadElements: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001121 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001122 explicit LLoadElements(LOperand* object) {
1123 inputs_[0] = object;
1124 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001125
1126 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1127};
1128
1129
Steve Block44f0eee2011-05-26 01:26:41 +01001130class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001131 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001132 explicit LLoadExternalArrayPointer(LOperand* object) {
Steve Block1e0659c2011-05-24 12:43:12 +01001133 inputs_[0] = object;
1134 }
1135
Steve Block44f0eee2011-05-26 01:26:41 +01001136 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1137 "load-external-array-pointer")
Steve Block1e0659c2011-05-24 12:43:12 +01001138};
1139
1140
1141class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001142 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001143 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1144 inputs_[0] = elements;
1145 inputs_[1] = key;
1146 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001147
1148 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1149 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1150
Ben Murdochb8e0da22011-05-16 14:20:40 +01001151 LOperand* elements() { return inputs_[0]; }
1152 LOperand* key() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001153};
1154
1155
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001156class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> {
1157 public:
1158 LLoadKeyedFastDoubleElement(LOperand* elements,
1159 LOperand* key) {
1160 inputs_[0] = elements;
1161 inputs_[1] = key;
1162 }
1163
1164 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement,
1165 "load-keyed-fast-double-element")
1166 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement)
1167
1168 LOperand* elements() { return inputs_[0]; }
1169 LOperand* key() { return inputs_[1]; }
1170};
1171
1172
Steve Block44f0eee2011-05-26 01:26:41 +01001173class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001174 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001175 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1176 LOperand* key) {
Steve Block1e0659c2011-05-24 12:43:12 +01001177 inputs_[0] = external_pointer;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001178 inputs_[1] = key;
1179 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001180
Steve Block44f0eee2011-05-26 01:26:41 +01001181 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1182 "load-keyed-specialized-array-element")
1183 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
Steve Block1e0659c2011-05-24 12:43:12 +01001184
1185 LOperand* external_pointer() { return inputs_[0]; }
1186 LOperand* key() { return inputs_[1]; }
Ben Murdoch589d6972011-11-30 16:04:58 +00001187 ElementsKind elements_kind() const {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001188 return hydrogen()->elements_kind();
Steve Block44f0eee2011-05-26 01:26:41 +01001189 }
Steve Block1e0659c2011-05-24 12:43:12 +01001190};
1191
1192
1193class LLoadKeyedGeneric: public LTemplateInstruction<1, 3, 0> {
1194 public:
1195 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1196 inputs_[0] = context;
1197 inputs_[1] = obj;
1198 inputs_[2] = key;
1199 }
1200
Ben Murdochb0fe1622011-05-05 13:52:32 +01001201 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1202
Steve Block1e0659c2011-05-24 12:43:12 +01001203 LOperand* context() { return inputs_[0]; }
1204 LOperand* object() { return inputs_[1]; }
1205 LOperand* key() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001206};
1207
1208
Ben Murdoch8b112d22011-06-08 16:22:53 +01001209class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001210 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001211 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1212 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001213};
1214
1215
Ben Murdoch8b112d22011-06-08 16:22:53 +01001216class LLoadGlobalGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001217 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001218 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1219 inputs_[0] = context;
1220 inputs_[1] = global_object;
1221 }
1222
1223 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1224 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1225
1226 LOperand* context() { return inputs_[0]; }
1227 LOperand* global_object() { return inputs_[1]; }
1228 Handle<Object> name() const { return hydrogen()->name(); }
1229 bool for_typeof() const { return hydrogen()->for_typeof(); }
1230};
1231
1232
1233class LStoreGlobalCell: public LTemplateInstruction<0, 1, 0> {
1234 public:
1235 explicit LStoreGlobalCell(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001236 inputs_[0] = value;
1237 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001238
Ben Murdoch8b112d22011-06-08 16:22:53 +01001239 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1240 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1241};
1242
1243
1244class LStoreGlobalGeneric: public LTemplateInstruction<0, 3, 0> {
1245 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001246 LStoreGlobalGeneric(LOperand* context,
1247 LOperand* global_object,
1248 LOperand* value) {
Ben Murdoch8b112d22011-06-08 16:22:53 +01001249 inputs_[0] = context;
1250 inputs_[1] = global_object;
1251 inputs_[2] = value;
1252 }
1253
1254 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1255 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1256
1257 LOperand* context() { return InputAt(0); }
1258 LOperand* global_object() { return InputAt(1); }
1259 Handle<Object> name() const { return hydrogen()->name(); }
1260 LOperand* value() { return InputAt(2); }
1261 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001262};
1263
1264
Steve Block1e0659c2011-05-24 12:43:12 +01001265class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001266 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001267 explicit LLoadContextSlot(LOperand* context) {
1268 inputs_[0] = context;
1269 }
1270
Ben Murdochb8e0da22011-05-16 14:20:40 +01001271 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1272 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1273
Steve Block1e0659c2011-05-24 12:43:12 +01001274 LOperand* context() { return InputAt(0); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001275 int slot_index() { return hydrogen()->slot_index(); }
1276
1277 virtual void PrintDataTo(StringStream* stream);
1278};
1279
1280
Steve Block1e0659c2011-05-24 12:43:12 +01001281class LStoreContextSlot: public LTemplateInstruction<0, 2, 1> {
1282 public:
1283 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1284 inputs_[0] = context;
1285 inputs_[1] = value;
1286 temps_[0] = temp;
1287 }
1288
1289 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1290 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1291
1292 LOperand* context() { return InputAt(0); }
1293 LOperand* value() { return InputAt(1); }
1294 int slot_index() { return hydrogen()->slot_index(); }
1295 int needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1296
1297 virtual void PrintDataTo(StringStream* stream);
1298};
1299
1300
1301class LPushArgument: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001302 public:
1303 explicit LPushArgument(LOperand* value) {
1304 inputs_[0] = value;
1305 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001306
1307 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1308};
1309
1310
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001311class LThisFunction: public LTemplateInstruction<1, 0, 0> {
1312 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1313};
1314
1315
Steve Block1e0659c2011-05-24 12:43:12 +01001316class LContext: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001317 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001318 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001319};
1320
1321
Steve Block1e0659c2011-05-24 12:43:12 +01001322class LOuterContext: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001323 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001324 explicit LOuterContext(LOperand* context) {
1325 inputs_[0] = context;
1326 }
1327
1328 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1329
1330 LOperand* context() { return InputAt(0); }
1331};
1332
1333
1334class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1335 public:
1336 explicit LGlobalObject(LOperand* context) {
1337 inputs_[0] = context;
1338 }
1339
1340 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1341
1342 LOperand* context() { return InputAt(0); }
1343};
1344
1345
1346class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1347 public:
1348 explicit LGlobalReceiver(LOperand* global_object) {
1349 inputs_[0] = global_object;
1350 }
1351
Ben Murdochb0fe1622011-05-05 13:52:32 +01001352 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
Steve Block1e0659c2011-05-24 12:43:12 +01001353
1354 LOperand* global() { return InputAt(0); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001355};
1356
1357
Ben Murdochb8e0da22011-05-16 14:20:40 +01001358class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001359 public:
1360 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1361 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1362
Ben Murdochb8e0da22011-05-16 14:20:40 +01001363 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001364
Ben Murdochb8e0da22011-05-16 14:20:40 +01001365 Handle<JSFunction> function() { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001366 int arity() const { return hydrogen()->argument_count() - 1; }
1367};
1368
1369
Ben Murdoch257744e2011-11-30 15:57:28 +00001370class LInvokeFunction: public LTemplateInstruction<1, 2, 0> {
1371 public:
1372 LInvokeFunction(LOperand* context, LOperand* function) {
1373 inputs_[0] = context;
1374 inputs_[1] = function;
1375 }
1376
1377 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1378 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1379
1380 LOperand* context() { return inputs_[0]; }
1381 LOperand* function() { return inputs_[1]; }
1382
1383 virtual void PrintDataTo(StringStream* stream);
1384
1385 int arity() const { return hydrogen()->argument_count() - 1; }
1386};
1387
1388
Steve Block1e0659c2011-05-24 12:43:12 +01001389class LCallKeyed: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001390 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001391 LCallKeyed(LOperand* context, LOperand* key) {
1392 inputs_[0] = context;
1393 inputs_[1] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001394 }
1395
Ben Murdochb0fe1622011-05-05 13:52:32 +01001396 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1397 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1398
Steve Block1e0659c2011-05-24 12:43:12 +01001399 LOperand* context() { return inputs_[0]; }
1400 LOperand* key() { return inputs_[1]; }
1401
Ben Murdochb8e0da22011-05-16 14:20:40 +01001402 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001403
1404 int arity() const { return hydrogen()->argument_count() - 1; }
1405};
1406
1407
Steve Block1e0659c2011-05-24 12:43:12 +01001408class LCallNamed: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001409 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001410 explicit LCallNamed(LOperand* context) {
1411 inputs_[0] = context;
1412 }
1413
Ben Murdochb0fe1622011-05-05 13:52:32 +01001414 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1415 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1416
Ben Murdochb8e0da22011-05-16 14:20:40 +01001417 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001418
Steve Block1e0659c2011-05-24 12:43:12 +01001419 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001420 Handle<String> name() const { return hydrogen()->name(); }
1421 int arity() const { return hydrogen()->argument_count() - 1; }
1422};
1423
1424
Steve Block1e0659c2011-05-24 12:43:12 +01001425class LCallFunction: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001426 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001427 explicit LCallFunction(LOperand* context) {
1428 inputs_[0] = context;
1429 }
1430
Ben Murdochb0fe1622011-05-05 13:52:32 +01001431 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1432 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1433
Steve Block1e0659c2011-05-24 12:43:12 +01001434 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001435 int arity() const { return hydrogen()->argument_count() - 2; }
1436};
1437
1438
Steve Block1e0659c2011-05-24 12:43:12 +01001439class LCallGlobal: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001440 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001441 explicit LCallGlobal(LOperand* context) {
1442 inputs_[0] = context;
1443 }
1444
Ben Murdochb0fe1622011-05-05 13:52:32 +01001445 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1446 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1447
Ben Murdochb8e0da22011-05-16 14:20:40 +01001448 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001449
Steve Block1e0659c2011-05-24 12:43:12 +01001450 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001451 Handle<String> name() const {return hydrogen()->name(); }
1452 int arity() const { return hydrogen()->argument_count() - 1; }
1453};
1454
1455
Ben Murdochb8e0da22011-05-16 14:20:40 +01001456class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001457 public:
1458 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1459 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1460
Ben Murdochb8e0da22011-05-16 14:20:40 +01001461 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001462
1463 Handle<JSFunction> target() const { return hydrogen()->target(); }
1464 int arity() const { return hydrogen()->argument_count() - 1; }
1465};
1466
1467
Steve Block1e0659c2011-05-24 12:43:12 +01001468class LCallNew: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001469 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001470 LCallNew(LOperand* context, LOperand* constructor) {
1471 inputs_[0] = context;
1472 inputs_[1] = constructor;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001473 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001474
1475 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1476 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1477
Ben Murdochb8e0da22011-05-16 14:20:40 +01001478 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001479
Steve Block1e0659c2011-05-24 12:43:12 +01001480 LOperand* context() { return inputs_[0]; }
1481 LOperand* constructor() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001482 int arity() const { return hydrogen()->argument_count() - 1; }
1483};
1484
1485
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001486class LCallRuntime: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001487 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001488 explicit LCallRuntime(LOperand* context) {
1489 inputs_[0] = context;
1490 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001491 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1492 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1493
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001494 LOperand* context() { return inputs_[0]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001495 const Runtime::Function* function() const { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001496 int arity() const { return hydrogen()->argument_count(); }
1497};
1498
1499
Steve Block1e0659c2011-05-24 12:43:12 +01001500class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001501 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001502 explicit LInteger32ToDouble(LOperand* value) {
1503 inputs_[0] = value;
1504 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001505
1506 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1507};
1508
1509
Steve Block1e0659c2011-05-24 12:43:12 +01001510class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001511 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001512 explicit LNumberTagI(LOperand* value) {
1513 inputs_[0] = value;
1514 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001515
1516 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1517};
1518
1519
Ben Murdochb8e0da22011-05-16 14:20:40 +01001520class LNumberTagD: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001521 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001522 LNumberTagD(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001523 inputs_[0] = value;
1524 temps_[0] = temp;
1525 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001526
1527 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001528};
1529
1530
1531// Sometimes truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001532class LDoubleToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001533 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001534 LDoubleToI(LOperand* value, LOperand* temp) {
1535 inputs_[0] = value;
1536 temps_[0] = temp;
1537 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001538
1539 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001540 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001541
1542 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1543};
1544
1545
1546// Truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001547class LTaggedToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001548 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001549 LTaggedToI(LOperand* value, LOperand* temp) {
1550 inputs_[0] = value;
1551 temps_[0] = temp;
1552 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001553
1554 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001555 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001556
1557 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001558};
1559
1560
Steve Block1e0659c2011-05-24 12:43:12 +01001561class LSmiTag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001562 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001563 explicit LSmiTag(LOperand* value) {
1564 inputs_[0] = value;
1565 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001566
1567 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1568};
1569
1570
Steve Block1e0659c2011-05-24 12:43:12 +01001571class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001572 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001573 explicit LNumberUntagD(LOperand* value) {
1574 inputs_[0] = value;
1575 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001576
1577 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +01001578 DECLARE_HYDROGEN_ACCESSOR(Change);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001579};
1580
1581
Steve Block1e0659c2011-05-24 12:43:12 +01001582class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001583 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001584 LSmiUntag(LOperand* value, bool needs_check)
1585 : needs_check_(needs_check) {
1586 inputs_[0] = value;
1587 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001588
1589 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1590
1591 bool needs_check() const { return needs_check_; }
1592
1593 private:
1594 bool needs_check_;
1595};
1596
1597
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001598class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001599 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001600 LStoreNamedField(LOperand* obj, LOperand* val, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001601 inputs_[0] = obj;
1602 inputs_[1] = val;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001603 temps_[0] = temp;
1604 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001605
1606 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001607 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001608
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001609 virtual void PrintDataTo(StringStream* stream);
1610
1611 LOperand* object() { return inputs_[0]; }
1612 LOperand* value() { return inputs_[1]; }
1613
1614 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001615 bool is_in_object() { return hydrogen()->is_in_object(); }
1616 int offset() { return hydrogen()->offset(); }
1617 bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1618 Handle<Map> transition() const { return hydrogen()->transition(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001619};
1620
1621
Steve Block1e0659c2011-05-24 12:43:12 +01001622class LStoreNamedGeneric: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001623 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001624 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
1625 inputs_[0] = context;
1626 inputs_[1] = object;
1627 inputs_[2] = value;
1628 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001629
1630 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001631 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001632
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001633 virtual void PrintDataTo(StringStream* stream);
1634
Steve Block1e0659c2011-05-24 12:43:12 +01001635 LOperand* context() { return inputs_[0]; }
1636 LOperand* object() { return inputs_[1]; }
1637 LOperand* value() { return inputs_[2]; }
1638 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001639 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001640};
1641
1642
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001643class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001644 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001645 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001646 inputs_[0] = obj;
1647 inputs_[1] = key;
1648 inputs_[2] = val;
1649 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001650
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001651 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1652 "store-keyed-fast-element")
1653 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001654
Ben Murdochb8e0da22011-05-16 14:20:40 +01001655 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001656
Ben Murdochb8e0da22011-05-16 14:20:40 +01001657 LOperand* object() { return inputs_[0]; }
1658 LOperand* key() { return inputs_[1]; }
1659 LOperand* value() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001660};
1661
1662
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001663class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> {
1664 public:
1665 LStoreKeyedFastDoubleElement(LOperand* elements,
1666 LOperand* key,
1667 LOperand* val) {
1668 inputs_[0] = elements;
1669 inputs_[1] = key;
1670 inputs_[2] = val;
1671 }
1672
1673 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement,
1674 "store-keyed-fast-double-element")
1675 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement)
1676
1677 virtual void PrintDataTo(StringStream* stream);
1678
1679 LOperand* elements() { return inputs_[0]; }
1680 LOperand* key() { return inputs_[1]; }
1681 LOperand* value() { return inputs_[2]; }
1682};
1683
1684
Ben Murdoch257744e2011-11-30 15:57:28 +00001685class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001686 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001687 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1688 LOperand* key,
Ben Murdoch257744e2011-11-30 15:57:28 +00001689 LOperand* val) {
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001690 inputs_[0] = external_pointer;
1691 inputs_[1] = key;
1692 inputs_[2] = val;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001693 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001694
Steve Block44f0eee2011-05-26 01:26:41 +01001695 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1696 "store-keyed-specialized-array-element")
1697 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001698
1699 LOperand* external_pointer() { return inputs_[0]; }
1700 LOperand* key() { return inputs_[1]; }
1701 LOperand* value() { return inputs_[2]; }
Ben Murdoch589d6972011-11-30 16:04:58 +00001702 ElementsKind elements_kind() const {
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001703 return hydrogen()->elements_kind();
Steve Block44f0eee2011-05-26 01:26:41 +01001704 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001705};
1706
1707
Steve Block1e0659c2011-05-24 12:43:12 +01001708class LStoreKeyedGeneric: public LTemplateInstruction<0, 4, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001709 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001710 LStoreKeyedGeneric(LOperand* context,
1711 LOperand* object,
1712 LOperand* key,
1713 LOperand* value) {
1714 inputs_[0] = context;
1715 inputs_[1] = object;
1716 inputs_[2] = key;
1717 inputs_[3] = value;
1718 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001719
1720 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
Ben Murdoch8b112d22011-06-08 16:22:53 +01001721 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001722
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001723 virtual void PrintDataTo(StringStream* stream);
1724
Steve Block1e0659c2011-05-24 12:43:12 +01001725 LOperand* context() { return inputs_[0]; }
1726 LOperand* object() { return inputs_[1]; }
1727 LOperand* key() { return inputs_[2]; }
1728 LOperand* value() { return inputs_[3]; }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001729 bool strict_mode() { return hydrogen()->strict_mode(); }
1730};
1731
1732
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001733class LStringAdd: public LTemplateInstruction<1, 3, 0> {
Ben Murdoch257744e2011-11-30 15:57:28 +00001734 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001735 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
1736 inputs_[0] = context;
1737 inputs_[1] = left;
1738 inputs_[2] = right;
Ben Murdoch257744e2011-11-30 15:57:28 +00001739 }
1740
1741 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1742 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1743
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001744 LOperand* context() { return inputs_[0]; }
1745 LOperand* left() { return inputs_[1]; }
1746 LOperand* right() { return inputs_[2]; }
Ben Murdoch257744e2011-11-30 15:57:28 +00001747};
1748
1749
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001750class LStringCharCodeAt: public LTemplateInstruction<1, 3, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001751 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001752 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
1753 inputs_[0] = context;
1754 inputs_[1] = string;
1755 inputs_[2] = index;
Steve Block1e0659c2011-05-24 12:43:12 +01001756 }
1757
1758 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1759 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1760
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001761 LOperand* context() { return inputs_[0]; }
1762 LOperand* string() { return inputs_[1]; }
1763 LOperand* index() { return inputs_[2]; }
Steve Block1e0659c2011-05-24 12:43:12 +01001764};
1765
1766
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001767class LStringCharFromCode: public LTemplateInstruction<1, 2, 0> {
Steve Block44f0eee2011-05-26 01:26:41 +01001768 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001769 LStringCharFromCode(LOperand* context, LOperand* char_code) {
1770 inputs_[0] = context;
1771 inputs_[1] = char_code;
Steve Block44f0eee2011-05-26 01:26:41 +01001772 }
1773
1774 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1775 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1776
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001777 LOperand* context() { return inputs_[0]; }
1778 LOperand* char_code() { return inputs_[1]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001779};
1780
1781
Steve Block1e0659c2011-05-24 12:43:12 +01001782class LStringLength: public LTemplateInstruction<1, 1, 0> {
1783 public:
1784 explicit LStringLength(LOperand* string) {
1785 inputs_[0] = string;
1786 }
1787
1788 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1789 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1790
1791 LOperand* string() { return inputs_[0]; }
1792};
1793
1794
1795class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001796 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001797 explicit LCheckFunction(LOperand* value) {
1798 inputs_[0] = value;
1799 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001800
1801 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1802 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1803};
1804
1805
Ben Murdochb8e0da22011-05-16 14:20:40 +01001806class LCheckInstanceType: public LTemplateInstruction<0, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001807 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001808 LCheckInstanceType(LOperand* value, LOperand* temp) {
1809 inputs_[0] = value;
1810 temps_[0] = temp;
1811 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001812
1813 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1814 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001815};
1816
1817
Steve Block1e0659c2011-05-24 12:43:12 +01001818class LCheckMap: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001819 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001820 explicit LCheckMap(LOperand* value) {
1821 inputs_[0] = value;
1822 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001823
1824 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1825 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1826};
1827
1828
Ben Murdochb8e0da22011-05-16 14:20:40 +01001829class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001830 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001831 explicit LCheckPrototypeMaps(LOperand* temp) {
1832 temps_[0] = temp;
1833 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001834
1835 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001836 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001837
Ben Murdochb8e0da22011-05-16 14:20:40 +01001838 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1839 Handle<JSObject> holder() const { return hydrogen()->holder(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001840};
1841
1842
Steve Block1e0659c2011-05-24 12:43:12 +01001843class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001844 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001845 explicit LCheckSmi(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001846 inputs_[0] = value;
1847 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001848
Steve Block44f0eee2011-05-26 01:26:41 +01001849 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1850};
Ben Murdochb0fe1622011-05-05 13:52:32 +01001851
Steve Block44f0eee2011-05-26 01:26:41 +01001852
Ben Murdoch257744e2011-11-30 15:57:28 +00001853class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
1854 public:
1855 explicit LClampDToUint8(LOperand* value) {
1856 inputs_[0] = value;
1857 }
1858
1859 LOperand* unclamped() { return inputs_[0]; }
1860
1861 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1862};
1863
1864
1865class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1866 public:
1867 explicit LClampIToUint8(LOperand* value) {
1868 inputs_[0] = value;
1869 }
1870
1871 LOperand* unclamped() { return inputs_[0]; }
1872
1873 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
1874};
1875
1876
1877class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
1878 public:
1879 LClampTToUint8(LOperand* value, LOperand* temp) {
1880 inputs_[0] = value;
1881 temps_[0] = temp;
1882 }
1883
1884 LOperand* unclamped() { return inputs_[0]; }
1885
1886 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
1887};
1888
1889
Steve Block44f0eee2011-05-26 01:26:41 +01001890class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1891 public:
1892 explicit LCheckNonSmi(LOperand* value) {
1893 inputs_[0] = value;
Ben Murdochb0fe1622011-05-05 13:52:32 +01001894 }
1895
Steve Block44f0eee2011-05-26 01:26:41 +01001896 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001897};
1898
1899
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001900class LArrayLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001901 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001902 explicit LArrayLiteral(LOperand* context) {
1903 inputs_[0] = context;
1904 }
1905
1906 LOperand* context() { return inputs_[0]; }
1907
Ben Murdochb0fe1622011-05-05 13:52:32 +01001908 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1909 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1910};
1911
1912
Steve Block1e0659c2011-05-24 12:43:12 +01001913class LObjectLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001914 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001915 explicit LObjectLiteral(LOperand* context) {
1916 inputs_[0] = context;
1917 }
1918
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001919 LOperand* context() { return inputs_[0]; }
1920
Ben Murdochb0fe1622011-05-05 13:52:32 +01001921 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
1922 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
1923};
1924
1925
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001926class LRegExpLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001927 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001928 explicit LRegExpLiteral(LOperand* context) {
1929 inputs_[0] = context;
1930 }
1931
1932 LOperand* context() { return inputs_[0]; }
1933
Ben Murdochb0fe1622011-05-05 13:52:32 +01001934 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
1935 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
1936};
1937
1938
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001939class LFunctionLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001940 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001941 explicit LFunctionLiteral(LOperand* context) {
1942 inputs_[0] = context;
1943 }
1944
1945 LOperand* context() { return inputs_[0]; }
1946
Ben Murdochb0fe1622011-05-05 13:52:32 +01001947 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1948 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1949
1950 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
1951};
1952
1953
Steve Block44f0eee2011-05-26 01:26:41 +01001954class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
1955 public:
1956 explicit LToFastProperties(LOperand* value) {
1957 inputs_[0] = value;
1958 }
1959
1960 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
1961 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
1962};
1963
1964
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001965class LTypeof: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001966 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001967 LTypeof(LOperand* context, LOperand* value) {
1968 inputs_[0] = context;
1969 inputs_[1] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001970 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001971
1972 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
1973};
1974
1975
Steve Block1e0659c2011-05-24 12:43:12 +01001976class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001977 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001978 explicit LTypeofIsAndBranch(LOperand* value) {
1979 inputs_[0] = value;
1980 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001981
1982 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001983 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001984
Ben Murdochb8e0da22011-05-16 14:20:40 +01001985 Handle<String> type_literal() { return hydrogen()->type_literal(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001986
Ben Murdochb8e0da22011-05-16 14:20:40 +01001987 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001988};
1989
1990
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001991class LDeleteProperty: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001992 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001993 LDeleteProperty(LOperand* context, LOperand* obj, LOperand* key) {
1994 inputs_[0] = context;
1995 inputs_[1] = obj;
1996 inputs_[2] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001997 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001998
1999 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
2000
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002001 LOperand* context() { return inputs_[0]; }
2002 LOperand* object() { return inputs_[1]; }
2003 LOperand* key() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002004};
2005
2006
Ben Murdochb8e0da22011-05-16 14:20:40 +01002007class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002008 public:
2009 LOsrEntry();
2010
2011 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2012
2013 LOperand** SpilledRegisterArray() { return register_spills_; }
2014 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2015
2016 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2017 void MarkSpilledDoubleRegister(int allocation_index,
2018 LOperand* spill_operand);
2019
2020 private:
2021 // Arrays of spill slot operands for registers with an assigned spill
2022 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2023 // NULL if the register has no assigned spill slot. Indexed by allocation
2024 // index.
2025 LOperand* register_spills_[Register::kNumAllocatableRegisters];
2026 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2027};
2028
2029
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002030class LStackCheck: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002031 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002032 explicit LStackCheck(LOperand* context) {
2033 inputs_[0] = context;
2034 }
2035
2036 LOperand* context() { return inputs_[0]; }
2037
Ben Murdochb0fe1622011-05-05 13:52:32 +01002038 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002039 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2040
2041 Label* done_label() { return &done_label_; }
2042
2043 private:
2044 Label done_label_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002045};
2046
2047
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002048class LIn: public LTemplateInstruction<1, 3, 0> {
Ben Murdoch257744e2011-11-30 15:57:28 +00002049 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002050 LIn(LOperand* context, LOperand* key, LOperand* object) {
2051 inputs_[0] = context;
2052 inputs_[1] = key;
2053 inputs_[2] = object;
Ben Murdoch257744e2011-11-30 15:57:28 +00002054 }
2055
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002056 LOperand* context() { return inputs_[0]; }
2057 LOperand* key() { return inputs_[1]; }
2058 LOperand* object() { return inputs_[2]; }
Ben Murdoch257744e2011-11-30 15:57:28 +00002059
2060 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2061};
2062
2063
Ben Murdochb0fe1622011-05-05 13:52:32 +01002064class LChunkBuilder;
2065class LChunk: public ZoneObject {
2066 public:
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00002067 LChunk(CompilationInfo* info, HGraph* graph)
Ben Murdoch086aeea2011-05-13 15:57:08 +01002068 : spill_slot_count_(0),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002069 info_(info),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002070 graph_(graph),
2071 instructions_(32),
2072 pointer_maps_(8),
2073 inlined_closures_(1) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002074
Steve Block1e0659c2011-05-24 12:43:12 +01002075 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002076 LConstantOperand* DefineConstantOperand(HConstant* constant);
2077 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2078 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
2079
2080 int GetNextSpillIndex(bool is_double);
2081 LOperand* GetNextSpillSlot(bool is_double);
2082
2083 int ParameterAt(int index);
2084 int GetParameterStackSlot(int index) const;
2085 int spill_slot_count() const { return spill_slot_count_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002086 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002087 HGraph* graph() const { return graph_; }
2088 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2089 void AddGapMove(int index, LOperand* from, LOperand* to);
2090 LGap* GetGapAt(int index) const;
2091 bool IsGapAt(int index) const;
2092 int NearestGapPos(int index) const;
2093 void MarkEmptyBlocks();
2094 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
2095 LLabel* GetLabel(int block_id) const {
2096 HBasicBlock* block = graph_->blocks()->at(block_id);
2097 int first_instruction = block->first_instruction_index();
2098 return LLabel::cast(instructions_[first_instruction]);
2099 }
2100 int LookupDestination(int block_id) const {
2101 LLabel* cur = GetLabel(block_id);
2102 while (cur->replacement() != NULL) {
2103 cur = cur->replacement();
2104 }
2105 return cur->block_id();
2106 }
2107 Label* GetAssemblyLabel(int block_id) const {
2108 LLabel* label = GetLabel(block_id);
2109 ASSERT(!label->HasReplacement());
2110 return label->label();
2111 }
2112
2113 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2114 return &inlined_closures_;
2115 }
2116
2117 void AddInlinedClosure(Handle<JSFunction> closure) {
2118 inlined_closures_.Add(closure);
2119 }
2120
Ben Murdochb0fe1622011-05-05 13:52:32 +01002121 private:
2122 int spill_slot_count_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002123 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002124 HGraph* const graph_;
2125 ZoneList<LInstruction*> instructions_;
2126 ZoneList<LPointerMap*> pointer_maps_;
2127 ZoneList<Handle<JSFunction> > inlined_closures_;
2128};
2129
2130
2131class LChunkBuilder BASE_EMBEDDED {
2132 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002133 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002134 : chunk_(NULL),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002135 info_(info),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002136 graph_(graph),
2137 status_(UNUSED),
2138 current_instruction_(NULL),
2139 current_block_(NULL),
2140 next_block_(NULL),
2141 argument_count_(0),
2142 allocator_(allocator),
2143 position_(RelocInfo::kNoPosition),
Steve Block1e0659c2011-05-24 12:43:12 +01002144 instruction_pending_deoptimization_environment_(NULL),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002145 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
2146
2147 // Build the sequence for the graph.
2148 LChunk* Build();
2149
2150 // Declare methods that deal with the individual node types.
2151#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2152 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2153#undef DECLARE_DO
2154
2155 private:
2156 enum Status {
2157 UNUSED,
2158 BUILDING,
2159 DONE,
2160 ABORTED
2161 };
2162
2163 LChunk* chunk() const { return chunk_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002164 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002165 HGraph* graph() const { return graph_; }
2166
2167 bool is_unused() const { return status_ == UNUSED; }
2168 bool is_building() const { return status_ == BUILDING; }
2169 bool is_done() const { return status_ == DONE; }
2170 bool is_aborted() const { return status_ == ABORTED; }
2171
2172 void Abort(const char* format, ...);
2173
2174 // Methods for getting operands for Use / Define / Temp.
2175 LRegister* ToOperand(Register reg);
2176 LUnallocated* ToUnallocated(Register reg);
2177 LUnallocated* ToUnallocated(XMMRegister reg);
2178
2179 // Methods for setting up define-use relationships.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002180 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2181 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2182 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2183 XMMRegister fixed_register);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002184
2185 // A value that is guaranteed to be allocated to a register.
2186 // Operand created by UseRegister is guaranteed to be live until the end of
2187 // instruction. This means that register allocator will not reuse it's
2188 // register for any other operand inside instruction.
2189 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2190 // instruction start. Register allocator is free to assign the same register
2191 // to some other operand used inside instruction (i.e. temporary or
2192 // output).
Ben Murdochb8e0da22011-05-16 14:20:40 +01002193 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2194 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002195
Ben Murdochb8e0da22011-05-16 14:20:40 +01002196 // An input operand in a register that may be trashed.
2197 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2198
2199 // An input operand in a register or stack slot.
2200 MUST_USE_RESULT LOperand* Use(HValue* value);
2201 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2202
2203 // An input operand in a register, stack slot or a constant operand.
2204 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2205 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2206
2207 // An input operand in a register or a constant operand.
2208 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2209 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2210
2211 // An input operand in register, stack slot or a constant operand.
2212 // Will not be moved to a register even if one is freely available.
2213 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2214
2215 // Temporary operand that must be in a register.
2216 MUST_USE_RESULT LUnallocated* TempRegister();
2217 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2218 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002219
2220 // Methods for setting up define-use relationships.
2221 // Return the same instruction that they are passed.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002222 template<int I, int T>
2223 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2224 LUnallocated* result);
2225 template<int I, int T>
2226 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2227 template<int I, int T>
2228 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2229 template<int I, int T>
2230 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2231 int index);
2232 template<int I, int T>
2233 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2234 template<int I, int T>
2235 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2236 Register reg);
2237 template<int I, int T>
2238 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2239 XMMRegister reg);
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002240 // Assigns an environment to an instruction. An instruction which can
2241 // deoptimize must have an environment.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002242 LInstruction* AssignEnvironment(LInstruction* instr);
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002243 // Assigns a pointer map to an instruction. An instruction which can
2244 // trigger a GC or a lazy deoptimization must have a pointer map.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002245 LInstruction* AssignPointerMap(LInstruction* instr);
2246
2247 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2248
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002249 // Marks a call for the register allocator. Assigns a pointer map to
2250 // support GC and lazy deoptimization. Assigns an environment to support
2251 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
Ben Murdochb0fe1622011-05-05 13:52:32 +01002252 LInstruction* MarkAsCall(
2253 LInstruction* instr,
2254 HInstruction* hinstr,
2255 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
Ben Murdoch086aeea2011-05-13 15:57:08 +01002256 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002257
2258 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2259 LInstruction* instr, int ast_id);
2260 void ClearInstructionPendingDeoptimizationEnvironment();
2261
Ben Murdoch589d6972011-11-30 16:04:58 +00002262 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002263
Ben Murdochb0fe1622011-05-05 13:52:32 +01002264 void VisitInstruction(HInstruction* current);
2265
2266 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2267 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2268 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2269 LInstruction* DoArithmeticD(Token::Value op,
2270 HArithmeticBinaryOperation* instr);
2271 LInstruction* DoArithmeticT(Token::Value op,
2272 HArithmeticBinaryOperation* instr);
2273
2274 LChunk* chunk_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002275 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002276 HGraph* const graph_;
2277 Status status_;
2278 HInstruction* current_instruction_;
2279 HBasicBlock* current_block_;
2280 HBasicBlock* next_block_;
2281 int argument_count_;
2282 LAllocator* allocator_;
2283 int position_;
Steve Block1e0659c2011-05-24 12:43:12 +01002284 LInstruction* instruction_pending_deoptimization_environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002285 int pending_deoptimization_ast_id_;
2286
2287 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2288};
2289
2290#undef DECLARE_HYDROGEN_ACCESSOR
Ben Murdochb0fe1622011-05-05 13:52:32 +01002291#undef DECLARE_CONCRETE_INSTRUCTION
2292
2293} } // namespace v8::internal
2294
2295#endif // V8_IA32_LITHIUM_IA32_H_