blob: 8e12282199a40bd374a0b27a1991cff325ac3797 [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_X64_LITHIUM_X64_H_
29#define V8_X64_LITHIUM_X64_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 Murdochb8e0da22011-05-16 14:20:40 +010041
Ben Murdochb8e0da22011-05-16 14:20:40 +010042#define LITHIUM_ALL_INSTRUCTION_LIST(V) \
43 V(ControlInstruction) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010044 V(Call) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010045 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
46
47
48#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
49 V(AccessArgumentsAt) \
50 V(AddI) \
51 V(ApplyArguments) \
52 V(ArgumentsElements) \
53 V(ArgumentsLength) \
54 V(ArithmeticD) \
55 V(ArithmeticT) \
56 V(ArrayLiteral) \
57 V(BitI) \
58 V(BitNotI) \
59 V(BoundsCheck) \
60 V(Branch) \
61 V(CallConstantFunction) \
62 V(CallFunction) \
63 V(CallGlobal) \
64 V(CallKeyed) \
65 V(CallKnownGlobal) \
66 V(CallNamed) \
67 V(CallNew) \
68 V(CallRuntime) \
69 V(CallStub) \
70 V(CheckFunction) \
71 V(CheckInstanceType) \
72 V(CheckMap) \
Steve Block44f0eee2011-05-26 01:26:41 +010073 V(CheckNonSmi) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010074 V(CheckPrototypeMaps) \
75 V(CheckSmi) \
Steve Block44f0eee2011-05-26 01:26:41 +010076 V(ClassOfTest) \
77 V(ClassOfTestAndBranch) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010078 V(CmpID) \
79 V(CmpIDAndBranch) \
80 V(CmpJSObjectEq) \
81 V(CmpJSObjectEqAndBranch) \
82 V(CmpMapAndBranch) \
83 V(CmpT) \
84 V(CmpTAndBranch) \
85 V(ConstantD) \
86 V(ConstantI) \
87 V(ConstantT) \
Steve Block1e0659c2011-05-24 12:43:12 +010088 V(Context) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010089 V(DeleteProperty) \
90 V(Deoptimize) \
91 V(DivI) \
92 V(DoubleToI) \
Steve Block44f0eee2011-05-26 01:26:41 +010093 V(ExternalArrayLength) \
94 V(FixedArrayLength) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010095 V(FunctionLiteral) \
96 V(Gap) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +010097 V(GetCachedArrayIndex) \
Ben Murdochb8e0da22011-05-16 14:20:40 +010098 V(GlobalObject) \
99 V(GlobalReceiver) \
100 V(Goto) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100101 V(HasInstanceType) \
102 V(HasInstanceTypeAndBranch) \
Steve Block053d10c2011-06-13 19:13:29 +0100103 V(HasCachedArrayIndex) \
104 V(HasCachedArrayIndexAndBranch) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100105 V(InstanceOf) \
106 V(InstanceOfAndBranch) \
107 V(InstanceOfKnownGlobal) \
108 V(Integer32ToDouble) \
109 V(IsNull) \
110 V(IsNullAndBranch) \
111 V(IsObject) \
112 V(IsObjectAndBranch) \
113 V(IsSmi) \
114 V(IsSmiAndBranch) \
115 V(JSArrayLength) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100116 V(Label) \
117 V(LazyBailout) \
118 V(LoadContextSlot) \
119 V(LoadElements) \
Steve Block44f0eee2011-05-26 01:26:41 +0100120 V(LoadExternalArrayPointer) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100121 V(LoadGlobalCell) \
122 V(LoadGlobalGeneric) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100123 V(LoadKeyedFastElement) \
124 V(LoadKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100125 V(LoadKeyedSpecializedArrayElement) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100126 V(LoadNamedField) \
Steve Block44f0eee2011-05-26 01:26:41 +0100127 V(LoadNamedFieldPolymorphic) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100128 V(LoadNamedGeneric) \
129 V(LoadFunctionPrototype) \
130 V(ModI) \
131 V(MulI) \
132 V(NumberTagD) \
133 V(NumberTagI) \
134 V(NumberUntagD) \
135 V(ObjectLiteral) \
136 V(OsrEntry) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100137 V(OuterContext) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100138 V(Parameter) \
139 V(Power) \
140 V(PushArgument) \
141 V(RegExpLiteral) \
142 V(Return) \
143 V(ShiftI) \
144 V(SmiTag) \
145 V(SmiUntag) \
146 V(StackCheck) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100147 V(StoreContextSlot) \
Ben Murdoch8b112d22011-06-08 16:22:53 +0100148 V(StoreGlobalCell) \
149 V(StoreGlobalGeneric) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100150 V(StoreKeyedFastElement) \
151 V(StoreKeyedGeneric) \
Steve Block44f0eee2011-05-26 01:26:41 +0100152 V(StoreKeyedSpecializedArrayElement) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100153 V(StoreNamedField) \
154 V(StoreNamedGeneric) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100155 V(StringCharCodeAt) \
Steve Block44f0eee2011-05-26 01:26:41 +0100156 V(StringCharFromCode) \
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100157 V(StringLength) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100158 V(SubI) \
159 V(TaggedToI) \
Steve Block44f0eee2011-05-26 01:26:41 +0100160 V(ToFastProperties) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100161 V(Throw) \
162 V(Typeof) \
163 V(TypeofIs) \
164 V(TypeofIsAndBranch) \
Steve Block1e0659c2011-05-24 12:43:12 +0100165 V(IsConstructCall) \
166 V(IsConstructCallAndBranch) \
Ben Murdochb8e0da22011-05-16 14:20:40 +0100167 V(UnaryMathOperation) \
168 V(UnknownOSRValue) \
169 V(ValueOf)
170
171
172#define DECLARE_INSTRUCTION(type) \
173 virtual bool Is##type() const { return true; } \
174 static L##type* cast(LInstruction* instr) { \
175 ASSERT(instr->Is##type()); \
176 return reinterpret_cast<L##type*>(instr); \
177 }
178
179
180#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
181 virtual void CompileToNative(LCodeGen* generator); \
182 virtual const char* Mnemonic() const { return mnemonic; } \
183 DECLARE_INSTRUCTION(type)
184
185
186#define DECLARE_HYDROGEN_ACCESSOR(type) \
187 H##type* hydrogen() const { \
188 return H##type::cast(hydrogen_value()); \
189 }
190
Ben Murdochb0fe1622011-05-05 13:52:32 +0100191
192class LInstruction: public ZoneObject {
193 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100194 LInstruction()
Steve Block1e0659c2011-05-24 12:43:12 +0100195 : environment_(NULL),
196 hydrogen_value_(NULL),
197 is_call_(false),
198 is_save_doubles_(false) { }
199
Ben Murdochb0fe1622011-05-05 13:52:32 +0100200 virtual ~LInstruction() { }
201
Ben Murdochb8e0da22011-05-16 14:20:40 +0100202 virtual void CompileToNative(LCodeGen* generator) = 0;
203 virtual const char* Mnemonic() const = 0;
204 virtual void PrintTo(StringStream* stream);
205 virtual void PrintDataTo(StringStream* stream) = 0;
206 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
Ben Murdoch086aeea2011-05-13 15:57:08 +0100207
Ben Murdochb8e0da22011-05-16 14:20:40 +0100208 // Declare virtual type testers.
209#define DECLARE_DO(type) virtual bool Is##type() const { return false; }
210 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO)
211#undef DECLARE_DO
212
213 virtual bool IsControl() const { return false; }
214 virtual void SetBranchTargets(int true_block_id, int false_block_id) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +0100215
Steve Block1e0659c2011-05-24 12:43:12 +0100216 void set_environment(LEnvironment* env) { environment_ = env; }
217 LEnvironment* environment() const { return environment_; }
218 bool HasEnvironment() const { return environment_ != NULL; }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100219
220 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
221 LPointerMap* pointer_map() const { return pointer_map_.get(); }
222 bool HasPointerMap() const { return pointer_map_.is_set(); }
223
Ben Murdoch086aeea2011-05-13 15:57:08 +0100224 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
225 HValue* hydrogen_value() const { return hydrogen_value_; }
226
227 void set_deoptimization_environment(LEnvironment* env) {
228 deoptimization_environment_.set(env);
229 }
230 LEnvironment* deoptimization_environment() const {
231 return deoptimization_environment_.get();
232 }
233 bool HasDeoptimizationEnvironment() const {
234 return deoptimization_environment_.is_set();
Ben Murdochb0fe1622011-05-05 13:52:32 +0100235 }
236
Steve Block1e0659c2011-05-24 12:43:12 +0100237 void MarkAsCall() { is_call_ = true; }
238 void MarkAsSaveDoubles() { is_save_doubles_ = true; }
239
240 // Interface to the register allocator and iterators.
241 bool IsMarkedAsCall() const { return is_call_; }
242 bool IsMarkedAsSaveDoubles() const { return is_save_doubles_; }
243
244 virtual bool HasResult() const = 0;
245 virtual LOperand* result() = 0;
246
247 virtual int InputCount() = 0;
248 virtual LOperand* InputAt(int i) = 0;
249 virtual int TempCount() = 0;
250 virtual LOperand* TempAt(int i) = 0;
251
252 LOperand* FirstInput() { return InputAt(0); }
253 LOperand* Output() { return HasResult() ? result() : NULL; }
254
255#ifdef DEBUG
256 void VerifyCall();
257#endif
258
Ben Murdoch086aeea2011-05-13 15:57:08 +0100259 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100260 LEnvironment* environment_;
Ben Murdoch086aeea2011-05-13 15:57:08 +0100261 SetOncePointer<LPointerMap> pointer_map_;
Ben Murdoch086aeea2011-05-13 15:57:08 +0100262 HValue* hydrogen_value_;
263 SetOncePointer<LEnvironment> deoptimization_environment_;
Steve Block1e0659c2011-05-24 12:43:12 +0100264 bool is_call_;
265 bool is_save_doubles_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100266};
267
268
Steve Block1e0659c2011-05-24 12:43:12 +0100269template<typename ElementType, int NumElements>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100270class OperandContainer {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100271 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100272 OperandContainer() {
Steve Block1e0659c2011-05-24 12:43:12 +0100273 for (int i = 0; i < NumElements; i++) elems_[i] = NULL;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100274 }
Steve Block1e0659c2011-05-24 12:43:12 +0100275 int length() { return NumElements; }
276 ElementType& operator[](int i) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100277 ASSERT(i < length());
278 return elems_[i];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100279 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100280 void PrintOperandsTo(StringStream* stream);
Ben Murdoch086aeea2011-05-13 15:57:08 +0100281
282 private:
Steve Block1e0659c2011-05-24 12:43:12 +0100283 ElementType elems_[NumElements];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100284};
285
286
Steve Block1e0659c2011-05-24 12:43:12 +0100287template<typename ElementType>
288class OperandContainer<ElementType, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100289 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100290 int length() { return 0; }
291 void PrintOperandsTo(StringStream* stream) { }
Steve Block1e0659c2011-05-24 12:43:12 +0100292 ElementType& operator[](int i) {
293 UNREACHABLE();
294 static ElementType t = 0;
295 return t;
296 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100297};
Ben Murdochb0fe1622011-05-05 13:52:32 +0100298
Ben Murdochb8e0da22011-05-16 14:20:40 +0100299
Steve Block1e0659c2011-05-24 12:43:12 +0100300// R = number of result operands (0 or 1).
301// I = number of input operands.
302// T = number of temporary operands.
303template<int R, int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100304class LTemplateInstruction: public LInstruction {
305 public:
306 // Allow 0 or 1 output operands.
307 STATIC_ASSERT(R == 0 || R == 1);
308 virtual bool HasResult() const { return R != 0; }
309 void set_result(LOperand* operand) { results_[0] = operand; }
310 LOperand* result() { return results_[0]; }
311
312 int InputCount() { return I; }
313 LOperand* InputAt(int i) { return inputs_[i]; }
314
315 int TempCount() { return T; }
316 LOperand* TempAt(int i) { return temps_[i]; }
317
318 virtual void PrintDataTo(StringStream* stream);
319 virtual void PrintOutputOperandTo(StringStream* stream);
320
321 protected:
322 OperandContainer<LOperand*, R> results_;
323 OperandContainer<LOperand*, I> inputs_;
324 OperandContainer<LOperand*, T> temps_;
325};
326
327
328class LGap: public LTemplateInstruction<0, 0, 0> {
329 public:
330 explicit LGap(HBasicBlock* block)
331 : block_(block) {
332 parallel_moves_[BEFORE] = NULL;
333 parallel_moves_[START] = NULL;
334 parallel_moves_[END] = NULL;
335 parallel_moves_[AFTER] = NULL;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100336 }
337
Ben Murdochb8e0da22011-05-16 14:20:40 +0100338 DECLARE_CONCRETE_INSTRUCTION(Gap, "gap")
339 virtual void PrintDataTo(StringStream* stream);
340
341 bool IsRedundant() const;
342
343 HBasicBlock* block() const { return block_; }
344
Ben Murdochb0fe1622011-05-05 13:52:32 +0100345 enum InnerPosition {
346 BEFORE,
347 START,
348 END,
349 AFTER,
350 FIRST_INNER_POSITION = BEFORE,
351 LAST_INNER_POSITION = AFTER
352 };
353
Ben Murdochb8e0da22011-05-16 14:20:40 +0100354 LParallelMove* GetOrCreateParallelMove(InnerPosition pos) {
355 if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove;
356 return parallel_moves_[pos];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100357 }
358
359 LParallelMove* GetParallelMove(InnerPosition pos) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100360 return parallel_moves_[pos];
Ben Murdochb0fe1622011-05-05 13:52:32 +0100361 }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100362
363 private:
364 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
365 HBasicBlock* block_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100366};
367
368
Ben Murdochb8e0da22011-05-16 14:20:40 +0100369class LGoto: public LTemplateInstruction<0, 0, 0> {
370 public:
371 LGoto(int block_id, bool include_stack_check = false)
372 : block_id_(block_id), include_stack_check_(include_stack_check) { }
373
374 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
375 virtual void PrintDataTo(StringStream* stream);
376 virtual bool IsControl() const { return true; }
377
378 int block_id() const { return block_id_; }
379 bool include_stack_check() const { return include_stack_check_; }
380
381 private:
382 int block_id_;
383 bool include_stack_check_;
384};
385
386
387class LLazyBailout: public LTemplateInstruction<0, 0, 0> {
388 public:
389 LLazyBailout() : gap_instructions_size_(0) { }
390
391 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
392
393 void set_gap_instructions_size(int gap_instructions_size) {
394 gap_instructions_size_ = gap_instructions_size;
395 }
396 int gap_instructions_size() { return gap_instructions_size_; }
397
398 private:
399 int gap_instructions_size_;
400};
401
402
403class LDeoptimize: public LTemplateInstruction<0, 0, 0> {
404 public:
405 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
406};
407
408
Ben Murdochb0fe1622011-05-05 13:52:32 +0100409class LLabel: public LGap {
410 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100411 explicit LLabel(HBasicBlock* block)
412 : LGap(block), replacement_(NULL) { }
413
414 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
415
416 virtual void PrintDataTo(StringStream* stream);
417
418 int block_id() const { return block()->block_id(); }
419 bool is_loop_header() const { return block()->IsLoopHeader(); }
420 Label* label() { return &label_; }
421 LLabel* replacement() const { return replacement_; }
422 void set_replacement(LLabel* label) { replacement_ = label; }
423 bool HasReplacement() const { return replacement_ != NULL; }
Ben Murdoch086aeea2011-05-13 15:57:08 +0100424
425 private:
426 Label label_;
427 LLabel* replacement_;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100428};
429
430
Ben Murdochb8e0da22011-05-16 14:20:40 +0100431class LParameter: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +0100432 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100433 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
434};
435
436
437class LCallStub: public LTemplateInstruction<1, 0, 0> {
438 public:
439 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
440 DECLARE_HYDROGEN_ACCESSOR(CallStub)
441
442 TranscendentalCache::Type transcendental_type() {
443 return hydrogen()->transcendental_type();
444 }
445};
446
447
448class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
449 public:
450 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
451};
452
453
Steve Block1e0659c2011-05-24 12:43:12 +0100454template<int I, int T>
Ben Murdochb8e0da22011-05-16 14:20:40 +0100455class LControlInstruction: public LTemplateInstruction<0, I, T> {
456 public:
457 DECLARE_INSTRUCTION(ControlInstruction)
458 virtual bool IsControl() const { return true; }
459
460 int true_block_id() const { return true_block_id_; }
461 int false_block_id() const { return false_block_id_; }
462 void SetBranchTargets(int true_block_id, int false_block_id) {
463 true_block_id_ = true_block_id;
464 false_block_id_ = false_block_id;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100465 }
466
Ben Murdochb8e0da22011-05-16 14:20:40 +0100467 private:
468 int true_block_id_;
469 int false_block_id_;
470};
471
472
473class LApplyArguments: public LTemplateInstruction<1, 4, 0> {
474 public:
475 LApplyArguments(LOperand* function,
476 LOperand* receiver,
477 LOperand* length,
478 LOperand* elements) {
479 inputs_[0] = function;
480 inputs_[1] = receiver;
481 inputs_[2] = length;
482 inputs_[3] = elements;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100483 }
484
Ben Murdochb8e0da22011-05-16 14:20:40 +0100485 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
486
487 LOperand* function() { return inputs_[0]; }
488 LOperand* receiver() { return inputs_[1]; }
489 LOperand* length() { return inputs_[2]; }
490 LOperand* elements() { return inputs_[3]; }
491};
492
493
494class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> {
495 public:
496 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
497 inputs_[0] = arguments;
498 inputs_[1] = length;
499 inputs_[2] = index;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100500 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100501
502 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
503
504 LOperand* arguments() { return inputs_[0]; }
505 LOperand* length() { return inputs_[1]; }
506 LOperand* index() { return inputs_[2]; }
507
508 virtual void PrintDataTo(StringStream* stream);
509};
510
511
Steve Block1e0659c2011-05-24 12:43:12 +0100512class LArgumentsLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100513 public:
514 explicit LArgumentsLength(LOperand* elements) {
515 inputs_[0] = elements;
516 }
517
518 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
519};
520
521
522class LArgumentsElements: public LTemplateInstruction<1, 0, 0> {
523 public:
524 LArgumentsElements() { }
525
526 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
527};
528
529
530class LModI: public LTemplateInstruction<1, 2, 1> {
531 public:
532 LModI(LOperand* left, LOperand* right, LOperand* temp) {
533 inputs_[0] = left;
534 inputs_[1] = right;
535 temps_[0] = temp;
536 }
537
538 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
539 DECLARE_HYDROGEN_ACCESSOR(Mod)
540};
541
542
543class LDivI: public LTemplateInstruction<1, 2, 1> {
544 public:
545 LDivI(LOperand* left, LOperand* right, LOperand* temp) {
546 inputs_[0] = left;
547 inputs_[1] = right;
548 temps_[0] = temp;
549 }
550
551 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
552 DECLARE_HYDROGEN_ACCESSOR(Div)
553};
554
555
Steve Block1e0659c2011-05-24 12:43:12 +0100556class LMulI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100557 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100558 LMulI(LOperand* left, LOperand* right) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100559 inputs_[0] = left;
560 inputs_[1] = right;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100561 }
562
563 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
564 DECLARE_HYDROGEN_ACCESSOR(Mul)
565};
566
567
Steve Block1e0659c2011-05-24 12:43:12 +0100568class LCmpID: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100569 public:
570 LCmpID(LOperand* left, LOperand* right) {
571 inputs_[0] = left;
572 inputs_[1] = right;
573 }
574
575 DECLARE_CONCRETE_INSTRUCTION(CmpID, "cmp-id")
576 DECLARE_HYDROGEN_ACCESSOR(Compare)
577
578 Token::Value op() const { return hydrogen()->token(); }
579 bool is_double() const {
580 return hydrogen()->GetInputRepresentation().IsDouble();
581 }
582};
583
584
Steve Block1e0659c2011-05-24 12:43:12 +0100585class LCmpIDAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100586 public:
587 LCmpIDAndBranch(LOperand* left, LOperand* right) {
588 inputs_[0] = left;
589 inputs_[1] = right;
590 }
591
592 DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch")
593 DECLARE_HYDROGEN_ACCESSOR(Compare)
594
595 Token::Value op() const { return hydrogen()->token(); }
596 bool is_double() const {
597 return hydrogen()->GetInputRepresentation().IsDouble();
598 }
599
600 virtual void PrintDataTo(StringStream* stream);
601};
602
603
Steve Block1e0659c2011-05-24 12:43:12 +0100604class LUnaryMathOperation: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100605 public:
606 explicit LUnaryMathOperation(LOperand* value) {
607 inputs_[0] = value;
608 }
609
610 DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation")
611 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
612
613 virtual void PrintDataTo(StringStream* stream);
614 BuiltinFunctionId op() const { return hydrogen()->op(); }
615};
616
617
Steve Block1e0659c2011-05-24 12:43:12 +0100618class LCmpJSObjectEq: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100619 public:
620 LCmpJSObjectEq(LOperand* left, LOperand* right) {
621 inputs_[0] = left;
622 inputs_[1] = right;
623 }
624
625 DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEq, "cmp-jsobject-eq")
626};
627
628
Steve Block1e0659c2011-05-24 12:43:12 +0100629class LCmpJSObjectEqAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100630 public:
631 LCmpJSObjectEqAndBranch(LOperand* left, LOperand* right) {
632 inputs_[0] = left;
633 inputs_[1] = right;
634 }
635
636 DECLARE_CONCRETE_INSTRUCTION(CmpJSObjectEqAndBranch,
637 "cmp-jsobject-eq-and-branch")
638};
639
640
Steve Block1e0659c2011-05-24 12:43:12 +0100641class LIsNull: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100642 public:
643 explicit LIsNull(LOperand* value) {
644 inputs_[0] = value;
645 }
646
647 DECLARE_CONCRETE_INSTRUCTION(IsNull, "is-null")
648 DECLARE_HYDROGEN_ACCESSOR(IsNull)
649
650 bool is_strict() const { return hydrogen()->is_strict(); }
651};
652
653
654class LIsNullAndBranch: public LControlInstruction<1, 1> {
655 public:
656 LIsNullAndBranch(LOperand* value, LOperand* temp) {
657 inputs_[0] = value;
658 temps_[0] = temp;
659 }
660
661 DECLARE_CONCRETE_INSTRUCTION(IsNullAndBranch, "is-null-and-branch")
662 DECLARE_HYDROGEN_ACCESSOR(IsNull)
663
664 bool is_strict() const { return hydrogen()->is_strict(); }
665
666 virtual void PrintDataTo(StringStream* stream);
667};
668
669
Steve Block1e0659c2011-05-24 12:43:12 +0100670class LIsObject: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100671 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100672 explicit LIsObject(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100673 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100674 }
675
676 DECLARE_CONCRETE_INSTRUCTION(IsObject, "is-object")
677};
678
679
Steve Block1e0659c2011-05-24 12:43:12 +0100680class LIsObjectAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100681 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100682 explicit LIsObjectAndBranch(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100683 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100684 }
685
686 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
687
688 virtual void PrintDataTo(StringStream* stream);
689};
690
691
Steve Block1e0659c2011-05-24 12:43:12 +0100692class LIsSmi: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100693 public:
694 explicit LIsSmi(LOperand* value) {
695 inputs_[0] = value;
696 }
697
698 DECLARE_CONCRETE_INSTRUCTION(IsSmi, "is-smi")
699 DECLARE_HYDROGEN_ACCESSOR(IsSmi)
700};
701
702
Steve Block1e0659c2011-05-24 12:43:12 +0100703class LIsSmiAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100704 public:
705 explicit LIsSmiAndBranch(LOperand* value) {
706 inputs_[0] = value;
707 }
708
709 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
710
711 virtual void PrintDataTo(StringStream* stream);
712};
713
714
Steve Block1e0659c2011-05-24 12:43:12 +0100715class LHasInstanceType: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100716 public:
717 explicit LHasInstanceType(LOperand* value) {
718 inputs_[0] = value;
719 }
720
721 DECLARE_CONCRETE_INSTRUCTION(HasInstanceType, "has-instance-type")
722 DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
723};
724
725
Steve Block1e0659c2011-05-24 12:43:12 +0100726class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100727 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100728 explicit LHasInstanceTypeAndBranch(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100729 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100730 }
731
732 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
733 "has-instance-type-and-branch")
734 DECLARE_HYDROGEN_ACCESSOR(HasInstanceType)
735
736 virtual void PrintDataTo(StringStream* stream);
737};
738
739
Ben Murdoche0cee9b2011-05-25 10:26:03 +0100740class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
741 public:
742 explicit LGetCachedArrayIndex(LOperand* value) {
743 inputs_[0] = value;
744 }
745
746 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
747 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
748};
749
750
Steve Block1e0659c2011-05-24 12:43:12 +0100751class LHasCachedArrayIndex: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100752 public:
753 explicit LHasCachedArrayIndex(LOperand* value) {
754 inputs_[0] = value;
755 }
756
757 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex, "has-cached-array-index")
758 DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndex)
759};
760
761
Steve Block1e0659c2011-05-24 12:43:12 +0100762class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100763 public:
764 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
765 inputs_[0] = value;
766 }
767
768 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
769 "has-cached-array-index-and-branch")
770 virtual void PrintDataTo(StringStream* stream);
771};
772
773
774class LClassOfTest: public LTemplateInstruction<1, 1, 1> {
775 public:
776 LClassOfTest(LOperand* value, LOperand* temp) {
777 inputs_[0] = value;
778 temps_[0] = temp;
779 }
780
781 DECLARE_CONCRETE_INSTRUCTION(ClassOfTest, "class-of-test")
782 DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
783
784 virtual void PrintDataTo(StringStream* stream);
785};
786
787
Steve Block1e0659c2011-05-24 12:43:12 +0100788class LClassOfTestAndBranch: public LControlInstruction<1, 1> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100789 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100790 LClassOfTestAndBranch(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100791 inputs_[0] = value;
792 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100793 }
794
795 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
796 "class-of-test-and-branch")
797 DECLARE_HYDROGEN_ACCESSOR(ClassOfTest)
798
799 virtual void PrintDataTo(StringStream* stream);
800};
801
802
Steve Block1e0659c2011-05-24 12:43:12 +0100803class LCmpT: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100804 public:
805 LCmpT(LOperand* left, LOperand* right) {
806 inputs_[0] = left;
807 inputs_[1] = right;
808 }
809
810 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
811 DECLARE_HYDROGEN_ACCESSOR(Compare)
812
813 Token::Value op() const { return hydrogen()->token(); }
814};
815
816
Steve Block1e0659c2011-05-24 12:43:12 +0100817class LCmpTAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100818 public:
819 LCmpTAndBranch(LOperand* left, LOperand* right) {
820 inputs_[0] = left;
821 inputs_[1] = right;
822 }
823
824 DECLARE_CONCRETE_INSTRUCTION(CmpTAndBranch, "cmp-t-and-branch")
825 DECLARE_HYDROGEN_ACCESSOR(Compare)
826
827 Token::Value op() const { return hydrogen()->token(); }
828};
829
830
Steve Block1e0659c2011-05-24 12:43:12 +0100831class LInstanceOf: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100832 public:
833 LInstanceOf(LOperand* left, LOperand* right) {
834 inputs_[0] = left;
835 inputs_[1] = right;
836 }
837
838 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
839};
840
841
Steve Block1e0659c2011-05-24 12:43:12 +0100842class LInstanceOfAndBranch: public LControlInstruction<2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100843 public:
844 LInstanceOfAndBranch(LOperand* left, LOperand* right) {
845 inputs_[0] = left;
846 inputs_[1] = right;
847 }
848
849 DECLARE_CONCRETE_INSTRUCTION(InstanceOfAndBranch, "instance-of-and-branch")
850};
851
852
Steve Block44f0eee2011-05-26 01:26:41 +0100853class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100854 public:
Steve Block44f0eee2011-05-26 01:26:41 +0100855 LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100856 inputs_[0] = value;
Steve Block44f0eee2011-05-26 01:26:41 +0100857 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +0100858 }
859
860 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
861 "instance-of-known-global")
862 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
863
864 Handle<JSFunction> function() const { return hydrogen()->function(); }
865};
866
867
868class LBoundsCheck: public LTemplateInstruction<0, 2, 0> {
869 public:
870 LBoundsCheck(LOperand* index, LOperand* length) {
871 inputs_[0] = index;
872 inputs_[1] = length;
873 }
874
875 LOperand* index() { return inputs_[0]; }
876 LOperand* length() { return inputs_[1]; }
877
878 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
879};
880
881
Steve Block1e0659c2011-05-24 12:43:12 +0100882class LBitI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100883 public:
884 LBitI(Token::Value op, LOperand* left, LOperand* right)
885 : op_(op) {
886 inputs_[0] = left;
887 inputs_[1] = right;
888 }
889
890 Token::Value op() const { return op_; }
891
892 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
893
894 private:
895 Token::Value op_;
896};
897
898
Steve Block1e0659c2011-05-24 12:43:12 +0100899class LShiftI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100900 public:
901 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
902 : op_(op), can_deopt_(can_deopt) {
903 inputs_[0] = left;
904 inputs_[1] = right;
905 }
906
907 Token::Value op() const { return op_; }
908
909 bool can_deopt() const { return can_deopt_; }
910
911 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
912
913 private:
914 Token::Value op_;
915 bool can_deopt_;
916};
917
918
Steve Block1e0659c2011-05-24 12:43:12 +0100919class LSubI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100920 public:
921 LSubI(LOperand* left, LOperand* right) {
922 inputs_[0] = left;
923 inputs_[1] = right;
924 }
925
926 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
927 DECLARE_HYDROGEN_ACCESSOR(Sub)
928};
929
930
Steve Block1e0659c2011-05-24 12:43:12 +0100931class LConstantI: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100932 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100933 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
Steve Block1e0659c2011-05-24 12:43:12 +0100934 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100935
Steve Block1e0659c2011-05-24 12:43:12 +0100936 int32_t value() const { return hydrogen()->Integer32Value(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100937};
938
939
Steve Block1e0659c2011-05-24 12:43:12 +0100940class LConstantD: public LTemplateInstruction<1, 0, 1> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100941 public:
Steve Block1e0659c2011-05-24 12:43:12 +0100942 explicit LConstantD(LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100943 temps_[0] = temp;
944 }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100945 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
Steve Block1e0659c2011-05-24 12:43:12 +0100946 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100947
Steve Block1e0659c2011-05-24 12:43:12 +0100948 double value() const { return hydrogen()->DoubleValue(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100949};
950
951
Steve Block1e0659c2011-05-24 12:43:12 +0100952class LConstantT: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100953 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +0100954 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
Steve Block1e0659c2011-05-24 12:43:12 +0100955 DECLARE_HYDROGEN_ACCESSOR(Constant)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100956
Steve Block1e0659c2011-05-24 12:43:12 +0100957 Handle<Object> value() const { return hydrogen()->handle(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +0100958};
959
960
Steve Block1e0659c2011-05-24 12:43:12 +0100961class LBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100962 public:
963 explicit LBranch(LOperand* value) {
964 inputs_[0] = value;
965 }
966
967 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
968 DECLARE_HYDROGEN_ACCESSOR(Value)
969
970 virtual void PrintDataTo(StringStream* stream);
971};
972
973
Steve Block1e0659c2011-05-24 12:43:12 +0100974class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100975 public:
976 explicit LCmpMapAndBranch(LOperand* value) {
977 inputs_[0] = value;
978 }
979
980 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
Steve Block1e0659c2011-05-24 12:43:12 +0100981 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
Ben Murdochb8e0da22011-05-16 14:20:40 +0100982
983 virtual bool IsControl() const { return true; }
984
985 Handle<Map> map() const { return hydrogen()->map(); }
986 int true_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100987 return hydrogen()->FirstSuccessor()->block_id();
Ben Murdochb8e0da22011-05-16 14:20:40 +0100988 }
989 int false_block_id() const {
Steve Block1e0659c2011-05-24 12:43:12 +0100990 return hydrogen()->SecondSuccessor()->block_id();
Ben Murdochb8e0da22011-05-16 14:20:40 +0100991 }
992};
993
994
Steve Block1e0659c2011-05-24 12:43:12 +0100995class LJSArrayLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +0100996 public:
997 explicit LJSArrayLength(LOperand* value) {
998 inputs_[0] = value;
999 }
1000
1001 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length")
1002 DECLARE_HYDROGEN_ACCESSOR(JSArrayLength)
1003};
1004
1005
Steve Block44f0eee2011-05-26 01:26:41 +01001006class LExternalArrayLength: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001007 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001008 explicit LExternalArrayLength(LOperand* value) {
Steve Block1e0659c2011-05-24 12:43:12 +01001009 inputs_[0] = value;
1010 }
1011
Steve Block44f0eee2011-05-26 01:26:41 +01001012 DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength, "external-array-length")
1013 DECLARE_HYDROGEN_ACCESSOR(ExternalArrayLength)
Steve Block1e0659c2011-05-24 12:43:12 +01001014};
1015
1016
1017class LFixedArrayLength: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001018 public:
1019 explicit LFixedArrayLength(LOperand* value) {
1020 inputs_[0] = value;
1021 }
1022
1023 DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength, "fixed-array-length")
1024 DECLARE_HYDROGEN_ACCESSOR(FixedArrayLength)
1025};
1026
1027
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001028class LValueOf: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001029 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001030 explicit LValueOf(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001031 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001032 }
1033
1034 DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of")
1035 DECLARE_HYDROGEN_ACCESSOR(ValueOf)
1036};
1037
1038
Steve Block1e0659c2011-05-24 12:43:12 +01001039class LThrow: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001040 public:
1041 explicit LThrow(LOperand* value) {
1042 inputs_[0] = value;
1043 }
1044
1045 DECLARE_CONCRETE_INSTRUCTION(Throw, "throw")
1046};
1047
1048
Steve Block1e0659c2011-05-24 12:43:12 +01001049class LBitNotI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001050 public:
1051 explicit LBitNotI(LOperand* value) {
1052 inputs_[0] = value;
1053 }
1054
1055 DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i")
1056};
1057
1058
Steve Block1e0659c2011-05-24 12:43:12 +01001059class LAddI: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001060 public:
1061 LAddI(LOperand* left, LOperand* right) {
1062 inputs_[0] = left;
1063 inputs_[1] = right;
1064 }
1065
1066 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1067 DECLARE_HYDROGEN_ACCESSOR(Add)
1068};
1069
1070
Steve Block1e0659c2011-05-24 12:43:12 +01001071class LPower: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001072 public:
1073 LPower(LOperand* left, LOperand* right) {
1074 inputs_[0] = left;
1075 inputs_[1] = right;
1076 }
1077
1078 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1079 DECLARE_HYDROGEN_ACCESSOR(Power)
1080};
1081
1082
Steve Block1e0659c2011-05-24 12:43:12 +01001083class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001084 public:
1085 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1086 : op_(op) {
1087 inputs_[0] = left;
1088 inputs_[1] = right;
1089 }
1090
1091 Token::Value op() const { return op_; }
1092
1093 virtual void CompileToNative(LCodeGen* generator);
1094 virtual const char* Mnemonic() const;
1095
1096 private:
1097 Token::Value op_;
1098};
1099
1100
Steve Block1e0659c2011-05-24 12:43:12 +01001101class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001102 public:
1103 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1104 : op_(op) {
1105 inputs_[0] = left;
1106 inputs_[1] = right;
1107 }
1108
1109 virtual void CompileToNative(LCodeGen* generator);
1110 virtual const char* Mnemonic() const;
1111
1112 Token::Value op() const { return op_; }
1113
1114 private:
1115 Token::Value op_;
1116};
1117
1118
Steve Block1e0659c2011-05-24 12:43:12 +01001119class LReturn: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001120 public:
1121 explicit LReturn(LOperand* value) {
1122 inputs_[0] = value;
1123 }
1124
1125 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1126};
1127
1128
Steve Block1e0659c2011-05-24 12:43:12 +01001129class LLoadNamedField: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001130 public:
1131 explicit LLoadNamedField(LOperand* object) {
1132 inputs_[0] = object;
1133 }
1134
1135 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1136 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1137};
1138
1139
Steve Block44f0eee2011-05-26 01:26:41 +01001140class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> {
1141 public:
1142 explicit LLoadNamedFieldPolymorphic(LOperand* object) {
1143 inputs_[0] = object;
1144 }
1145
1146 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic")
1147 DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic)
1148
1149 LOperand* object() { return inputs_[0]; }
1150};
1151
1152
Steve Block1e0659c2011-05-24 12:43:12 +01001153class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001154 public:
1155 explicit LLoadNamedGeneric(LOperand* object) {
1156 inputs_[0] = object;
1157 }
1158
1159 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1160 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1161
1162 LOperand* object() { return inputs_[0]; }
1163 Handle<Object> name() const { return hydrogen()->name(); }
1164};
1165
1166
Steve Block1e0659c2011-05-24 12:43:12 +01001167class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001168 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001169 explicit LLoadFunctionPrototype(LOperand* function) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001170 inputs_[0] = function;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001171 }
1172
1173 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1174 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1175
1176 LOperand* function() { return inputs_[0]; }
1177};
1178
1179
Steve Block1e0659c2011-05-24 12:43:12 +01001180class LLoadElements: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001181 public:
1182 explicit LLoadElements(LOperand* object) {
1183 inputs_[0] = object;
1184 }
1185
1186 DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements")
1187};
1188
1189
Steve Block44f0eee2011-05-26 01:26:41 +01001190class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001191 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001192 explicit LLoadExternalArrayPointer(LOperand* object) {
Steve Block1e0659c2011-05-24 12:43:12 +01001193 inputs_[0] = object;
1194 }
1195
Steve Block44f0eee2011-05-26 01:26:41 +01001196 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer,
1197 "load-external-array-pointer")
Steve Block1e0659c2011-05-24 12:43:12 +01001198};
1199
1200
1201class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001202 public:
1203 LLoadKeyedFastElement(LOperand* elements, LOperand* key) {
1204 inputs_[0] = elements;
1205 inputs_[1] = key;
1206 }
1207
1208 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element")
1209 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement)
1210
1211 LOperand* elements() { return inputs_[0]; }
1212 LOperand* key() { return inputs_[1]; }
1213};
1214
1215
Steve Block44f0eee2011-05-26 01:26:41 +01001216class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> {
Steve Block1e0659c2011-05-24 12:43:12 +01001217 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001218 LLoadKeyedSpecializedArrayElement(LOperand* external_pointer,
1219 LOperand* key) {
Steve Block1e0659c2011-05-24 12:43:12 +01001220 inputs_[0] = external_pointer;
1221 inputs_[1] = key;
1222 }
1223
Steve Block44f0eee2011-05-26 01:26:41 +01001224 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement,
1225 "load-keyed-specialized-array-element")
1226 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement)
Steve Block1e0659c2011-05-24 12:43:12 +01001227
1228 LOperand* external_pointer() { return inputs_[0]; }
1229 LOperand* key() { return inputs_[1]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001230 ExternalArrayType array_type() const {
1231 return hydrogen()->array_type();
1232 }
Steve Block1e0659c2011-05-24 12:43:12 +01001233};
1234
1235
1236class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001237 public:
1238 LLoadKeyedGeneric(LOperand* obj, LOperand* key) {
1239 inputs_[0] = obj;
1240 inputs_[1] = key;
1241 }
1242
1243 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1244
1245 LOperand* object() { return inputs_[0]; }
1246 LOperand* key() { return inputs_[1]; }
1247};
1248
1249
Ben Murdoch8b112d22011-06-08 16:22:53 +01001250class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001251 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001252 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1253 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001254};
1255
1256
Ben Murdoch8b112d22011-06-08 16:22:53 +01001257class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001258 public:
Ben Murdoch8b112d22011-06-08 16:22:53 +01001259 explicit LLoadGlobalGeneric(LOperand* global_object) {
1260 inputs_[0] = global_object;
1261 }
1262
1263 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1264 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1265
1266 LOperand* global_object() { return inputs_[0]; }
1267 Handle<Object> name() const { return hydrogen()->name(); }
1268 bool for_typeof() const { return hydrogen()->for_typeof(); }
1269};
1270
1271
1272class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> {
1273 public:
1274 explicit LStoreGlobalCell(LOperand* value, LOperand* temp) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001275 inputs_[0] = value;
Steve Block1e0659c2011-05-24 12:43:12 +01001276 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001277 }
1278
Ben Murdoch8b112d22011-06-08 16:22:53 +01001279 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1280 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1281};
1282
1283
1284class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> {
1285 public:
1286 explicit LStoreGlobalGeneric(LOperand* global_object,
1287 LOperand* value) {
1288 inputs_[0] = global_object;
1289 inputs_[1] = value;
1290 }
1291
1292 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic")
1293 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric)
1294
1295 LOperand* global_object() { return InputAt(0); }
1296 Handle<Object> name() const { return hydrogen()->name(); }
1297 LOperand* value() { return InputAt(1); }
1298 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001299};
1300
1301
Steve Block1e0659c2011-05-24 12:43:12 +01001302class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001303 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001304 explicit LLoadContextSlot(LOperand* context) {
1305 inputs_[0] = context;
1306 }
1307
Ben Murdochb8e0da22011-05-16 14:20:40 +01001308 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1309 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1310
Steve Block1e0659c2011-05-24 12:43:12 +01001311 LOperand* context() { return InputAt(0); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001312 int slot_index() { return hydrogen()->slot_index(); }
1313
1314 virtual void PrintDataTo(StringStream* stream);
1315};
1316
1317
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001318class LStoreContextSlot: public LTemplateInstruction<0, 2, 1> {
1319 public:
1320 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1321 inputs_[0] = context;
1322 inputs_[1] = value;
1323 temps_[0] = temp;
1324 }
1325
1326 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1327 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1328
1329 LOperand* context() { return InputAt(0); }
1330 LOperand* value() { return InputAt(1); }
1331 int slot_index() { return hydrogen()->slot_index(); }
1332 int needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1333
1334 virtual void PrintDataTo(StringStream* stream);
1335};
1336
1337
Steve Block1e0659c2011-05-24 12:43:12 +01001338class LPushArgument: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001339 public:
1340 explicit LPushArgument(LOperand* value) {
1341 inputs_[0] = value;
1342 }
1343
1344 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1345};
1346
1347
Steve Block1e0659c2011-05-24 12:43:12 +01001348class LContext: public LTemplateInstruction<1, 0, 0> {
1349 public:
1350 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1351};
1352
1353
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001354class LOuterContext: public LTemplateInstruction<1, 1, 0> {
1355 public:
1356 explicit LOuterContext(LOperand* context) {
1357 inputs_[0] = context;
1358 }
1359
1360 DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context")
1361
1362 LOperand* context() { return InputAt(0); }
1363};
1364
1365
Ben Murdochb8e0da22011-05-16 14:20:40 +01001366class LGlobalObject: public LTemplateInstruction<1, 0, 0> {
1367 public:
1368 DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object")
1369};
1370
1371
Steve Block44f0eee2011-05-26 01:26:41 +01001372class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001373 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001374 explicit LGlobalReceiver(LOperand* global_object) {
1375 inputs_[0] = global_object;
1376 }
1377
Ben Murdochb8e0da22011-05-16 14:20:40 +01001378 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
Steve Block44f0eee2011-05-26 01:26:41 +01001379
1380 LOperand* global() { return InputAt(0); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001381};
1382
1383
1384class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> {
1385 public:
1386 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function")
1387 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction)
1388
1389 virtual void PrintDataTo(StringStream* stream);
1390
1391 Handle<JSFunction> function() { return hydrogen()->function(); }
1392 int arity() const { return hydrogen()->argument_count() - 1; }
1393};
1394
1395
Steve Block1e0659c2011-05-24 12:43:12 +01001396class LCallKeyed: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001397 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001398 explicit LCallKeyed(LOperand* key) {
1399 inputs_[0] = key;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001400 }
1401
1402 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1403 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1404
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001405 LOperand* key() { return inputs_[0]; }
1406
Ben Murdochb8e0da22011-05-16 14:20:40 +01001407 virtual void PrintDataTo(StringStream* stream);
1408
1409 int arity() const { return hydrogen()->argument_count() - 1; }
1410};
1411
1412
1413class LCallNamed: public LTemplateInstruction<1, 0, 0> {
1414 public:
1415 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1416 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1417
1418 virtual void PrintDataTo(StringStream* stream);
1419
1420 Handle<String> name() const { return hydrogen()->name(); }
1421 int arity() const { return hydrogen()->argument_count() - 1; }
1422};
1423
1424
1425class LCallFunction: public LTemplateInstruction<1, 0, 0> {
1426 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001427 LCallFunction() {}
1428
Ben Murdochb8e0da22011-05-16 14:20:40 +01001429 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1430 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1431
1432 int arity() const { return hydrogen()->argument_count() - 2; }
1433};
1434
1435
1436class LCallGlobal: public LTemplateInstruction<1, 0, 0> {
1437 public:
1438 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1439 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1440
1441 virtual void PrintDataTo(StringStream* stream);
1442
1443 Handle<String> name() const {return hydrogen()->name(); }
1444 int arity() const { return hydrogen()->argument_count() - 1; }
1445};
1446
1447
1448class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> {
1449 public:
1450 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1451 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1452
1453 virtual void PrintDataTo(StringStream* stream);
1454
1455 Handle<JSFunction> target() const { return hydrogen()->target(); }
1456 int arity() const { return hydrogen()->argument_count() - 1; }
1457};
1458
1459
Steve Block1e0659c2011-05-24 12:43:12 +01001460class LCallNew: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001461 public:
1462 explicit LCallNew(LOperand* constructor) {
1463 inputs_[0] = constructor;
1464 }
1465
1466 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1467 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1468
1469 virtual void PrintDataTo(StringStream* stream);
1470
1471 int arity() const { return hydrogen()->argument_count() - 1; }
1472};
1473
1474
1475class LCallRuntime: public LTemplateInstruction<1, 0, 0> {
1476 public:
1477 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1478 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1479
Steve Block44f0eee2011-05-26 01:26:41 +01001480 const Runtime::Function* function() const { return hydrogen()->function(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001481 int arity() const { return hydrogen()->argument_count(); }
1482};
1483
1484
Steve Block1e0659c2011-05-24 12:43:12 +01001485class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001486 public:
1487 explicit LInteger32ToDouble(LOperand* value) {
1488 inputs_[0] = value;
1489 }
1490
1491 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1492};
1493
1494
Steve Block1e0659c2011-05-24 12:43:12 +01001495class LNumberTagI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001496 public:
1497 explicit LNumberTagI(LOperand* value) {
1498 inputs_[0] = value;
1499 }
1500
1501 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1502};
1503
1504
1505class LNumberTagD: public LTemplateInstruction<1, 1, 1> {
1506 public:
1507 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1508 inputs_[0] = value;
1509 temps_[0] = temp;
1510 }
1511
1512 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1513};
1514
1515
1516// Sometimes truncating conversion from a tagged value to an int32.
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001517class LDoubleToI: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001518 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001519 explicit LDoubleToI(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001520 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001521 }
1522
1523 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1524 DECLARE_HYDROGEN_ACCESSOR(Change)
1525
1526 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1527};
1528
1529
1530// Truncating conversion from a tagged value to an int32.
1531class LTaggedToI: public LTemplateInstruction<1, 1, 1> {
1532 public:
1533 LTaggedToI(LOperand* value, LOperand* temp) {
1534 inputs_[0] = value;
1535 temps_[0] = temp;
1536 }
1537
1538 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1539 DECLARE_HYDROGEN_ACCESSOR(Change)
1540
1541 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1542};
1543
1544
Steve Block1e0659c2011-05-24 12:43:12 +01001545class LSmiTag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001546 public:
1547 explicit LSmiTag(LOperand* value) {
1548 inputs_[0] = value;
1549 }
1550
1551 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1552};
1553
1554
Steve Block1e0659c2011-05-24 12:43:12 +01001555class LNumberUntagD: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001556 public:
1557 explicit LNumberUntagD(LOperand* value) {
1558 inputs_[0] = value;
1559 }
1560
1561 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
Ben Murdoch7d3e7fc2011-07-12 16:37:06 +01001562 DECLARE_HYDROGEN_ACCESSOR(Change);
Ben Murdochb8e0da22011-05-16 14:20:40 +01001563};
1564
1565
Steve Block1e0659c2011-05-24 12:43:12 +01001566class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001567 public:
1568 LSmiUntag(LOperand* value, bool needs_check)
1569 : needs_check_(needs_check) {
1570 inputs_[0] = value;
1571 }
1572
1573 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1574
1575 bool needs_check() const { return needs_check_; }
1576
1577 private:
1578 bool needs_check_;
1579};
1580
1581
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001582class LStoreNamedField: public LTemplateInstruction<0, 2, 1> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001583 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001584 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
1585 inputs_[0] = object;
1586 inputs_[1] = value;
1587 temps_[0] = temp;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001588 }
1589
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001590 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1591 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1592
1593 virtual void PrintDataTo(StringStream* stream);
1594
1595 LOperand* object() { return inputs_[0]; }
1596 LOperand* value() { return inputs_[1]; }
1597
1598 Handle<Object> name() const { return hydrogen()->name(); }
1599 bool is_in_object() { return hydrogen()->is_in_object(); }
1600 int offset() { return hydrogen()->offset(); }
1601 bool needs_write_barrier() { return hydrogen()->NeedsWriteBarrier(); }
1602 Handle<Map> transition() const { return hydrogen()->transition(); }
1603};
1604
1605
1606class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> {
1607 public:
1608 LStoreNamedGeneric(LOperand* object, LOperand* value) {
1609 inputs_[0] = object;
1610 inputs_[1] = value;
1611 }
1612
1613 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1614 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001615
1616 virtual void PrintDataTo(StringStream* stream);
1617
1618 LOperand* object() { return inputs_[0]; }
1619 LOperand* value() { return inputs_[1]; }
1620 Handle<Object> name() const { return hydrogen()->name(); }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001621 bool strict_mode() { return hydrogen()->strict_mode(); }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001622};
1623
1624
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001625class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001626 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001627 LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001628 inputs_[0] = obj;
1629 inputs_[1] = key;
1630 inputs_[2] = val;
1631 }
1632
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001633 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement,
1634 "store-keyed-fast-element")
1635 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement)
Ben Murdochb8e0da22011-05-16 14:20:40 +01001636
1637 virtual void PrintDataTo(StringStream* stream);
1638
1639 LOperand* object() { return inputs_[0]; }
1640 LOperand* key() { return inputs_[1]; }
1641 LOperand* value() { return inputs_[2]; }
1642};
1643
1644
Steve Block44f0eee2011-05-26 01:26:41 +01001645class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001646 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001647 LStoreKeyedSpecializedArrayElement(LOperand* external_pointer,
1648 LOperand* key,
1649 LOperand* val) {
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001650 inputs_[0] = external_pointer;
1651 inputs_[1] = key;
1652 inputs_[2] = val;
1653 }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001654
Steve Block44f0eee2011-05-26 01:26:41 +01001655 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement,
1656 "store-keyed-specialized-array-element")
1657 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement)
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001658
1659 LOperand* external_pointer() { return inputs_[0]; }
1660 LOperand* key() { return inputs_[1]; }
1661 LOperand* value() { return inputs_[2]; }
Steve Block44f0eee2011-05-26 01:26:41 +01001662 ExternalArrayType array_type() const {
1663 return hydrogen()->array_type();
1664 }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001665};
1666
1667
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001668class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001669 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001670 LStoreKeyedGeneric(LOperand* object, LOperand* key, LOperand* value) {
1671 inputs_[0] = object;
1672 inputs_[1] = key;
1673 inputs_[2] = value;
1674 }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001675
1676 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
Ben Murdoch8b112d22011-06-08 16:22:53 +01001677 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001678
1679 virtual void PrintDataTo(StringStream* stream);
1680
1681 LOperand* object() { return inputs_[0]; }
1682 LOperand* key() { return inputs_[1]; }
1683 LOperand* value() { return inputs_[2]; }
Ben Murdoch8b112d22011-06-08 16:22:53 +01001684 bool strict_mode() { return hydrogen()->strict_mode(); }
1685};
1686
1687
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001688class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> {
1689 public:
1690 LStringCharCodeAt(LOperand* string, LOperand* index) {
1691 inputs_[0] = string;
1692 inputs_[1] = index;
1693 }
1694
1695 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
1696 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
1697
1698 LOperand* string() { return inputs_[0]; }
1699 LOperand* index() { return inputs_[1]; }
1700};
1701
1702
Steve Block44f0eee2011-05-26 01:26:41 +01001703class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> {
1704 public:
1705 explicit LStringCharFromCode(LOperand* char_code) {
1706 inputs_[0] = char_code;
1707 }
1708
1709 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
1710 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
1711
1712 LOperand* char_code() { return inputs_[0]; }
1713};
1714
1715
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001716class LStringLength: public LTemplateInstruction<1, 1, 0> {
1717 public:
1718 explicit LStringLength(LOperand* string) {
1719 inputs_[0] = string;
1720 }
1721
1722 DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length")
1723 DECLARE_HYDROGEN_ACCESSOR(StringLength)
1724
1725 LOperand* string() { return inputs_[0]; }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001726};
1727
1728
Steve Block1e0659c2011-05-24 12:43:12 +01001729class LCheckFunction: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001730 public:
1731 explicit LCheckFunction(LOperand* value) {
1732 inputs_[0] = value;
1733 }
1734
1735 DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function")
1736 DECLARE_HYDROGEN_ACCESSOR(CheckFunction)
1737};
1738
1739
Steve Block1e0659c2011-05-24 12:43:12 +01001740class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001741 public:
Steve Block1e0659c2011-05-24 12:43:12 +01001742 explicit LCheckInstanceType(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001743 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001744 }
1745
1746 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
1747 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
1748};
1749
1750
Steve Block1e0659c2011-05-24 12:43:12 +01001751class LCheckMap: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001752 public:
1753 explicit LCheckMap(LOperand* value) {
1754 inputs_[0] = value;
1755 }
1756
1757 DECLARE_CONCRETE_INSTRUCTION(CheckMap, "check-map")
1758 DECLARE_HYDROGEN_ACCESSOR(CheckMap)
1759};
1760
1761
1762class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 1> {
1763 public:
1764 explicit LCheckPrototypeMaps(LOperand* temp) {
1765 temps_[0] = temp;
1766 }
1767
1768 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps")
1769 DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps)
1770
1771 Handle<JSObject> prototype() const { return hydrogen()->prototype(); }
1772 Handle<JSObject> holder() const { return hydrogen()->holder(); }
1773};
1774
1775
Steve Block1e0659c2011-05-24 12:43:12 +01001776class LCheckSmi: public LTemplateInstruction<0, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001777 public:
Steve Block44f0eee2011-05-26 01:26:41 +01001778 explicit LCheckSmi(LOperand* value) {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001779 inputs_[0] = value;
1780 }
1781
Steve Block44f0eee2011-05-26 01:26:41 +01001782 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
1783};
Ben Murdochb8e0da22011-05-16 14:20:40 +01001784
Steve Block44f0eee2011-05-26 01:26:41 +01001785
1786class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> {
1787 public:
1788 explicit LCheckNonSmi(LOperand* value) {
1789 inputs_[0] = value;
Ben Murdochb8e0da22011-05-16 14:20:40 +01001790 }
1791
Steve Block44f0eee2011-05-26 01:26:41 +01001792 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
Ben Murdochb8e0da22011-05-16 14:20:40 +01001793};
1794
1795
1796class LArrayLiteral: public LTemplateInstruction<1, 0, 0> {
1797 public:
1798 DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal")
1799 DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral)
1800};
1801
1802
1803class LObjectLiteral: public LTemplateInstruction<1, 0, 0> {
1804 public:
1805 DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal")
1806 DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral)
1807};
1808
1809
1810class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> {
1811 public:
1812 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
1813 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
1814};
1815
1816
1817class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> {
1818 public:
1819 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
1820 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
1821
1822 Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); }
1823};
1824
1825
Steve Block44f0eee2011-05-26 01:26:41 +01001826class LToFastProperties: public LTemplateInstruction<1, 1, 0> {
1827 public:
1828 explicit LToFastProperties(LOperand* value) {
1829 inputs_[0] = value;
1830 }
1831
1832 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
1833 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
1834};
1835
1836
Steve Block1e0659c2011-05-24 12:43:12 +01001837class LTypeof: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001838 public:
1839 explicit LTypeof(LOperand* value) {
1840 inputs_[0] = value;
1841 }
1842
1843 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
1844};
1845
1846
Steve Block1e0659c2011-05-24 12:43:12 +01001847class LTypeofIs: public LTemplateInstruction<1, 1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001848 public:
1849 explicit LTypeofIs(LOperand* value) {
1850 inputs_[0] = value;
1851 }
1852
1853 DECLARE_CONCRETE_INSTRUCTION(TypeofIs, "typeof-is")
1854 DECLARE_HYDROGEN_ACCESSOR(TypeofIs)
1855
1856 Handle<String> type_literal() { return hydrogen()->type_literal(); }
1857
1858 virtual void PrintDataTo(StringStream* stream);
1859};
1860
1861
Steve Block1e0659c2011-05-24 12:43:12 +01001862class LTypeofIsAndBranch: public LControlInstruction<1, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001863 public:
1864 explicit LTypeofIsAndBranch(LOperand* value) {
1865 inputs_[0] = value;
1866 }
1867
1868 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
1869 DECLARE_HYDROGEN_ACCESSOR(TypeofIs)
1870
1871 Handle<String> type_literal() { return hydrogen()->type_literal(); }
1872
1873 virtual void PrintDataTo(StringStream* stream);
1874};
1875
1876
Steve Block1e0659c2011-05-24 12:43:12 +01001877class LIsConstructCall: public LTemplateInstruction<1, 0, 0> {
1878 public:
1879 DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is-construct-call")
1880 DECLARE_HYDROGEN_ACCESSOR(IsConstructCall)
1881};
1882
1883
1884class LIsConstructCallAndBranch: public LControlInstruction<0, 1> {
1885 public:
1886 explicit LIsConstructCallAndBranch(LOperand* temp) {
1887 temps_[0] = temp;
1888 }
1889
1890 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1891 "is-construct-call-and-branch")
1892};
1893
1894
1895class LDeleteProperty: public LTemplateInstruction<1, 2, 0> {
Ben Murdochb8e0da22011-05-16 14:20:40 +01001896 public:
1897 LDeleteProperty(LOperand* obj, LOperand* key) {
1898 inputs_[0] = obj;
1899 inputs_[1] = key;
1900 }
1901
1902 DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property")
1903
1904 LOperand* object() { return inputs_[0]; }
1905 LOperand* key() { return inputs_[1]; }
1906};
1907
1908
1909class LOsrEntry: public LTemplateInstruction<0, 0, 0> {
1910 public:
1911 LOsrEntry();
1912
1913 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
1914
1915 LOperand** SpilledRegisterArray() { return register_spills_; }
1916 LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; }
1917
1918 void MarkSpilledRegister(int allocation_index, LOperand* spill_operand);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001919 void MarkSpilledDoubleRegister(int allocation_index,
Ben Murdochb8e0da22011-05-16 14:20:40 +01001920 LOperand* spill_operand);
Ben Murdoch086aeea2011-05-13 15:57:08 +01001921
1922 private:
1923 // Arrays of spill slot operands for registers with an assigned spill
1924 // slot, i.e., that must also be restored to the spill slot on OSR entry.
1925 // NULL if the register has no assigned spill slot. Indexed by allocation
1926 // index.
1927 LOperand* register_spills_[Register::kNumAllocatableRegisters];
1928 LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters];
Ben Murdochb0fe1622011-05-05 13:52:32 +01001929};
1930
1931
Ben Murdochb8e0da22011-05-16 14:20:40 +01001932class LStackCheck: public LTemplateInstruction<0, 0, 0> {
Ben Murdochb0fe1622011-05-05 13:52:32 +01001933 public:
Ben Murdochb8e0da22011-05-16 14:20:40 +01001934 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
Ben Murdoch086aeea2011-05-13 15:57:08 +01001935};
1936
1937
1938class LChunkBuilder;
1939class LChunk: public ZoneObject {
1940 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001941 explicit LChunk(CompilationInfo* info, HGraph* graph)
Ben Murdoch086aeea2011-05-13 15:57:08 +01001942 : spill_slot_count_(0),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001943 info_(info),
Ben Murdoch086aeea2011-05-13 15:57:08 +01001944 graph_(graph),
1945 instructions_(32),
1946 pointer_maps_(8),
1947 inlined_closures_(1) { }
1948
Steve Block1e0659c2011-05-24 12:43:12 +01001949 void AddInstruction(LInstruction* instruction, HBasicBlock* block);
Ben Murdochb8e0da22011-05-16 14:20:40 +01001950 LConstantOperand* DefineConstantOperand(HConstant* constant);
1951 Handle<Object> LookupLiteral(LConstantOperand* operand) const;
1952 Representation LookupLiteralRepresentation(LConstantOperand* operand) const;
1953
1954 int GetNextSpillIndex(bool is_double);
1955 LOperand* GetNextSpillSlot(bool is_double);
1956
1957 int ParameterAt(int index);
1958 int GetParameterStackSlot(int index) const;
Ben Murdoch086aeea2011-05-13 15:57:08 +01001959 int spill_slot_count() const { return spill_slot_count_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001960 CompilationInfo* info() const { return info_; }
Ben Murdoch086aeea2011-05-13 15:57:08 +01001961 HGraph* graph() const { return graph_; }
1962 const ZoneList<LInstruction*>* instructions() const { return &instructions_; }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001963 void AddGapMove(int index, LOperand* from, LOperand* to);
1964 LGap* GetGapAt(int index) const;
1965 bool IsGapAt(int index) const;
1966 int NearestGapPos(int index) const;
1967 void MarkEmptyBlocks();
Ben Murdoch086aeea2011-05-13 15:57:08 +01001968 const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; }
Ben Murdochb8e0da22011-05-16 14:20:40 +01001969 LLabel* GetLabel(int block_id) const {
1970 HBasicBlock* block = graph_->blocks()->at(block_id);
1971 int first_instruction = block->first_instruction_index();
1972 return LLabel::cast(instructions_[first_instruction]);
1973 }
1974 int LookupDestination(int block_id) const {
1975 LLabel* cur = GetLabel(block_id);
1976 while (cur->replacement() != NULL) {
1977 cur = cur->replacement();
1978 }
1979 return cur->block_id();
1980 }
1981 Label* GetAssemblyLabel(int block_id) const {
1982 LLabel* label = GetLabel(block_id);
1983 ASSERT(!label->HasReplacement());
1984 return label->label();
1985 }
1986
Ben Murdoch086aeea2011-05-13 15:57:08 +01001987 const ZoneList<Handle<JSFunction> >* inlined_closures() const {
1988 return &inlined_closures_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01001989 }
1990
Ben Murdochb8e0da22011-05-16 14:20:40 +01001991 void AddInlinedClosure(Handle<JSFunction> closure) {
1992 inlined_closures_.Add(closure);
Ben Murdochb0fe1622011-05-05 13:52:32 +01001993 }
1994
Ben Murdoch086aeea2011-05-13 15:57:08 +01001995 private:
1996 int spill_slot_count_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01001997 CompilationInfo* info_;
Ben Murdoch086aeea2011-05-13 15:57:08 +01001998 HGraph* const graph_;
1999 ZoneList<LInstruction*> instructions_;
2000 ZoneList<LPointerMap*> pointer_maps_;
2001 ZoneList<Handle<JSFunction> > inlined_closures_;
Ben Murdochb0fe1622011-05-05 13:52:32 +01002002};
2003
2004
2005class LChunkBuilder BASE_EMBEDDED {
2006 public:
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002007 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
Ben Murdoch086aeea2011-05-13 15:57:08 +01002008 : chunk_(NULL),
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002009 info_(info),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002010 graph_(graph),
2011 status_(UNUSED),
2012 current_instruction_(NULL),
2013 current_block_(NULL),
2014 next_block_(NULL),
2015 argument_count_(0),
2016 allocator_(allocator),
2017 position_(RelocInfo::kNoPosition),
Steve Block1e0659c2011-05-24 12:43:12 +01002018 instruction_pending_deoptimization_environment_(NULL),
Ben Murdoch086aeea2011-05-13 15:57:08 +01002019 pending_deoptimization_ast_id_(AstNode::kNoNumber) { }
Ben Murdochb0fe1622011-05-05 13:52:32 +01002020
2021 // Build the sequence for the graph.
Ben Murdoch086aeea2011-05-13 15:57:08 +01002022 LChunk* Build();
Ben Murdochb0fe1622011-05-05 13:52:32 +01002023
2024 // Declare methods that deal with the individual node types.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002025#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
Ben Murdochb0fe1622011-05-05 13:52:32 +01002026 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2027#undef DECLARE_DO
2028
Ben Murdoch086aeea2011-05-13 15:57:08 +01002029 private:
2030 enum Status {
2031 UNUSED,
2032 BUILDING,
2033 DONE,
2034 ABORTED
2035 };
2036
2037 LChunk* chunk() const { return chunk_; }
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002038 CompilationInfo* info() const { return info_; }
Ben Murdoch086aeea2011-05-13 15:57:08 +01002039 HGraph* graph() const { return graph_; }
2040
2041 bool is_unused() const { return status_ == UNUSED; }
2042 bool is_building() const { return status_ == BUILDING; }
2043 bool is_done() const { return status_ == DONE; }
2044 bool is_aborted() const { return status_ == ABORTED; }
2045
2046 void Abort(const char* format, ...);
2047
Ben Murdochb8e0da22011-05-16 14:20:40 +01002048 // Methods for getting operands for Use / Define / Temp.
2049 LRegister* ToOperand(Register reg);
2050 LUnallocated* ToUnallocated(Register reg);
2051 LUnallocated* ToUnallocated(XMMRegister reg);
2052
2053 // Methods for setting up define-use relationships.
2054 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2055 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2056 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2057 XMMRegister fixed_register);
2058
2059 // A value that is guaranteed to be allocated to a register.
2060 // Operand created by UseRegister is guaranteed to be live until the end of
2061 // instruction. This means that register allocator will not reuse it's
2062 // register for any other operand inside instruction.
2063 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2064 // instruction start. Register allocator is free to assign the same register
2065 // to some other operand used inside instruction (i.e. temporary or
2066 // output).
2067 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2068 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2069
Steve Block1e0659c2011-05-24 12:43:12 +01002070 // An input operand in a register that may be trashed.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002071 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2072
Steve Block1e0659c2011-05-24 12:43:12 +01002073 // An input operand in a register or stack slot.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002074 MUST_USE_RESULT LOperand* Use(HValue* value);
2075 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2076
Steve Block1e0659c2011-05-24 12:43:12 +01002077 // An input operand in a register, stack slot or a constant operand.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002078 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2079 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2080
Steve Block1e0659c2011-05-24 12:43:12 +01002081 // An input operand in a register or a constant operand.
Ben Murdochb8e0da22011-05-16 14:20:40 +01002082 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2083 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2084
Steve Block1e0659c2011-05-24 12:43:12 +01002085 // An input operand in register, stack slot or a constant operand.
2086 // Will not be moved to a register even if one is freely available.
2087 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2088
Ben Murdochb8e0da22011-05-16 14:20:40 +01002089 // Temporary operand that must be in a register.
2090 MUST_USE_RESULT LUnallocated* TempRegister();
2091 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2092 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2093
Ben Murdochb8e0da22011-05-16 14:20:40 +01002094 // Methods for setting up define-use relationships.
2095 // Return the same instruction that they are passed.
2096 template<int I, int T>
2097 LInstruction* Define(LTemplateInstruction<1, I, T>* instr,
2098 LUnallocated* result);
2099 template<int I, int T>
2100 LInstruction* Define(LTemplateInstruction<1, I, T>* instr);
2101 template<int I, int T>
2102 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr);
2103 template<int I, int T>
2104 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr,
2105 int index);
2106 template<int I, int T>
2107 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr);
2108 template<int I, int T>
2109 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2110 Register reg);
2111 template<int I, int T>
2112 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2113 XMMRegister reg);
2114 LInstruction* AssignEnvironment(LInstruction* instr);
2115 LInstruction* AssignPointerMap(LInstruction* instr);
2116
2117 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2118
2119 // By default we assume that instruction sequences generated for calls
2120 // cannot deoptimize eagerly and we do not attach environment to this
2121 // instruction.
2122 LInstruction* MarkAsCall(
2123 LInstruction* instr,
2124 HInstruction* hinstr,
2125 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2126 LInstruction* MarkAsSaveDoubles(LInstruction* instr);
2127
2128 LInstruction* SetInstructionPendingDeoptimizationEnvironment(
2129 LInstruction* instr, int ast_id);
2130 void ClearInstructionPendingDeoptimizationEnvironment();
2131
2132 LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env);
2133
2134 void VisitInstruction(HInstruction* current);
2135
Ben Murdoch086aeea2011-05-13 15:57:08 +01002136 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
Ben Murdochb8e0da22011-05-16 14:20:40 +01002137 LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr);
2138 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2139 LInstruction* DoArithmeticD(Token::Value op,
2140 HArithmeticBinaryOperation* instr);
2141 LInstruction* DoArithmeticT(Token::Value op,
2142 HArithmeticBinaryOperation* instr);
Ben Murdoch086aeea2011-05-13 15:57:08 +01002143
2144 LChunk* chunk_;
Ben Murdoche0cee9b2011-05-25 10:26:03 +01002145 CompilationInfo* info_;
Ben Murdoch086aeea2011-05-13 15:57:08 +01002146 HGraph* const graph_;
2147 Status status_;
2148 HInstruction* current_instruction_;
2149 HBasicBlock* current_block_;
2150 HBasicBlock* next_block_;
2151 int argument_count_;
2152 LAllocator* allocator_;
2153 int position_;
Steve Block1e0659c2011-05-24 12:43:12 +01002154 LInstruction* instruction_pending_deoptimization_environment_;
Ben Murdoch086aeea2011-05-13 15:57:08 +01002155 int pending_deoptimization_ast_id_;
2156
Ben Murdochb0fe1622011-05-05 13:52:32 +01002157 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2158};
2159
Ben Murdochb8e0da22011-05-16 14:20:40 +01002160#undef DECLARE_HYDROGEN_ACCESSOR
2161#undef DECLARE_INSTRUCTION
2162#undef DECLARE_CONCRETE_INSTRUCTION
Ben Murdochb0fe1622011-05-05 13:52:32 +01002163
Ben Murdochb8e0da22011-05-16 14:20:40 +01002164} } // namespace v8::int
Ben Murdochb0fe1622011-05-05 13:52:32 +01002165
2166#endif // V8_X64_LITHIUM_X64_H_