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