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