blob: 979c4943a895ba87773b89ff41a541e63ac9456b [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"
35
36namespace v8 {
37namespace internal {
38
39// Forward declarations.
40class LCodeGen;
Ben Murdochb0fe1622011-05-05 13:52:32 +010041
Ben Murdochb0fe1622011-05-05 13:52:32 +010042#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
43 V(AccessArgumentsAt) \
44 V(AddI) \
45 V(ApplyArguments) \
46 V(ArgumentsElements) \
47 V(ArgumentsLength) \
48 V(ArithmeticD) \
49 V(ArithmeticT) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010050 V(ArrayLiteral) \
51 V(BitI) \
52 V(BitNotI) \
53 V(BoundsCheck) \
54 V(Branch) \
55 V(CallConstantFunction) \
56 V(CallFunction) \
57 V(CallGlobal) \
58 V(CallKeyed) \
59 V(CallKnownGlobal) \
60 V(CallNamed) \
61 V(CallNew) \
62 V(CallRuntime) \
63 V(CallStub) \
64 V(CheckFunction) \
65 V(CheckInstanceType) \
66 V(CheckMap) \
Steve Block44f0eee2011-05-26 01:26:41 +010067 V(CheckNonSmi) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010068 V(CheckPrototypeMaps) \
69 V(CheckSmi) \
Ben Murdoch257744e2011-11-30 15:57:28 +000070 V(ClampDToUint8) \
71 V(ClampIToUint8) \
72 V(ClampTToUint8) \
Steve Block1e0659c2011-05-24 12:43:12 +010073 V(ClassOfTest) \
74 V(ClassOfTestAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010075 V(CmpID) \
76 V(CmpIDAndBranch) \
77 V(CmpJSObjectEq) \
78 V(CmpJSObjectEqAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +000079 V(CmpSymbolEq) \
80 V(CmpSymbolEqAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010081 V(CmpMapAndBranch) \
82 V(CmpT) \
83 V(CmpTAndBranch) \
84 V(ConstantD) \
85 V(ConstantI) \
86 V(ConstantT) \
Steve Block1e0659c2011-05-24 12:43:12 +010087 V(Context) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010088 V(DeleteProperty) \
89 V(Deoptimize) \
90 V(DivI) \
91 V(DoubleToI) \
Steve Block44f0eee2011-05-26 01:26:41 +010092 V(ExternalArrayLength) \
Steve Block1e0659c2011-05-24 12:43:12 +010093 V(FixedArrayLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010094 V(FunctionLiteral) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +010095 V(GetCachedArrayIndex) \
Ben Murdochb0fe1622011-05-05 13:52:32 +010096 V(GlobalObject) \
97 V(GlobalReceiver) \
98 V(Goto) \
Steve Block1e0659c2011-05-24 12:43:12 +010099 V(HasCachedArrayIndex) \
100 V(HasCachedArrayIndexAndBranch) \
101 V(HasInstanceType) \
102 V(HasInstanceTypeAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000103 V(In) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100104 V(InstanceOf) \
105 V(InstanceOfAndBranch) \
Ben Murdoch086aeea2011-05-13 15:57:08 +0100106 V(InstanceOfKnownGlobal) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000107 V(InstructionGap) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100108 V(Integer32ToDouble) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000109 V(InvokeFunction) \
110 V(IsConstructCall) \
111 V(IsConstructCallAndBranch) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100112 V(IsNull) \
113 V(IsNullAndBranch) \
114 V(IsObject) \
115 V(IsObjectAndBranch) \
116 V(IsSmi) \
117 V(IsSmiAndBranch) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000118 V(IsUndetectable) \
119 V(IsUndetectableAndBranch) \
Steve Block9fac8402011-05-12 15:51:54 +0100120 V(JSArrayLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100121 V(Label) \
122 V(LazyBailout) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100123 V(LoadContextSlot) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100124 V(LoadElements) \
Steve Block44f0eee2011-05-26 01:26:41 +0100125 V(LoadExternalArrayPointer) \
Steve Block1e0659c2011-05-24 12:43:12 +0100126 V(LoadFunctionPrototype) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100127 V(LoadGlobalCell) \
128 V(LoadGlobalGeneric) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100129 V(LoadKeyedFastElement) \
130 V(LoadKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100131 V(LoadKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100132 V(LoadNamedField) \
Steve Block44f0eee2011-05-26 01:26:41 +0100133 V(LoadNamedFieldPolymorphic) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100134 V(LoadNamedGeneric) \
135 V(ModI) \
136 V(MulI) \
137 V(NumberTagD) \
138 V(NumberTagI) \
139 V(NumberUntagD) \
140 V(ObjectLiteral) \
141 V(OsrEntry) \
Steve Block1e0659c2011-05-24 12:43:12 +0100142 V(OuterContext) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100143 V(Parameter) \
144 V(Power) \
145 V(PushArgument) \
146 V(RegExpLiteral) \
147 V(Return) \
148 V(ShiftI) \
149 V(SmiTag) \
150 V(SmiUntag) \
151 V(StackCheck) \
Steve Block1e0659c2011-05-24 12:43:12 +0100152 V(StoreContextSlot) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100153 V(StoreGlobalCell) \
154 V(StoreGlobalGeneric) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100155 V(StoreKeyedFastElement) \
156 V(StoreKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100157 V(StoreKeyedSpecializedArrayElement) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100158 V(StoreNamedField) \
159 V(StoreNamedGeneric) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000160 V(StringAdd) \
Steve Block1e0659c2011-05-24 12:43:12 +0100161 V(StringCharCodeAt) \
Steve Block44f0eee2011-05-26 01:26:41 +0100162 V(StringCharFromCode) \
Steve Block1e0659c2011-05-24 12:43:12 +0100163 V(StringLength) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100164 V(SubI) \
165 V(TaggedToI) \
166 V(Throw) \
Steve Block44f0eee2011-05-26 01:26:41 +0100167 V(ToFastProperties) \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100168 V(Typeof) \
169 V(TypeofIs) \
170 V(TypeofIsAndBranch) \
171 V(UnaryMathOperation) \
172 V(UnknownOSRValue) \
173 V(ValueOf)
174
175
Ben Murdoch257744e2011-11-30 15:57:28 +0000176#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
177 virtual Opcode opcode() const { return LInstruction::k##type; } \
178 virtual void CompileToNative(LCodeGen* generator); \
179 virtual const char* Mnemonic() const { return mnemonic; } \
180 static L##type* cast(LInstruction* instr) { \
181 ASSERT(instr->Is##type()); \
182 return reinterpret_cast<L##type*>(instr); \
Ben Murdochb0fe1622011-05-05 13:52:32 +0100183 }
184
185
Ben Murdochb0fe1622011-05-05 13:52:32 +0100186#define DECLARE_HYDROGEN_ACCESSOR(type) \
187 H##type* hydrogen() const { \
188 return H##type::cast(hydrogen_value()); \
189 }
190
191
192class LInstruction: public ZoneObject {
193 public:
194 LInstruction()
Steve Block1e0659c2011-05-24 12:43:12 +0100195 : environment_(NULL),
196 hydrogen_value_(NULL),
197 is_call_(false),
198 is_save_doubles_(false) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100199 virtual ~LInstruction() { }
200
201 virtual void CompileToNative(LCodeGen* generator) = 0;
202 virtual const char* Mnemonic() const = 0;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100203 virtual void PrintTo(StringStream* stream);
204 virtual void PrintDataTo(StringStream* stream) = 0;
205 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100206
Ben Murdoch257744e2011-11-30 15:57:28 +0000207 enum Opcode {
208 // Declare a unique enum value for each instruction.
209#define DECLARE_OPCODE(type) k##type,
210 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
211 kNumberOfInstructions
212#undef DECLARE_OPCODE
213 };
214
215 virtual Opcode opcode() const = 0;
216
217 // Declare non-virtual type testers for all leaf IR classes.
218#define DECLARE_PREDICATE(type) \
219 bool Is##type() const { return opcode() == k##type; }
220 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
221#undef DECLARE_PREDICATE
222
223 // Declare virtual predicates for instructions that don't have
224 // an opcode.
225 virtual bool IsGap() const { return false; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100226
Ben Murdochb0fe1622011-05-05 13:52:32 +0100227 virtual bool IsControl() const { return false; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100228 virtual void SetBranchTargets(int true_block_id, int false_block_id) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100229
Steve Block1e0659c2011-05-24 12:43:12 +0100230 void set_environment(LEnvironment* env) { environment_ = env; }
231 LEnvironment* environment() const { return environment_; }
232 bool HasEnvironment() const { return environment_ != NULL; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100233
234 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
235 LPointerMap* pointer_map() const { return pointer_map_.get(); }
236 bool HasPointerMap() const { return pointer_map_.is_set(); }
237
Ben Murdochb0fe1622011-05-05 13:52:32 +0100238
239 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
240 HValue* hydrogen_value() const { return hydrogen_value_; }
241
242 void set_deoptimization_environment(LEnvironment* env) {
243 deoptimization_environment_.set(env);
244 }
245 LEnvironment* deoptimization_environment() const {
246 return deoptimization_environment_.get();
247 }
248 bool HasDeoptimizationEnvironment() const {
249 return deoptimization_environment_.is_set();
250 }
251
Steve Block1e0659c2011-05-24 12:43:12 +0100252 void MarkAsCall() { is_call_ = true; }
253 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
254
255 // Interface to the register allocator and iterators.
256 bool IsMarkedAsCall() const { return is_call_; }
257 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
258
259 virtual bool HasResult() const = 0;
260 virtual LOperand* result() = 0;
261
262 virtual int InputCount() = 0;
263 virtual LOperand* InputAt(int i) = 0;
264 virtual int TempCount() = 0;
265 virtual LOperand* TempAt(int i) = 0;
266
267 LOperand* FirstInput() { return InputAt(0); }
268 LOperand* Output() { return HasResult() ? result() : NULL; }
269
270#ifdef DEBUG
271 void VerifyCall();
272#endif
273
Ben Murdochb0fe1622011-05-05 13:52:32 +0100274 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100275 LEnvironment* environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100276 SetOncePointer<LPointerMap> pointer_map_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100277 HValue* hydrogen_value_;
278 SetOncePointer<LEnvironment> deoptimization_environment_;
Steve Block1e0659c2011-05-24 12:43:12 +0100279 bool is_call_;
280 bool is_save_doubles_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100281};
282
283
Steve Block1e0659c2011-05-24 12:43:12 +0100284template<typename ElementType, int NumElements>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100285class OperandContainer {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100286 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100287 OperandContainer() {
Steve Block1e0659c2011-05-24 12:43:12 +0100288 for (int i = 0; i < NumElements; i++) elems_[i] = NULL;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100289 }
Steve Block1e0659c2011-05-24 12:43:12 +0100290 int length() { return NumElements; }
291 ElementType& operator[](int i) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100292 ASSERT(i < length());
293 return elems_[i];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100294 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100295 void PrintOperandsTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100296
297 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100298 ElementType elems_[NumElements];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100299};
300
301
Steve Block1e0659c2011-05-24 12:43:12 +0100302template<typename ElementType>
303class OperandContainer<ElementType, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100304 public:
305 int length() { return 0; }
306 void PrintOperandsTo(StringStream* stream) { }
Steve Block1e0659c2011-05-24 12:43:12 +0100307 ElementType& operator[](int i) {
308 UNREACHABLE();
309 static ElementType t = 0;
310 return t;
311 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100312};
313
314
Steve Block1e0659c2011-05-24 12:43:12 +0100315// R = number of result operands (0 or 1).
316// I = number of input operands.
317// T = number of temporary operands.
318template<int R, int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100319class LTemplateInstruction: public LInstruction {
320 public:
321 // Allow 0 or 1 output operands.
322 STATIC_ASSERT(R == 0 || R == 1);
323 virtual bool HasResult() const { return R != 0; }
324 void set_result(LOperand* operand) { results_[0] = operand; }
325 LOperand* result() { return results_[0]; }
326
327 int InputCount() { return I; }
328 LOperand* InputAt(int i) { return inputs_[i]; }
329
330 int TempCount() { return T; }
331 LOperand* TempAt(int i) { return temps_[i]; }
332
333 virtual void PrintDataTo(StringStream* stream);
334 virtual void PrintOutputOperandTo(StringStream* stream);
335
336 protected:
337 OperandContainer<LOperand*, R> results_;
338 OperandContainer<LOperand*, I> inputs_;
339 OperandContainer<LOperand*, T> temps_;
340};
341
342
343class LGap: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100344 public:
Ben Murdoch257744e2011-11-30 15:57:28 +0000345 explicit LGap(HBasicBlock* block) : block_(block) {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100346 parallel_moves_[BEFORE] = NULL;
347 parallel_moves_[START] = NULL;
348 parallel_moves_[END] = NULL;
349 parallel_moves_[AFTER] = NULL;
350 }
351
Ben Murdoch257744e2011-11-30 15:57:28 +0000352 // Can't use the DECLARE-macro here because of sub-classes.
353 virtual bool IsGap() const { return true; }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100354 virtual void PrintDataTo(StringStream* stream);
Ben Murdoch257744e2011-11-30 15:57:28 +0000355 static LGap* cast(LInstruction* instr) {
356 ASSERT(instr->IsGap());
357 return reinterpret_cast<LGap*>(instr);
358 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100359
360 bool IsRedundant() const;
361
362 HBasicBlock* block() const { return block_; }
363
364 enum InnerPosition {
365 BEFORE,
366 START,
367 END,
368 AFTER,
369 FIRST_INNER_POSITION = BEFORE,
370 LAST_INNER_POSITION = AFTER
371 };
372
373 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
374 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
375 return parallel_moves_[pos];
376 }
377
378 LParallelMove* GetParallelMove(InnerPosition pos) {
379 return parallel_moves_[pos];
380 }
381
382 private:
383 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
384 HBasicBlock* block_;
385};
386
387
Ben Murdoch257744e2011-11-30 15:57:28 +0000388class LInstructionGap: public LGap {
389 public:
390 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
391
392 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
393};
394
395
Ben Murdochb8e0da22011-05-16 14:20:40 +0100396class LGoto: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100397 public:
398 LGoto(int block_id, bool include_stack_check = false)
399 : block_id_(block_id), include_stack_check_(include_stack_check) { }
400
401 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100402 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100403 virtual bool IsControl() const { return true; }
404
405 int block_id() const { return block_id_; }
406 bool include_stack_check() const { return include_stack_check_; }
407
408 private:
409 int block_id_;
410 bool include_stack_check_;
411};
412
413
Ben Murdochb8e0da22011-05-16 14:20:40 +0100414class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100415 public:
416 LLazyBailout() : gap_instructions_size_(0) { }
417
418 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
419
420 void set_gap_instructions_size(int gap_instructions_size) {
421 gap_instructions_size_ = gap_instructions_size;
422 }
423 int gap_instructions_size() { return gap_instructions_size_; }
424
425 private:
426 int gap_instructions_size_;
427};
428
429
Ben Murdochb8e0da22011-05-16 14:20:40 +0100430class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100431 public:
432 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
433};
434
435
436class LLabel: public LGap {
437 public:
438 explicit LLabel(HBasicBlock* block)
439 : LGap(block), replacement_(NULL) { }
440
441 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
442
Ben Murdochb8e0da22011-05-16 14:20:40 +0100443 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100444
445 int block_id() const { return block()->block_id(); }
446 bool is_loop_header() const { return block()->IsLoopHeader(); }
447 Label* label() { return &label_; }
448 LLabel* replacement() const { return replacement_; }
449 void set_replacement(LLabel* label) { replacement_ = label; }
450 bool HasReplacement() const { return replacement_ != NULL; }
451
452 private:
453 Label label_;
454 LLabel* replacement_;
455};
456
457
Ben Murdochb8e0da22011-05-16 14:20:40 +0100458class LParameter: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100459 public:
460 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
461};
462
463
Steve Block1e0659c2011-05-24 12:43:12 +0100464class LCallStub: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100465 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100466 explicit LCallStub(LOperand* context) {
467 inputs_[0] = context;
468 }
469
Ben Murdochb0fe1622011-05-05 13:52:32 +0100470 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
471 DECLARE_HYDROGEN_ACCESSOR(CallStub)
472
Steve Block1e0659c2011-05-24 12:43:12 +0100473 LOperand* context() { return inputs_[0]; }
474
Ben Murdochb0fe1622011-05-05 13:52:32 +0100475 TranscendentalCache::Type transcendental_type() {
476 return hydrogen()->transcendental_type();
477 }
478};
479
480
Ben Murdochb8e0da22011-05-16 14:20:40 +0100481class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100482 public:
483 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
484};
485
486
Steve Block1e0659c2011-05-24 12:43:12 +0100487template<int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100488class LControlInstruction: public LTemplateInstruction<0, I, T> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100489 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100490 virtual bool IsControl() const { return true; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100491
Ben Murdochb8e0da22011-05-16 14:20:40 +0100492 int true_block_id() const { return true_block_id_; }
493 int false_block_id() const { return false_block_id_; }
494 void SetBranchTargets(int true_block_id, int false_block_id) {
495 true_block_id_ = true_block_id;
496 false_block_id_ = false_block_id;
497 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100498
499 private:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100500 int true_block_id_;
501 int false_block_id_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100502};
503
504
Steve Block1e0659c2011-05-24 12:43:12 +0100505class LApplyArguments: public LTemplateInstruction<1, 4, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100506 public:
507 LApplyArguments(LOperand* function,
508 LOperand* receiver,
509 LOperand* length,
Steve Block1e0659c2011-05-24 12:43:12 +0100510 LOperand* elements,
511 LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100512 inputs_[0] = function;
513 inputs_[1] = receiver;
514 inputs_[2] = length;
515 inputs_[3] = elements;
Steve Block1e0659c2011-05-24 12:43:12 +0100516 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100517 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100518
519 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
520
Ben Murdochb8e0da22011-05-16 14:20:40 +0100521 LOperand* function() { return inputs_[0]; }
522 LOperand* receiver() { return inputs_[1]; }
523 LOperand* length() { return inputs_[2]; }
524 LOperand* elements() { return inputs_[3]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100525};
526
527
Ben Murdochb8e0da22011-05-16 14:20:40 +0100528class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100529 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100530 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
531 inputs_[0] = arguments;
532 inputs_[1] = length;
533 inputs_[2] = index;
534 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100535
536 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
537
Ben Murdochb8e0da22011-05-16 14:20:40 +0100538 LOperand* arguments() { return inputs_[0]; }
539 LOperand* length() { return inputs_[1]; }
540 LOperand* index() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100541
Ben Murdochb8e0da22011-05-16 14:20:40 +0100542 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100543};
544
545
Steve Block1e0659c2011-05-24 12:43:12 +0100546class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100547 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100548 explicit LArgumentsLength(LOperand* elements) {
549 inputs_[0] = elements;
550 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100551
552 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
553};
554
555
Ben Murdochb8e0da22011-05-16 14:20:40 +0100556class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100557 public:
558 LArgumentsElements() { }
559
560 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
561};
562
563
Ben Murdochb8e0da22011-05-16 14:20:40 +0100564class LModI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100565 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100566 LModI(LOperand* left, LOperand* right, LOperand* temp) {
567 inputs_[0] = left;
568 inputs_[1] = right;
569 temps_[0] = temp;
570 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100571
572 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
573 DECLARE_HYDROGEN_ACCESSOR(Mod)
574};
575
576
Ben Murdochb8e0da22011-05-16 14:20:40 +0100577class LDivI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100578 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100579 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
580 inputs_[0] = left;
581 inputs_[1] = right;
582 temps_[0] = temp;
583 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100584
585 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
586 DECLARE_HYDROGEN_ACCESSOR(Div)
587};
588
589
Ben Murdochb8e0da22011-05-16 14:20:40 +0100590class LMulI: public LTemplateInstruction<1, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100591 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100592 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
593 inputs_[0] = left;
594 inputs_[1] = right;
595 temps_[0] = temp;
596 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100597
598 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
599 DECLARE_HYDROGEN_ACCESSOR(Mul)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100600};
601
602
Steve Block1e0659c2011-05-24 12:43:12 +0100603class LCmpID: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100604 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100605 LCmpID(LOperand* left, LOperand* right) {
606 inputs_[0] = left;
607 inputs_[1] = right;
608 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100609
610 DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100611 DECLARE_HYDROGEN_ACCESSOR(Compare)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100612
Ben Murdochb8e0da22011-05-16 14:20:40 +0100613 Token::Value op() const { return hydrogen()->token(); }
614 bool is_double() const {
615 return hydrogen()->GetInputRepresentation().IsDouble();
616 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100617};
618
619
Steve Block1e0659c2011-05-24 12:43:12 +0100620class LCmpIDAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100621 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100622 LCmpIDAndBranch(LOperand* left, LOperand* right) {
623 inputs_[0] = left;
624 inputs_[1] = right;
625 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100626
627 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100628 DECLARE_HYDROGEN_ACCESSOR(Compare)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100629
Ben Murdochb8e0da22011-05-16 14:20:40 +0100630 Token::Value op() const { return hydrogen()->token(); }
631 bool is_double() const {
632 return hydrogen()->GetInputRepresentation().IsDouble();
633 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100634
Ben Murdochb8e0da22011-05-16 14:20:40 +0100635 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100636};
637
638
Steve Block1e0659c2011-05-24 12:43:12 +0100639class LUnaryMathOperation: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100640 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100641 explicit LUnaryMathOperation(LOperand* value) {
642 inputs_[0] = value;
643 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100644
645 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
646 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
647
Ben Murdochb8e0da22011-05-16 14:20:40 +0100648 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100649 BuiltinFunctionId op() const { return hydrogen()->op(); }
650};
651
652
Steve Block1e0659c2011-05-24 12:43:12 +0100653class LCmpJSObjectEq: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100654 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100655 LCmpJSObjectEq(LOperand* left, LOperand* right) {
656 inputs_[0] = left;
657 inputs_[1] = right;
658 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100659
660 DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEq, "cmp-jsobject-eq")
661};
662
663
Steve Block1e0659c2011-05-24 12:43:12 +0100664class LCmpJSObjectEqAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100665 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100666 LCmpJSObjectEqAndBranch(LOperand* left, LOperand* right) {
667 inputs_[0] = left;
668 inputs_[1] = right;
669 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100670
671 DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEqAndBranch,
672 "cmp-jsobject-eq-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100673};
674
675
Ben Murdoch257744e2011-11-30 15:57:28 +0000676class LCmpSymbolEq: public LTemplateInstruction<1, 2, 0> {
677 public:
678 LCmpSymbolEq(LOperand* left, LOperand* right) {
679 inputs_[0] = left;
680 inputs_[1] = right;
681 }
682
683 DECLARE_CONCRETE_INSTRUCTION(CmpSymbolEq, "cmp-symbol-eq")
684};
685
686
687class LCmpSymbolEqAndBranch: public LControlInstruction<2, 0> {
688 public:
689 LCmpSymbolEqAndBranch(LOperand* left, LOperand* right) {
690 inputs_[0] = left;
691 inputs_[1] = right;
692 }
693
694 DECLARE_CONCRETE_INSTRUCTION(CmpSymbolEqAndBranch, "cmp-symbol-eq-and-branch")
695};
696
697
Steve Block1e0659c2011-05-24 12:43:12 +0100698class LIsNull: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100699 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100700 explicit LIsNull(LOperand* value) {
701 inputs_[0] = value;
702 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100703
704 DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100705 DECLARE_HYDROGEN_ACCESSOR(IsNull)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100706
Ben Murdochb8e0da22011-05-16 14:20:40 +0100707 bool is_strict() const { return hydrogen()->is_strict(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100708};
709
710
Ben Murdochb8e0da22011-05-16 14:20:40 +0100711class LIsNullAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100712 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100713 LIsNullAndBranch(LOperand* value, LOperand* temp) {
714 inputs_[0] = value;
715 temps_[0] = temp;
716 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100717
718 DECLARE_CONCRETE_INSTRUCTION(IsNullAndBranch, "is-null-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100719 DECLARE_HYDROGEN_ACCESSOR(IsNull)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100720
Ben Murdochb8e0da22011-05-16 14:20:40 +0100721 bool is_strict() const { return hydrogen()->is_strict(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100722
Ben Murdochb8e0da22011-05-16 14:20:40 +0100723 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100724};
725
726
Ben Murdochb8e0da22011-05-16 14:20:40 +0100727class LIsObject: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100728 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100729 LIsObject(LOperand* value, LOperand* temp) {
730 inputs_[0] = value;
731 temps_[0] = temp;
732 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100733
734 DECLARE_CONCRETE_INSTRUCTION(IsObject, "is-object")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100735};
736
737
Ben Murdochb8e0da22011-05-16 14:20:40 +0100738class LIsObjectAndBranch: public LControlInstruction<1, 2> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100739 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100740 LIsObjectAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
741 inputs_[0] = value;
742 temps_[0] = temp;
743 temps_[1] = temp2;
744 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100745
746 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100747
Ben Murdochb8e0da22011-05-16 14:20:40 +0100748 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100749};
750
751
Steve Block1e0659c2011-05-24 12:43:12 +0100752class LIsSmi: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100753 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100754 explicit LIsSmi(LOperand* value) {
755 inputs_[0] = value;
756 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100757
758 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is-smi")
759 DECLARE_HYDROGEN_ACCESSOR(IsSmi)
760};
761
762
Steve Block1e0659c2011-05-24 12:43:12 +0100763class LIsSmiAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100764 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100765 explicit LIsSmiAndBranch(LOperand* value) {
766 inputs_[0] = value;
767 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100768
769 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
Ben Murdochb0fe1622011-05-05 13:52:32 +0100770
Ben Murdochb8e0da22011-05-16 14:20:40 +0100771 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100772};
773
774
Ben Murdoch257744e2011-11-30 15:57:28 +0000775class LIsUndetectable: public LTemplateInstruction<1, 1, 0> {
776 public:
777 explicit LIsUndetectable(LOperand* value) {
778 inputs_[0] = value;
779 }
780
781 DECLARE_CONCRETE_INSTRUCTION(IsUndetectable, "is-undetectable")
782 DECLARE_HYDROGEN_ACCESSOR(IsUndetectable)
783};
784
785
786class LIsUndetectableAndBranch: public LControlInstruction<1, 1> {
787 public:
788 explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
789 inputs_[0] = value;
790 temps_[0] = temp;
791 }
792
793 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
794 "is-undetectable-and-branch")
795
796 virtual void PrintDataTo(StringStream* stream);
797};
798
799
Steve Block1e0659c2011-05-24 12:43:12 +0100800class LHasInstanceType: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100801 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100802 explicit LHasInstanceType(LOperand* value) {
803 inputs_[0] = value;
804 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100805
806 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has-instance-type")
807 DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100808};
809
810
Ben Murdochb8e0da22011-05-16 14:20:40 +0100811class LHasInstanceTypeAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100812 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100813 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
814 inputs_[0] = value;
815 temps_[0] = temp;
816 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100817
818 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
819 "has-instance-type-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100820 DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100821
Ben Murdochb8e0da22011-05-16 14:20:40 +0100822 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100823};
824
825
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100826class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
827 public:
828 explicit LGetCachedArrayIndex(LOperand* value) {
829 inputs_[0] = value;
830 }
831
832 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
833 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
834};
835
836
Steve Block1e0659c2011-05-24 12:43:12 +0100837class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100838 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100839 explicit LHasCachedArrayIndex(LOperand* value) {
840 inputs_[0] = value;
841 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100842
843 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has-cached-array-index")
844 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndex)
845};
846
847
Steve Block1e0659c2011-05-24 12:43:12 +0100848class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100849 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100850 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
851 inputs_[0] = value;
852 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100853
854 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
855 "has-cached-array-index-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100856 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100857};
858
859
Steve Block1e0659c2011-05-24 12:43:12 +0100860class LIsConstructCall: public LTemplateInstruction<1, 0, 0> {
861 public:
862 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is-construct-call")
863 DECLARE_HYDROGEN_ACCESSOR(IsConstructCall)
864};
865
866
867class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
868 public:
869 explicit LIsConstructCallAndBranch(LOperand* temp) {
870 temps_[0] = temp;
871 }
872
873 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
874 "is-construct-call-and-branch")
875};
876
877
Ben Murdochb8e0da22011-05-16 14:20:40 +0100878class LClassOfTest: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100879 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100880 LClassOfTest(LOperand* value, LOperand* temp) {
881 inputs_[0] = value;
882 temps_[0] = temp;
883 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100884
885 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class-of-test")
886 DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
887
Ben Murdochb8e0da22011-05-16 14:20:40 +0100888 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100889};
890
891
Ben Murdochb8e0da22011-05-16 14:20:40 +0100892class LClassOfTestAndBranch: public LControlInstruction<1, 2> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100893 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100894 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
895 inputs_[0] = value;
896 temps_[0] = temp;
897 temps_[1] = temp2;
898 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100899
900 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
901 "class-of-test-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100902 DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100903
Ben Murdochb8e0da22011-05-16 14:20:40 +0100904 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +0100905};
906
907
Steve Block1e0659c2011-05-24 12:43:12 +0100908class LCmpT: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100909 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100910 LCmpT(LOperand* left, LOperand* right) {
911 inputs_[0] = left;
912 inputs_[1] = right;
913 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100914
915 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
916 DECLARE_HYDROGEN_ACCESSOR(Compare)
917
918 Token::Value op() const { return hydrogen()->token(); }
919};
920
921
Steve Block1e0659c2011-05-24 12:43:12 +0100922class LCmpTAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100923 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100924 LCmpTAndBranch(LOperand* left, LOperand* right) {
925 inputs_[0] = left;
926 inputs_[1] = right;
927 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100928
929 DECLARE_CONCRETE_INSTRUCTION(CmpTAndBranch, "cmp-t-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +0100930 DECLARE_HYDROGEN_ACCESSOR(Compare)
Ben Murdochb0fe1622011-05-05 13:52:32 +0100931
Ben Murdochb8e0da22011-05-16 14:20:40 +0100932 Token::Value op() const { return hydrogen()->token(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100933};
934
935
Steve Block1e0659c2011-05-24 12:43:12 +0100936class LInstanceOf: public LTemplateInstruction<1, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100937 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100938 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
939 inputs_[0] = context;
940 inputs_[1] = left;
941 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100942 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100943
944 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
Steve Block1e0659c2011-05-24 12:43:12 +0100945
946 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100947};
948
949
Steve Block1e0659c2011-05-24 12:43:12 +0100950class LInstanceOfAndBranch: public LControlInstruction<3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100951 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100952 LInstanceOfAndBranch(LOperand* context, LOperand* left, LOperand* right) {
953 inputs_[0] = context;
954 inputs_[1] = left;
955 inputs_[2] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100956 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100957
958 DECLARE_CONCRETE_INSTRUCTION(InstanceOfAndBranch, "instance-of-and-branch")
Steve Block1e0659c2011-05-24 12:43:12 +0100959
960 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100961};
962
963
Ben Murdochb8e0da22011-05-16 14:20:40 +0100964class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
Ben Murdoch086aeea2011-05-13 15:57:08 +0100965 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100966 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
967 inputs_[0] = value;
968 temps_[0] = temp;
969 }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100970
971 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
972 "instance-of-known-global")
973 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
974
975 Handle<JSFunction> function() const { return hydrogen()->function(); }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100976};
977
978
Ben Murdochb8e0da22011-05-16 14:20:40 +0100979class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100980 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100981 LBoundsCheck(LOperand* index, LOperand* length) {
982 inputs_[0] = index;
983 inputs_[1] = length;
984 }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100985
Ben Murdochb8e0da22011-05-16 14:20:40 +0100986 LOperand* index() { return inputs_[0]; }
987 LOperand* length() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100988
989 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
990};
991
992
Steve Block1e0659c2011-05-24 12:43:12 +0100993class LBitI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100994 public:
995 LBitI(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100996 : op_(op) {
997 inputs_[0] = left;
998 inputs_[1] = right;
999 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001000
1001 Token::Value op() const { return op_; }
1002
1003 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1004
1005 private:
1006 Token::Value op_;
1007};
1008
1009
Steve Block1e0659c2011-05-24 12:43:12 +01001010class LShiftI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001011 public:
1012 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001013 : op_(op), can_deopt_(can_deopt) {
1014 inputs_[0] = left;
1015 inputs_[1] = right;
1016 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001017
1018 Token::Value op() const { return op_; }
1019
1020 bool can_deopt() const { return can_deopt_; }
1021
1022 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1023
1024 private:
1025 Token::Value op_;
1026 bool can_deopt_;
1027};
1028
1029
Steve Block1e0659c2011-05-24 12:43:12 +01001030class LSubI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001031 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001032 LSubI(LOperand* left, LOperand* right) {
1033 inputs_[0] = left;
1034 inputs_[1] = right;
1035 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001036
1037 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1038 DECLARE_HYDROGEN_ACCESSOR(Sub)
1039};
1040
1041
Steve Block1e0659c2011-05-24 12:43:12 +01001042class LConstantI: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001043 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +01001044 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
Steve Block1e0659c2011-05-24 12:43:12 +01001045 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001046
Steve Block1e0659c2011-05-24 12:43:12 +01001047 int32_t value() const { return hydrogen()->Integer32Value(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001048};
1049
1050
Steve Block1e0659c2011-05-24 12:43:12 +01001051class LConstantD: public LTemplateInstruction<1, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001052 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001053 explicit LConstantD(LOperand* temp) {
1054 temps_[0] = temp;
1055 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001056
1057 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
Steve Block1e0659c2011-05-24 12:43:12 +01001058 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001059
Steve Block1e0659c2011-05-24 12:43:12 +01001060 double value() const { return hydrogen()->DoubleValue(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001061};
1062
1063
Steve Block1e0659c2011-05-24 12:43:12 +01001064class LConstantT: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001065 public:
Ben Murdochb0fe1622011-05-05 13:52:32 +01001066 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
Steve Block1e0659c2011-05-24 12:43:12 +01001067 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001068
Steve Block1e0659c2011-05-24 12:43:12 +01001069 Handle<Object> value() const { return hydrogen()->handle(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001070};
1071
1072
Steve Block1e0659c2011-05-24 12:43:12 +01001073class LBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001074 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001075 explicit LBranch(LOperand* value) {
1076 inputs_[0] = value;
1077 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001078
1079 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1080 DECLARE_HYDROGEN_ACCESSOR(Value)
1081
Ben Murdochb8e0da22011-05-16 14:20:40 +01001082 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001083};
1084
1085
Steve Block1e0659c2011-05-24 12:43:12 +01001086class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001087 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001088 explicit LCmpMapAndBranch(LOperand* value) {
1089 inputs_[0] = value;
1090 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001091
1092 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
Steve Block1e0659c2011-05-24 12:43:12 +01001093 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001094
1095 virtual bool IsControl() const { return true; }
1096
Ben Murdoch086aeea2011-05-13 15:57:08 +01001097 Handle<Map> map() const { return hydrogen()->map(); }
1098 int true_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +01001099 return hydrogen()->FirstSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +01001100 }
1101 int false_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +01001102 return hydrogen()->SecondSuccessor()->block_id();
Ben Murdoch086aeea2011-05-13 15:57:08 +01001103 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001104};
1105
1106
Steve Block1e0659c2011-05-24 12:43:12 +01001107class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001108 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001109 explicit LJSArrayLength(LOperand* value) {
1110 inputs_[0] = value;
1111 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001112
Steve Block9fac8402011-05-12 15:51:54 +01001113 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
1114 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
1115};
Ben Murdochb0fe1622011-05-05 13:52:32 +01001116
Ben Murdochb0fe1622011-05-05 13:52:32 +01001117
Steve Block44f0eee2011-05-26 01:26:41 +01001118class LExternalArrayLength: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001119 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001120 explicit LExternalArrayLength(LOperand* value) {
Steve Block1e0659c2011-05-24 12:43:12 +01001121 inputs_[0] = value;
1122 }
1123
Steve Block44f0eee2011-05-26 01:26:41 +01001124 DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength, "external-array-length")
1125 DECLARE_HYDROGEN_ACCESSOR(ExternalArrayLength)
Steve Block1e0659c2011-05-24 12:43:12 +01001126};
1127
1128
1129class LFixedArrayLength: public LTemplateInstruction<1, 1, 0> {
Steve Block9fac8402011-05-12 15:51:54 +01001130 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001131 explicit LFixedArrayLength(LOperand* value) {
1132 inputs_[0] = value;
1133 }
Steve Block9fac8402011-05-12 15:51:54 +01001134
1135 DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength, "fixed-array-length")
1136 DECLARE_HYDROGEN_ACCESSOR(FixedArrayLength)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001137};
1138
1139
Ben Murdochb8e0da22011-05-16 14:20:40 +01001140class LValueOf: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001141 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001142 LValueOf(LOperand* value, LOperand* temp) {
1143 inputs_[0] = value;
1144 temps_[0] = temp;
1145 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001146
1147 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1148 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001149};
1150
1151
Steve Block1e0659c2011-05-24 12:43:12 +01001152class LThrow: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001153 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001154 explicit LThrow(LOperand* value) {
1155 inputs_[0] = value;
1156 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001157
1158 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1159};
1160
1161
Steve Block1e0659c2011-05-24 12:43:12 +01001162class LBitNotI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001163 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001164 explicit LBitNotI(LOperand* value) {
1165 inputs_[0] = value;
1166 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001167
1168 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1169};
1170
1171
Steve Block1e0659c2011-05-24 12:43:12 +01001172class LAddI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001173 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001174 LAddI(LOperand* left, LOperand* right) {
1175 inputs_[0] = left;
1176 inputs_[1] = right;
1177 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001178
1179 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1180 DECLARE_HYDROGEN_ACCESSOR(Add)
1181};
1182
1183
Steve Block1e0659c2011-05-24 12:43:12 +01001184class LPower: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001185 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001186 LPower(LOperand* left, LOperand* right) {
1187 inputs_[0] = left;
1188 inputs_[1] = right;
1189 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001190
1191 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1192 DECLARE_HYDROGEN_ACCESSOR(Power)
1193};
1194
1195
Steve Block1e0659c2011-05-24 12:43:12 +01001196class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001197 public:
1198 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001199 : op_(op) {
1200 inputs_[0] = left;
1201 inputs_[1] = right;
1202 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001203
1204 Token::Value op() const { return op_; }
1205
Ben Murdoch257744e2011-11-30 15:57:28 +00001206 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001207 virtual void CompileToNative(LCodeGen* generator);
1208 virtual const char* Mnemonic() const;
1209
1210 private:
1211 Token::Value op_;
1212};
1213
1214
Steve Block1e0659c2011-05-24 12:43:12 +01001215class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001216 public:
1217 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001218 : op_(op) {
1219 inputs_[0] = left;
1220 inputs_[1] = right;
1221 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001222
Ben Murdoch257744e2011-11-30 15:57:28 +00001223 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001224 virtual void CompileToNative(LCodeGen* generator);
1225 virtual const char* Mnemonic() const;
1226
1227 Token::Value op() const { return op_; }
1228
1229 private:
1230 Token::Value op_;
1231};
1232
1233
Steve Block1e0659c2011-05-24 12:43:12 +01001234class LReturn: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001235 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001236 explicit LReturn(LOperand* value) {
1237 inputs_[0] = value;
1238 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001239
1240 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1241};
1242
1243
Steve Block1e0659c2011-05-24 12:43:12 +01001244class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001245 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001246 explicit LLoadNamedField(LOperand* object) {
1247 inputs_[0] = object;
1248 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001249
1250 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1251 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
Steve Block44f0eee2011-05-26 01:26:41 +01001252
1253 LOperand* object() { return inputs_[0]; }
1254};
1255
1256
1257class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1258 public:
1259 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1260 inputs_[0] = object;
1261 }
1262
1263 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1264 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1265
1266 LOperand* object() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001267};
1268
1269
Steve Block1e0659c2011-05-24 12:43:12 +01001270class LLoadNamedGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001271 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001272 LLoadNamedGeneric(LOperand* context, LOperand* object) {
1273 inputs_[0] = context;
1274 inputs_[1] = object;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001275 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001276
1277 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1278 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1279
Steve Block1e0659c2011-05-24 12:43:12 +01001280 LOperand* context() { return inputs_[0]; }
1281 LOperand* object() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001282 Handle<Object> name() const { return hydrogen()->name(); }
1283};
1284
1285
Ben Murdochb8e0da22011-05-16 14:20:40 +01001286class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 1> {
Steve Block9fac8402011-05-12 15:51:54 +01001287 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001288 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1289 inputs_[0] = function;
1290 temps_[0] = temp;
1291 }
Steve Block9fac8402011-05-12 15:51:54 +01001292
1293 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1294 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1295
Ben Murdochb8e0da22011-05-16 14:20:40 +01001296 LOperand* function() { return inputs_[0]; }
Steve Block9fac8402011-05-12 15:51:54 +01001297};
1298
1299
Steve Block1e0659c2011-05-24 12:43:12 +01001300class LLoadElements: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001301 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001302 explicit LLoadElements(LOperand* object) {
1303 inputs_[0] = object;
1304 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001305
1306 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1307};
1308
1309
Steve Block44f0eee2011-05-26 01:26:41 +01001310class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001311 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001312 explicit LLoadExternalArrayPointer(LOperand* object) {
Steve Block1e0659c2011-05-24 12:43:12 +01001313 inputs_[0] = object;
1314 }
1315
Steve Block44f0eee2011-05-26 01:26:41 +01001316 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1317 "load-external-array-pointer")
Steve Block1e0659c2011-05-24 12:43:12 +01001318};
1319
1320
1321class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001322 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001323 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1324 inputs_[0] = elements;
1325 inputs_[1] = key;
1326 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001327
1328 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1329 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1330
Ben Murdochb8e0da22011-05-16 14:20:40 +01001331 LOperand* elements() { return inputs_[0]; }
1332 LOperand* key() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001333};
1334
1335
Steve Block44f0eee2011-05-26 01:26:41 +01001336class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001337 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001338 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1339 LOperand* key) {
Steve Block1e0659c2011-05-24 12:43:12 +01001340 inputs_[0] = external_pointer;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001341 inputs_[1] = key;
1342 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001343
Steve Block44f0eee2011-05-26 01:26:41 +01001344 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1345 "load-keyed-specialized-array-element")
1346 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
Steve Block1e0659c2011-05-24 12:43:12 +01001347
1348 LOperand* external_pointer() { return inputs_[0]; }
1349 LOperand* key() { return inputs_[1]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001350 ExternalArrayType array_type() const {
1351 return hydrogen()->array_type();
1352 }
Steve Block1e0659c2011-05-24 12:43:12 +01001353};
1354
1355
1356class LLoadKeyedGeneric: public LTemplateInstruction<1, 3, 0> {
1357 public:
1358 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key) {
1359 inputs_[0] = context;
1360 inputs_[1] = obj;
1361 inputs_[2] = key;
1362 }
1363
Ben Murdochb0fe1622011-05-05 13:52:32 +01001364 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1365
Steve Block1e0659c2011-05-24 12:43:12 +01001366 LOperand* context() { return inputs_[0]; }
1367 LOperand* object() { return inputs_[1]; }
1368 LOperand* key() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001369};
1370
1371
Ben Murdoch8b112d22011-06-08 16:22:53 +01001372class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001373 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001374 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1375 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001376};
1377
1378
Ben Murdoch8b112d22011-06-08 16:22:53 +01001379class LLoadGlobalGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001380 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001381 LLoadGlobalGeneric(LOperand* context, LOperand* global_object) {
1382 inputs_[0] = context;
1383 inputs_[1] = global_object;
1384 }
1385
1386 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1387 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1388
1389 LOperand* context() { return inputs_[0]; }
1390 LOperand* global_object() { return inputs_[1]; }
1391 Handle<Object> name() const { return hydrogen()->name(); }
1392 bool for_typeof() const { return hydrogen()->for_typeof(); }
1393};
1394
1395
1396class LStoreGlobalCell: public LTemplateInstruction<0, 1, 0> {
1397 public:
1398 explicit LStoreGlobalCell(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001399 inputs_[0] = value;
1400 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001401
Ben Murdoch8b112d22011-06-08 16:22:53 +01001402 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1403 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1404};
1405
1406
1407class LStoreGlobalGeneric: public LTemplateInstruction<0, 3, 0> {
1408 public:
1409 explicit LStoreGlobalGeneric(LOperand* context,
1410 LOperand* global_object,
1411 LOperand* value) {
1412 inputs_[0] = context;
1413 inputs_[1] = global_object;
1414 inputs_[2] = value;
1415 }
1416
1417 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1418 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1419
1420 LOperand* context() { return InputAt(0); }
1421 LOperand* global_object() { return InputAt(1); }
1422 Handle<Object> name() const { return hydrogen()->name(); }
1423 LOperand* value() { return InputAt(2); }
1424 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001425};
1426
1427
Steve Block1e0659c2011-05-24 12:43:12 +01001428class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001429 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001430 explicit LLoadContextSlot(LOperand* context) {
1431 inputs_[0] = context;
1432 }
1433
Ben Murdochb8e0da22011-05-16 14:20:40 +01001434 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1435 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1436
Steve Block1e0659c2011-05-24 12:43:12 +01001437 LOperand* context() { return InputAt(0); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001438 int slot_index() { return hydrogen()->slot_index(); }
1439
1440 virtual void PrintDataTo(StringStream* stream);
1441};
1442
1443
Steve Block1e0659c2011-05-24 12:43:12 +01001444class LStoreContextSlot: public LTemplateInstruction<0, 2, 1> {
1445 public:
1446 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1447 inputs_[0] = context;
1448 inputs_[1] = value;
1449 temps_[0] = temp;
1450 }
1451
1452 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1453 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1454
1455 LOperand* context() { return InputAt(0); }
1456 LOperand* value() { return InputAt(1); }
1457 int slot_index() { return hydrogen()->slot_index(); }
1458 int needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1459
1460 virtual void PrintDataTo(StringStream* stream);
1461};
1462
1463
1464class LPushArgument: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001465 public:
1466 explicit LPushArgument(LOperand* value) {
1467 inputs_[0] = value;
1468 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001469
1470 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1471};
1472
1473
Steve Block1e0659c2011-05-24 12:43:12 +01001474class LContext: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001475 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001476 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001477};
1478
1479
Steve Block1e0659c2011-05-24 12:43:12 +01001480class LOuterContext: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001481 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001482 explicit LOuterContext(LOperand* context) {
1483 inputs_[0] = context;
1484 }
1485
1486 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1487
1488 LOperand* context() { return InputAt(0); }
1489};
1490
1491
1492class LGlobalObject: public LTemplateInstruction<1, 1, 0> {
1493 public:
1494 explicit LGlobalObject(LOperand* context) {
1495 inputs_[0] = context;
1496 }
1497
1498 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1499
1500 LOperand* context() { return InputAt(0); }
1501};
1502
1503
1504class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
1505 public:
1506 explicit LGlobalReceiver(LOperand* global_object) {
1507 inputs_[0] = global_object;
1508 }
1509
Ben Murdochb0fe1622011-05-05 13:52:32 +01001510 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
Steve Block1e0659c2011-05-24 12:43:12 +01001511
1512 LOperand* global() { return InputAt(0); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001513};
1514
1515
Ben Murdochb8e0da22011-05-16 14:20:40 +01001516class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001517 public:
1518 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1519 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1520
Ben Murdochb8e0da22011-05-16 14:20:40 +01001521 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001522
Ben Murdochb8e0da22011-05-16 14:20:40 +01001523 Handle<JSFunction> function() { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001524 int arity() const { return hydrogen()->argument_count() - 1; }
1525};
1526
1527
Ben Murdoch257744e2011-11-30 15:57:28 +00001528class LInvokeFunction: public LTemplateInstruction<1, 2, 0> {
1529 public:
1530 LInvokeFunction(LOperand* context, LOperand* function) {
1531 inputs_[0] = context;
1532 inputs_[1] = function;
1533 }
1534
1535 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1536 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1537
1538 LOperand* context() { return inputs_[0]; }
1539 LOperand* function() { return inputs_[1]; }
1540
1541 virtual void PrintDataTo(StringStream* stream);
1542
1543 int arity() const { return hydrogen()->argument_count() - 1; }
1544};
1545
1546
Steve Block1e0659c2011-05-24 12:43:12 +01001547class LCallKeyed: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001548 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001549 LCallKeyed(LOperand* context, LOperand* key) {
1550 inputs_[0] = context;
1551 inputs_[1] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001552 }
1553
Ben Murdochb0fe1622011-05-05 13:52:32 +01001554 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1555 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1556
Steve Block1e0659c2011-05-24 12:43:12 +01001557 LOperand* context() { return inputs_[0]; }
1558 LOperand* key() { return inputs_[1]; }
1559
Ben Murdochb8e0da22011-05-16 14:20:40 +01001560 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001561
1562 int arity() const { return hydrogen()->argument_count() - 1; }
1563};
1564
1565
Steve Block1e0659c2011-05-24 12:43:12 +01001566class LCallNamed: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001567 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001568 explicit LCallNamed(LOperand* context) {
1569 inputs_[0] = context;
1570 }
1571
Ben Murdochb0fe1622011-05-05 13:52:32 +01001572 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1573 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1574
Ben Murdochb8e0da22011-05-16 14:20:40 +01001575 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001576
Steve Block1e0659c2011-05-24 12:43:12 +01001577 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001578 Handle<String> name() const { return hydrogen()->name(); }
1579 int arity() const { return hydrogen()->argument_count() - 1; }
1580};
1581
1582
Steve Block1e0659c2011-05-24 12:43:12 +01001583class LCallFunction: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001584 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001585 explicit LCallFunction(LOperand* context) {
1586 inputs_[0] = context;
1587 }
1588
Ben Murdochb0fe1622011-05-05 13:52:32 +01001589 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1590 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1591
Steve Block1e0659c2011-05-24 12:43:12 +01001592 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001593 int arity() const { return hydrogen()->argument_count() - 2; }
1594};
1595
1596
Steve Block1e0659c2011-05-24 12:43:12 +01001597class LCallGlobal: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001598 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001599 explicit LCallGlobal(LOperand* context) {
1600 inputs_[0] = context;
1601 }
1602
Ben Murdochb0fe1622011-05-05 13:52:32 +01001603 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1604 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1605
Ben Murdochb8e0da22011-05-16 14:20:40 +01001606 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001607
Steve Block1e0659c2011-05-24 12:43:12 +01001608 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001609 Handle<String> name() const {return hydrogen()->name(); }
1610 int arity() const { return hydrogen()->argument_count() - 1; }
1611};
1612
1613
Ben Murdochb8e0da22011-05-16 14:20:40 +01001614class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001615 public:
1616 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1617 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1618
Ben Murdochb8e0da22011-05-16 14:20:40 +01001619 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001620
1621 Handle<JSFunction> target() const { return hydrogen()->target(); }
1622 int arity() const { return hydrogen()->argument_count() - 1; }
1623};
1624
1625
Steve Block1e0659c2011-05-24 12:43:12 +01001626class LCallNew: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001627 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001628 LCallNew(LOperand* context, LOperand* constructor) {
1629 inputs_[0] = context;
1630 inputs_[1] = constructor;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001631 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001632
1633 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1634 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1635
Ben Murdochb8e0da22011-05-16 14:20:40 +01001636 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001637
Steve Block1e0659c2011-05-24 12:43:12 +01001638 LOperand* context() { return inputs_[0]; }
1639 LOperand* constructor() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001640 int arity() const { return hydrogen()->argument_count() - 1; }
1641};
1642
1643
Ben Murdochb8e0da22011-05-16 14:20:40 +01001644class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001645 public:
1646 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1647 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1648
Steve Block44f0eee2011-05-26 01:26:41 +01001649 const Runtime::Function* function() const { return hydrogen()->function(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001650 int arity() const { return hydrogen()->argument_count(); }
1651};
1652
1653
Steve Block1e0659c2011-05-24 12:43:12 +01001654class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001655 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001656 explicit LInteger32ToDouble(LOperand* value) {
1657 inputs_[0] = value;
1658 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001659
1660 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1661};
1662
1663
Steve Block1e0659c2011-05-24 12:43:12 +01001664class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001665 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001666 explicit LNumberTagI(LOperand* value) {
1667 inputs_[0] = value;
1668 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001669
1670 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1671};
1672
1673
Ben Murdochb8e0da22011-05-16 14:20:40 +01001674class LNumberTagD: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001675 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001676 LNumberTagD(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001677 inputs_[0] = value;
1678 temps_[0] = temp;
1679 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001680
1681 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
Ben Murdochb0fe1622011-05-05 13:52:32 +01001682};
1683
1684
1685// Sometimes truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001686class LDoubleToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001687 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001688 LDoubleToI(LOperand* value, LOperand* temp) {
1689 inputs_[0] = value;
1690 temps_[0] = temp;
1691 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001692
1693 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1694 DECLARE_HYDROGEN_ACCESSOR(Change)
1695
1696 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1697};
1698
1699
1700// Truncating conversion from a tagged value to an int32.
Ben Murdochb8e0da22011-05-16 14:20:40 +01001701class LTaggedToI: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001702 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001703 LTaggedToI(LOperand* value, LOperand* temp) {
1704 inputs_[0] = value;
1705 temps_[0] = temp;
1706 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001707
1708 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1709 DECLARE_HYDROGEN_ACCESSOR(Change)
1710
1711 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001712};
1713
1714
Steve Block1e0659c2011-05-24 12:43:12 +01001715class LSmiTag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001716 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001717 explicit LSmiTag(LOperand* value) {
1718 inputs_[0] = value;
1719 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001720
1721 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1722};
1723
1724
Steve Block1e0659c2011-05-24 12:43:12 +01001725class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001726 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001727 explicit LNumberUntagD(LOperand* value) {
1728 inputs_[0] = value;
1729 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001730
1731 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +01001732 DECLARE_HYDROGEN_ACCESSOR(Change);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001733};
1734
1735
Steve Block1e0659c2011-05-24 12:43:12 +01001736class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001737 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001738 LSmiUntag(LOperand* value, bool needs_check)
1739 : needs_check_(needs_check) {
1740 inputs_[0] = value;
1741 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001742
1743 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1744
1745 bool needs_check() const { return needs_check_; }
1746
1747 private:
1748 bool needs_check_;
1749};
1750
1751
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001752class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001753 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001754 LStoreNamedField(LOperand* obj, LOperand* val, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001755 inputs_[0] = obj;
1756 inputs_[1] = val;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001757 temps_[0] = temp;
1758 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001759
1760 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001761 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001762
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001763 virtual void PrintDataTo(StringStream* stream);
1764
1765 LOperand* object() { return inputs_[0]; }
1766 LOperand* value() { return inputs_[1]; }
1767
1768 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001769 bool is_in_object() { return hydrogen()->is_in_object(); }
1770 int offset() { return hydrogen()->offset(); }
1771 bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1772 Handle<Map> transition() const { return hydrogen()->transition(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001773};
1774
1775
Steve Block1e0659c2011-05-24 12:43:12 +01001776class LStoreNamedGeneric: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001777 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001778 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
1779 inputs_[0] = context;
1780 inputs_[1] = object;
1781 inputs_[2] = value;
1782 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001783
1784 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001785 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001786
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001787 virtual void PrintDataTo(StringStream* stream);
1788
Steve Block1e0659c2011-05-24 12:43:12 +01001789 LOperand* context() { return inputs_[0]; }
1790 LOperand* object() { return inputs_[1]; }
1791 LOperand* value() { return inputs_[2]; }
1792 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001793 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001794};
1795
1796
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001797class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001798 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001799 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001800 inputs_[0] = obj;
1801 inputs_[1] = key;
1802 inputs_[2] = val;
1803 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001804
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001805 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1806 "store-keyed-fast-element")
1807 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001808
Ben Murdochb8e0da22011-05-16 14:20:40 +01001809 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001810
Ben Murdochb8e0da22011-05-16 14:20:40 +01001811 LOperand* object() { return inputs_[0]; }
1812 LOperand* key() { return inputs_[1]; }
1813 LOperand* value() { return inputs_[2]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001814};
1815
1816
Ben Murdoch257744e2011-11-30 15:57:28 +00001817class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001818 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001819 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1820 LOperand* key,
Ben Murdoch257744e2011-11-30 15:57:28 +00001821 LOperand* val) {
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001822 inputs_[0] = external_pointer;
1823 inputs_[1] = key;
1824 inputs_[2] = val;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001825 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001826
Steve Block44f0eee2011-05-26 01:26:41 +01001827 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1828 "store-keyed-specialized-array-element")
1829 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001830
1831 LOperand* external_pointer() { return inputs_[0]; }
1832 LOperand* key() { return inputs_[1]; }
1833 LOperand* value() { return inputs_[2]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001834 ExternalArrayType array_type() const {
1835 return hydrogen()->array_type();
1836 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001837};
1838
1839
Steve Block1e0659c2011-05-24 12:43:12 +01001840class LStoreKeyedGeneric: public LTemplateInstruction<0, 4, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001841 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001842 LStoreKeyedGeneric(LOperand* context,
1843 LOperand* object,
1844 LOperand* key,
1845 LOperand* value) {
1846 inputs_[0] = context;
1847 inputs_[1] = object;
1848 inputs_[2] = key;
1849 inputs_[3] = value;
1850 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001851
1852 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
Ben Murdoch8b112d22011-06-08 16:22:53 +01001853 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
Steve Block1e0659c2011-05-24 12:43:12 +01001854
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001855 virtual void PrintDataTo(StringStream* stream);
1856
Steve Block1e0659c2011-05-24 12:43:12 +01001857 LOperand* context() { return inputs_[0]; }
1858 LOperand* object() { return inputs_[1]; }
1859 LOperand* key() { return inputs_[2]; }
1860 LOperand* value() { return inputs_[3]; }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001861 bool strict_mode() { return hydrogen()->strict_mode(); }
1862};
1863
1864
Ben Murdoch257744e2011-11-30 15:57:28 +00001865class LStringAdd: public LTemplateInstruction<1, 2, 0> {
1866 public:
1867 LStringAdd(LOperand* left, LOperand* right) {
1868 inputs_[0] = left;
1869 inputs_[1] = right;
1870 }
1871
1872 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1873 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1874
1875 LOperand* left() { return inputs_[0]; }
1876 LOperand* right() { return inputs_[1]; }
1877};
1878
1879
Steve Block1e0659c2011-05-24 12:43:12 +01001880class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
1881 public:
1882 LStringCharCodeAt(LOperand* string, LOperand* index) {
1883 inputs_[0] = string;
1884 inputs_[1] = index;
1885 }
1886
1887 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1888 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1889
1890 LOperand* string() { return inputs_[0]; }
1891 LOperand* index() { return inputs_[1]; }
1892};
1893
1894
Steve Block44f0eee2011-05-26 01:26:41 +01001895class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
1896 public:
1897 explicit LStringCharFromCode(LOperand* char_code) {
1898 inputs_[0] = char_code;
1899 }
1900
1901 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1902 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1903
1904 LOperand* char_code() { return inputs_[0]; }
1905};
1906
1907
Steve Block1e0659c2011-05-24 12:43:12 +01001908class LStringLength: public LTemplateInstruction<1, 1, 0> {
1909 public:
1910 explicit LStringLength(LOperand* string) {
1911 inputs_[0] = string;
1912 }
1913
1914 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1915 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1916
1917 LOperand* string() { return inputs_[0]; }
1918};
1919
1920
1921class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001922 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001923 explicit LCheckFunction(LOperand* value) {
1924 inputs_[0] = value;
1925 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001926
1927 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1928 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1929};
1930
1931
Ben Murdochb8e0da22011-05-16 14:20:40 +01001932class LCheckInstanceType: public LTemplateInstruction<0, 1, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001933 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001934 LCheckInstanceType(LOperand* value, LOperand* temp) {
1935 inputs_[0] = value;
1936 temps_[0] = temp;
1937 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001938
1939 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1940 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001941};
1942
1943
Steve Block1e0659c2011-05-24 12:43:12 +01001944class LCheckMap: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001945 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001946 explicit LCheckMap(LOperand* value) {
1947 inputs_[0] = value;
1948 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001949
1950 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1951 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1952};
1953
1954
Ben Murdochb8e0da22011-05-16 14:20:40 +01001955class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001956 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001957 explicit LCheckPrototypeMaps(LOperand* temp) {
1958 temps_[0] = temp;
1959 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001960
1961 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001962 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
Ben Murdochb0fe1622011-05-05 13:52:32 +01001963
Ben Murdochb8e0da22011-05-16 14:20:40 +01001964 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1965 Handle<JSObject> holder() const { return hydrogen()->holder(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001966};
1967
1968
Steve Block1e0659c2011-05-24 12:43:12 +01001969class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001970 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001971 explicit LCheckSmi(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001972 inputs_[0] = value;
1973 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01001974
Steve Block44f0eee2011-05-26 01:26:41 +01001975 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1976};
Ben Murdochb0fe1622011-05-05 13:52:32 +01001977
Steve Block44f0eee2011-05-26 01:26:41 +01001978
Ben Murdoch257744e2011-11-30 15:57:28 +00001979class LClampDToUint8: public LTemplateInstruction<1, 1, 0> {
1980 public:
1981 explicit LClampDToUint8(LOperand* value) {
1982 inputs_[0] = value;
1983 }
1984
1985 LOperand* unclamped() { return inputs_[0]; }
1986
1987 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
1988};
1989
1990
1991class LClampIToUint8: public LTemplateInstruction<1, 1, 0> {
1992 public:
1993 explicit LClampIToUint8(LOperand* value) {
1994 inputs_[0] = value;
1995 }
1996
1997 LOperand* unclamped() { return inputs_[0]; }
1998
1999 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2000};
2001
2002
2003class LClampTToUint8: public LTemplateInstruction<1, 1, 1> {
2004 public:
2005 LClampTToUint8(LOperand* value, LOperand* temp) {
2006 inputs_[0] = value;
2007 temps_[0] = temp;
2008 }
2009
2010 LOperand* unclamped() { return inputs_[0]; }
2011
2012 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2013};
2014
2015
Steve Block44f0eee2011-05-26 01:26:41 +01002016class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
2017 public:
2018 explicit LCheckNonSmi(LOperand* value) {
2019 inputs_[0] = value;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002020 }
2021
Steve Block44f0eee2011-05-26 01:26:41 +01002022 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Ben Murdochb0fe1622011-05-05 13:52:32 +01002023};
2024
2025
Ben Murdochb8e0da22011-05-16 14:20:40 +01002026class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002027 public:
2028 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
2029 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
2030};
2031
2032
Steve Block1e0659c2011-05-24 12:43:12 +01002033class LObjectLiteral: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002034 public:
Steve Block1e0659c2011-05-24 12:43:12 +01002035 explicit LObjectLiteral(LOperand* context) {
2036 inputs_[0] = context;
2037 }
2038
Ben Murdochb0fe1622011-05-05 13:52:32 +01002039 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
2040 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
Steve Block1e0659c2011-05-24 12:43:12 +01002041
2042 LOperand* context() { return inputs_[0]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002043};
2044
2045
Ben Murdochb8e0da22011-05-16 14:20:40 +01002046class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002047 public:
2048 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2049 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2050};
2051
2052
Ben Murdochb8e0da22011-05-16 14:20:40 +01002053class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002054 public:
2055 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2056 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2057
2058 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
2059};
2060
2061
Steve Block44f0eee2011-05-26 01:26:41 +01002062class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
2063 public:
2064 explicit LToFastProperties(LOperand* value) {
2065 inputs_[0] = value;
2066 }
2067
2068 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2069 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2070};
2071
2072
Steve Block1e0659c2011-05-24 12:43:12 +01002073class LTypeof: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002074 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01002075 explicit LTypeof(LOperand* value) {
2076 inputs_[0] = value;
2077 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002078
2079 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2080};
2081
2082
Steve Block1e0659c2011-05-24 12:43:12 +01002083class LTypeofIs: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002084 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01002085 explicit LTypeofIs(LOperand* value) {
2086 inputs_[0] = value;
2087 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002088
2089 DECLARE_CONCRETE_INSTRUCTION(TypeofIs, "typeof-is")
2090 DECLARE_HYDROGEN_ACCESSOR(TypeofIs)
2091
2092 Handle<String> type_literal() { return hydrogen()->type_literal(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01002093
2094 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002095};
2096
2097
Steve Block1e0659c2011-05-24 12:43:12 +01002098class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002099 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01002100 explicit LTypeofIsAndBranch(LOperand* value) {
2101 inputs_[0] = value;
2102 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002103
2104 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
Ben Murdochb8e0da22011-05-16 14:20:40 +01002105 DECLARE_HYDROGEN_ACCESSOR(TypeofIs)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002106
Ben Murdochb8e0da22011-05-16 14:20:40 +01002107 Handle<String> type_literal() { return hydrogen()->type_literal(); }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002108
Ben Murdochb8e0da22011-05-16 14:20:40 +01002109 virtual void PrintDataTo(StringStream* stream);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002110};
2111
2112
Steve Block1e0659c2011-05-24 12:43:12 +01002113class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002114 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01002115 LDeleteProperty(LOperand* obj, LOperand* key) {
2116 inputs_[0] = obj;
2117 inputs_[1] = key;
2118 }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002119
2120 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
2121
Ben Murdochb8e0da22011-05-16 14:20:40 +01002122 LOperand* object() { return inputs_[0]; }
2123 LOperand* key() { return inputs_[1]; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002124};
2125
2126
Ben Murdochb8e0da22011-05-16 14:20:40 +01002127class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002128 public:
2129 LOsrEntry();
2130
2131 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2132
2133 LOperand** SpilledRegisterArray() { return register_spills_; }
2134 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
2135
2136 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
2137 void MarkSpilledDoubleRegister(int allocation_index,
2138 LOperand* spill_operand);
2139
2140 private:
2141 // Arrays of spill slot operands for registers with an assigned spill
2142 // slot, i.e., that must also be restored to the spill slot on OSR entry.
2143 // NULL if the register has no assigned spill slot. Indexed by allocation
2144 // index.
2145 LOperand* register_spills_[Register::kNumAllocatableRegisters];
2146 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
2147};
2148
2149
Ben Murdochb8e0da22011-05-16 14:20:40 +01002150class LStackCheck: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01002151 public:
2152 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2153};
2154
2155
Ben Murdoch257744e2011-11-30 15:57:28 +00002156class LIn: public LTemplateInstruction<1, 2, 0> {
2157 public:
2158 LIn(LOperand* key, LOperand* object) {
2159 inputs_[0] = key;
2160 inputs_[1] = object;
2161 }
2162
2163 LOperand* key() { return inputs_[0]; }
2164 LOperand* object() { return inputs_[1]; }
2165
2166 DECLARE_CONCRETE_INSTRUCTION(In, "in")
2167};
2168
2169
Ben Murdochb0fe1622011-05-05 13:52:32 +01002170class LChunkBuilder;
2171class LChunk: public ZoneObject {
2172 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002173 explicit LChunk(CompilationInfo* info, HGraph* graph)
Ben Murdoch086aeea2011-05-13 15:57:08 +01002174 : spill_slot_count_(0),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002175 info_(info),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002176 graph_(graph),
2177 instructions_(32),
2178 pointer_maps_(8),
2179 inlined_closures_(1) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002180
Steve Block1e0659c2011-05-24 12:43:12 +01002181 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002182 LConstantOperand* DefineConstantOperand(HConstant* constant);
2183 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
2184 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
2185
2186 int GetNextSpillIndex(bool is_double);
2187 LOperand* GetNextSpillSlot(bool is_double);
2188
2189 int ParameterAt(int index);
2190 int GetParameterStackSlot(int index) const;
2191 int spill_slot_count() const { return spill_slot_count_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002192 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002193 HGraph* graph() const { return graph_; }
2194 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
2195 void AddGapMove(int index, LOperand* from, LOperand* to);
2196 LGap* GetGapAt(int index) const;
2197 bool IsGapAt(int index) const;
2198 int NearestGapPos(int index) const;
2199 void MarkEmptyBlocks();
2200 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
2201 LLabel* GetLabel(int block_id) const {
2202 HBasicBlock* block = graph_->blocks()->at(block_id);
2203 int first_instruction = block->first_instruction_index();
2204 return LLabel::cast(instructions_[first_instruction]);
2205 }
2206 int LookupDestination(int block_id) const {
2207 LLabel* cur = GetLabel(block_id);
2208 while (cur->replacement() != NULL) {
2209 cur = cur->replacement();
2210 }
2211 return cur->block_id();
2212 }
2213 Label* GetAssemblyLabel(int block_id) const {
2214 LLabel* label = GetLabel(block_id);
2215 ASSERT(!label->HasReplacement());
2216 return label->label();
2217 }
2218
2219 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
2220 return &inlined_closures_;
2221 }
2222
2223 void AddInlinedClosure(Handle<JSFunction> closure) {
2224 inlined_closures_.Add(closure);
2225 }
2226
Ben Murdochb0fe1622011-05-05 13:52:32 +01002227 private:
2228 int spill_slot_count_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002229 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002230 HGraph* const graph_;
2231 ZoneList<LInstruction*> instructions_;
2232 ZoneList<LPointerMap*> pointer_maps_;
2233 ZoneList<Handle<JSFunction> > inlined_closures_;
2234};
2235
2236
2237class LChunkBuilder BASE_EMBEDDED {
2238 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002239 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
Ben Murdochb0fe1622011-05-05 13:52:32 +01002240 : chunk_(NULL),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002241 info_(info),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002242 graph_(graph),
2243 status_(UNUSED),
2244 current_instruction_(NULL),
2245 current_block_(NULL),
2246 next_block_(NULL),
2247 argument_count_(0),
2248 allocator_(allocator),
2249 position_(RelocInfo::kNoPosition),
Steve Block1e0659c2011-05-24 12:43:12 +01002250 instruction_pending_deoptimization_environment_(NULL),
Ben Murdochb0fe1622011-05-05 13:52:32 +01002251 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
2252
2253 // Build the sequence for the graph.
2254 LChunk* Build();
2255
2256 // Declare methods that deal with the individual node types.
2257#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2258 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2259#undef DECLARE_DO
2260
2261 private:
2262 enum Status {
2263 UNUSED,
2264 BUILDING,
2265 DONE,
2266 ABORTED
2267 };
2268
2269 LChunk* chunk() const { return chunk_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002270 CompilationInfo* info() const { return info_; }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002271 HGraph* graph() const { return graph_; }
2272
2273 bool is_unused() const { return status_ == UNUSED; }
2274 bool is_building() const { return status_ == BUILDING; }
2275 bool is_done() const { return status_ == DONE; }
2276 bool is_aborted() const { return status_ == ABORTED; }
2277
2278 void Abort(const char* format, ...);
2279
2280 // Methods for getting operands for Use / Define / Temp.
2281 LRegister* ToOperand(Register reg);
2282 LUnallocated* ToUnallocated(Register reg);
2283 LUnallocated* ToUnallocated(XMMRegister reg);
2284
2285 // Methods for setting up define-use relationships.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002286 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2287 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2288 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2289 XMMRegister fixed_register);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002290
2291 // A value that is guaranteed to be allocated to a register.
2292 // Operand created by UseRegister is guaranteed to be live until the end of
2293 // instruction. This means that register allocator will not reuse it's
2294 // register for any other operand inside instruction.
2295 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2296 // instruction start. Register allocator is free to assign the same register
2297 // to some other operand used inside instruction (i.e. temporary or
2298 // output).
Ben Murdochb8e0da22011-05-16 14:20:40 +01002299 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2300 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002301
Ben Murdochb8e0da22011-05-16 14:20:40 +01002302 // An input operand in a register that may be trashed.
2303 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2304
2305 // An input operand in a register or stack slot.
2306 MUST_USE_RESULT LOperand* Use(HValue* value);
2307 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2308
2309 // An input operand in a register, stack slot or a constant operand.
2310 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2311 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2312
2313 // An input operand in a register or a constant operand.
2314 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2315 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2316
2317 // An input operand in register, stack slot or a constant operand.
2318 // Will not be moved to a register even if one is freely available.
2319 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2320
2321 // Temporary operand that must be in a register.
2322 MUST_USE_RESULT LUnallocated* TempRegister();
2323 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2324 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002325
2326 // Methods for setting up define-use relationships.
2327 // Return the same instruction that they are passed.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002328 template<int I, int T>
2329 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2330 LUnallocated* result);
2331 template<int I, int T>
2332 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2333 template<int I, int T>
2334 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2335 template<int I, int T>
2336 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2337 int index);
2338 template<int I, int T>
2339 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2340 template<int I, int T>
2341 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2342 Register reg);
2343 template<int I, int T>
2344 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2345 XMMRegister reg);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002346 LInstruction* AssignEnvironment(LInstruction* instr);
2347 LInstruction* AssignPointerMap(LInstruction* instr);
2348
2349 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2350
2351 // By default we assume that instruction sequences generated for calls
2352 // cannot deoptimize eagerly and we do not attach environment to this
2353 // instruction.
2354 LInstruction* MarkAsCall(
2355 LInstruction* instr,
2356 HInstruction* hinstr,
2357 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
Ben Murdoch086aeea2011-05-13 15:57:08 +01002358 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002359
2360 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2361 LInstruction* instr, int ast_id);
2362 void ClearInstructionPendingDeoptimizationEnvironment();
2363
2364 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env);
2365
Ben Murdochb0fe1622011-05-05 13:52:32 +01002366 void VisitInstruction(HInstruction* current);
2367
2368 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2369 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2370 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2371 LInstruction* DoArithmeticD(Token::Value op,
2372 HArithmeticBinaryOperation* instr);
2373 LInstruction* DoArithmeticT(Token::Value op,
2374 HArithmeticBinaryOperation* instr);
2375
2376 LChunk* chunk_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002377 CompilationInfo* info_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002378 HGraph* const graph_;
2379 Status status_;
2380 HInstruction* current_instruction_;
2381 HBasicBlock* current_block_;
2382 HBasicBlock* next_block_;
2383 int argument_count_;
2384 LAllocator* allocator_;
2385 int position_;
Steve Block1e0659c2011-05-24 12:43:12 +01002386 LInstruction* instruction_pending_deoptimization_environment_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002387 int pending_deoptimization_ast_id_;
2388
2389 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2390};
2391
2392#undef DECLARE_HYDROGEN_ACCESSOR
Ben Murdochb0fe1622011-05-05 13:52:32 +01002393#undef DECLARE_CONCRETE_INSTRUCTION
2394
2395} } // namespace v8::internal
2396
2397#endif // V8_IA32_LITHIUM_IA32_H_