blob: 91f554137ac9d17c4e36f01ee74babfdfdadea7e [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) \
Ben Murdochc5610432016-08-08 18:44:38 +010070 V(FastAllocate) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000071 V(FlooringDivByConstI) \
72 V(FlooringDivByPowerOf2I) \
73 V(FlooringDivI) \
74 V(ForInCacheArray) \
75 V(ForInPrepareMap) \
76 V(GetCachedArrayIndex) \
77 V(Goto) \
78 V(HasCachedArrayIndexAndBranch) \
79 V(HasInPrototypeChainAndBranch) \
80 V(HasInstanceTypeAndBranch) \
81 V(InnerAllocatedObject) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000082 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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001139class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1140 public:
1141 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1142 inputs_[0] = object;
1143 inputs_[1] = prototype;
1144 }
1145
1146 LOperand* object() const { return inputs_[0]; }
1147 LOperand* prototype() const { return inputs_[1]; }
1148
1149 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1150 "has-in-prototype-chain-and-branch")
1151 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1152};
1153
1154
1155class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1156 public:
1157 LBoundsCheck(LOperand* index, LOperand* length) {
1158 inputs_[0] = index;
1159 inputs_[1] = length;
1160 }
1161
1162 LOperand* index() { return inputs_[0]; }
1163 LOperand* length() { return inputs_[1]; }
1164
1165 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1166 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1167};
1168
1169
1170class LBitI final : public LTemplateInstruction<1, 2, 0> {
1171 public:
1172 LBitI(LOperand* left, LOperand* right) {
1173 inputs_[0] = left;
1174 inputs_[1] = right;
1175 }
1176
1177 LOperand* left() { return inputs_[0]; }
1178 LOperand* right() { return inputs_[1]; }
1179
1180 Token::Value op() const { return hydrogen()->op(); }
1181 bool IsInteger32() const {
1182 return hydrogen()->representation().IsInteger32();
1183 }
1184
1185 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1186 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1187};
1188
1189
1190class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1191 public:
1192 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1193 : op_(op), can_deopt_(can_deopt) {
1194 inputs_[0] = left;
1195 inputs_[1] = right;
1196 }
1197
1198 Token::Value op() const { return op_; }
1199 LOperand* left() { return inputs_[0]; }
1200 LOperand* right() { return inputs_[1]; }
1201 bool can_deopt() const { return can_deopt_; }
1202
1203 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1204
1205 private:
1206 Token::Value op_;
1207 bool can_deopt_;
1208};
1209
1210
1211class LSubI final : public LTemplateInstruction<1, 2, 0> {
1212 public:
1213 LSubI(LOperand* left, LOperand* right) {
1214 inputs_[0] = left;
1215 inputs_[1] = right;
1216 }
1217
1218 LOperand* left() { return inputs_[0]; }
1219 LOperand* right() { return inputs_[1]; }
1220
1221 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1222 DECLARE_HYDROGEN_ACCESSOR(Sub)
1223};
1224
1225
1226class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1227 public:
1228 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1229 DECLARE_HYDROGEN_ACCESSOR(Constant)
1230
1231 int32_t value() const { return hydrogen()->Integer32Value(); }
1232};
1233
1234
1235class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1236 public:
1237 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1238 DECLARE_HYDROGEN_ACCESSOR(Constant)
1239
1240 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1241};
1242
1243
1244class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1245 public:
1246 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1247 DECLARE_HYDROGEN_ACCESSOR(Constant)
1248
1249 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1250};
1251
1252
1253class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1254 public:
1255 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1256 DECLARE_HYDROGEN_ACCESSOR(Constant)
1257
1258 ExternalReference value() const {
1259 return hydrogen()->ExternalReferenceValue();
1260 }
1261};
1262
1263
1264class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1265 public:
1266 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1267 DECLARE_HYDROGEN_ACCESSOR(Constant)
1268
1269 Handle<Object> value(Isolate* isolate) const {
1270 return hydrogen()->handle(isolate);
1271 }
1272};
1273
1274
1275class LBranch final : public LControlInstruction<1, 0> {
1276 public:
1277 explicit LBranch(LOperand* value) {
1278 inputs_[0] = value;
1279 }
1280
1281 LOperand* value() { return inputs_[0]; }
1282
1283 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1284 DECLARE_HYDROGEN_ACCESSOR(Branch)
1285
1286 void PrintDataTo(StringStream* stream) override;
1287};
1288
1289
1290class LDebugBreak final : public LTemplateInstruction<0, 0, 0> {
1291 public:
1292 DECLARE_CONCRETE_INSTRUCTION(DebugBreak, "break")
1293};
1294
1295
1296class LCmpMapAndBranch final : public LControlInstruction<1, 0> {
1297 public:
1298 explicit LCmpMapAndBranch(LOperand* value) {
1299 inputs_[0] = value;
1300 }
1301
1302 LOperand* value() { return inputs_[0]; }
1303
1304 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1305 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1306
1307 Handle<Map> map() const { return hydrogen()->map().handle(); }
1308};
1309
1310
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001311class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1312 public:
1313 LSeqStringGetChar(LOperand* string, LOperand* index) {
1314 inputs_[0] = string;
1315 inputs_[1] = index;
1316 }
1317
1318 LOperand* string() const { return inputs_[0]; }
1319 LOperand* index() const { return inputs_[1]; }
1320
1321 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1322 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1323};
1324
1325
1326class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1327 public:
1328 LSeqStringSetChar(LOperand* context,
1329 LOperand* string,
1330 LOperand* index,
1331 LOperand* value) {
1332 inputs_[0] = context;
1333 inputs_[1] = string;
1334 inputs_[2] = index;
1335 inputs_[3] = value;
1336 }
1337
1338 LOperand* string() { return inputs_[1]; }
1339 LOperand* index() { return inputs_[2]; }
1340 LOperand* value() { return inputs_[3]; }
1341
1342 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1343 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1344};
1345
1346
1347class LAddI final : public LTemplateInstruction<1, 2, 0> {
1348 public:
1349 LAddI(LOperand* left, LOperand* right) {
1350 inputs_[0] = left;
1351 inputs_[1] = right;
1352 }
1353
1354 LOperand* left() { return inputs_[0]; }
1355 LOperand* right() { return inputs_[1]; }
1356
1357 static bool UseLea(HAdd* add) {
1358 return !add->CheckFlag(HValue::kCanOverflow) &&
1359 add->BetterLeftOperand()->UseCount() > 1;
1360 }
1361
1362 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1363 DECLARE_HYDROGEN_ACCESSOR(Add)
1364};
1365
1366
1367class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1368 public:
1369 LMathMinMax(LOperand* left, LOperand* right) {
1370 inputs_[0] = left;
1371 inputs_[1] = right;
1372 }
1373
1374 LOperand* left() { return inputs_[0]; }
1375 LOperand* right() { return inputs_[1]; }
1376
1377 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1378 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1379};
1380
1381
1382class LPower final : public LTemplateInstruction<1, 2, 0> {
1383 public:
1384 LPower(LOperand* left, LOperand* right) {
1385 inputs_[0] = left;
1386 inputs_[1] = right;
1387 }
1388
1389 LOperand* left() { return inputs_[0]; }
1390 LOperand* right() { return inputs_[1]; }
1391
1392 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1393 DECLARE_HYDROGEN_ACCESSOR(Power)
1394};
1395
1396
1397class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1398 public:
1399 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1400 : op_(op) {
1401 inputs_[0] = left;
1402 inputs_[1] = right;
1403 }
1404
1405 Token::Value op() const { return op_; }
1406 LOperand* left() { return inputs_[0]; }
1407 LOperand* right() { return inputs_[1]; }
1408
1409 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1410 void CompileToNative(LCodeGen* generator) override;
1411 const char* Mnemonic() const override;
1412
1413 private:
1414 Token::Value op_;
1415};
1416
1417
1418class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1419 public:
1420 LArithmeticT(Token::Value op,
1421 LOperand* context,
1422 LOperand* left,
1423 LOperand* right)
1424 : op_(op) {
1425 inputs_[0] = context;
1426 inputs_[1] = left;
1427 inputs_[2] = right;
1428 }
1429
1430 Token::Value op() const { return op_; }
1431 LOperand* context() { return inputs_[0]; }
1432 LOperand* left() { return inputs_[1]; }
1433 LOperand* right() { return inputs_[2]; }
1434
1435 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1436 void CompileToNative(LCodeGen* generator) override;
1437 const char* Mnemonic() const override;
1438
1439 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1440
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001441 private:
1442 Token::Value op_;
1443};
1444
1445
1446class LReturn final : public LTemplateInstruction<0, 3, 0> {
1447 public:
1448 explicit LReturn(LOperand* value,
1449 LOperand* context,
1450 LOperand* parameter_count) {
1451 inputs_[0] = value;
1452 inputs_[1] = context;
1453 inputs_[2] = parameter_count;
1454 }
1455
1456 LOperand* value() { return inputs_[0]; }
1457 LOperand* context() { return inputs_[1]; }
1458
1459 bool has_constant_parameter_count() {
1460 return parameter_count()->IsConstantOperand();
1461 }
1462 LConstantOperand* constant_parameter_count() {
1463 DCHECK(has_constant_parameter_count());
1464 return LConstantOperand::cast(parameter_count());
1465 }
1466 LOperand* parameter_count() { return inputs_[2]; }
1467
1468 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1469 DECLARE_HYDROGEN_ACCESSOR(Return)
1470};
1471
1472
1473class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1474 public:
1475 explicit LLoadNamedField(LOperand* object) {
1476 inputs_[0] = object;
1477 }
1478
1479 LOperand* object() { return inputs_[0]; }
1480
1481 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1482 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1483};
1484
1485
1486class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1487 public:
1488 explicit LLoadNamedGeneric(LOperand* context, LOperand* object,
1489 LOperand* vector) {
1490 inputs_[0] = context;
1491 inputs_[1] = object;
1492 temps_[0] = vector;
1493 }
1494
1495 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1496 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1497
1498 LOperand* context() { return inputs_[0]; }
1499 LOperand* object() { return inputs_[1]; }
1500 LOperand* temp_vector() { return temps_[0]; }
1501
1502 Handle<Object> name() const { return hydrogen()->name(); }
1503};
1504
1505
1506class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1507 public:
1508 explicit LLoadFunctionPrototype(LOperand* function) {
1509 inputs_[0] = function;
1510 }
1511
1512 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1513 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1514
1515 LOperand* function() { return inputs_[0]; }
1516};
1517
1518
1519class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1520 public:
1521 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1522 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1523
1524 Heap::RootListIndex index() const { return hydrogen()->index(); }
1525};
1526
1527
1528inline static bool ExternalArrayOpRequiresTemp(
1529 Representation key_representation,
1530 ElementsKind elements_kind) {
1531 // Operations that require the key to be divided by two to be converted into
1532 // an index cannot fold the scale operation into a load and need an extra
1533 // temp register to do the work.
1534 return SmiValuesAre31Bits() && key_representation.IsSmi() &&
1535 (elements_kind == UINT8_ELEMENTS || elements_kind == INT8_ELEMENTS ||
1536 elements_kind == UINT8_CLAMPED_ELEMENTS);
1537}
1538
1539
1540class LLoadKeyed final : public LTemplateInstruction<1, 3, 0> {
1541 public:
1542 LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
1543 inputs_[0] = elements;
1544 inputs_[1] = key;
1545 inputs_[2] = backing_store_owner;
1546 }
1547
1548 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1549 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1550
1551 bool is_fixed_typed_array() const {
1552 return hydrogen()->is_fixed_typed_array();
1553 }
1554 LOperand* elements() { return inputs_[0]; }
1555 LOperand* key() { return inputs_[1]; }
1556 LOperand* backing_store_owner() { return inputs_[2]; }
1557 void PrintDataTo(StringStream* stream) override;
1558 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1559 ElementsKind elements_kind() const {
1560 return hydrogen()->elements_kind();
1561 }
1562};
1563
1564
1565class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1566 public:
1567 LLoadKeyedGeneric(LOperand* context, LOperand* obj, LOperand* key,
1568 LOperand* vector) {
1569 inputs_[0] = context;
1570 inputs_[1] = obj;
1571 inputs_[2] = key;
1572 temps_[0] = vector;
1573 }
1574
1575 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1576 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1577
1578 LOperand* context() { return inputs_[0]; }
1579 LOperand* object() { return inputs_[1]; }
1580 LOperand* key() { return inputs_[2]; }
1581 LOperand* temp_vector() { return temps_[0]; }
1582};
1583
1584
1585class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1586 public:
1587 explicit LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1588 LOperand* vector) {
1589 inputs_[0] = context;
1590 inputs_[1] = global_object;
1591 temps_[0] = vector;
1592 }
1593
1594 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1595 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1596
1597 LOperand* context() { return inputs_[0]; }
1598 LOperand* global_object() { return inputs_[1]; }
1599 LOperand* temp_vector() { return temps_[0]; }
1600
1601 Handle<Object> name() const { return hydrogen()->name(); }
1602 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1603};
1604
1605
1606class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1607 public:
1608 explicit LLoadContextSlot(LOperand* context) {
1609 inputs_[0] = context;
1610 }
1611
1612 LOperand* context() { return inputs_[0]; }
1613
1614 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1615 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1616
1617 int slot_index() { return hydrogen()->slot_index(); }
1618
1619 void PrintDataTo(StringStream* stream) override;
1620};
1621
1622
1623class LStoreContextSlot final : public LTemplateInstruction<0, 2, 1> {
1624 public:
1625 LStoreContextSlot(LOperand* context, LOperand* value, LOperand* temp) {
1626 inputs_[0] = context;
1627 inputs_[1] = value;
1628 temps_[0] = temp;
1629 }
1630
1631 LOperand* context() { return inputs_[0]; }
1632 LOperand* value() { return inputs_[1]; }
1633 LOperand* temp() { return temps_[0]; }
1634
1635 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1636 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1637
1638 int slot_index() { return hydrogen()->slot_index(); }
1639
1640 void PrintDataTo(StringStream* stream) override;
1641};
1642
1643
1644class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1645 public:
1646 explicit LPushArgument(LOperand* value) {
1647 inputs_[0] = value;
1648 }
1649
1650 LOperand* value() { return inputs_[0]; }
1651
1652 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1653};
1654
1655
1656class LDrop final : public LTemplateInstruction<0, 0, 0> {
1657 public:
1658 explicit LDrop(int count) : count_(count) { }
1659
1660 int count() const { return count_; }
1661
1662 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1663
1664 private:
1665 int count_;
1666};
1667
1668
1669class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1670 public:
1671 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1672 inputs_[0] = function;
1673 inputs_[1] = code_object;
1674 }
1675
1676 LOperand* function() { return inputs_[0]; }
1677 LOperand* code_object() { return inputs_[1]; }
1678
1679 void PrintDataTo(StringStream* stream) override;
1680
1681 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1682 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1683};
1684
1685
1686class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1687 public:
1688 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1689 inputs_[0] = base_object;
1690 inputs_[1] = offset;
1691 }
1692
1693 LOperand* base_object() const { return inputs_[0]; }
1694 LOperand* offset() const { return inputs_[1]; }
1695
1696 void PrintDataTo(StringStream* stream) override;
1697
1698 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1699};
1700
1701
1702class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1703 public:
1704 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1705 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1706};
1707
1708
1709class LContext final : public LTemplateInstruction<1, 0, 0> {
1710 public:
1711 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1712 DECLARE_HYDROGEN_ACCESSOR(Context)
1713};
1714
1715
1716class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1717 public:
1718 explicit LDeclareGlobals(LOperand* context) {
1719 inputs_[0] = context;
1720 }
1721
1722 LOperand* context() { return inputs_[0]; }
1723
1724 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1725 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1726};
1727
1728
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001729class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1730 public:
1731 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1732 const ZoneList<LOperand*>& operands, Zone* zone)
1733 : inputs_(descriptor.GetRegisterParameterCount() +
1734 kImplicitRegisterParameterCount,
1735 zone) {
1736 DCHECK(descriptor.GetRegisterParameterCount() +
1737 kImplicitRegisterParameterCount ==
1738 operands.length());
1739 inputs_.AddAll(operands, zone);
1740 }
1741
1742 LOperand* target() const { return inputs_[0]; }
1743
1744 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1745
1746 // The target and context are passed as implicit parameters that are not
1747 // explicitly listed in the descriptor.
1748 static const int kImplicitRegisterParameterCount = 2;
1749
1750 private:
1751 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1752
1753 void PrintDataTo(StringStream* stream) override;
1754
1755 int arity() const { return hydrogen()->argument_count() - 1; }
1756
1757 ZoneList<LOperand*> inputs_;
1758
1759 // Iterator support.
1760 int InputCount() final { return inputs_.length(); }
1761 LOperand* InputAt(int i) final { return inputs_[i]; }
1762
1763 int TempCount() final { return 0; }
1764 LOperand* TempAt(int i) final { return NULL; }
1765};
1766
1767
1768class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1769 public:
1770 LInvokeFunction(LOperand* context, LOperand* function) {
1771 inputs_[0] = context;
1772 inputs_[1] = function;
1773 }
1774
1775 LOperand* context() { return inputs_[0]; }
1776 LOperand* function() { return inputs_[1]; }
1777
1778 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1779 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1780
1781 void PrintDataTo(StringStream* stream) override;
1782
1783 int arity() const { return hydrogen()->argument_count() - 1; }
1784};
1785
1786
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001787class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1788 public:
1789 LCallNewArray(LOperand* context, LOperand* constructor) {
1790 inputs_[0] = context;
1791 inputs_[1] = constructor;
1792 }
1793
1794 LOperand* context() { return inputs_[0]; }
1795 LOperand* constructor() { return inputs_[1]; }
1796
1797 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1798 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1799
1800 void PrintDataTo(StringStream* stream) override;
1801
1802 int arity() const { return hydrogen()->argument_count() - 1; }
1803};
1804
1805
1806class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1807 public:
1808 explicit LCallRuntime(LOperand* context) {
1809 inputs_[0] = context;
1810 }
1811
1812 LOperand* context() { return inputs_[0]; }
1813
1814 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1815 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1816
1817 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1818 return save_doubles() == kDontSaveFPRegs;
1819 }
1820
1821 const Runtime::Function* function() const { return hydrogen()->function(); }
1822 int arity() const { return hydrogen()->argument_count(); }
1823 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1824};
1825
1826
1827class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1828 public:
1829 explicit LInteger32ToDouble(LOperand* value) {
1830 inputs_[0] = value;
1831 }
1832
1833 LOperand* value() { return inputs_[0]; }
1834
1835 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1836};
1837
1838
1839class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1840 public:
1841 explicit LUint32ToDouble(LOperand* value) {
1842 inputs_[0] = value;
1843 }
1844
1845 LOperand* value() { return inputs_[0]; }
1846
1847 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1848};
1849
1850
1851class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1852 public:
1853 LNumberTagI(LOperand* value, LOperand* temp1, LOperand* temp2) {
1854 inputs_[0] = value;
1855 temps_[0] = temp1;
1856 temps_[1] = temp2;
1857 }
1858
1859 LOperand* value() { return inputs_[0]; }
1860 LOperand* temp1() { return temps_[0]; }
1861 LOperand* temp2() { return temps_[1]; }
1862
1863 DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i")
1864};
1865
1866
1867class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1868 public:
1869 LNumberTagU(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(NumberTagU, "number-tag-u")
1880};
1881
1882
1883class LNumberTagD final : public LTemplateInstruction<1, 1, 1> {
1884 public:
1885 explicit LNumberTagD(LOperand* value, LOperand* temp) {
1886 inputs_[0] = value;
1887 temps_[0] = temp;
1888 }
1889
1890 LOperand* value() { return inputs_[0]; }
1891 LOperand* temp() { return temps_[0]; }
1892
1893 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1894 DECLARE_HYDROGEN_ACCESSOR(Change)
1895};
1896
1897
1898// Sometimes truncating conversion from a tagged value to an int32.
1899class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
1900 public:
1901 explicit LDoubleToI(LOperand* value) {
1902 inputs_[0] = value;
1903 }
1904
1905 LOperand* value() { return inputs_[0]; }
1906
1907 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1908 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1909
1910 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1911};
1912
1913
1914class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
1915 public:
1916 explicit LDoubleToSmi(LOperand* value) {
1917 inputs_[0] = value;
1918 }
1919
1920 LOperand* value() { return inputs_[0]; }
1921
1922 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1923 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1924};
1925
1926
1927// Truncating conversion from a tagged value to an int32.
1928class LTaggedToI final : public LTemplateInstruction<1, 1, 1> {
1929 public:
1930 LTaggedToI(LOperand* value, LOperand* temp) {
1931 inputs_[0] = value;
1932 temps_[0] = temp;
1933 }
1934
1935 LOperand* value() { return inputs_[0]; }
1936 LOperand* temp() { return temps_[0]; }
1937
1938 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1939 DECLARE_HYDROGEN_ACCESSOR(Change)
1940
1941 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1942};
1943
1944
1945class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
1946 public:
1947 explicit LSmiTag(LOperand* value) {
1948 inputs_[0] = value;
1949 }
1950
1951 LOperand* value() { return inputs_[0]; }
1952
1953 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1954 DECLARE_HYDROGEN_ACCESSOR(Change)
1955};
1956
1957
1958class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
1959 public:
1960 explicit LNumberUntagD(LOperand* value) {
1961 inputs_[0] = value;
1962 }
1963
1964 LOperand* value() { return inputs_[0]; }
1965
1966 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1967 DECLARE_HYDROGEN_ACCESSOR(Change);
1968};
1969
1970
1971class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
1972 public:
1973 LSmiUntag(LOperand* value, bool needs_check)
1974 : needs_check_(needs_check) {
1975 inputs_[0] = value;
1976 }
1977
1978 LOperand* value() { return inputs_[0]; }
1979 bool needs_check() const { return needs_check_; }
1980
1981 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1982
1983 private:
1984 bool needs_check_;
1985};
1986
1987
1988class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
1989 public:
1990 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
1991 inputs_[0] = object;
1992 inputs_[1] = value;
1993 temps_[0] = temp;
1994 }
1995
1996 LOperand* object() { return inputs_[0]; }
1997 LOperand* value() { return inputs_[1]; }
1998 LOperand* temp() { return temps_[0]; }
1999
2000 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
2001 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
2002
2003 void PrintDataTo(StringStream* stream) override;
2004
2005 Representation representation() const {
2006 return hydrogen()->field_representation();
2007 }
2008};
2009
2010
2011class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
2012 public:
2013 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
2014 LOperand* slot, LOperand* vector) {
2015 inputs_[0] = context;
2016 inputs_[1] = object;
2017 inputs_[2] = value;
2018 temps_[0] = slot;
2019 temps_[1] = vector;
2020 }
2021
2022 LOperand* context() { return inputs_[0]; }
2023 LOperand* object() { return inputs_[1]; }
2024 LOperand* value() { return inputs_[2]; }
2025 LOperand* temp_slot() { return temps_[0]; }
2026 LOperand* temp_vector() { return temps_[1]; }
2027
2028 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
2029 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
2030
2031 void PrintDataTo(StringStream* stream) override;
2032
2033 Handle<Object> name() const { return hydrogen()->name(); }
2034 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2035};
2036
2037
2038class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> {
2039 public:
2040 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
2041 LOperand* backing_store_owner) {
2042 inputs_[0] = object;
2043 inputs_[1] = key;
2044 inputs_[2] = value;
2045 inputs_[3] = backing_store_owner;
2046 }
2047
2048 bool is_fixed_typed_array() const {
2049 return hydrogen()->is_fixed_typed_array();
2050 }
2051 LOperand* elements() { return inputs_[0]; }
2052 LOperand* key() { return inputs_[1]; }
2053 LOperand* value() { return inputs_[2]; }
2054 LOperand* backing_store_owner() { return inputs_[3]; }
2055 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
2056
2057 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
2058 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
2059
2060 void PrintDataTo(StringStream* stream) override;
2061 bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); }
2062 uint32_t base_offset() const { return hydrogen()->base_offset(); }
2063};
2064
2065
2066class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
2067 public:
2068 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
2069 LOperand* value, LOperand* slot, LOperand* vector) {
2070 inputs_[0] = context;
2071 inputs_[1] = object;
2072 inputs_[2] = key;
2073 inputs_[3] = value;
2074 temps_[0] = slot;
2075 temps_[1] = vector;
2076 }
2077
2078 LOperand* context() { return inputs_[0]; }
2079 LOperand* object() { return inputs_[1]; }
2080 LOperand* key() { return inputs_[2]; }
2081 LOperand* value() { return inputs_[3]; }
2082 LOperand* temp_slot() { return temps_[0]; }
2083 LOperand* temp_vector() { return temps_[1]; }
2084
2085 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
2086 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
2087
2088 void PrintDataTo(StringStream* stream) override;
2089
2090 LanguageMode language_mode() { return hydrogen()->language_mode(); }
2091};
2092
2093
2094class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 2> {
2095 public:
2096 LTransitionElementsKind(LOperand* object,
2097 LOperand* context,
2098 LOperand* new_map_temp,
2099 LOperand* temp) {
2100 inputs_[0] = object;
2101 inputs_[1] = context;
2102 temps_[0] = new_map_temp;
2103 temps_[1] = temp;
2104 }
2105
2106 LOperand* object() { return inputs_[0]; }
2107 LOperand* context() { return inputs_[1]; }
2108 LOperand* new_map_temp() { return temps_[0]; }
2109 LOperand* temp() { return temps_[1]; }
2110
2111 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
2112 "transition-elements-kind")
2113 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
2114
2115 void PrintDataTo(StringStream* stream) override;
2116
2117 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
2118 Handle<Map> transitioned_map() {
2119 return hydrogen()->transitioned_map().handle();
2120 }
2121 ElementsKind from_kind() { return hydrogen()->from_kind(); }
2122 ElementsKind to_kind() { return hydrogen()->to_kind(); }
2123};
2124
2125
2126class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
2127 public:
2128 LTrapAllocationMemento(LOperand* object,
2129 LOperand* temp) {
2130 inputs_[0] = object;
2131 temps_[0] = temp;
2132 }
2133
2134 LOperand* object() { return inputs_[0]; }
2135 LOperand* temp() { return temps_[0]; }
2136
2137 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento,
2138 "trap-allocation-memento")
2139};
2140
2141
2142class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
2143 public:
2144 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
2145 LOperand* key, LOperand* current_capacity) {
2146 inputs_[0] = context;
2147 inputs_[1] = object;
2148 inputs_[2] = elements;
2149 inputs_[3] = key;
2150 inputs_[4] = current_capacity;
2151 }
2152
2153 LOperand* context() { return inputs_[0]; }
2154 LOperand* object() { return inputs_[1]; }
2155 LOperand* elements() { return inputs_[2]; }
2156 LOperand* key() { return inputs_[3]; }
2157 LOperand* current_capacity() { return inputs_[4]; }
2158
2159 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
2160 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
2161};
2162
2163
2164class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
2165 public:
2166 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
2167 inputs_[0] = context;
2168 inputs_[1] = left;
2169 inputs_[2] = right;
2170 }
2171
2172 LOperand* context() { return inputs_[0]; }
2173 LOperand* left() { return inputs_[1]; }
2174 LOperand* right() { return inputs_[2]; }
2175
2176 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
2177 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
2178};
2179
2180
2181class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2182 public:
2183 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2184 inputs_[0] = context;
2185 inputs_[1] = string;
2186 inputs_[2] = index;
2187 }
2188
2189 LOperand* context() { return inputs_[0]; }
2190 LOperand* string() { return inputs_[1]; }
2191 LOperand* index() { return inputs_[2]; }
2192
2193 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2194 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2195};
2196
2197
2198class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2199 public:
2200 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2201 inputs_[0] = context;
2202 inputs_[1] = char_code;
2203 }
2204
2205 LOperand* context() { return inputs_[0]; }
2206 LOperand* char_code() { return inputs_[1]; }
2207
2208 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2209 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2210};
2211
2212
2213class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2214 public:
2215 explicit LCheckValue(LOperand* value) {
2216 inputs_[0] = value;
2217 }
2218
2219 LOperand* value() { return inputs_[0]; }
2220
2221 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2222 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2223};
2224
2225
2226class LCheckArrayBufferNotNeutered final
2227 : public LTemplateInstruction<0, 1, 0> {
2228 public:
2229 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2230
2231 LOperand* view() { return inputs_[0]; }
2232
2233 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2234 "check-array-buffer-not-neutered")
2235 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2236};
2237
2238
2239class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2240 public:
2241 explicit LCheckInstanceType(LOperand* value) {
2242 inputs_[0] = value;
2243 }
2244
2245 LOperand* value() { return inputs_[0]; }
2246
2247 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2248 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2249};
2250
2251
2252class LCheckMaps final : public LTemplateInstruction<0, 1, 0> {
2253 public:
2254 explicit LCheckMaps(LOperand* value = NULL) {
2255 inputs_[0] = value;
2256 }
2257
2258 LOperand* value() { return inputs_[0]; }
2259
2260 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2261 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2262};
2263
2264
2265class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2266 public:
2267 explicit LCheckSmi(LOperand* value) {
2268 inputs_[0] = value;
2269 }
2270
2271 LOperand* value() { return inputs_[0]; }
2272
2273 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2274};
2275
2276
2277class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2278 public:
2279 explicit LClampDToUint8(LOperand* unclamped) {
2280 inputs_[0] = unclamped;
2281 }
2282
2283 LOperand* unclamped() { return inputs_[0]; }
2284
2285 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2286};
2287
2288
2289class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2290 public:
2291 explicit LClampIToUint8(LOperand* unclamped) {
2292 inputs_[0] = unclamped;
2293 }
2294
2295 LOperand* unclamped() { return inputs_[0]; }
2296
2297 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2298};
2299
2300
2301class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2302 public:
2303 LClampTToUint8(LOperand* unclamped,
2304 LOperand* temp_xmm) {
2305 inputs_[0] = unclamped;
2306 temps_[0] = temp_xmm;
2307 }
2308
2309 LOperand* unclamped() { return inputs_[0]; }
2310 LOperand* temp_xmm() { return temps_[0]; }
2311
2312 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2313};
2314
2315
2316class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2317 public:
2318 explicit LCheckNonSmi(LOperand* value) {
2319 inputs_[0] = value;
2320 }
2321
2322 LOperand* value() { return inputs_[0]; }
2323
2324 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2325 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2326};
2327
2328
2329class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2330 public:
2331 explicit LDoubleBits(LOperand* value) {
2332 inputs_[0] = value;
2333 }
2334
2335 LOperand* value() { return inputs_[0]; }
2336
2337 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2338 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2339};
2340
2341
2342class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2343 public:
2344 LConstructDouble(LOperand* hi, LOperand* lo) {
2345 inputs_[0] = hi;
2346 inputs_[1] = lo;
2347 }
2348
2349 LOperand* hi() { return inputs_[0]; }
2350 LOperand* lo() { return inputs_[1]; }
2351
2352 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2353};
2354
2355
2356class LAllocate final : public LTemplateInstruction<1, 2, 1> {
2357 public:
2358 LAllocate(LOperand* context, LOperand* size, LOperand* temp) {
2359 inputs_[0] = context;
2360 inputs_[1] = size;
2361 temps_[0] = temp;
2362 }
2363
2364 LOperand* context() { return inputs_[0]; }
2365 LOperand* size() { return inputs_[1]; }
2366 LOperand* temp() { return temps_[0]; }
2367
2368 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2369 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2370};
2371
Ben Murdochc5610432016-08-08 18:44:38 +01002372class LFastAllocate final : public LTemplateInstruction<1, 1, 1> {
2373 public:
2374 LFastAllocate(LOperand* size, LOperand* temp) {
2375 inputs_[0] = size;
2376 temps_[0] = temp;
2377 }
2378
2379 LOperand* size() const { return inputs_[0]; }
2380 LOperand* temp() { return temps_[0]; }
2381
2382 DECLARE_CONCRETE_INSTRUCTION(FastAllocate, "fast-allocate")
2383 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2384};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002385
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002386class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2387 public:
2388 LTypeof(LOperand* context, LOperand* value) {
2389 inputs_[0] = context;
2390 inputs_[1] = value;
2391 }
2392
2393 LOperand* context() { return inputs_[0]; }
2394 LOperand* value() { return inputs_[1]; }
2395
2396 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2397};
2398
2399
2400class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2401 public:
2402 explicit LTypeofIsAndBranch(LOperand* value) {
2403 inputs_[0] = value;
2404 }
2405
2406 LOperand* value() { return inputs_[0]; }
2407
2408 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2409 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2410
2411 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2412
2413 void PrintDataTo(StringStream* stream) override;
2414};
2415
2416
2417class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2418 public:
2419 LOsrEntry() {}
2420
2421 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2422 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2423};
2424
2425
2426class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2427 public:
2428 explicit LStackCheck(LOperand* context) {
2429 inputs_[0] = context;
2430 }
2431
2432 LOperand* context() { return inputs_[0]; }
2433
2434 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2435 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2436
2437 Label* done_label() { return &done_label_; }
2438
2439 private:
2440 Label done_label_;
2441};
2442
2443
2444class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2445 public:
2446 LForInPrepareMap(LOperand* context, LOperand* object) {
2447 inputs_[0] = context;
2448 inputs_[1] = object;
2449 }
2450
2451 LOperand* context() { return inputs_[0]; }
2452 LOperand* object() { return inputs_[1]; }
2453
2454 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2455};
2456
2457
2458class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2459 public:
2460 explicit LForInCacheArray(LOperand* map) {
2461 inputs_[0] = map;
2462 }
2463
2464 LOperand* map() { return inputs_[0]; }
2465
2466 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2467
2468 int idx() {
2469 return HForInCacheArray::cast(this->hydrogen_value())->idx();
2470 }
2471};
2472
2473
2474class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2475 public:
2476 LCheckMapValue(LOperand* value, LOperand* map) {
2477 inputs_[0] = value;
2478 inputs_[1] = map;
2479 }
2480
2481 LOperand* value() { return inputs_[0]; }
2482 LOperand* map() { return inputs_[1]; }
2483
2484 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2485};
2486
2487
2488class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2489 public:
2490 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2491 inputs_[0] = object;
2492 inputs_[1] = index;
2493 }
2494
2495 LOperand* object() { return inputs_[0]; }
2496 LOperand* index() { return inputs_[1]; }
2497
2498 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2499};
2500
2501
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002502class LChunkBuilder;
2503class LPlatformChunk final : public LChunk {
2504 public:
2505 LPlatformChunk(CompilationInfo* info, HGraph* graph)
2506 : LChunk(info, graph),
2507 dehoisted_key_ids_(graph->GetMaximumValueID(), graph->zone()) { }
2508
2509 int GetNextSpillIndex(RegisterKind kind);
2510 LOperand* GetNextSpillSlot(RegisterKind kind);
2511 BitVector* GetDehoistedKeyIds() { return &dehoisted_key_ids_; }
2512 bool IsDehoistedKey(HValue* value) {
2513 return dehoisted_key_ids_.Contains(value->id());
2514 }
2515
2516 private:
2517 BitVector dehoisted_key_ids_;
2518};
2519
2520
2521class LChunkBuilder final : public LChunkBuilderBase {
2522 public:
2523 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2524 : LChunkBuilderBase(info, graph),
2525 current_instruction_(NULL),
2526 current_block_(NULL),
2527 next_block_(NULL),
2528 allocator_(allocator) {}
2529
2530 // Build the sequence for the graph.
2531 LPlatformChunk* Build();
2532
2533 // Declare methods that deal with the individual node types.
2534#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2535 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2536#undef DECLARE_DO
2537
2538 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2539 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2540 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2541 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2542 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2543 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2544 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2545 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2546 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2547 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2548 LInstruction* DoDivByConstI(HDiv* instr);
2549 LInstruction* DoDivI(HDiv* instr);
2550 LInstruction* DoModByPowerOf2I(HMod* instr);
2551 LInstruction* DoModByConstI(HMod* instr);
2552 LInstruction* DoModI(HMod* instr);
2553 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2554 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2555 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2556
2557 private:
2558 // Methods for getting operands for Use / Define / Temp.
2559 LUnallocated* ToUnallocated(Register reg);
2560 LUnallocated* ToUnallocated(XMMRegister reg);
2561
2562 // Methods for setting up define-use relationships.
2563 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2564 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2565 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2566 XMMRegister fixed_register);
2567
2568 // A value that is guaranteed to be allocated to a register.
2569 // Operand created by UseRegister is guaranteed to be live until the end of
2570 // instruction. This means that register allocator will not reuse it's
2571 // register for any other operand inside instruction.
2572 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2573 // instruction start. Register allocator is free to assign the same register
2574 // to some other operand used inside instruction (i.e. temporary or
2575 // output).
2576 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2577 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2578
2579 // An input operand in a register that may be trashed.
2580 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2581
2582 // An input operand in a register that may be trashed or a constant operand.
2583 MUST_USE_RESULT LOperand* UseTempRegisterOrConstant(HValue* value);
2584
2585 // An input operand in a register or stack slot.
2586 MUST_USE_RESULT LOperand* Use(HValue* value);
2587 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2588
2589 // An input operand in a register, stack slot or a constant operand.
2590 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2591 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2592
2593 // An input operand in a register or a constant operand.
2594 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2595 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2596
2597 // An input operand in a constant operand.
2598 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2599
2600 // An input operand in register, stack slot or a constant operand.
2601 // Will not be moved to a register even if one is freely available.
2602 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2603
2604 // Temporary operand that must be in a register.
2605 MUST_USE_RESULT LUnallocated* TempRegister();
2606 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2607 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2608
2609 // Methods for setting up define-use relationships.
2610 // Return the same instruction that they are passed.
2611 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2612 LUnallocated* result);
2613 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2614 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2615 int index);
2616 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2617 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2618 Register reg);
2619 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2620 XMMRegister reg);
2621 // Assigns an environment to an instruction. An instruction which can
2622 // deoptimize must have an environment.
2623 LInstruction* AssignEnvironment(LInstruction* instr);
2624 // Assigns a pointer map to an instruction. An instruction which can
2625 // trigger a GC or a lazy deoptimization must have a pointer map.
2626 LInstruction* AssignPointerMap(LInstruction* instr);
2627
2628 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2629
2630 // Marks a call for the register allocator. Assigns a pointer map to
2631 // support GC and lazy deoptimization. Assigns an environment to support
2632 // eager deoptimization if CAN_DEOPTIMIZE_EAGERLY.
2633 LInstruction* MarkAsCall(
2634 LInstruction* instr,
2635 HInstruction* hinstr,
2636 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2637
2638 void VisitInstruction(HInstruction* current);
2639 void AddInstruction(LInstruction* instr, HInstruction* current);
2640
2641 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2642 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2643 LInstruction* DoArithmeticD(Token::Value op,
2644 HArithmeticBinaryOperation* instr);
2645 LInstruction* DoArithmeticT(Token::Value op,
2646 HBinaryOperation* instr);
2647 void FindDehoistedKeyDefinitions(HValue* candidate);
2648
2649 HInstruction* current_instruction_;
2650 HBasicBlock* current_block_;
2651 HBasicBlock* next_block_;
2652 LAllocator* allocator_;
2653
2654 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2655};
2656
2657#undef DECLARE_HYDROGEN_ACCESSOR
2658#undef DECLARE_CONCRETE_INSTRUCTION
2659
2660} // namespace internal
2661} // namespace v8
2662
2663#endif // V8_CRANKSHAFT_X64_LITHIUM_X64_H_