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