blob: 5d27fcb7a335c837ff4e82dede31670da2a63659 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2012 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_X87_LITHIUM_X87_H_
6#define V8_X87_LITHIUM_X87_H_
7
8#include "src/hydrogen.h"
9#include "src/lithium.h"
10#include "src/lithium-allocator.h"
11#include "src/safepoint-table.h"
12#include "src/utils.h"
13
14namespace v8 {
15namespace internal {
16
17namespace compiler {
18class RCodeVisualizer;
19}
20
21// Forward declarations.
22class LCodeGen;
23
24#define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
25 V(AccessArgumentsAt) \
26 V(AddI) \
27 V(AllocateBlockContext) \
28 V(Allocate) \
29 V(ApplyArguments) \
30 V(ArgumentsElements) \
31 V(ArgumentsLength) \
32 V(ArithmeticD) \
33 V(ArithmeticT) \
34 V(BitI) \
35 V(BoundsCheck) \
36 V(Branch) \
37 V(CallJSFunction) \
38 V(CallWithDescriptor) \
39 V(CallFunction) \
40 V(CallNew) \
41 V(CallNewArray) \
42 V(CallRuntime) \
43 V(CallStub) \
44 V(CheckInstanceType) \
45 V(CheckMaps) \
46 V(CheckMapValue) \
47 V(CheckNonSmi) \
48 V(CheckSmi) \
49 V(CheckValue) \
50 V(ClampDToUint8) \
51 V(ClampIToUint8) \
52 V(ClampTToUint8NoSSE2) \
53 V(ClassOfTestAndBranch) \
54 V(ClobberDoubles) \
55 V(CompareMinusZeroAndBranch) \
56 V(CompareNumericAndBranch) \
57 V(CmpObjectEqAndBranch) \
58 V(CmpHoleAndBranch) \
59 V(CmpMapAndBranch) \
60 V(CmpT) \
61 V(ConstantD) \
62 V(ConstantE) \
63 V(ConstantI) \
64 V(ConstantS) \
65 V(ConstantT) \
66 V(ConstructDouble) \
67 V(Context) \
68 V(DateField) \
69 V(DebugBreak) \
70 V(DeclareGlobals) \
71 V(Deoptimize) \
72 V(DivByConstI) \
73 V(DivByPowerOf2I) \
74 V(DivI) \
75 V(DoubleBits) \
76 V(DoubleToI) \
77 V(DoubleToSmi) \
78 V(Drop) \
79 V(Dummy) \
80 V(DummyUse) \
81 V(FlooringDivByConstI) \
82 V(FlooringDivByPowerOf2I) \
83 V(FlooringDivI) \
84 V(ForInCacheArray) \
85 V(ForInPrepareMap) \
86 V(FunctionLiteral) \
87 V(GetCachedArrayIndex) \
88 V(Goto) \
89 V(HasCachedArrayIndexAndBranch) \
90 V(HasInstanceTypeAndBranch) \
91 V(InnerAllocatedObject) \
92 V(InstanceOf) \
93 V(InstanceOfKnownGlobal) \
94 V(InstructionGap) \
95 V(Integer32ToDouble) \
96 V(InvokeFunction) \
97 V(IsConstructCallAndBranch) \
98 V(IsObjectAndBranch) \
99 V(IsStringAndBranch) \
100 V(IsSmiAndBranch) \
101 V(IsUndetectableAndBranch) \
102 V(Label) \
103 V(LazyBailout) \
104 V(LoadContextSlot) \
105 V(LoadFieldByIndex) \
106 V(LoadFunctionPrototype) \
107 V(LoadGlobalCell) \
108 V(LoadGlobalGeneric) \
109 V(LoadKeyed) \
110 V(LoadKeyedGeneric) \
111 V(LoadNamedField) \
112 V(LoadNamedGeneric) \
113 V(LoadRoot) \
114 V(MapEnumLength) \
115 V(MathAbs) \
116 V(MathClz32) \
117 V(MathExp) \
118 V(MathFloor) \
119 V(MathFround) \
120 V(MathLog) \
121 V(MathMinMax) \
122 V(MathPowHalf) \
123 V(MathRound) \
124 V(MathSqrt) \
125 V(ModByConstI) \
126 V(ModByPowerOf2I) \
127 V(ModI) \
128 V(MulI) \
129 V(NumberTagD) \
130 V(NumberTagI) \
131 V(NumberTagU) \
132 V(NumberUntagD) \
133 V(OsrEntry) \
134 V(Parameter) \
135 V(Power) \
136 V(PushArgument) \
137 V(RegExpLiteral) \
138 V(Return) \
139 V(SeqStringGetChar) \
140 V(SeqStringSetChar) \
141 V(ShiftI) \
142 V(SmiTag) \
143 V(SmiUntag) \
144 V(StackCheck) \
145 V(StoreCodeEntry) \
146 V(StoreContextSlot) \
147 V(StoreFrameContext) \
148 V(StoreGlobalCell) \
149 V(StoreKeyed) \
150 V(StoreKeyedGeneric) \
151 V(StoreNamedField) \
152 V(StoreNamedGeneric) \
153 V(StringAdd) \
154 V(StringCharCodeAt) \
155 V(StringCharFromCode) \
156 V(StringCompareAndBranch) \
157 V(SubI) \
158 V(TaggedToI) \
159 V(TailCallThroughMegamorphicCache) \
160 V(ThisFunction) \
161 V(ToFastProperties) \
162 V(TransitionElementsKind) \
163 V(TrapAllocationMemento) \
164 V(Typeof) \
165 V(TypeofIsAndBranch) \
166 V(Uint32ToDouble) \
167 V(UnknownOSRValue) \
168 V(WrapReceiver)
169
170
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400171#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
172 Opcode opcode() const FINAL { return LInstruction::k##type; } \
173 void CompileToNative(LCodeGen* generator) FINAL; \
174 const char* Mnemonic() const FINAL { return mnemonic; } \
175 static L##type* cast(LInstruction* instr) { \
176 DCHECK(instr->Is##type()); \
177 return reinterpret_cast<L##type*>(instr); \
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000178 }
179
180
181#define DECLARE_HYDROGEN_ACCESSOR(type) \
182 H##type* hydrogen() const { \
183 return H##type::cast(hydrogen_value()); \
184 }
185
186
187class LInstruction : public ZoneObject {
188 public:
189 LInstruction()
190 : environment_(NULL),
191 hydrogen_value_(NULL),
192 bit_field_(IsCallBits::encode(false)) {
193 }
194
195 virtual ~LInstruction() {}
196
197 virtual void CompileToNative(LCodeGen* generator) = 0;
198 virtual const char* Mnemonic() const = 0;
199 virtual void PrintTo(StringStream* stream);
200 virtual void PrintDataTo(StringStream* stream);
201 virtual void PrintOutputOperandTo(StringStream* stream);
202
203 enum Opcode {
204 // Declare a unique enum value for each instruction.
205#define DECLARE_OPCODE(type) k##type,
206 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) kAdapter,
207 kNumberOfInstructions
208#undef DECLARE_OPCODE
209 };
210
211 virtual Opcode opcode() const = 0;
212
213 // Declare non-virtual type testers for all leaf IR classes.
214#define DECLARE_PREDICATE(type) \
215 bool Is##type() const { return opcode() == k##type; }
216 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
217#undef DECLARE_PREDICATE
218
219 // Declare virtual predicates for instructions that don't have
220 // an opcode.
221 virtual bool IsGap() const { return false; }
222
223 virtual bool IsControl() const { return false; }
224
225 // Try deleting this instruction if possible.
226 virtual bool TryDelete() { return false; }
227
228 void set_environment(LEnvironment* env) { environment_ = env; }
229 LEnvironment* environment() const { return environment_; }
230 bool HasEnvironment() const { return environment_ != NULL; }
231
232 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
233 LPointerMap* pointer_map() const { return pointer_map_.get(); }
234 bool HasPointerMap() const { return pointer_map_.is_set(); }
235
236 void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; }
237 HValue* hydrogen_value() const { return hydrogen_value_; }
238
239 virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { }
240
241 void MarkAsCall() { bit_field_ = IsCallBits::update(bit_field_, true); }
242 bool IsCall() const { return IsCallBits::decode(bit_field_); }
243
244 // Interface to the register allocator and iterators.
245 bool ClobbersTemps() const { return IsCall(); }
246 bool ClobbersRegisters() const { return IsCall(); }
247 virtual bool ClobbersDoubleRegisters(Isolate* isolate) const {
248 return IsCall() ||
249 // We only have rudimentary X87Stack tracking, thus in general
250 // cannot handle phi-nodes.
251 (IsControl());
252 }
253
254 virtual bool HasResult() const = 0;
255 virtual LOperand* result() const = 0;
256
257 bool HasDoubleRegisterResult();
258 bool HasDoubleRegisterInput();
259 bool IsDoubleInput(X87Register reg, LCodeGen* cgen);
260
261 LOperand* FirstInput() { return InputAt(0); }
262 LOperand* Output() { return HasResult() ? result() : NULL; }
263
264 virtual bool HasInterestingComment(LCodeGen* gen) const { return true; }
265
266#ifdef DEBUG
267 void VerifyCall();
268#endif
269
270 virtual int InputCount() = 0;
271 virtual LOperand* InputAt(int i) = 0;
272
273 private:
274 // Iterator support.
275 friend class InputIterator;
276
277 friend class TempIterator;
278 virtual int TempCount() = 0;
279 virtual LOperand* TempAt(int i) = 0;
280
281 class IsCallBits: public BitField<bool, 0, 1> {};
282
283 LEnvironment* environment_;
284 SetOncePointer<LPointerMap> pointer_map_;
285 HValue* hydrogen_value_;
286 int bit_field_;
287};
288
289
290// R = number of result operands (0 or 1).
291template<int R>
292class LTemplateResultInstruction : public LInstruction {
293 public:
294 // Allow 0 or 1 output operands.
295 STATIC_ASSERT(R == 0 || R == 1);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400296 bool HasResult() const FINAL { return R != 0 && result() != NULL; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000297 void set_result(LOperand* operand) { results_[0] = operand; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400298 LOperand* result() const OVERRIDE { return results_[0]; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000299
300 protected:
301 EmbeddedContainer<LOperand*, R> results_;
302};
303
304
305// R = number of result operands (0 or 1).
306// I = number of input operands.
307// T = number of temporary operands.
308template<int R, int I, int T>
309class LTemplateInstruction : public LTemplateResultInstruction<R> {
310 protected:
311 EmbeddedContainer<LOperand*, I> inputs_;
312 EmbeddedContainer<LOperand*, T> temps_;
313
314 private:
315 // Iterator support.
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400316 int InputCount() FINAL { return I; }
317 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000318
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400319 int TempCount() FINAL { return T; }
320 LOperand* TempAt(int i) FINAL { return temps_[i]; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000321};
322
323
324class LGap : public LTemplateInstruction<0, 0, 0> {
325 public:
326 explicit LGap(HBasicBlock* block) : block_(block) {
327 parallel_moves_[BEFORE] = NULL;
328 parallel_moves_[START] = NULL;
329 parallel_moves_[END] = NULL;
330 parallel_moves_[AFTER] = NULL;
331 }
332
333 // Can't use the DECLARE-macro here because of sub-classes.
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400334 bool IsGap() const FINAL { return true; }
335 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000336 static LGap* cast(LInstruction* instr) {
337 DCHECK(instr->IsGap());
338 return reinterpret_cast<LGap*>(instr);
339 }
340
341 bool IsRedundant() const;
342
343 HBasicBlock* block() const { return block_; }
344
345 enum InnerPosition {
346 BEFORE,
347 START,
348 END,
349 AFTER,
350 FIRST_INNER_POSITION = BEFORE,
351 LAST_INNER_POSITION = AFTER
352 };
353
354 LParallelMove* GetOrCreateParallelMove(InnerPosition pos, Zone* zone) {
355 if (parallel_moves_[pos] == NULL) {
356 parallel_moves_[pos] = new(zone) LParallelMove(zone);
357 }
358 return parallel_moves_[pos];
359 }
360
361 LParallelMove* GetParallelMove(InnerPosition pos) {
362 return parallel_moves_[pos];
363 }
364
365 private:
366 LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1];
367 HBasicBlock* block_;
368};
369
370
371class LInstructionGap FINAL : public LGap {
372 public:
373 explicit LInstructionGap(HBasicBlock* block) : LGap(block) { }
374
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400375 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000376 return !IsRedundant();
377 }
378
379 DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap")
380};
381
382
383class LClobberDoubles FINAL : public LTemplateInstruction<0, 0, 0> {
384 public:
385 explicit LClobberDoubles(Isolate* isolate) { }
386
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400387 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE { return true; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000388
389 DECLARE_CONCRETE_INSTRUCTION(ClobberDoubles, "clobber-d")
390};
391
392
393class LGoto FINAL : public LTemplateInstruction<0, 0, 0> {
394 public:
395 explicit LGoto(HBasicBlock* block) : block_(block) { }
396
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400397 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000398 DECLARE_CONCRETE_INSTRUCTION(Goto, "goto")
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400399 void PrintDataTo(StringStream* stream) OVERRIDE;
400 bool IsControl() const OVERRIDE { return true; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000401
402 int block_id() const { return block_->block_id(); }
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400403 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000404 return false;
405 }
406
407 bool jumps_to_join() const { return block_->predecessors()->length() > 1; }
408 HBasicBlock* block() const { return block_; }
409
410 private:
411 HBasicBlock* block_;
412};
413
414
415class LLazyBailout FINAL : public LTemplateInstruction<0, 0, 0> {
416 public:
417 DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout")
418};
419
420
421class LDummy FINAL : public LTemplateInstruction<1, 0, 0> {
422 public:
423 LDummy() {}
424 DECLARE_CONCRETE_INSTRUCTION(Dummy, "dummy")
425};
426
427
428class LDummyUse FINAL : public LTemplateInstruction<1, 1, 0> {
429 public:
430 explicit LDummyUse(LOperand* value) {
431 inputs_[0] = value;
432 }
433 DECLARE_CONCRETE_INSTRUCTION(DummyUse, "dummy-use")
434};
435
436
437class LDeoptimize FINAL : public LTemplateInstruction<0, 0, 0> {
438 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400439 bool IsControl() const OVERRIDE { return true; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000440 DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize")
441 DECLARE_HYDROGEN_ACCESSOR(Deoptimize)
442};
443
444
445class LLabel FINAL : public LGap {
446 public:
447 explicit LLabel(HBasicBlock* block)
448 : LGap(block), replacement_(NULL) { }
449
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400450 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000451 DECLARE_CONCRETE_INSTRUCTION(Label, "label")
452
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400453 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000454
455 int block_id() const { return block()->block_id(); }
456 bool is_loop_header() const { return block()->IsLoopHeader(); }
457 bool is_osr_entry() const { return block()->is_osr_entry(); }
458 Label* label() { return &label_; }
459 LLabel* replacement() const { return replacement_; }
460 void set_replacement(LLabel* label) { replacement_ = label; }
461 bool HasReplacement() const { return replacement_ != NULL; }
462
463 private:
464 Label label_;
465 LLabel* replacement_;
466};
467
468
469class LParameter FINAL : public LTemplateInstruction<1, 0, 0> {
470 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400471 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000472 DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter")
473};
474
475
476class LCallStub FINAL : public LTemplateInstruction<1, 1, 0> {
477 public:
478 explicit LCallStub(LOperand* context) {
479 inputs_[0] = context;
480 }
481
482 LOperand* context() { return inputs_[0]; }
483
484 DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub")
485 DECLARE_HYDROGEN_ACCESSOR(CallStub)
486};
487
488
489class LTailCallThroughMegamorphicCache FINAL
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400490 : public LTemplateInstruction<0, 5, 0> {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000491 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400492 LTailCallThroughMegamorphicCache(LOperand* context, LOperand* receiver,
493 LOperand* name, LOperand* slot,
494 LOperand* vector) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000495 inputs_[0] = context;
496 inputs_[1] = receiver;
497 inputs_[2] = name;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400498 inputs_[3] = slot;
499 inputs_[4] = vector;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000500 }
501
502 LOperand* context() { return inputs_[0]; }
503 LOperand* receiver() { return inputs_[1]; }
504 LOperand* name() { return inputs_[2]; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400505 LOperand* slot() { return inputs_[3]; }
506 LOperand* vector() { return inputs_[4]; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000507
508 DECLARE_CONCRETE_INSTRUCTION(TailCallThroughMegamorphicCache,
509 "tail-call-through-megamorphic-cache")
510 DECLARE_HYDROGEN_ACCESSOR(TailCallThroughMegamorphicCache)
511};
512
513
514class LUnknownOSRValue FINAL : public LTemplateInstruction<1, 0, 0> {
515 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400516 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000517 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
518};
519
520
521template<int I, int T>
522class LControlInstruction: public LTemplateInstruction<0, I, T> {
523 public:
524 LControlInstruction() : false_label_(NULL), true_label_(NULL) { }
525
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400526 bool IsControl() const FINAL { return true; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000527
528 int SuccessorCount() { return hydrogen()->SuccessorCount(); }
529 HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); }
530
531 int TrueDestination(LChunk* chunk) {
532 return chunk->LookupDestination(true_block_id());
533 }
534 int FalseDestination(LChunk* chunk) {
535 return chunk->LookupDestination(false_block_id());
536 }
537
538 Label* TrueLabel(LChunk* chunk) {
539 if (true_label_ == NULL) {
540 true_label_ = chunk->GetAssemblyLabel(TrueDestination(chunk));
541 }
542 return true_label_;
543 }
544 Label* FalseLabel(LChunk* chunk) {
545 if (false_label_ == NULL) {
546 false_label_ = chunk->GetAssemblyLabel(FalseDestination(chunk));
547 }
548 return false_label_;
549 }
550
551 protected:
552 int true_block_id() { return SuccessorAt(0)->block_id(); }
553 int false_block_id() { return SuccessorAt(1)->block_id(); }
554
555 private:
556 HControlInstruction* hydrogen() {
557 return HControlInstruction::cast(this->hydrogen_value());
558 }
559
560 Label* false_label_;
561 Label* true_label_;
562};
563
564
565class LWrapReceiver FINAL : public LTemplateInstruction<1, 2, 1> {
566 public:
567 LWrapReceiver(LOperand* receiver,
568 LOperand* function,
569 LOperand* temp) {
570 inputs_[0] = receiver;
571 inputs_[1] = function;
572 temps_[0] = temp;
573 }
574
575 LOperand* receiver() { return inputs_[0]; }
576 LOperand* function() { return inputs_[1]; }
577 LOperand* temp() { return temps_[0]; }
578
579 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver")
580 DECLARE_HYDROGEN_ACCESSOR(WrapReceiver)
581};
582
583
584class LApplyArguments FINAL : public LTemplateInstruction<1, 4, 0> {
585 public:
586 LApplyArguments(LOperand* function,
587 LOperand* receiver,
588 LOperand* length,
589 LOperand* elements) {
590 inputs_[0] = function;
591 inputs_[1] = receiver;
592 inputs_[2] = length;
593 inputs_[3] = elements;
594 }
595
596 LOperand* function() { return inputs_[0]; }
597 LOperand* receiver() { return inputs_[1]; }
598 LOperand* length() { return inputs_[2]; }
599 LOperand* elements() { return inputs_[3]; }
600
601 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments")
602};
603
604
605class LAccessArgumentsAt FINAL : public LTemplateInstruction<1, 3, 0> {
606 public:
607 LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) {
608 inputs_[0] = arguments;
609 inputs_[1] = length;
610 inputs_[2] = index;
611 }
612
613 LOperand* arguments() { return inputs_[0]; }
614 LOperand* length() { return inputs_[1]; }
615 LOperand* index() { return inputs_[2]; }
616
617 DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at")
618
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400619 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000620};
621
622
623class LArgumentsLength FINAL : public LTemplateInstruction<1, 1, 0> {
624 public:
625 explicit LArgumentsLength(LOperand* elements) {
626 inputs_[0] = elements;
627 }
628
629 LOperand* elements() { return inputs_[0]; }
630
631 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length")
632};
633
634
635class LArgumentsElements FINAL : public LTemplateInstruction<1, 0, 0> {
636 public:
637 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements")
638 DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements)
639};
640
641
642class LDebugBreak FINAL : public LTemplateInstruction<0, 0, 0> {
643 public:
644 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
645};
646
647
648class LModByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
649 public:
650 LModByPowerOf2I(LOperand* dividend, int32_t divisor) {
651 inputs_[0] = dividend;
652 divisor_ = divisor;
653 }
654
655 LOperand* dividend() { return inputs_[0]; }
656 int32_t divisor() const { return divisor_; }
657
658 DECLARE_CONCRETE_INSTRUCTION(ModByPowerOf2I, "mod-by-power-of-2-i")
659 DECLARE_HYDROGEN_ACCESSOR(Mod)
660
661 private:
662 int32_t divisor_;
663};
664
665
666class LModByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
667 public:
668 LModByConstI(LOperand* dividend,
669 int32_t divisor,
670 LOperand* temp1,
671 LOperand* temp2) {
672 inputs_[0] = dividend;
673 divisor_ = divisor;
674 temps_[0] = temp1;
675 temps_[1] = temp2;
676 }
677
678 LOperand* dividend() { return inputs_[0]; }
679 int32_t divisor() const { return divisor_; }
680 LOperand* temp1() { return temps_[0]; }
681 LOperand* temp2() { return temps_[1]; }
682
683 DECLARE_CONCRETE_INSTRUCTION(ModByConstI, "mod-by-const-i")
684 DECLARE_HYDROGEN_ACCESSOR(Mod)
685
686 private:
687 int32_t divisor_;
688};
689
690
691class LModI FINAL : public LTemplateInstruction<1, 2, 1> {
692 public:
693 LModI(LOperand* left, LOperand* right, LOperand* temp) {
694 inputs_[0] = left;
695 inputs_[1] = right;
696 temps_[0] = temp;
697 }
698
699 LOperand* left() { return inputs_[0]; }
700 LOperand* right() { return inputs_[1]; }
701 LOperand* temp() { return temps_[0]; }
702
703 DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i")
704 DECLARE_HYDROGEN_ACCESSOR(Mod)
705};
706
707
708class LDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
709 public:
710 LDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
711 inputs_[0] = dividend;
712 divisor_ = divisor;
713 }
714
715 LOperand* dividend() { return inputs_[0]; }
716 int32_t divisor() const { return divisor_; }
717
718 DECLARE_CONCRETE_INSTRUCTION(DivByPowerOf2I, "div-by-power-of-2-i")
719 DECLARE_HYDROGEN_ACCESSOR(Div)
720
721 private:
722 int32_t divisor_;
723};
724
725
726class LDivByConstI FINAL : public LTemplateInstruction<1, 1, 2> {
727 public:
728 LDivByConstI(LOperand* dividend,
729 int32_t divisor,
730 LOperand* temp1,
731 LOperand* temp2) {
732 inputs_[0] = dividend;
733 divisor_ = divisor;
734 temps_[0] = temp1;
735 temps_[1] = temp2;
736 }
737
738 LOperand* dividend() { return inputs_[0]; }
739 int32_t divisor() const { return divisor_; }
740 LOperand* temp1() { return temps_[0]; }
741 LOperand* temp2() { return temps_[1]; }
742
743 DECLARE_CONCRETE_INSTRUCTION(DivByConstI, "div-by-const-i")
744 DECLARE_HYDROGEN_ACCESSOR(Div)
745
746 private:
747 int32_t divisor_;
748};
749
750
751class LDivI FINAL : public LTemplateInstruction<1, 2, 1> {
752 public:
753 LDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
754 inputs_[0] = dividend;
755 inputs_[1] = divisor;
756 temps_[0] = temp;
757 }
758
759 LOperand* dividend() { return inputs_[0]; }
760 LOperand* divisor() { return inputs_[1]; }
761 LOperand* temp() { return temps_[0]; }
762
763 DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i")
764 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
765};
766
767
768class LFlooringDivByPowerOf2I FINAL : public LTemplateInstruction<1, 1, 0> {
769 public:
770 LFlooringDivByPowerOf2I(LOperand* dividend, int32_t divisor) {
771 inputs_[0] = dividend;
772 divisor_ = divisor;
773 }
774
775 LOperand* dividend() { return inputs_[0]; }
776 int32_t divisor() const { return divisor_; }
777
778 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByPowerOf2I,
779 "flooring-div-by-power-of-2-i")
780 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
781
782 private:
783 int32_t divisor_;
784};
785
786
787class LFlooringDivByConstI FINAL : public LTemplateInstruction<1, 1, 3> {
788 public:
789 LFlooringDivByConstI(LOperand* dividend,
790 int32_t divisor,
791 LOperand* temp1,
792 LOperand* temp2,
793 LOperand* temp3) {
794 inputs_[0] = dividend;
795 divisor_ = divisor;
796 temps_[0] = temp1;
797 temps_[1] = temp2;
798 temps_[2] = temp3;
799 }
800
801 LOperand* dividend() { return inputs_[0]; }
802 int32_t divisor() const { return divisor_; }
803 LOperand* temp1() { return temps_[0]; }
804 LOperand* temp2() { return temps_[1]; }
805 LOperand* temp3() { return temps_[2]; }
806
807 DECLARE_CONCRETE_INSTRUCTION(FlooringDivByConstI, "flooring-div-by-const-i")
808 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
809
810 private:
811 int32_t divisor_;
812};
813
814
815class LFlooringDivI FINAL : public LTemplateInstruction<1, 2, 1> {
816 public:
817 LFlooringDivI(LOperand* dividend, LOperand* divisor, LOperand* temp) {
818 inputs_[0] = dividend;
819 inputs_[1] = divisor;
820 temps_[0] = temp;
821 }
822
823 LOperand* dividend() { return inputs_[0]; }
824 LOperand* divisor() { return inputs_[1]; }
825 LOperand* temp() { return temps_[0]; }
826
827 DECLARE_CONCRETE_INSTRUCTION(FlooringDivI, "flooring-div-i")
828 DECLARE_HYDROGEN_ACCESSOR(MathFloorOfDiv)
829};
830
831
832class LMulI FINAL : public LTemplateInstruction<1, 2, 1> {
833 public:
834 LMulI(LOperand* left, LOperand* right, LOperand* temp) {
835 inputs_[0] = left;
836 inputs_[1] = right;
837 temps_[0] = temp;
838 }
839
840 LOperand* left() { return inputs_[0]; }
841 LOperand* right() { return inputs_[1]; }
842 LOperand* temp() { return temps_[0]; }
843
844 DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i")
845 DECLARE_HYDROGEN_ACCESSOR(Mul)
846};
847
848
849class LCompareNumericAndBranch FINAL : public LControlInstruction<2, 0> {
850 public:
851 LCompareNumericAndBranch(LOperand* left, LOperand* right) {
852 inputs_[0] = left;
853 inputs_[1] = right;
854 }
855
856 LOperand* left() { return inputs_[0]; }
857 LOperand* right() { return inputs_[1]; }
858
859 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch,
860 "compare-numeric-and-branch")
861 DECLARE_HYDROGEN_ACCESSOR(CompareNumericAndBranch)
862
863 Token::Value op() const { return hydrogen()->token(); }
864 bool is_double() const {
865 return hydrogen()->representation().IsDouble();
866 }
867
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400868 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000869};
870
871
872class LMathFloor FINAL : public LTemplateInstruction<1, 1, 0> {
873 public:
874 explicit LMathFloor(LOperand* value) {
875 inputs_[0] = value;
876 }
877
878 LOperand* value() { return inputs_[0]; }
879
880 DECLARE_CONCRETE_INSTRUCTION(MathFloor, "math-floor")
881 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
882};
883
884
885class LMathRound FINAL : public LTemplateInstruction<1, 1, 0> {
886 public:
887 explicit LMathRound(LOperand* value) {
888 inputs_[0] = value;
889 }
890
891 LOperand* value() { return inputs_[0]; }
892
893 DECLARE_CONCRETE_INSTRUCTION(MathRound, "math-round")
894 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
895};
896
897
898class LMathFround FINAL : public LTemplateInstruction<1, 1, 0> {
899 public:
900 explicit LMathFround(LOperand* value) { inputs_[0] = value; }
901
902 LOperand* value() { return inputs_[0]; }
903
904 DECLARE_CONCRETE_INSTRUCTION(MathFround, "math-fround")
905};
906
907
908class LMathAbs FINAL : public LTemplateInstruction<1, 2, 0> {
909 public:
910 LMathAbs(LOperand* context, LOperand* value) {
911 inputs_[1] = context;
912 inputs_[0] = value;
913 }
914
915 LOperand* context() { return inputs_[1]; }
916 LOperand* value() { return inputs_[0]; }
917
918 DECLARE_CONCRETE_INSTRUCTION(MathAbs, "math-abs")
919 DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation)
920};
921
922
923class LMathLog FINAL : public LTemplateInstruction<1, 1, 0> {
924 public:
925 explicit LMathLog(LOperand* value) {
926 inputs_[0] = value;
927 }
928
929 LOperand* value() { return inputs_[0]; }
930
931 DECLARE_CONCRETE_INSTRUCTION(MathLog, "math-log")
932};
933
934
935class LMathClz32 FINAL : public LTemplateInstruction<1, 1, 0> {
936 public:
937 explicit LMathClz32(LOperand* value) {
938 inputs_[0] = value;
939 }
940
941 LOperand* value() { return inputs_[0]; }
942
943 DECLARE_CONCRETE_INSTRUCTION(MathClz32, "math-clz32")
944};
945
946
947class LMathExp FINAL : public LTemplateInstruction<1, 1, 2> {
948 public:
949 LMathExp(LOperand* value,
950 LOperand* temp1,
951 LOperand* temp2) {
952 inputs_[0] = value;
953 temps_[0] = temp1;
954 temps_[1] = temp2;
955 ExternalReference::InitializeMathExpData();
956 }
957
958 LOperand* value() { return inputs_[0]; }
959 LOperand* temp1() { return temps_[0]; }
960 LOperand* temp2() { return temps_[1]; }
961
962 DECLARE_CONCRETE_INSTRUCTION(MathExp, "math-exp")
963};
964
965
966class LMathSqrt FINAL : public LTemplateInstruction<1, 1, 2> {
967 public:
968 explicit LMathSqrt(LOperand* value,
969 LOperand* temp1,
970 LOperand* temp2) {
971 inputs_[0] = value;
972 temps_[0] = temp1;
973 temps_[1] = temp2;
974 }
975
976 LOperand* value() { return inputs_[0]; }
977 LOperand* temp1() { return temps_[0]; }
978 LOperand* temp2() { return temps_[1]; }
979
980 DECLARE_CONCRETE_INSTRUCTION(MathSqrt, "math-sqrt")
981};
982
983
984class LMathPowHalf FINAL : public LTemplateInstruction<1, 1, 0> {
985 public:
986 explicit LMathPowHalf(LOperand* value) { inputs_[0] = value; }
987
988 LOperand* value() { return inputs_[0]; }
989
990 DECLARE_CONCRETE_INSTRUCTION(MathPowHalf, "math-pow-half")
991};
992
993
994class LCmpObjectEqAndBranch FINAL : public LControlInstruction<2, 0> {
995 public:
996 LCmpObjectEqAndBranch(LOperand* left, LOperand* right) {
997 inputs_[0] = left;
998 inputs_[1] = right;
999 }
1000
1001 LOperand* left() { return inputs_[0]; }
1002 LOperand* right() { return inputs_[1]; }
1003
1004 DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, "cmp-object-eq-and-branch")
1005};
1006
1007
1008class LCmpHoleAndBranch FINAL : public LControlInstruction<1, 0> {
1009 public:
1010 explicit LCmpHoleAndBranch(LOperand* object) {
1011 inputs_[0] = object;
1012 }
1013
1014 LOperand* object() { return inputs_[0]; }
1015
1016 DECLARE_CONCRETE_INSTRUCTION(CmpHoleAndBranch, "cmp-hole-and-branch")
1017 DECLARE_HYDROGEN_ACCESSOR(CompareHoleAndBranch)
1018};
1019
1020
1021class LCompareMinusZeroAndBranch FINAL : public LControlInstruction<1, 0> {
1022 public:
1023 explicit LCompareMinusZeroAndBranch(LOperand* value) { inputs_[0] = value; }
1024
1025 LOperand* value() { return inputs_[0]; }
1026
1027 DECLARE_CONCRETE_INSTRUCTION(CompareMinusZeroAndBranch,
1028 "cmp-minus-zero-and-branch")
1029 DECLARE_HYDROGEN_ACCESSOR(CompareMinusZeroAndBranch)
1030};
1031
1032
1033class LIsObjectAndBranch FINAL : public LControlInstruction<1, 1> {
1034 public:
1035 LIsObjectAndBranch(LOperand* value, LOperand* temp) {
1036 inputs_[0] = value;
1037 temps_[0] = temp;
1038 }
1039
1040 LOperand* value() { return inputs_[0]; }
1041 LOperand* temp() { return temps_[0]; }
1042
1043 DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch")
1044
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001045 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001046};
1047
1048
1049class LIsStringAndBranch FINAL : public LControlInstruction<1, 1> {
1050 public:
1051 LIsStringAndBranch(LOperand* value, LOperand* temp) {
1052 inputs_[0] = value;
1053 temps_[0] = temp;
1054 }
1055
1056 LOperand* value() { return inputs_[0]; }
1057 LOperand* temp() { return temps_[0]; }
1058
1059 DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch")
1060 DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch)
1061
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001062 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001063};
1064
1065
1066class LIsSmiAndBranch FINAL : public LControlInstruction<1, 0> {
1067 public:
1068 explicit LIsSmiAndBranch(LOperand* value) {
1069 inputs_[0] = value;
1070 }
1071
1072 LOperand* value() { return inputs_[0]; }
1073
1074 DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch")
1075 DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch)
1076
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001077 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001078};
1079
1080
1081class LIsUndetectableAndBranch FINAL : public LControlInstruction<1, 1> {
1082 public:
1083 LIsUndetectableAndBranch(LOperand* value, LOperand* temp) {
1084 inputs_[0] = value;
1085 temps_[0] = temp;
1086 }
1087
1088 LOperand* value() { return inputs_[0]; }
1089 LOperand* temp() { return temps_[0]; }
1090
1091 DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch,
1092 "is-undetectable-and-branch")
1093 DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch)
1094
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001095 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001096};
1097
1098
1099class LStringCompareAndBranch FINAL : public LControlInstruction<3, 0> {
1100 public:
1101 LStringCompareAndBranch(LOperand* context, LOperand* left, LOperand* right) {
1102 inputs_[0] = context;
1103 inputs_[1] = left;
1104 inputs_[2] = right;
1105 }
1106
1107 LOperand* context() { return inputs_[1]; }
1108 LOperand* left() { return inputs_[1]; }
1109 LOperand* right() { return inputs_[2]; }
1110
1111 DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch,
1112 "string-compare-and-branch")
1113 DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch)
1114
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001115 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001116
1117 Token::Value op() const { return hydrogen()->token(); }
1118};
1119
1120
1121class LHasInstanceTypeAndBranch FINAL : public LControlInstruction<1, 1> {
1122 public:
1123 LHasInstanceTypeAndBranch(LOperand* value, LOperand* temp) {
1124 inputs_[0] = value;
1125 temps_[0] = temp;
1126 }
1127
1128 LOperand* value() { return inputs_[0]; }
1129 LOperand* temp() { return temps_[0]; }
1130
1131 DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch,
1132 "has-instance-type-and-branch")
1133 DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch)
1134
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001135 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001136};
1137
1138
1139class LGetCachedArrayIndex FINAL : public LTemplateInstruction<1, 1, 0> {
1140 public:
1141 explicit LGetCachedArrayIndex(LOperand* value) {
1142 inputs_[0] = value;
1143 }
1144
1145 LOperand* value() { return inputs_[0]; }
1146
1147 DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index")
1148 DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex)
1149};
1150
1151
1152class LHasCachedArrayIndexAndBranch FINAL
1153 : public LControlInstruction<1, 0> {
1154 public:
1155 explicit LHasCachedArrayIndexAndBranch(LOperand* value) {
1156 inputs_[0] = value;
1157 }
1158
1159 LOperand* value() { return inputs_[0]; }
1160
1161 DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch,
1162 "has-cached-array-index-and-branch")
1163
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001164 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001165};
1166
1167
1168class LIsConstructCallAndBranch FINAL : public LControlInstruction<0, 1> {
1169 public:
1170 explicit LIsConstructCallAndBranch(LOperand* temp) {
1171 temps_[0] = temp;
1172 }
1173
1174 LOperand* temp() { return temps_[0]; }
1175
1176 DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch,
1177 "is-construct-call-and-branch")
1178};
1179
1180
1181class LClassOfTestAndBranch FINAL : public LControlInstruction<1, 2> {
1182 public:
1183 LClassOfTestAndBranch(LOperand* value, LOperand* temp, LOperand* temp2) {
1184 inputs_[0] = value;
1185 temps_[0] = temp;
1186 temps_[1] = temp2;
1187 }
1188
1189 LOperand* value() { return inputs_[0]; }
1190 LOperand* temp() { return temps_[0]; }
1191 LOperand* temp2() { return temps_[1]; }
1192
1193 DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch,
1194 "class-of-test-and-branch")
1195 DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch)
1196
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001197 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001198};
1199
1200
1201class LCmpT FINAL : public LTemplateInstruction<1, 3, 0> {
1202 public:
1203 LCmpT(LOperand* context, LOperand* left, LOperand* right) {
1204 inputs_[0] = context;
1205 inputs_[1] = left;
1206 inputs_[2] = right;
1207 }
1208
1209 DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t")
1210 DECLARE_HYDROGEN_ACCESSOR(CompareGeneric)
1211
1212 LOperand* context() { return inputs_[0]; }
1213 Token::Value op() const { return hydrogen()->token(); }
1214};
1215
1216
1217class LInstanceOf FINAL : public LTemplateInstruction<1, 3, 0> {
1218 public:
1219 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1220 inputs_[0] = context;
1221 inputs_[1] = left;
1222 inputs_[2] = right;
1223 }
1224
1225 LOperand* context() { return inputs_[0]; }
1226
1227 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1228};
1229
1230
1231class LInstanceOfKnownGlobal FINAL : public LTemplateInstruction<1, 2, 1> {
1232 public:
1233 LInstanceOfKnownGlobal(LOperand* context, LOperand* value, LOperand* temp) {
1234 inputs_[0] = context;
1235 inputs_[1] = value;
1236 temps_[0] = temp;
1237 }
1238
1239 LOperand* context() { return inputs_[0]; }
1240 LOperand* value() { return inputs_[1]; }
1241 LOperand* temp() { return temps_[0]; }
1242
1243 DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal,
1244 "instance-of-known-global")
1245 DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal)
1246
1247 Handle<JSFunction> function() const { return hydrogen()->function(); }
1248 LEnvironment* GetDeferredLazyDeoptimizationEnvironment() {
1249 return lazy_deopt_env_;
1250 }
1251 virtual void SetDeferredLazyDeoptimizationEnvironment(
1252 LEnvironment* env) OVERRIDE {
1253 lazy_deopt_env_ = env;
1254 }
1255
1256 private:
1257 LEnvironment* lazy_deopt_env_;
1258};
1259
1260
1261class LBoundsCheck FINAL : public LTemplateInstruction<0, 2, 0> {
1262 public:
1263 LBoundsCheck(LOperand* index, LOperand* length) {
1264 inputs_[0] = index;
1265 inputs_[1] = length;
1266 }
1267
1268 LOperand* index() { return inputs_[0]; }
1269 LOperand* length() { return inputs_[1]; }
1270
1271 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1272 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1273};
1274
1275
1276class LBitI FINAL : public LTemplateInstruction<1, 2, 0> {
1277 public:
1278 LBitI(LOperand* left, LOperand* right) {
1279 inputs_[0] = left;
1280 inputs_[1] = right;
1281 }
1282
1283 LOperand* left() { return inputs_[0]; }
1284 LOperand* right() { return inputs_[1]; }
1285
1286 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1287 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1288
1289 Token::Value op() const { return hydrogen()->op(); }
1290};
1291
1292
1293class LShiftI FINAL : public LTemplateInstruction<1, 2, 0> {
1294 public:
1295 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1296 : op_(op), can_deopt_(can_deopt) {
1297 inputs_[0] = left;
1298 inputs_[1] = right;
1299 }
1300
1301 LOperand* left() { return inputs_[0]; }
1302 LOperand* right() { return inputs_[1]; }
1303
1304 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1305
1306 Token::Value op() const { return op_; }
1307 bool can_deopt() const { return can_deopt_; }
1308
1309 private:
1310 Token::Value op_;
1311 bool can_deopt_;
1312};
1313
1314
1315class LSubI FINAL : public LTemplateInstruction<1, 2, 0> {
1316 public:
1317 LSubI(LOperand* left, LOperand* right) {
1318 inputs_[0] = left;
1319 inputs_[1] = right;
1320 }
1321
1322 LOperand* left() { return inputs_[0]; }
1323 LOperand* right() { return inputs_[1]; }
1324
1325 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1326 DECLARE_HYDROGEN_ACCESSOR(Sub)
1327};
1328
1329
1330class LConstantI FINAL : public LTemplateInstruction<1, 0, 0> {
1331 public:
1332 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1333 DECLARE_HYDROGEN_ACCESSOR(Constant)
1334
1335 int32_t value() const { return hydrogen()->Integer32Value(); }
1336};
1337
1338
1339class LConstantS FINAL : public LTemplateInstruction<1, 0, 0> {
1340 public:
1341 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1342 DECLARE_HYDROGEN_ACCESSOR(Constant)
1343
1344 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1345};
1346
1347
1348class LConstantD FINAL : public LTemplateInstruction<1, 0, 1> {
1349 public:
1350 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1351 DECLARE_HYDROGEN_ACCESSOR(Constant)
1352
1353 double value() const { return hydrogen()->DoubleValue(); }
1354};
1355
1356
1357class LConstantE FINAL : public LTemplateInstruction<1, 0, 0> {
1358 public:
1359 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1360 DECLARE_HYDROGEN_ACCESSOR(Constant)
1361
1362 ExternalReference value() const {
1363 return hydrogen()->ExternalReferenceValue();
1364 }
1365};
1366
1367
1368class LConstantT FINAL : public LTemplateInstruction<1, 0, 0> {
1369 public:
1370 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1371 DECLARE_HYDROGEN_ACCESSOR(Constant)
1372
1373 Handle<Object> value(Isolate* isolate) const {
1374 return hydrogen()->handle(isolate);
1375 }
1376};
1377
1378
1379class LBranch FINAL : public LControlInstruction<1, 1> {
1380 public:
1381 LBranch(LOperand* value, LOperand* temp) {
1382 inputs_[0] = value;
1383 temps_[0] = temp;
1384 }
1385
1386 LOperand* value() { return inputs_[0]; }
1387 LOperand* temp() { return temps_[0]; }
1388
1389 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1390 DECLARE_HYDROGEN_ACCESSOR(Branch)
1391
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001392 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001393};
1394
1395
1396class LCmpMapAndBranch FINAL : public LControlInstruction<1, 0> {
1397 public:
1398 explicit LCmpMapAndBranch(LOperand* value) {
1399 inputs_[0] = value;
1400 }
1401
1402 LOperand* value() { return inputs_[0]; }
1403
1404 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1405 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1406
1407 Handle<Map> map() const { return hydrogen()->map().handle(); }
1408};
1409
1410
1411class LMapEnumLength FINAL : public LTemplateInstruction<1, 1, 0> {
1412 public:
1413 explicit LMapEnumLength(LOperand* value) {
1414 inputs_[0] = value;
1415 }
1416
1417 LOperand* value() { return inputs_[0]; }
1418
1419 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength, "map-enum-length")
1420};
1421
1422
1423class LDateField FINAL : public LTemplateInstruction<1, 1, 1> {
1424 public:
1425 LDateField(LOperand* date, LOperand* temp, Smi* index)
1426 : index_(index) {
1427 inputs_[0] = date;
1428 temps_[0] = temp;
1429 }
1430
1431 LOperand* date() { return inputs_[0]; }
1432 LOperand* temp() { return temps_[0]; }
1433
1434 DECLARE_CONCRETE_INSTRUCTION(DateField, "date-field")
1435 DECLARE_HYDROGEN_ACCESSOR(DateField)
1436
1437 Smi* index() const { return index_; }
1438
1439 private:
1440 Smi* index_;
1441};
1442
1443
1444class LSeqStringGetChar FINAL : public LTemplateInstruction<1, 2, 0> {
1445 public:
1446 LSeqStringGetChar(LOperand* string, LOperand* index) {
1447 inputs_[0] = string;
1448 inputs_[1] = index;
1449 }
1450
1451 LOperand* string() const { return inputs_[0]; }
1452 LOperand* index() const { return inputs_[1]; }
1453
1454 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1455 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1456};
1457
1458
1459class LSeqStringSetChar FINAL : public LTemplateInstruction<1, 4, 0> {
1460 public:
1461 LSeqStringSetChar(LOperand* context,
1462 LOperand* string,
1463 LOperand* index,
1464 LOperand* value) {
1465 inputs_[0] = context;
1466 inputs_[1] = string;
1467 inputs_[2] = index;
1468 inputs_[3] = value;
1469 }
1470
1471 LOperand* string() { return inputs_[1]; }
1472 LOperand* index() { return inputs_[2]; }
1473 LOperand* value() { return inputs_[3]; }
1474
1475 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1476 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1477};
1478
1479
1480class LAddI FINAL : public LTemplateInstruction<1, 2, 0> {
1481 public:
1482 LAddI(LOperand* left, LOperand* right) {
1483 inputs_[0] = left;
1484 inputs_[1] = right;
1485 }
1486
1487 LOperand* left() { return inputs_[0]; }
1488 LOperand* right() { return inputs_[1]; }
1489
1490 static bool UseLea(HAdd* add) {
1491 return !add->CheckFlag(HValue::kCanOverflow) &&
1492 add->BetterLeftOperand()->UseCount() > 1;
1493 }
1494
1495 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1496 DECLARE_HYDROGEN_ACCESSOR(Add)
1497};
1498
1499
1500class LMathMinMax FINAL : public LTemplateInstruction<1, 2, 1> {
1501 public:
1502 LMathMinMax(LOperand* left, LOperand* right, LOperand* temp) {
1503 inputs_[0] = left;
1504 inputs_[1] = right;
1505 temps_[0] = temp;
1506 }
1507
1508 LOperand* left() { return inputs_[0]; }
1509 LOperand* right() { return inputs_[1]; }
1510 LOperand* temp() { return temps_[0]; }
1511
1512 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1513 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1514};
1515
1516
1517class LPower FINAL : public LTemplateInstruction<1, 2, 0> {
1518 public:
1519 LPower(LOperand* left, LOperand* right) {
1520 inputs_[0] = left;
1521 inputs_[1] = right;
1522 }
1523
1524 LOperand* left() { return inputs_[0]; }
1525 LOperand* right() { return inputs_[1]; }
1526
1527 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1528 DECLARE_HYDROGEN_ACCESSOR(Power)
1529};
1530
1531
1532class LArithmeticD FINAL : public LTemplateInstruction<1, 2, 0> {
1533 public:
1534 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1535 : op_(op) {
1536 inputs_[0] = left;
1537 inputs_[1] = right;
1538 }
1539
1540 LOperand* left() { return inputs_[0]; }
1541 LOperand* right() { return inputs_[1]; }
1542
1543 Token::Value op() const { return op_; }
1544
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001545 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticD; }
1546 void CompileToNative(LCodeGen* generator) OVERRIDE;
1547 const char* Mnemonic() const OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001548
1549 private:
1550 Token::Value op_;
1551};
1552
1553
1554class LArithmeticT FINAL : public LTemplateInstruction<1, 3, 0> {
1555 public:
1556 LArithmeticT(Token::Value op,
1557 LOperand* context,
1558 LOperand* left,
1559 LOperand* right)
1560 : op_(op) {
1561 inputs_[0] = context;
1562 inputs_[1] = left;
1563 inputs_[2] = right;
1564 }
1565
1566 LOperand* context() { return inputs_[0]; }
1567 LOperand* left() { return inputs_[1]; }
1568 LOperand* right() { return inputs_[2]; }
1569
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001570 Opcode opcode() const OVERRIDE { return LInstruction::kArithmeticT; }
1571 void CompileToNative(LCodeGen* generator) OVERRIDE;
1572 const char* Mnemonic() const OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001573
1574 Token::Value op() const { return op_; }
1575
1576 private:
1577 Token::Value op_;
1578};
1579
1580
1581class LReturn FINAL : public LTemplateInstruction<0, 3, 0> {
1582 public:
1583 explicit LReturn(LOperand* value,
1584 LOperand* context,
1585 LOperand* parameter_count) {
1586 inputs_[0] = value;
1587 inputs_[1] = context;
1588 inputs_[2] = parameter_count;
1589 }
1590
1591 bool has_constant_parameter_count() {
1592 return parameter_count()->IsConstantOperand();
1593 }
1594 LConstantOperand* constant_parameter_count() {
1595 DCHECK(has_constant_parameter_count());
1596 return LConstantOperand::cast(parameter_count());
1597 }
1598 LOperand* parameter_count() { return inputs_[2]; }
1599
1600 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1601 DECLARE_HYDROGEN_ACCESSOR(Return)
1602};
1603
1604
1605class LLoadNamedField FINAL : public LTemplateInstruction<1, 1, 0> {
1606 public:
1607 explicit LLoadNamedField(LOperand* object) {
1608 inputs_[0] = object;
1609 }
1610
1611 LOperand* object() { return inputs_[0]; }
1612
1613 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1614 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1615};
1616
1617
1618class LLoadNamedGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1619 public:
1620 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1621 inputs_[0] = context;
1622 inputs_[1] = object;
1623 temps_[0] = vector;
1624 }
1625
1626 LOperand* context() { return inputs_[0]; }
1627 LOperand* object() { return inputs_[1]; }
1628 LOperand* temp_vector() { return temps_[0]; }
1629
1630 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1631 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1632
1633 Handle<Object> name() const { return hydrogen()->name(); }
1634};
1635
1636
1637class LLoadFunctionPrototype FINAL : public LTemplateInstruction<1, 1, 1> {
1638 public:
1639 LLoadFunctionPrototype(LOperand* function, LOperand* temp) {
1640 inputs_[0] = function;
1641 temps_[0] = temp;
1642 }
1643
1644 LOperand* function() { return inputs_[0]; }
1645 LOperand* temp() { return temps_[0]; }
1646
1647 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1648 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1649};
1650
1651
1652class LLoadRoot FINAL : public LTemplateInstruction<1, 0, 0> {
1653 public:
1654 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1655 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1656
1657 Heap::RootListIndex index() const { return hydrogen()->index(); }
1658};
1659
1660
1661class LLoadKeyed FINAL : public LTemplateInstruction<1, 2, 0> {
1662 public:
1663 LLoadKeyed(LOperand* elements, LOperand* key) {
1664 inputs_[0] = elements;
1665 inputs_[1] = key;
1666 }
1667 LOperand* elements() { return inputs_[0]; }
1668 LOperand* key() { return inputs_[1]; }
1669 ElementsKind elements_kind() const {
1670 return hydrogen()->elements_kind();
1671 }
1672 bool is_external() const {
1673 return hydrogen()->is_external();
1674 }
1675 bool is_fixed_typed_array() const {
1676 return hydrogen()->is_fixed_typed_array();
1677 }
1678 bool is_typed_elements() const {
1679 return is_external() || is_fixed_typed_array();
1680 }
1681
1682 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1683 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1684
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001685 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001686 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1687 bool key_is_smi() {
1688 return hydrogen()->key()->representation().IsTagged();
1689 }
1690};
1691
1692
1693inline static bool ExternalArrayOpRequiresTemp(
1694 Representation key_representation,
1695 ElementsKind elements_kind) {
1696 // Operations that require the key to be divided by two to be converted into
1697 // an index cannot fold the scale operation into a load and need an extra
1698 // temp register to do the work.
1699 return key_representation.IsSmi() &&
1700 (elements_kind == EXTERNAL_INT8_ELEMENTS ||
1701 elements_kind == EXTERNAL_UINT8_ELEMENTS ||
1702 elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS ||
1703 elements_kind == UINT8_ELEMENTS ||
1704 elements_kind == INT8_ELEMENTS ||
1705 elements_kind == UINT8_CLAMPED_ELEMENTS);
1706}
1707
1708
1709class LLoadKeyedGeneric FINAL : public LTemplateInstruction<1, 3, 1> {
1710 public:
1711 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1712 LOperand* vector) {
1713 inputs_[0] = context;
1714 inputs_[1] = obj;
1715 inputs_[2] = key;
1716 temps_[0] = vector;
1717 }
1718
1719 LOperand* context() { return inputs_[0]; }
1720 LOperand* object() { return inputs_[1]; }
1721 LOperand* key() { return inputs_[2]; }
1722 LOperand* temp_vector() { return temps_[0]; }
1723
1724 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1725 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1726};
1727
1728
1729class LLoadGlobalCell FINAL : public LTemplateInstruction<1, 0, 0> {
1730 public:
1731 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell")
1732 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell)
1733};
1734
1735
1736class LLoadGlobalGeneric FINAL : public LTemplateInstruction<1, 2, 1> {
1737 public:
1738 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1739 LOperand* vector) {
1740 inputs_[0] = context;
1741 inputs_[1] = global_object;
1742 temps_[0] = vector;
1743 }
1744
1745 LOperand* context() { return inputs_[0]; }
1746 LOperand* global_object() { return inputs_[1]; }
1747 LOperand* temp_vector() { return temps_[0]; }
1748
1749 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1750 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1751
1752 Handle<Object> name() const { return hydrogen()->name(); }
1753 bool for_typeof() const { return hydrogen()->for_typeof(); }
1754};
1755
1756
1757class LStoreGlobalCell FINAL : public LTemplateInstruction<0, 1, 0> {
1758 public:
1759 explicit LStoreGlobalCell(LOperand* value) {
1760 inputs_[0] = value;
1761 }
1762
1763 LOperand* value() { return inputs_[0]; }
1764
1765 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell")
1766 DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell)
1767};
1768
1769
1770class LLoadContextSlot FINAL : public LTemplateInstruction<1, 1, 0> {
1771 public:
1772 explicit LLoadContextSlot(LOperand* context) {
1773 inputs_[0] = context;
1774 }
1775
1776 LOperand* context() { return inputs_[0]; }
1777
1778 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1779 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1780
1781 int slot_index() { return hydrogen()->slot_index(); }
1782
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001783 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001784};
1785
1786
1787class LStoreContextSlot FINAL : public LTemplateInstruction<0, 2, 1> {
1788 public:
1789 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1790 inputs_[0] = context;
1791 inputs_[1] = value;
1792 temps_[0] = temp;
1793 }
1794
1795 LOperand* context() { return inputs_[0]; }
1796 LOperand* value() { return inputs_[1]; }
1797 LOperand* temp() { return temps_[0]; }
1798
1799 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1800 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1801
1802 int slot_index() { return hydrogen()->slot_index(); }
1803
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001804 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001805};
1806
1807
1808class LPushArgument FINAL : public LTemplateInstruction<0, 1, 0> {
1809 public:
1810 explicit LPushArgument(LOperand* value) {
1811 inputs_[0] = value;
1812 }
1813
1814 LOperand* value() { return inputs_[0]; }
1815
1816 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1817};
1818
1819
1820class LDrop FINAL : public LTemplateInstruction<0, 0, 0> {
1821 public:
1822 explicit LDrop(int count) : count_(count) { }
1823
1824 int count() const { return count_; }
1825
1826 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1827
1828 private:
1829 int count_;
1830};
1831
1832
1833class LStoreCodeEntry FINAL: public LTemplateInstruction<0, 2, 0> {
1834 public:
1835 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1836 inputs_[0] = function;
1837 inputs_[1] = code_object;
1838 }
1839
1840 LOperand* function() { return inputs_[0]; }
1841 LOperand* code_object() { return inputs_[1]; }
1842
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001843 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001844
1845 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1846 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1847};
1848
1849
1850class LInnerAllocatedObject FINAL: public LTemplateInstruction<1, 2, 0> {
1851 public:
1852 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1853 inputs_[0] = base_object;
1854 inputs_[1] = offset;
1855 }
1856
1857 LOperand* base_object() const { return inputs_[0]; }
1858 LOperand* offset() const { return inputs_[1]; }
1859
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001860 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001861
1862 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1863};
1864
1865
1866class LThisFunction FINAL : public LTemplateInstruction<1, 0, 0> {
1867 public:
1868 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1869 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1870};
1871
1872
1873class LContext FINAL : public LTemplateInstruction<1, 0, 0> {
1874 public:
1875 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1876 DECLARE_HYDROGEN_ACCESSOR(Context)
1877};
1878
1879
1880class LDeclareGlobals FINAL : public LTemplateInstruction<0, 1, 0> {
1881 public:
1882 explicit LDeclareGlobals(LOperand* context) {
1883 inputs_[0] = context;
1884 }
1885
1886 LOperand* context() { return inputs_[0]; }
1887
1888 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1889 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1890};
1891
1892
1893class LCallJSFunction FINAL : public LTemplateInstruction<1, 1, 0> {
1894 public:
1895 explicit LCallJSFunction(LOperand* function) {
1896 inputs_[0] = function;
1897 }
1898
1899 LOperand* function() { return inputs_[0]; }
1900
1901 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1902 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1903
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001904 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001905
1906 int arity() const { return hydrogen()->argument_count() - 1; }
1907};
1908
1909
1910class LCallWithDescriptor FINAL : public LTemplateResultInstruction<1> {
1911 public:
1912 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1913 const ZoneList<LOperand*>& operands, Zone* zone)
1914 : inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
1915 DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
1916 inputs_.AddAll(operands, zone);
1917 }
1918
1919 LOperand* target() const { return inputs_[0]; }
1920
1921 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1922
1923 private:
1924 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1925
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001926 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001927
1928 int arity() const { return hydrogen()->argument_count() - 1; }
1929
1930 ZoneList<LOperand*> inputs_;
1931
1932 // Iterator support.
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001933 int InputCount() FINAL { return inputs_.length(); }
1934 LOperand* InputAt(int i) FINAL { return inputs_[i]; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001935
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001936 int TempCount() FINAL { return 0; }
1937 LOperand* TempAt(int i) FINAL { return NULL; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001938};
1939
1940
1941class LInvokeFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1942 public:
1943 LInvokeFunction(LOperand* context, LOperand* function) {
1944 inputs_[0] = context;
1945 inputs_[1] = function;
1946 }
1947
1948 LOperand* context() { return inputs_[0]; }
1949 LOperand* function() { return inputs_[1]; }
1950
1951 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1952 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1953
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001954 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001955
1956 int arity() const { return hydrogen()->argument_count() - 1; }
1957};
1958
1959
1960class LCallFunction FINAL : public LTemplateInstruction<1, 2, 0> {
1961 public:
1962 explicit LCallFunction(LOperand* context, LOperand* function) {
1963 inputs_[0] = context;
1964 inputs_[1] = function;
1965 }
1966
1967 LOperand* context() { return inputs_[0]; }
1968 LOperand* function() { return inputs_[1]; }
1969
1970 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1971 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
1972
1973 int arity() const { return hydrogen()->argument_count() - 1; }
1974};
1975
1976
1977class LCallNew FINAL : public LTemplateInstruction<1, 2, 0> {
1978 public:
1979 LCallNew(LOperand* context, LOperand* constructor) {
1980 inputs_[0] = context;
1981 inputs_[1] = constructor;
1982 }
1983
1984 LOperand* context() { return inputs_[0]; }
1985 LOperand* constructor() { return inputs_[1]; }
1986
1987 DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new")
1988 DECLARE_HYDROGEN_ACCESSOR(CallNew)
1989
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001990 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001991
1992 int arity() const { return hydrogen()->argument_count() - 1; }
1993};
1994
1995
1996class LCallNewArray FINAL : public LTemplateInstruction<1, 2, 0> {
1997 public:
1998 LCallNewArray(LOperand* context, LOperand* constructor) {
1999 inputs_[0] = context;
2000 inputs_[1] = constructor;
2001 }
2002
2003 LOperand* context() { return inputs_[0]; }
2004 LOperand* constructor() { return inputs_[1]; }
2005
2006 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
2007 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
2008
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002009 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002010
2011 int arity() const { return hydrogen()->argument_count() - 1; }
2012};
2013
2014
2015class LCallRuntime FINAL : public LTemplateInstruction<1, 1, 0> {
2016 public:
2017 explicit LCallRuntime(LOperand* context) {
2018 inputs_[0] = context;
2019 }
2020
2021 LOperand* context() { return inputs_[0]; }
2022
2023 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
2024 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
2025
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002026 bool ClobbersDoubleRegisters(Isolate* isolate) const OVERRIDE {
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002027 return save_doubles() == kDontSaveFPRegs;
2028 }
2029
2030 const Runtime::Function* function() const { return hydrogen()->function(); }
2031 int arity() const { return hydrogen()->argument_count(); }
2032 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
2033};
2034
2035
2036class LInteger32ToDouble FINAL : public LTemplateInstruction<1, 1, 0> {
2037 public:
2038 explicit LInteger32ToDouble(LOperand* value) {
2039 inputs_[0] = value;
2040 }
2041
2042 LOperand* value() { return inputs_[0]; }
2043
2044 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
2045};
2046
2047
2048class LUint32ToDouble FINAL : public LTemplateInstruction<1, 1, 1> {
2049 public:
2050 explicit LUint32ToDouble(LOperand* value) {
2051 inputs_[0] = value;
2052 }
2053
2054 LOperand* value() { return inputs_[0]; }
2055
2056 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
2057};
2058
2059
2060class LNumberTagI FINAL : public LTemplateInstruction<1, 1, 1> {
2061 public:
2062 LNumberTagI(LOperand* value, LOperand* temp) {
2063 inputs_[0] = value;
2064 temps_[0] = temp;
2065 }
2066
2067 LOperand* value() { return inputs_[0]; }
2068 LOperand* temp() { return temps_[0]; }
2069
2070 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
2071};
2072
2073
2074class LNumberTagU FINAL : public LTemplateInstruction<1, 1, 1> {
2075 public:
2076 LNumberTagU(LOperand* value, LOperand* temp) {
2077 inputs_[0] = value;
2078 temps_[0] = temp;
2079 }
2080
2081 LOperand* value() { return inputs_[0]; }
2082 LOperand* temp() { return temps_[0]; }
2083
2084 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
2085};
2086
2087
2088class LNumberTagD FINAL : public LTemplateInstruction<1, 1, 1> {
2089 public:
2090 LNumberTagD(LOperand* value, LOperand* temp) {
2091 inputs_[0] = value;
2092 temps_[0] = temp;
2093 }
2094
2095 LOperand* value() { return inputs_[0]; }
2096 LOperand* temp() { return temps_[0]; }
2097
2098 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
2099 DECLARE_HYDROGEN_ACCESSOR(Change)
2100};
2101
2102
2103// Sometimes truncating conversion from a tagged value to an int32.
2104class LDoubleToI FINAL : public LTemplateInstruction<1, 1, 0> {
2105 public:
2106 explicit LDoubleToI(LOperand* value) {
2107 inputs_[0] = value;
2108 }
2109
2110 LOperand* value() { return inputs_[0]; }
2111
2112 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
2113 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2114
2115 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2116};
2117
2118
2119class LDoubleToSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2120 public:
2121 explicit LDoubleToSmi(LOperand* value) {
2122 inputs_[0] = value;
2123 }
2124
2125 LOperand* value() { return inputs_[0]; }
2126
2127 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
2128 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2129};
2130
2131
2132// Truncating conversion from a tagged value to an int32.
2133class LTaggedToI FINAL : public LTemplateInstruction<1, 1, 0> {
2134 public:
2135 explicit LTaggedToI(LOperand* value) {
2136 inputs_[0] = value;
2137 }
2138
2139 LOperand* value() { return inputs_[0]; }
2140
2141 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
2142 DECLARE_HYDROGEN_ACCESSOR(Change)
2143
2144 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
2145};
2146
2147
2148class LSmiTag FINAL : public LTemplateInstruction<1, 1, 0> {
2149 public:
2150 explicit LSmiTag(LOperand* value) {
2151 inputs_[0] = value;
2152 }
2153
2154 LOperand* value() { return inputs_[0]; }
2155
2156 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
2157 DECLARE_HYDROGEN_ACCESSOR(Change)
2158};
2159
2160
2161class LNumberUntagD FINAL : public LTemplateInstruction<1, 1, 1> {
2162 public:
2163 explicit LNumberUntagD(LOperand* value, LOperand* temp) {
2164 inputs_[0] = value;
2165 temps_[0] = temp;
2166 }
2167
2168 LOperand* value() { return inputs_[0]; }
2169 LOperand* temp() { return temps_[0]; }
2170
2171 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
2172 DECLARE_HYDROGEN_ACCESSOR(Change);
2173};
2174
2175
2176class LSmiUntag FINAL : public LTemplateInstruction<1, 1, 0> {
2177 public:
2178 LSmiUntag(LOperand* value, bool needs_check)
2179 : needs_check_(needs_check) {
2180 inputs_[0] = value;
2181 }
2182
2183 LOperand* value() { return inputs_[0]; }
2184
2185 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
2186
2187 bool needs_check() const { return needs_check_; }
2188
2189 private:
2190 bool needs_check_;
2191};
2192
2193
2194class LStoreNamedField FINAL : public LTemplateInstruction<0, 2, 2> {
2195 public:
2196 LStoreNamedField(LOperand* obj,
2197 LOperand* val,
2198 LOperand* temp,
2199 LOperand* temp_map) {
2200 inputs_[0] = obj;
2201 inputs_[1] = val;
2202 temps_[0] = temp;
2203 temps_[1] = temp_map;
2204 }
2205
2206 LOperand* object() { return inputs_[0]; }
2207 LOperand* value() { return inputs_[1]; }
2208 LOperand* temp() { return temps_[0]; }
2209 LOperand* temp_map() { return temps_[1]; }
2210
2211 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2212 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2213
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002214 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002215};
2216
2217
2218class LStoreNamedGeneric FINAL : public LTemplateInstruction<0, 3, 0> {
2219 public:
2220 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value) {
2221 inputs_[0] = context;
2222 inputs_[1] = object;
2223 inputs_[2] = value;
2224 }
2225
2226 LOperand* context() { return inputs_[0]; }
2227 LOperand* object() { return inputs_[1]; }
2228 LOperand* value() { return inputs_[2]; }
2229
2230 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2231 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2232
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002233 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002234 Handle<Object> name() const { return hydrogen()->name(); }
2235 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2236};
2237
2238
2239class LStoreKeyed FINAL : public LTemplateInstruction<0, 3, 0> {
2240 public:
2241 LStoreKeyed(LOperand* obj, LOperand* key, LOperand* val) {
2242 inputs_[0] = obj;
2243 inputs_[1] = key;
2244 inputs_[2] = val;
2245 }
2246
2247 bool is_external() const { return hydrogen()->is_external(); }
2248 bool is_fixed_typed_array() const {
2249 return hydrogen()->is_fixed_typed_array();
2250 }
2251 bool is_typed_elements() const {
2252 return is_external() || is_fixed_typed_array();
2253 }
2254 LOperand* elements() { return inputs_[0]; }
2255 LOperand* key() { return inputs_[1]; }
2256 LOperand* value() { return inputs_[2]; }
2257 ElementsKind elements_kind() const {
2258 return hydrogen()->elements_kind();
2259 }
2260
2261 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2262 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2263
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002264 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002265 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2266 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2267};
2268
2269
2270class LStoreKeyedGeneric FINAL : public LTemplateInstruction<0, 4, 0> {
2271 public:
2272 LStoreKeyedGeneric(LOperand* context,
2273 LOperand* object,
2274 LOperand* key,
2275 LOperand* value) {
2276 inputs_[0] = context;
2277 inputs_[1] = object;
2278 inputs_[2] = key;
2279 inputs_[3] = value;
2280 }
2281
2282 LOperand* context() { return inputs_[0]; }
2283 LOperand* object() { return inputs_[1]; }
2284 LOperand* key() { return inputs_[2]; }
2285 LOperand* value() { return inputs_[3]; }
2286
2287 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2288 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2289
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002290 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002291
2292 StrictMode strict_mode() { return hydrogen()->strict_mode(); }
2293};
2294
2295
2296class LTransitionElementsKind FINAL : public LTemplateInstruction<0, 2, 2> {
2297 public:
2298 LTransitionElementsKind(LOperand* object,
2299 LOperand* context,
2300 LOperand* new_map_temp,
2301 LOperand* temp) {
2302 inputs_[0] = object;
2303 inputs_[1] = context;
2304 temps_[0] = new_map_temp;
2305 temps_[1] = temp;
2306 }
2307
2308 LOperand* context() { return inputs_[1]; }
2309 LOperand* object() { return inputs_[0]; }
2310 LOperand* new_map_temp() { return temps_[0]; }
2311 LOperand* temp() { return temps_[1]; }
2312
2313 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2314 "transition-elements-kind")
2315 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2316
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002317 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002318
2319 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2320 Handle<Map> transitioned_map() {
2321 return hydrogen()->transitioned_map().handle();
2322 }
2323 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2324 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2325};
2326
2327
2328class LTrapAllocationMemento FINAL : public LTemplateInstruction<0, 1, 1> {
2329 public:
2330 LTrapAllocationMemento(LOperand* object,
2331 LOperand* temp) {
2332 inputs_[0] = object;
2333 temps_[0] = temp;
2334 }
2335
2336 LOperand* object() { return inputs_[0]; }
2337 LOperand* temp() { return temps_[0]; }
2338
2339 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2340 "trap-allocation-memento")
2341};
2342
2343
2344class LStringAdd FINAL : public LTemplateInstruction<1, 3, 0> {
2345 public:
2346 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2347 inputs_[0] = context;
2348 inputs_[1] = left;
2349 inputs_[2] = right;
2350 }
2351
2352 LOperand* context() { return inputs_[0]; }
2353 LOperand* left() { return inputs_[1]; }
2354 LOperand* right() { return inputs_[2]; }
2355
2356 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2357 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2358};
2359
2360
2361class LStringCharCodeAt FINAL : public LTemplateInstruction<1, 3, 0> {
2362 public:
2363 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2364 inputs_[0] = context;
2365 inputs_[1] = string;
2366 inputs_[2] = index;
2367 }
2368
2369 LOperand* context() { return inputs_[0]; }
2370 LOperand* string() { return inputs_[1]; }
2371 LOperand* index() { return inputs_[2]; }
2372
2373 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2374 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2375};
2376
2377
2378class LStringCharFromCode FINAL : public LTemplateInstruction<1, 2, 0> {
2379 public:
2380 LStringCharFromCode(LOperand* context, LOperand* char_code) {
2381 inputs_[0] = context;
2382 inputs_[1] = char_code;
2383 }
2384
2385 LOperand* context() { return inputs_[0]; }
2386 LOperand* char_code() { return inputs_[1]; }
2387
2388 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2389 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2390};
2391
2392
2393class LCheckValue FINAL : public LTemplateInstruction<0, 1, 0> {
2394 public:
2395 explicit LCheckValue(LOperand* value) {
2396 inputs_[0] = value;
2397 }
2398
2399 LOperand* value() { return inputs_[0]; }
2400
2401 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2402 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2403};
2404
2405
2406class LCheckInstanceType FINAL : public LTemplateInstruction<0, 1, 1> {
2407 public:
2408 LCheckInstanceType(LOperand* value, LOperand* temp) {
2409 inputs_[0] = value;
2410 temps_[0] = temp;
2411 }
2412
2413 LOperand* value() { return inputs_[0]; }
2414 LOperand* temp() { return temps_[0]; }
2415
2416 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2417 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2418};
2419
2420
2421class LCheckMaps FINAL : public LTemplateInstruction<0, 1, 0> {
2422 public:
2423 explicit LCheckMaps(LOperand* value = NULL) {
2424 inputs_[0] = value;
2425 }
2426
2427 LOperand* value() { return inputs_[0]; }
2428
2429 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2430 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2431};
2432
2433
2434class LCheckSmi FINAL : public LTemplateInstruction<1, 1, 0> {
2435 public:
2436 explicit LCheckSmi(LOperand* value) {
2437 inputs_[0] = value;
2438 }
2439
2440 LOperand* value() { return inputs_[0]; }
2441
2442 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2443};
2444
2445
2446class LClampDToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2447 public:
2448 explicit LClampDToUint8(LOperand* value) {
2449 inputs_[0] = value;
2450 }
2451
2452 LOperand* unclamped() { return inputs_[0]; }
2453
2454 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2455};
2456
2457
2458class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
2459 public:
2460 explicit LClampIToUint8(LOperand* value) {
2461 inputs_[0] = value;
2462 }
2463
2464 LOperand* unclamped() { return inputs_[0]; }
2465
2466 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2467};
2468
2469
2470// Truncating conversion from a tagged value to an int32.
2471class LClampTToUint8NoSSE2 FINAL : public LTemplateInstruction<1, 1, 3> {
2472 public:
2473 LClampTToUint8NoSSE2(LOperand* unclamped,
2474 LOperand* temp1,
2475 LOperand* temp2,
2476 LOperand* temp3) {
2477 inputs_[0] = unclamped;
2478 temps_[0] = temp1;
2479 temps_[1] = temp2;
2480 temps_[2] = temp3;
2481 }
2482
2483 LOperand* unclamped() { return inputs_[0]; }
2484 LOperand* scratch() { return temps_[0]; }
2485 LOperand* scratch2() { return temps_[1]; }
2486 LOperand* scratch3() { return temps_[2]; }
2487
2488 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8NoSSE2,
2489 "clamp-t-to-uint8-nosse2")
2490 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
2491};
2492
2493
2494class LCheckNonSmi FINAL : public LTemplateInstruction<0, 1, 0> {
2495 public:
2496 explicit LCheckNonSmi(LOperand* value) {
2497 inputs_[0] = value;
2498 }
2499
2500 LOperand* value() { return inputs_[0]; }
2501
2502 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2503 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2504};
2505
2506
2507class LDoubleBits FINAL : public LTemplateInstruction<1, 1, 0> {
2508 public:
2509 explicit LDoubleBits(LOperand* value) {
2510 inputs_[0] = value;
2511 }
2512
2513 LOperand* value() { return inputs_[0]; }
2514
2515 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2516 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2517};
2518
2519
2520class LConstructDouble FINAL : public LTemplateInstruction<1, 2, 0> {
2521 public:
2522 LConstructDouble(LOperand* hi, LOperand* lo) {
2523 inputs_[0] = hi;
2524 inputs_[1] = lo;
2525 }
2526
2527 LOperand* hi() { return inputs_[0]; }
2528 LOperand* lo() { return inputs_[1]; }
2529
2530 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2531};
2532
2533
2534class LAllocate FINAL : public LTemplateInstruction<1, 2, 1> {
2535 public:
2536 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2537 inputs_[0] = context;
2538 inputs_[1] = size;
2539 temps_[0] = temp;
2540 }
2541
2542 LOperand* context() { return inputs_[0]; }
2543 LOperand* size() { return inputs_[1]; }
2544 LOperand* temp() { return temps_[0]; }
2545
2546 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2547 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2548};
2549
2550
2551class LRegExpLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2552 public:
2553 explicit LRegExpLiteral(LOperand* context) {
2554 inputs_[0] = context;
2555 }
2556
2557 LOperand* context() { return inputs_[0]; }
2558
2559 DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal")
2560 DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral)
2561};
2562
2563
2564class LFunctionLiteral FINAL : public LTemplateInstruction<1, 1, 0> {
2565 public:
2566 explicit LFunctionLiteral(LOperand* context) {
2567 inputs_[0] = context;
2568 }
2569
2570 LOperand* context() { return inputs_[0]; }
2571
2572 DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal")
2573 DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral)
2574};
2575
2576
2577class LToFastProperties FINAL : public LTemplateInstruction<1, 1, 0> {
2578 public:
2579 explicit LToFastProperties(LOperand* value) {
2580 inputs_[0] = value;
2581 }
2582
2583 LOperand* value() { return inputs_[0]; }
2584
2585 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties")
2586 DECLARE_HYDROGEN_ACCESSOR(ToFastProperties)
2587};
2588
2589
2590class LTypeof FINAL : public LTemplateInstruction<1, 2, 0> {
2591 public:
2592 LTypeof(LOperand* context, LOperand* value) {
2593 inputs_[0] = context;
2594 inputs_[1] = value;
2595 }
2596
2597 LOperand* context() { return inputs_[0]; }
2598 LOperand* value() { return inputs_[1]; }
2599
2600 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2601};
2602
2603
2604class LTypeofIsAndBranch FINAL : public LControlInstruction<1, 0> {
2605 public:
2606 explicit LTypeofIsAndBranch(LOperand* value) {
2607 inputs_[0] = value;
2608 }
2609
2610 LOperand* value() { return inputs_[0]; }
2611
2612 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2613 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2614
2615 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2616
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002617 void PrintDataTo(StringStream* stream) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002618};
2619
2620
2621class LOsrEntry FINAL : public LTemplateInstruction<0, 0, 0> {
2622 public:
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002623 bool HasInterestingComment(LCodeGen* gen) const OVERRIDE { return false; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002624 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2625};
2626
2627
2628class LStackCheck FINAL : public LTemplateInstruction<0, 1, 0> {
2629 public:
2630 explicit LStackCheck(LOperand* context) {
2631 inputs_[0] = context;
2632 }
2633
2634 LOperand* context() { return inputs_[0]; }
2635
2636 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2637 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2638
2639 Label* done_label() { return &done_label_; }
2640
2641 private:
2642 Label done_label_;
2643};
2644
2645
2646class LForInPrepareMap FINAL : public LTemplateInstruction<1, 2, 0> {
2647 public:
2648 LForInPrepareMap(LOperand* context, LOperand* object) {
2649 inputs_[0] = context;
2650 inputs_[1] = object;
2651 }
2652
2653 LOperand* context() { return inputs_[0]; }
2654 LOperand* object() { return inputs_[1]; }
2655
2656 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2657};
2658
2659
2660class LForInCacheArray FINAL : public LTemplateInstruction<1, 1, 0> {
2661 public:
2662 explicit LForInCacheArray(LOperand* map) {
2663 inputs_[0] = map;
2664 }
2665
2666 LOperand* map() { return inputs_[0]; }
2667
2668 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2669
2670 int idx() {
2671 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2672 }
2673};
2674
2675
2676class LCheckMapValue FINAL : public LTemplateInstruction<0, 2, 0> {
2677 public:
2678 LCheckMapValue(LOperand* value, LOperand* map) {
2679 inputs_[0] = value;
2680 inputs_[1] = map;
2681 }
2682
2683 LOperand* value() { return inputs_[0]; }
2684 LOperand* map() { return inputs_[1]; }
2685
2686 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2687};
2688
2689
2690class LLoadFieldByIndex FINAL : public LTemplateInstruction<1, 2, 0> {
2691 public:
2692 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2693 inputs_[0] = object;
2694 inputs_[1] = index;
2695 }
2696
2697 LOperand* object() { return inputs_[0]; }
2698 LOperand* index() { return inputs_[1]; }
2699
2700 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2701};
2702
2703
2704class LStoreFrameContext: public LTemplateInstruction<0, 1, 0> {
2705 public:
2706 explicit LStoreFrameContext(LOperand* context) {
2707 inputs_[0] = context;
2708 }
2709
2710 LOperand* context() { return inputs_[0]; }
2711
2712 DECLARE_CONCRETE_INSTRUCTION(StoreFrameContext, "store-frame-context")
2713};
2714
2715
2716class LAllocateBlockContext: public LTemplateInstruction<1, 2, 0> {
2717 public:
2718 LAllocateBlockContext(LOperand* context, LOperand* function) {
2719 inputs_[0] = context;
2720 inputs_[1] = function;
2721 }
2722
2723 LOperand* context() { return inputs_[0]; }
2724 LOperand* function() { return inputs_[1]; }
2725
2726 Handle<ScopeInfo> scope_info() { return hydrogen()->scope_info(); }
2727
2728 DECLARE_CONCRETE_INSTRUCTION(AllocateBlockContext, "allocate-block-context")
2729 DECLARE_HYDROGEN_ACCESSOR(AllocateBlockContext)
2730};
2731
2732
2733class LChunkBuilder;
2734class LPlatformChunk FINAL : public LChunk {
2735 public:
2736 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2737 : LChunk(info, graph),
2738 num_double_slots_(0) { }
2739
2740 int GetNextSpillIndex(RegisterKind kind);
2741 LOperand* GetNextSpillSlot(RegisterKind kind);
2742
2743 int num_double_slots() const { return num_double_slots_; }
2744
2745 private:
2746 int num_double_slots_;
2747};
2748
2749
2750class LChunkBuilder FINAL : public LChunkBuilderBase {
2751 public:
2752 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2753 : LChunkBuilderBase(info, graph),
2754 current_instruction_(NULL),
2755 current_block_(NULL),
2756 next_block_(NULL),
2757 allocator_(allocator) {}
2758
2759 // Build the sequence for the graph.
2760 LPlatformChunk* Build();
2761
2762 // Declare methods that deal with the individual node types.
2763#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2764 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2765#undef DECLARE_DO
2766
2767 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2768 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2769 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2770 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2771 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2772 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2773 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2774 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2775 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2776 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2777 LInstruction* DoDivByConstI(HDiv* instr);
2778 LInstruction* DoDivI(HDiv* instr);
2779 LInstruction* DoModByPowerOf2I(HMod* instr);
2780 LInstruction* DoModByConstI(HMod* instr);
2781 LInstruction* DoModI(HMod* instr);
2782 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2783 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2784 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2785
2786 private:
2787 // Methods for getting operands for Use / Define / Temp.
2788 LUnallocated* ToUnallocated(Register reg);
2789 LUnallocated* ToUnallocated(X87Register reg);
2790
2791 // Methods for setting up define-use relationships.
2792 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2793 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2794
2795 // A value that is guaranteed to be allocated to a register.
2796 // Operand created by UseRegister is guaranteed to be live until the end of
2797 // instruction. This means that register allocator will not reuse it's
2798 // register for any other operand inside instruction.
2799 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2800 // instruction start. Register allocator is free to assign the same register
2801 // to some other operand used inside instruction (i.e. temporary or
2802 // output).
2803 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2804 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2805
2806 // An input operand in a register that may be trashed.
2807 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2808
2809 // An input operand in a register or stack slot.
2810 MUST_USE_RESULT LOperand* Use(HValue* value);
2811 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2812
2813 // An input operand in a register, stack slot or a constant operand.
2814 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2815 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2816
2817 // An input operand in a fixed register or a constant operand.
2818 MUST_USE_RESULT LOperand* UseFixedOrConstant(HValue* value,
2819 Register fixed_register);
2820
2821 // An input operand in a register or a constant operand.
2822 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2823 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2824
2825 // An input operand in a constant operand.
2826 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2827
2828 // An input operand in register, stack slot or a constant operand.
2829 // Will not be moved to a register even if one is freely available.
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002830 MUST_USE_RESULT LOperand* UseAny(HValue* value) OVERRIDE;
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002831
2832 // Temporary operand that must be in a register.
2833 MUST_USE_RESULT LUnallocated* TempRegister();
2834 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2835
2836 // Methods for setting up define-use relationships.
2837 // Return the same instruction that they are passed.
2838 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2839 LUnallocated* result);
2840 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2841 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2842 int index);
2843 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2844 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2845 Register reg);
2846 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2847 X87Register reg);
2848 LInstruction* DefineX87TOS(LTemplateResultInstruction<1>* instr);
2849 // Assigns an environment to an instruction. An instruction which can
2850 // deoptimize must have an environment.
2851 LInstruction* AssignEnvironment(LInstruction* instr);
2852 // Assigns a pointer map to an instruction. An instruction which can
2853 // trigger a GC or a lazy deoptimization must have a pointer map.
2854 LInstruction* AssignPointerMap(LInstruction* instr);
2855
2856 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2857
2858 LOperand* GetSeqStringSetCharOperand(HSeqStringSetChar* instr);
2859
2860 // Marks a call for the register allocator. Assigns a pointer map to
2861 // support GC and lazy deoptimization. Assigns an environment to support
2862 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2863 LInstruction* MarkAsCall(
2864 LInstruction* instr,
2865 HInstruction* hinstr,
2866 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2867
2868 void VisitInstruction(HInstruction* current);
2869 void AddInstruction(LInstruction* instr, HInstruction* current);
2870
2871 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2872 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2873 LInstruction* DoArithmeticD(Token::Value op,
2874 HArithmeticBinaryOperation* instr);
2875 LInstruction* DoArithmeticT(Token::Value op,
2876 HBinaryOperation* instr);
2877
2878 LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
2879
2880 HInstruction* current_instruction_;
2881 HBasicBlock* current_block_;
2882 HBasicBlock* next_block_;
2883 LAllocator* allocator_;
2884
2885 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2886};
2887
2888#undef DECLARE_HYDROGEN_ACCESSOR
2889#undef DECLARE_CONCRETE_INSTRUCTION
2890
2891} } // namespace v8::internal
2892
2893#endif // V8_X87_LITHIUM_X87_H_