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