blob: b6a161411d9154cdd5eef42ea4fa6e82158ce1fe [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) \
70 V(FlooringDivByConstI) \
71 V(FlooringDivByPowerOf2I) \
72 V(FlooringDivI) \
73 V(ForInCacheArray) \
74 V(ForInPrepareMap) \
75 V(GetCachedArrayIndex) \
76 V(Goto) \
77 V(HasCachedArrayIndexAndBranch) \
78 V(HasInPrototypeChainAndBranch) \
79 V(HasInstanceTypeAndBranch) \
80 V(InnerAllocatedObject) \
81 V(InstanceOf) \
82 V(InstructionGap) \
83 V(Integer32ToDouble) \
84 V(InvokeFunction) \
85 V(IsStringAndBranch) \
86 V(IsSmiAndBranch) \
87 V(IsUndetectableAndBranch) \
88 V(Label) \
89 V(LazyBailout) \
90 V(LoadContextSlot) \
91 V(LoadRoot) \
92 V(LoadFieldByIndex) \
93 V(LoadFunctionPrototype) \
94 V(LoadGlobalGeneric) \
95 V(LoadKeyed) \
96 V(LoadKeyedGeneric) \
97 V(LoadNamedField) \
98 V(LoadNamedGeneric) \
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
1038class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
1039 public:
1040 LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
1041 inputs_[0] = context;
1042 inputs_[1] = left;
1043 inputs_[2] = right;
1044 }
1045
1046 LOperand* context() const { return inputs_[0]; }
1047 LOperand* left() const { return inputs_[1]; }
1048 LOperand* right() const { return inputs_[2]; }
1049
1050 DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
1051};
1052
1053class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
1054 public:
1055 LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
1056 inputs_[0] = object;
1057 inputs_[1] = prototype;
1058 }
1059
1060 LOperand* object() const { return inputs_[0]; }
1061 LOperand* prototype() const { return inputs_[1]; }
1062
1063 DECLARE_CONCRETE_INSTRUCTION(HasInPrototypeChainAndBranch,
1064 "has-in-prototype-chain-and-branch")
1065 DECLARE_HYDROGEN_ACCESSOR(HasInPrototypeChainAndBranch)
1066};
1067
1068class LBoundsCheck final : public LTemplateInstruction<0, 2, 0> {
1069 public:
1070 LBoundsCheck(LOperand* index, LOperand* length) {
1071 inputs_[0] = index;
1072 inputs_[1] = length;
1073 }
1074
1075 LOperand* index() { return inputs_[0]; }
1076 LOperand* length() { return inputs_[1]; }
1077
1078 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check")
1079 DECLARE_HYDROGEN_ACCESSOR(BoundsCheck)
1080};
1081
1082class LBitI final : public LTemplateInstruction<1, 2, 0> {
1083 public:
1084 LBitI(LOperand* left, LOperand* right) {
1085 inputs_[0] = left;
1086 inputs_[1] = right;
1087 }
1088
1089 LOperand* left() { return inputs_[0]; }
1090 LOperand* right() { return inputs_[1]; }
1091
1092 Token::Value op() const { return hydrogen()->op(); }
1093
1094 DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i")
1095 DECLARE_HYDROGEN_ACCESSOR(Bitwise)
1096};
1097
1098class LShiftI final : public LTemplateInstruction<1, 2, 0> {
1099 public:
1100 LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt)
1101 : op_(op), can_deopt_(can_deopt) {
1102 inputs_[0] = left;
1103 inputs_[1] = right;
1104 }
1105
1106 Token::Value op() const { return op_; }
1107 LOperand* left() { return inputs_[0]; }
1108 LOperand* right() { return inputs_[1]; }
1109 bool can_deopt() const { return can_deopt_; }
1110
1111 DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i")
1112
1113 private:
1114 Token::Value op_;
1115 bool can_deopt_;
1116};
1117
1118class LSubI final : public LTemplateInstruction<1, 2, 0> {
1119 public:
1120 LSubI(LOperand* left, LOperand* right) {
1121 inputs_[0] = left;
1122 inputs_[1] = right;
1123 }
1124
1125 LOperand* left() { return inputs_[0]; }
1126 LOperand* right() { return inputs_[1]; }
1127
1128 DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i")
1129 DECLARE_HYDROGEN_ACCESSOR(Sub)
1130};
1131
1132class LRSubI final : public LTemplateInstruction<1, 2, 0> {
1133 public:
1134 LRSubI(LOperand* left, LOperand* right) {
1135 inputs_[0] = left;
1136 inputs_[1] = right;
1137 }
1138
1139 LOperand* left() { return inputs_[0]; }
1140 LOperand* right() { return inputs_[1]; }
1141
1142 DECLARE_CONCRETE_INSTRUCTION(RSubI, "rsub-i")
1143 DECLARE_HYDROGEN_ACCESSOR(Sub)
1144};
1145
1146class LConstantI final : public LTemplateInstruction<1, 0, 0> {
1147 public:
1148 DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i")
1149 DECLARE_HYDROGEN_ACCESSOR(Constant)
1150
1151 int32_t value() const { return hydrogen()->Integer32Value(); }
1152};
1153
1154class LConstantS final : public LTemplateInstruction<1, 0, 0> {
1155 public:
1156 DECLARE_CONCRETE_INSTRUCTION(ConstantS, "constant-s")
1157 DECLARE_HYDROGEN_ACCESSOR(Constant)
1158
1159 Smi* value() const { return Smi::FromInt(hydrogen()->Integer32Value()); }
1160};
1161
1162class LConstantD final : public LTemplateInstruction<1, 0, 0> {
1163 public:
1164 DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
1165 DECLARE_HYDROGEN_ACCESSOR(Constant)
1166
1167 double value() const { return hydrogen()->DoubleValue(); }
1168
1169 uint64_t bits() const { return hydrogen()->DoubleValueAsBits(); }
1170};
1171
1172class LConstantE final : public LTemplateInstruction<1, 0, 0> {
1173 public:
1174 DECLARE_CONCRETE_INSTRUCTION(ConstantE, "constant-e")
1175 DECLARE_HYDROGEN_ACCESSOR(Constant)
1176
1177 ExternalReference value() const {
1178 return hydrogen()->ExternalReferenceValue();
1179 }
1180};
1181
1182class LConstantT final : public LTemplateInstruction<1, 0, 0> {
1183 public:
1184 DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t")
1185 DECLARE_HYDROGEN_ACCESSOR(Constant)
1186
1187 Handle<Object> value(Isolate* isolate) const {
1188 return hydrogen()->handle(isolate);
1189 }
1190};
1191
1192class LBranch final : public LControlInstruction<1, 0> {
1193 public:
1194 explicit LBranch(LOperand* value) { inputs_[0] = value; }
1195
1196 LOperand* value() { return inputs_[0]; }
1197
1198 DECLARE_CONCRETE_INSTRUCTION(Branch, "branch")
1199 DECLARE_HYDROGEN_ACCESSOR(Branch)
1200
1201 void PrintDataTo(StringStream* stream) override;
1202};
1203
1204class LCmpMapAndBranch final : public LControlInstruction<1, 1> {
1205 public:
1206 LCmpMapAndBranch(LOperand* value, LOperand* temp) {
1207 inputs_[0] = value;
1208 temps_[0] = temp;
1209 }
1210
1211 LOperand* value() { return inputs_[0]; }
1212 LOperand* temp() { return temps_[0]; }
1213
1214 DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch")
1215 DECLARE_HYDROGEN_ACCESSOR(CompareMap)
1216
1217 Handle<Map> map() const { return hydrogen()->map().handle(); }
1218};
1219
1220class LSeqStringGetChar final : public LTemplateInstruction<1, 2, 0> {
1221 public:
1222 LSeqStringGetChar(LOperand* string, LOperand* index) {
1223 inputs_[0] = string;
1224 inputs_[1] = index;
1225 }
1226
1227 LOperand* string() const { return inputs_[0]; }
1228 LOperand* index() const { return inputs_[1]; }
1229
1230 DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
1231 DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
1232};
1233
1234class LSeqStringSetChar final : public LTemplateInstruction<1, 4, 0> {
1235 public:
1236 LSeqStringSetChar(LOperand* context, LOperand* string, LOperand* index,
1237 LOperand* value) {
1238 inputs_[0] = context;
1239 inputs_[1] = string;
1240 inputs_[2] = index;
1241 inputs_[3] = value;
1242 }
1243
1244 LOperand* string() { return inputs_[1]; }
1245 LOperand* index() { return inputs_[2]; }
1246 LOperand* value() { return inputs_[3]; }
1247
1248 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
1249 DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
1250};
1251
1252class LAddI final : public LTemplateInstruction<1, 2, 0> {
1253 public:
1254 LAddI(LOperand* left, LOperand* right) {
1255 inputs_[0] = left;
1256 inputs_[1] = right;
1257 }
1258
1259 LOperand* left() { return inputs_[0]; }
1260 LOperand* right() { return inputs_[1]; }
1261
1262 DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i")
1263 DECLARE_HYDROGEN_ACCESSOR(Add)
1264};
1265
1266class LMathMinMax final : public LTemplateInstruction<1, 2, 0> {
1267 public:
1268 LMathMinMax(LOperand* left, LOperand* right) {
1269 inputs_[0] = left;
1270 inputs_[1] = right;
1271 }
1272
1273 LOperand* left() { return inputs_[0]; }
1274 LOperand* right() { return inputs_[1]; }
1275
1276 DECLARE_CONCRETE_INSTRUCTION(MathMinMax, "math-min-max")
1277 DECLARE_HYDROGEN_ACCESSOR(MathMinMax)
1278};
1279
1280class LPower final : public LTemplateInstruction<1, 2, 0> {
1281 public:
1282 LPower(LOperand* left, LOperand* right) {
1283 inputs_[0] = left;
1284 inputs_[1] = right;
1285 }
1286
1287 LOperand* left() { return inputs_[0]; }
1288 LOperand* right() { return inputs_[1]; }
1289
1290 DECLARE_CONCRETE_INSTRUCTION(Power, "power")
1291 DECLARE_HYDROGEN_ACCESSOR(Power)
1292};
1293
1294class LArithmeticD final : public LTemplateInstruction<1, 2, 0> {
1295 public:
1296 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) : op_(op) {
1297 inputs_[0] = left;
1298 inputs_[1] = right;
1299 }
1300
1301 Token::Value op() const { return op_; }
1302 LOperand* left() { return inputs_[0]; }
1303 LOperand* right() { return inputs_[1]; }
1304
1305 Opcode opcode() const override { return LInstruction::kArithmeticD; }
1306 void CompileToNative(LCodeGen* generator) override;
1307 const char* Mnemonic() const override;
1308
1309 private:
1310 Token::Value op_;
1311};
1312
1313class LArithmeticT final : public LTemplateInstruction<1, 3, 0> {
1314 public:
1315 LArithmeticT(Token::Value op, LOperand* context, LOperand* left,
1316 LOperand* right)
1317 : op_(op) {
1318 inputs_[0] = context;
1319 inputs_[1] = left;
1320 inputs_[2] = right;
1321 }
1322
1323 LOperand* context() { return inputs_[0]; }
1324 LOperand* left() { return inputs_[1]; }
1325 LOperand* right() { return inputs_[2]; }
1326 Token::Value op() const { return op_; }
1327
1328 Opcode opcode() const override { return LInstruction::kArithmeticT; }
1329 void CompileToNative(LCodeGen* generator) override;
1330 const char* Mnemonic() const override;
1331
1332 DECLARE_HYDROGEN_ACCESSOR(BinaryOperation)
1333
1334 private:
1335 Token::Value op_;
1336};
1337
1338class LReturn final : public LTemplateInstruction<0, 3, 0> {
1339 public:
1340 LReturn(LOperand* value, LOperand* context, LOperand* parameter_count) {
1341 inputs_[0] = value;
1342 inputs_[1] = context;
1343 inputs_[2] = parameter_count;
1344 }
1345
1346 LOperand* value() { return inputs_[0]; }
1347
1348 bool has_constant_parameter_count() {
1349 return parameter_count()->IsConstantOperand();
1350 }
1351 LConstantOperand* constant_parameter_count() {
1352 DCHECK(has_constant_parameter_count());
1353 return LConstantOperand::cast(parameter_count());
1354 }
1355 LOperand* parameter_count() { return inputs_[2]; }
1356
1357 DECLARE_CONCRETE_INSTRUCTION(Return, "return")
1358};
1359
1360class LLoadNamedField final : public LTemplateInstruction<1, 1, 0> {
1361 public:
1362 explicit LLoadNamedField(LOperand* object) { inputs_[0] = object; }
1363
1364 LOperand* object() { return inputs_[0]; }
1365
1366 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
1367 DECLARE_HYDROGEN_ACCESSOR(LoadNamedField)
1368};
1369
1370class LLoadNamedGeneric final : public LTemplateInstruction<1, 2, 1> {
1371 public:
1372 LLoadNamedGeneric(LOperand* context, LOperand* object, LOperand* vector) {
1373 inputs_[0] = context;
1374 inputs_[1] = object;
1375 temps_[0] = vector;
1376 }
1377
1378 LOperand* context() { return inputs_[0]; }
1379 LOperand* object() { return inputs_[1]; }
1380 LOperand* temp_vector() { return temps_[0]; }
1381
1382 DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic")
1383 DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric)
1384
1385 Handle<Object> name() const { return hydrogen()->name(); }
1386};
1387
1388class LLoadFunctionPrototype final : public LTemplateInstruction<1, 1, 0> {
1389 public:
1390 explicit LLoadFunctionPrototype(LOperand* function) { inputs_[0] = function; }
1391
1392 LOperand* function() { return inputs_[0]; }
1393
1394 DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype")
1395 DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype)
1396};
1397
1398class LLoadRoot final : public LTemplateInstruction<1, 0, 0> {
1399 public:
1400 DECLARE_CONCRETE_INSTRUCTION(LoadRoot, "load-root")
1401 DECLARE_HYDROGEN_ACCESSOR(LoadRoot)
1402
1403 Heap::RootListIndex index() const { return hydrogen()->index(); }
1404};
1405
1406class LLoadKeyed final : public LTemplateInstruction<1, 3, 0> {
1407 public:
1408 LLoadKeyed(LOperand* elements, LOperand* key, LOperand* backing_store_owner) {
1409 inputs_[0] = elements;
1410 inputs_[1] = key;
1411 inputs_[2] = backing_store_owner;
1412 }
1413
1414 LOperand* elements() { return inputs_[0]; }
1415 LOperand* key() { return inputs_[1]; }
1416 LOperand* backing_store_owner() { return inputs_[2]; }
1417 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1418 bool is_fixed_typed_array() const {
1419 return hydrogen()->is_fixed_typed_array();
1420 }
1421
1422 DECLARE_CONCRETE_INSTRUCTION(LoadKeyed, "load-keyed")
1423 DECLARE_HYDROGEN_ACCESSOR(LoadKeyed)
1424
1425 void PrintDataTo(StringStream* stream) override;
1426 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1427};
1428
1429class LLoadKeyedGeneric final : public LTemplateInstruction<1, 3, 1> {
1430 public:
1431 LLoadKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1432 LOperand* vector) {
1433 inputs_[0] = context;
1434 inputs_[1] = object;
1435 inputs_[2] = key;
1436 temps_[0] = vector;
1437 }
1438
1439 LOperand* context() { return inputs_[0]; }
1440 LOperand* object() { return inputs_[1]; }
1441 LOperand* key() { return inputs_[2]; }
1442 LOperand* temp_vector() { return temps_[0]; }
1443
1444 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic")
1445 DECLARE_HYDROGEN_ACCESSOR(LoadKeyedGeneric)
1446};
1447
1448class LLoadGlobalGeneric final : public LTemplateInstruction<1, 2, 1> {
1449 public:
1450 LLoadGlobalGeneric(LOperand* context, LOperand* global_object,
1451 LOperand* vector) {
1452 inputs_[0] = context;
1453 inputs_[1] = global_object;
1454 temps_[0] = vector;
1455 }
1456
1457 LOperand* context() { return inputs_[0]; }
1458 LOperand* global_object() { return inputs_[1]; }
1459 LOperand* temp_vector() { return temps_[0]; }
1460
1461 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic")
1462 DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric)
1463
1464 Handle<Object> name() const { return hydrogen()->name(); }
1465 TypeofMode typeof_mode() const { return hydrogen()->typeof_mode(); }
1466};
1467
1468class LLoadContextSlot final : public LTemplateInstruction<1, 1, 0> {
1469 public:
1470 explicit LLoadContextSlot(LOperand* context) { inputs_[0] = context; }
1471
1472 LOperand* context() { return inputs_[0]; }
1473
1474 DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot")
1475 DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot)
1476
1477 int slot_index() { return hydrogen()->slot_index(); }
1478
1479 void PrintDataTo(StringStream* stream) override;
1480};
1481
1482class LStoreContextSlot final : public LTemplateInstruction<0, 2, 0> {
1483 public:
1484 LStoreContextSlot(LOperand* context, LOperand* value) {
1485 inputs_[0] = context;
1486 inputs_[1] = value;
1487 }
1488
1489 LOperand* context() { return inputs_[0]; }
1490 LOperand* value() { return inputs_[1]; }
1491
1492 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot")
1493 DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot)
1494
1495 int slot_index() { return hydrogen()->slot_index(); }
1496
1497 void PrintDataTo(StringStream* stream) override;
1498};
1499
1500class LPushArgument final : public LTemplateInstruction<0, 1, 0> {
1501 public:
1502 explicit LPushArgument(LOperand* value) { inputs_[0] = value; }
1503
1504 LOperand* value() { return inputs_[0]; }
1505
1506 DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument")
1507};
1508
1509class LDrop final : public LTemplateInstruction<0, 0, 0> {
1510 public:
1511 explicit LDrop(int count) : count_(count) {}
1512
1513 int count() const { return count_; }
1514
1515 DECLARE_CONCRETE_INSTRUCTION(Drop, "drop")
1516
1517 private:
1518 int count_;
1519};
1520
1521class LStoreCodeEntry final : public LTemplateInstruction<0, 2, 0> {
1522 public:
1523 LStoreCodeEntry(LOperand* function, LOperand* code_object) {
1524 inputs_[0] = function;
1525 inputs_[1] = code_object;
1526 }
1527
1528 LOperand* function() { return inputs_[0]; }
1529 LOperand* code_object() { return inputs_[1]; }
1530
1531 void PrintDataTo(StringStream* stream) override;
1532
1533 DECLARE_CONCRETE_INSTRUCTION(StoreCodeEntry, "store-code-entry")
1534 DECLARE_HYDROGEN_ACCESSOR(StoreCodeEntry)
1535};
1536
1537class LInnerAllocatedObject final : public LTemplateInstruction<1, 2, 0> {
1538 public:
1539 LInnerAllocatedObject(LOperand* base_object, LOperand* offset) {
1540 inputs_[0] = base_object;
1541 inputs_[1] = offset;
1542 }
1543
1544 LOperand* base_object() const { return inputs_[0]; }
1545 LOperand* offset() const { return inputs_[1]; }
1546
1547 void PrintDataTo(StringStream* stream) override;
1548
1549 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object")
1550};
1551
1552class LThisFunction final : public LTemplateInstruction<1, 0, 0> {
1553 public:
1554 DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
1555 DECLARE_HYDROGEN_ACCESSOR(ThisFunction)
1556};
1557
1558class LContext final : public LTemplateInstruction<1, 0, 0> {
1559 public:
1560 DECLARE_CONCRETE_INSTRUCTION(Context, "context")
1561 DECLARE_HYDROGEN_ACCESSOR(Context)
1562};
1563
1564class LDeclareGlobals final : public LTemplateInstruction<0, 1, 0> {
1565 public:
1566 explicit LDeclareGlobals(LOperand* context) { inputs_[0] = context; }
1567
1568 LOperand* context() { return inputs_[0]; }
1569
1570 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals")
1571 DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals)
1572};
1573
1574class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
1575 public:
1576 LCallWithDescriptor(CallInterfaceDescriptor descriptor,
1577 const ZoneList<LOperand*>& operands, Zone* zone)
1578 : descriptor_(descriptor),
1579 inputs_(descriptor.GetRegisterParameterCount() +
1580 kImplicitRegisterParameterCount,
1581 zone) {
1582 DCHECK(descriptor.GetRegisterParameterCount() +
1583 kImplicitRegisterParameterCount ==
1584 operands.length());
1585 inputs_.AddAll(operands, zone);
1586 }
1587
1588 LOperand* target() const { return inputs_[0]; }
1589
1590 const CallInterfaceDescriptor descriptor() { return descriptor_; }
1591
1592 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1593
1594 // The target and context are passed as implicit parameters that are not
1595 // explicitly listed in the descriptor.
1596 static const int kImplicitRegisterParameterCount = 2;
1597
1598 private:
1599 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1600
1601 void PrintDataTo(StringStream* stream) override;
1602
1603 int arity() const { return hydrogen()->argument_count() - 1; }
1604
1605 CallInterfaceDescriptor descriptor_;
1606 ZoneList<LOperand*> inputs_;
1607
1608 // Iterator support.
1609 int InputCount() final { return inputs_.length(); }
1610 LOperand* InputAt(int i) final { return inputs_[i]; }
1611
1612 int TempCount() final { return 0; }
1613 LOperand* TempAt(int i) final { return NULL; }
1614};
1615
1616class LInvokeFunction final : public LTemplateInstruction<1, 2, 0> {
1617 public:
1618 LInvokeFunction(LOperand* context, LOperand* function) {
1619 inputs_[0] = context;
1620 inputs_[1] = function;
1621 }
1622
1623 LOperand* context() { return inputs_[0]; }
1624 LOperand* function() { return inputs_[1]; }
1625
1626 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1627 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1628
1629 void PrintDataTo(StringStream* stream) override;
1630
1631 int arity() const { return hydrogen()->argument_count() - 1; }
1632};
1633
1634class LCallNewArray final : public LTemplateInstruction<1, 2, 0> {
1635 public:
1636 LCallNewArray(LOperand* context, LOperand* constructor) {
1637 inputs_[0] = context;
1638 inputs_[1] = constructor;
1639 }
1640
1641 LOperand* context() { return inputs_[0]; }
1642 LOperand* constructor() { return inputs_[1]; }
1643
1644 DECLARE_CONCRETE_INSTRUCTION(CallNewArray, "call-new-array")
1645 DECLARE_HYDROGEN_ACCESSOR(CallNewArray)
1646
1647 void PrintDataTo(StringStream* stream) override;
1648
1649 int arity() const { return hydrogen()->argument_count() - 1; }
1650};
1651
1652class LCallRuntime final : public LTemplateInstruction<1, 1, 0> {
1653 public:
1654 explicit LCallRuntime(LOperand* context) { inputs_[0] = context; }
1655
1656 LOperand* context() { return inputs_[0]; }
1657
1658 DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime")
1659 DECLARE_HYDROGEN_ACCESSOR(CallRuntime)
1660
1661 bool ClobbersDoubleRegisters(Isolate* isolate) const override {
1662 return save_doubles() == kDontSaveFPRegs;
1663 }
1664
1665 const Runtime::Function* function() const { return hydrogen()->function(); }
1666 int arity() const { return hydrogen()->argument_count(); }
1667 SaveFPRegsMode save_doubles() const { return hydrogen()->save_doubles(); }
1668};
1669
1670class LInteger32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1671 public:
1672 explicit LInteger32ToDouble(LOperand* value) { inputs_[0] = value; }
1673
1674 LOperand* value() { return inputs_[0]; }
1675
1676 DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double")
1677};
1678
1679class LUint32ToDouble final : public LTemplateInstruction<1, 1, 0> {
1680 public:
1681 explicit LUint32ToDouble(LOperand* value) { inputs_[0] = value; }
1682
1683 LOperand* value() { return inputs_[0]; }
1684
1685 DECLARE_CONCRETE_INSTRUCTION(Uint32ToDouble, "uint32-to-double")
1686};
1687
1688class LNumberTagI final : public LTemplateInstruction<1, 1, 2> {
1689 public:
1690 LNumberTagI(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(NumberTagI, "number-tag-i")
1701};
1702
1703class LNumberTagU final : public LTemplateInstruction<1, 1, 2> {
1704 public:
1705 LNumberTagU(LOperand* value, LOperand* temp1, LOperand* temp2) {
1706 inputs_[0] = value;
1707 temps_[0] = temp1;
1708 temps_[1] = temp2;
1709 }
1710
1711 LOperand* value() { return inputs_[0]; }
1712 LOperand* temp1() { return temps_[0]; }
1713 LOperand* temp2() { return temps_[1]; }
1714
1715 DECLARE_CONCRETE_INSTRUCTION(NumberTagU, "number-tag-u")
1716};
1717
1718class LNumberTagD final : public LTemplateInstruction<1, 1, 2> {
1719 public:
1720 LNumberTagD(LOperand* value, LOperand* temp, LOperand* temp2) {
1721 inputs_[0] = value;
1722 temps_[0] = temp;
1723 temps_[1] = temp2;
1724 }
1725
1726 LOperand* value() { return inputs_[0]; }
1727 LOperand* temp() { return temps_[0]; }
1728 LOperand* temp2() { return temps_[1]; }
1729
1730 DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d")
1731 DECLARE_HYDROGEN_ACCESSOR(Change)
1732};
1733
1734class LDoubleToSmi final : public LTemplateInstruction<1, 1, 0> {
1735 public:
1736 explicit LDoubleToSmi(LOperand* value) { inputs_[0] = value; }
1737
1738 LOperand* value() { return inputs_[0]; }
1739
1740 DECLARE_CONCRETE_INSTRUCTION(DoubleToSmi, "double-to-smi")
1741 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1742
1743 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1744};
1745
1746// Sometimes truncating conversion from a tagged value to an int32.
1747class LDoubleToI final : public LTemplateInstruction<1, 1, 0> {
1748 public:
1749 explicit LDoubleToI(LOperand* value) { inputs_[0] = value; }
1750
1751 LOperand* value() { return inputs_[0]; }
1752
1753 DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i")
1754 DECLARE_HYDROGEN_ACCESSOR(UnaryOperation)
1755
1756 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1757};
1758
1759// Truncating conversion from a tagged value to an int32.
1760class LTaggedToI final : public LTemplateInstruction<1, 1, 2> {
1761 public:
1762 LTaggedToI(LOperand* value, LOperand* temp, LOperand* temp2) {
1763 inputs_[0] = value;
1764 temps_[0] = temp;
1765 temps_[1] = temp2;
1766 }
1767
1768 LOperand* value() { return inputs_[0]; }
1769 LOperand* temp() { return temps_[0]; }
1770 LOperand* temp2() { return temps_[1]; }
1771
1772 DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i")
1773 DECLARE_HYDROGEN_ACCESSOR(Change)
1774
1775 bool truncating() { return hydrogen()->CanTruncateToInt32(); }
1776};
1777
1778class LSmiTag final : public LTemplateInstruction<1, 1, 0> {
1779 public:
1780 explicit LSmiTag(LOperand* value) { inputs_[0] = value; }
1781
1782 LOperand* value() { return inputs_[0]; }
1783
1784 DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag")
1785 DECLARE_HYDROGEN_ACCESSOR(Change)
1786};
1787
1788class LNumberUntagD final : public LTemplateInstruction<1, 1, 0> {
1789 public:
1790 explicit LNumberUntagD(LOperand* value) { inputs_[0] = value; }
1791
1792 LOperand* value() { return inputs_[0]; }
1793
1794 DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
1795 DECLARE_HYDROGEN_ACCESSOR(Change)
1796};
1797
1798class LSmiUntag final : public LTemplateInstruction<1, 1, 0> {
1799 public:
1800 LSmiUntag(LOperand* value, bool needs_check) : needs_check_(needs_check) {
1801 inputs_[0] = value;
1802 }
1803
1804 LOperand* value() { return inputs_[0]; }
1805 bool needs_check() const { return needs_check_; }
1806
1807 DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
1808
1809 private:
1810 bool needs_check_;
1811};
1812
1813class LStoreNamedField final : public LTemplateInstruction<0, 2, 1> {
1814 public:
1815 LStoreNamedField(LOperand* object, LOperand* value, LOperand* temp) {
1816 inputs_[0] = object;
1817 inputs_[1] = value;
1818 temps_[0] = temp;
1819 }
1820
1821 LOperand* object() { return inputs_[0]; }
1822 LOperand* value() { return inputs_[1]; }
1823 LOperand* temp() { return temps_[0]; }
1824
1825 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field")
1826 DECLARE_HYDROGEN_ACCESSOR(StoreNamedField)
1827
1828 void PrintDataTo(StringStream* stream) override;
1829
1830 Representation representation() const {
1831 return hydrogen()->field_representation();
1832 }
1833};
1834
1835class LStoreNamedGeneric final : public LTemplateInstruction<0, 3, 2> {
1836 public:
1837 LStoreNamedGeneric(LOperand* context, LOperand* object, LOperand* value,
1838 LOperand* slot, LOperand* vector) {
1839 inputs_[0] = context;
1840 inputs_[1] = object;
1841 inputs_[2] = value;
1842 temps_[0] = slot;
1843 temps_[1] = vector;
1844 }
1845
1846 LOperand* context() { return inputs_[0]; }
1847 LOperand* object() { return inputs_[1]; }
1848 LOperand* value() { return inputs_[2]; }
1849 LOperand* temp_slot() { return temps_[0]; }
1850 LOperand* temp_vector() { return temps_[1]; }
1851
1852 DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic")
1853 DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric)
1854
1855 void PrintDataTo(StringStream* stream) override;
1856
1857 Handle<Object> name() const { return hydrogen()->name(); }
1858 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1859};
1860
1861class LStoreKeyed final : public LTemplateInstruction<0, 4, 0> {
1862 public:
1863 LStoreKeyed(LOperand* object, LOperand* key, LOperand* value,
1864 LOperand* backing_store_owner) {
1865 inputs_[0] = object;
1866 inputs_[1] = key;
1867 inputs_[2] = value;
1868 inputs_[3] = backing_store_owner;
1869 }
1870
1871 bool is_fixed_typed_array() const {
1872 return hydrogen()->is_fixed_typed_array();
1873 }
1874 LOperand* elements() { return inputs_[0]; }
1875 LOperand* key() { return inputs_[1]; }
1876 LOperand* value() { return inputs_[2]; }
1877 LOperand* backing_store_owner() { return inputs_[3]; }
1878 ElementsKind elements_kind() const { return hydrogen()->elements_kind(); }
1879
1880 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed, "store-keyed")
1881 DECLARE_HYDROGEN_ACCESSOR(StoreKeyed)
1882
1883 void PrintDataTo(StringStream* stream) override;
1884 bool NeedsCanonicalization() {
1885 if (hydrogen()->value()->IsAdd() || hydrogen()->value()->IsSub() ||
1886 hydrogen()->value()->IsMul() || hydrogen()->value()->IsDiv()) {
1887 return false;
1888 }
1889 return hydrogen()->NeedsCanonicalization();
1890 }
1891 uint32_t base_offset() const { return hydrogen()->base_offset(); }
1892};
1893
1894class LStoreKeyedGeneric final : public LTemplateInstruction<0, 4, 2> {
1895 public:
1896 LStoreKeyedGeneric(LOperand* context, LOperand* object, LOperand* key,
1897 LOperand* value, LOperand* slot, LOperand* vector) {
1898 inputs_[0] = context;
1899 inputs_[1] = object;
1900 inputs_[2] = key;
1901 inputs_[3] = value;
1902 temps_[0] = slot;
1903 temps_[1] = vector;
1904 }
1905
1906 LOperand* context() { return inputs_[0]; }
1907 LOperand* object() { return inputs_[1]; }
1908 LOperand* key() { return inputs_[2]; }
1909 LOperand* value() { return inputs_[3]; }
1910 LOperand* temp_slot() { return temps_[0]; }
1911 LOperand* temp_vector() { return temps_[1]; }
1912
1913 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic")
1914 DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric)
1915
1916 void PrintDataTo(StringStream* stream) override;
1917
1918 LanguageMode language_mode() { return hydrogen()->language_mode(); }
1919};
1920
1921class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
1922 public:
1923 LTransitionElementsKind(LOperand* object, LOperand* context,
1924 LOperand* new_map_temp) {
1925 inputs_[0] = object;
1926 inputs_[1] = context;
1927 temps_[0] = new_map_temp;
1928 }
1929
1930 LOperand* context() { return inputs_[1]; }
1931 LOperand* object() { return inputs_[0]; }
1932 LOperand* new_map_temp() { return temps_[0]; }
1933
1934 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind,
1935 "transition-elements-kind")
1936 DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind)
1937
1938 void PrintDataTo(StringStream* stream) override;
1939
1940 Handle<Map> original_map() { return hydrogen()->original_map().handle(); }
1941 Handle<Map> transitioned_map() {
1942 return hydrogen()->transitioned_map().handle();
1943 }
1944 ElementsKind from_kind() { return hydrogen()->from_kind(); }
1945 ElementsKind to_kind() { return hydrogen()->to_kind(); }
1946};
1947
1948class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 2> {
1949 public:
1950 LTrapAllocationMemento(LOperand* object, LOperand* temp1, LOperand* temp2) {
1951 inputs_[0] = object;
1952 temps_[0] = temp1;
1953 temps_[1] = temp2;
1954 }
1955
1956 LOperand* object() { return inputs_[0]; }
1957 LOperand* temp1() { return temps_[0]; }
1958 LOperand* temp2() { return temps_[1]; }
1959
1960 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
1961};
1962
1963class LMaybeGrowElements final : public LTemplateInstruction<1, 5, 0> {
1964 public:
1965 LMaybeGrowElements(LOperand* context, LOperand* object, LOperand* elements,
1966 LOperand* key, LOperand* current_capacity) {
1967 inputs_[0] = context;
1968 inputs_[1] = object;
1969 inputs_[2] = elements;
1970 inputs_[3] = key;
1971 inputs_[4] = current_capacity;
1972 }
1973
1974 LOperand* context() { return inputs_[0]; }
1975 LOperand* object() { return inputs_[1]; }
1976 LOperand* elements() { return inputs_[2]; }
1977 LOperand* key() { return inputs_[3]; }
1978 LOperand* current_capacity() { return inputs_[4]; }
1979
1980 DECLARE_HYDROGEN_ACCESSOR(MaybeGrowElements)
1981 DECLARE_CONCRETE_INSTRUCTION(MaybeGrowElements, "maybe-grow-elements")
1982};
1983
1984class LStringAdd final : public LTemplateInstruction<1, 3, 0> {
1985 public:
1986 LStringAdd(LOperand* context, LOperand* left, LOperand* right) {
1987 inputs_[0] = context;
1988 inputs_[1] = left;
1989 inputs_[2] = right;
1990 }
1991
1992 LOperand* context() { return inputs_[0]; }
1993 LOperand* left() { return inputs_[1]; }
1994 LOperand* right() { return inputs_[2]; }
1995
1996 DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add")
1997 DECLARE_HYDROGEN_ACCESSOR(StringAdd)
1998};
1999
2000class LStringCharCodeAt final : public LTemplateInstruction<1, 3, 0> {
2001 public:
2002 LStringCharCodeAt(LOperand* context, LOperand* string, LOperand* index) {
2003 inputs_[0] = context;
2004 inputs_[1] = string;
2005 inputs_[2] = index;
2006 }
2007
2008 LOperand* context() { return inputs_[0]; }
2009 LOperand* string() { return inputs_[1]; }
2010 LOperand* index() { return inputs_[2]; }
2011
2012 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at")
2013 DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt)
2014};
2015
2016class LStringCharFromCode final : public LTemplateInstruction<1, 2, 0> {
2017 public:
2018 explicit LStringCharFromCode(LOperand* context, LOperand* char_code) {
2019 inputs_[0] = context;
2020 inputs_[1] = char_code;
2021 }
2022
2023 LOperand* context() { return inputs_[0]; }
2024 LOperand* char_code() { return inputs_[1]; }
2025
2026 DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code")
2027 DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode)
2028};
2029
2030class LCheckValue final : public LTemplateInstruction<0, 1, 0> {
2031 public:
2032 explicit LCheckValue(LOperand* value) { inputs_[0] = value; }
2033
2034 LOperand* value() { return inputs_[0]; }
2035
2036 DECLARE_CONCRETE_INSTRUCTION(CheckValue, "check-value")
2037 DECLARE_HYDROGEN_ACCESSOR(CheckValue)
2038};
2039
2040class LCheckArrayBufferNotNeutered final
2041 : public LTemplateInstruction<0, 1, 0> {
2042 public:
2043 explicit LCheckArrayBufferNotNeutered(LOperand* view) { inputs_[0] = view; }
2044
2045 LOperand* view() { return inputs_[0]; }
2046
2047 DECLARE_CONCRETE_INSTRUCTION(CheckArrayBufferNotNeutered,
2048 "check-array-buffer-not-neutered")
2049 DECLARE_HYDROGEN_ACCESSOR(CheckArrayBufferNotNeutered)
2050};
2051
2052class LCheckInstanceType final : public LTemplateInstruction<0, 1, 0> {
2053 public:
2054 explicit LCheckInstanceType(LOperand* value) { inputs_[0] = value; }
2055
2056 LOperand* value() { return inputs_[0]; }
2057
2058 DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type")
2059 DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType)
2060};
2061
2062class LCheckMaps final : public LTemplateInstruction<0, 1, 1> {
2063 public:
2064 explicit LCheckMaps(LOperand* value = NULL, LOperand* temp = NULL) {
2065 inputs_[0] = value;
2066 temps_[0] = temp;
2067 }
2068
2069 LOperand* value() { return inputs_[0]; }
2070 LOperand* temp() { return temps_[0]; }
2071
2072 DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps")
2073 DECLARE_HYDROGEN_ACCESSOR(CheckMaps)
2074};
2075
2076class LCheckSmi final : public LTemplateInstruction<1, 1, 0> {
2077 public:
2078 explicit LCheckSmi(LOperand* value) { inputs_[0] = value; }
2079
2080 LOperand* value() { return inputs_[0]; }
2081
2082 DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi")
2083};
2084
2085class LCheckNonSmi final : public LTemplateInstruction<0, 1, 0> {
2086 public:
2087 explicit LCheckNonSmi(LOperand* value) { inputs_[0] = value; }
2088
2089 LOperand* value() { return inputs_[0]; }
2090
2091 DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi")
2092 DECLARE_HYDROGEN_ACCESSOR(CheckHeapObject)
2093};
2094
2095class LClampDToUint8 final : public LTemplateInstruction<1, 1, 0> {
2096 public:
2097 explicit LClampDToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2098
2099 LOperand* unclamped() { return inputs_[0]; }
2100
2101 DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8")
2102};
2103
2104class LClampIToUint8 final : public LTemplateInstruction<1, 1, 0> {
2105 public:
2106 explicit LClampIToUint8(LOperand* unclamped) { inputs_[0] = unclamped; }
2107
2108 LOperand* unclamped() { return inputs_[0]; }
2109
2110 DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8")
2111};
2112
2113class LClampTToUint8 final : public LTemplateInstruction<1, 1, 1> {
2114 public:
2115 LClampTToUint8(LOperand* unclamped, LOperand* temp) {
2116 inputs_[0] = unclamped;
2117 temps_[0] = temp;
2118 }
2119
2120 LOperand* unclamped() { return inputs_[0]; }
2121 LOperand* temp() { return temps_[0]; }
2122
2123 DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
2124};
2125
2126class LDoubleBits final : public LTemplateInstruction<1, 1, 0> {
2127 public:
2128 explicit LDoubleBits(LOperand* value) { inputs_[0] = value; }
2129
2130 LOperand* value() { return inputs_[0]; }
2131
2132 DECLARE_CONCRETE_INSTRUCTION(DoubleBits, "double-bits")
2133 DECLARE_HYDROGEN_ACCESSOR(DoubleBits)
2134};
2135
2136class LConstructDouble final : public LTemplateInstruction<1, 2, 0> {
2137 public:
2138 LConstructDouble(LOperand* hi, LOperand* lo) {
2139 inputs_[0] = hi;
2140 inputs_[1] = lo;
2141 }
2142
2143 LOperand* hi() { return inputs_[0]; }
2144 LOperand* lo() { return inputs_[1]; }
2145
2146 DECLARE_CONCRETE_INSTRUCTION(ConstructDouble, "construct-double")
2147};
2148
2149class LAllocate final : public LTemplateInstruction<1, 2, 2> {
2150 public:
2151 LAllocate(LOperand* context, LOperand* size, LOperand* temp1,
2152 LOperand* temp2) {
2153 inputs_[0] = context;
2154 inputs_[1] = size;
2155 temps_[0] = temp1;
2156 temps_[1] = temp2;
2157 }
2158
2159 LOperand* context() { return inputs_[0]; }
2160 LOperand* size() { return inputs_[1]; }
2161 LOperand* temp1() { return temps_[0]; }
2162 LOperand* temp2() { return temps_[1]; }
2163
2164 DECLARE_CONCRETE_INSTRUCTION(Allocate, "allocate")
2165 DECLARE_HYDROGEN_ACCESSOR(Allocate)
2166};
2167
2168class LTypeof final : public LTemplateInstruction<1, 2, 0> {
2169 public:
2170 LTypeof(LOperand* context, LOperand* value) {
2171 inputs_[0] = context;
2172 inputs_[1] = value;
2173 }
2174
2175 LOperand* context() { return inputs_[0]; }
2176 LOperand* value() { return inputs_[1]; }
2177
2178 DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof")
2179};
2180
2181class LTypeofIsAndBranch final : public LControlInstruction<1, 0> {
2182 public:
2183 explicit LTypeofIsAndBranch(LOperand* value) { inputs_[0] = value; }
2184
2185 LOperand* value() { return inputs_[0]; }
2186
2187 DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch")
2188 DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch)
2189
2190 Handle<String> type_literal() { return hydrogen()->type_literal(); }
2191
2192 void PrintDataTo(StringStream* stream) override;
2193};
2194
2195class LOsrEntry final : public LTemplateInstruction<0, 0, 0> {
2196 public:
2197 LOsrEntry() {}
2198
2199 bool HasInterestingComment(LCodeGen* gen) const override { return false; }
2200 DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry")
2201};
2202
2203class LStackCheck final : public LTemplateInstruction<0, 1, 0> {
2204 public:
2205 explicit LStackCheck(LOperand* context) { inputs_[0] = context; }
2206
2207 LOperand* context() { return inputs_[0]; }
2208
2209 DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check")
2210 DECLARE_HYDROGEN_ACCESSOR(StackCheck)
2211
2212 Label* done_label() { return &done_label_; }
2213
2214 private:
2215 Label done_label_;
2216};
2217
2218class LForInPrepareMap final : public LTemplateInstruction<1, 2, 0> {
2219 public:
2220 LForInPrepareMap(LOperand* context, LOperand* object) {
2221 inputs_[0] = context;
2222 inputs_[1] = object;
2223 }
2224
2225 LOperand* context() { return inputs_[0]; }
2226 LOperand* object() { return inputs_[1]; }
2227
2228 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map")
2229};
2230
2231class LForInCacheArray final : public LTemplateInstruction<1, 1, 0> {
2232 public:
2233 explicit LForInCacheArray(LOperand* map) { inputs_[0] = map; }
2234
2235 LOperand* map() { return inputs_[0]; }
2236
2237 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array")
2238
2239 int idx() { return HForInCacheArray::cast(this->hydrogen_value())->idx(); }
2240};
2241
2242class LCheckMapValue final : public LTemplateInstruction<0, 2, 0> {
2243 public:
2244 LCheckMapValue(LOperand* value, LOperand* map) {
2245 inputs_[0] = value;
2246 inputs_[1] = map;
2247 }
2248
2249 LOperand* value() { return inputs_[0]; }
2250 LOperand* map() { return inputs_[1]; }
2251
2252 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value")
2253};
2254
2255class LLoadFieldByIndex final : public LTemplateInstruction<1, 2, 0> {
2256 public:
2257 LLoadFieldByIndex(LOperand* object, LOperand* index) {
2258 inputs_[0] = object;
2259 inputs_[1] = index;
2260 }
2261
2262 LOperand* object() { return inputs_[0]; }
2263 LOperand* index() { return inputs_[1]; }
2264
2265 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index")
2266};
2267
2268class LChunkBuilder;
2269class LPlatformChunk final : public LChunk {
2270 public:
2271 LPlatformChunk(CompilationInfo* info, HGraph* graph) : LChunk(info, graph) {}
2272
2273 int GetNextSpillIndex(RegisterKind kind);
2274 LOperand* GetNextSpillSlot(RegisterKind kind);
2275};
2276
2277class LChunkBuilder final : public LChunkBuilderBase {
2278 public:
2279 LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
2280 : LChunkBuilderBase(info, graph),
2281 current_instruction_(NULL),
2282 current_block_(NULL),
2283 next_block_(NULL),
2284 allocator_(allocator) {}
2285
2286 // Build the sequence for the graph.
2287 LPlatformChunk* Build();
2288
2289// Declare methods that deal with the individual node types.
2290#define DECLARE_DO(type) LInstruction* Do##type(H##type* node);
2291 HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO)
2292#undef DECLARE_DO
2293
2294 LInstruction* DoMultiplyAdd(HMul* mul, HValue* addend);
2295 LInstruction* DoMultiplySub(HValue* minuend, HMul* mul);
2296 LInstruction* DoRSub(HSub* instr);
2297
2298 static bool HasMagicNumberForDivisor(int32_t divisor);
2299
2300 LInstruction* DoMathFloor(HUnaryMathOperation* instr);
2301 LInstruction* DoMathRound(HUnaryMathOperation* instr);
2302 LInstruction* DoMathFround(HUnaryMathOperation* instr);
2303 LInstruction* DoMathAbs(HUnaryMathOperation* instr);
2304 LInstruction* DoMathLog(HUnaryMathOperation* instr);
2305 LInstruction* DoMathExp(HUnaryMathOperation* instr);
2306 LInstruction* DoMathSqrt(HUnaryMathOperation* instr);
2307 LInstruction* DoMathPowHalf(HUnaryMathOperation* instr);
2308 LInstruction* DoMathClz32(HUnaryMathOperation* instr);
2309 LInstruction* DoDivByPowerOf2I(HDiv* instr);
2310 LInstruction* DoDivByConstI(HDiv* instr);
2311 LInstruction* DoDivI(HDiv* instr);
2312 LInstruction* DoModByPowerOf2I(HMod* instr);
2313 LInstruction* DoModByConstI(HMod* instr);
2314 LInstruction* DoModI(HMod* instr);
2315 LInstruction* DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr);
2316 LInstruction* DoFlooringDivByConstI(HMathFloorOfDiv* instr);
2317 LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
2318
2319 private:
2320 // Methods for getting operands for Use / Define / Temp.
2321 LUnallocated* ToUnallocated(Register reg);
2322 LUnallocated* ToUnallocated(DoubleRegister reg);
2323
2324 // Methods for setting up define-use relationships.
2325 MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand);
2326 MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register);
2327 MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value,
2328 DoubleRegister fixed_register);
2329
2330 // A value that is guaranteed to be allocated to a register.
2331 // Operand created by UseRegister is guaranteed to be live until the end of
2332 // instruction. This means that register allocator will not reuse it's
2333 // register for any other operand inside instruction.
2334 // Operand created by UseRegisterAtStart is guaranteed to be live only at
2335 // instruction start. Register allocator is free to assign the same register
2336 // to some other operand used inside instruction (i.e. temporary or
2337 // output).
2338 MUST_USE_RESULT LOperand* UseRegister(HValue* value);
2339 MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value);
2340
2341 // An input operand in a register that may be trashed.
2342 MUST_USE_RESULT LOperand* UseTempRegister(HValue* value);
2343
2344 // An input operand in a register or stack slot.
2345 MUST_USE_RESULT LOperand* Use(HValue* value);
2346 MUST_USE_RESULT LOperand* UseAtStart(HValue* value);
2347
2348 // An input operand in a register, stack slot or a constant operand.
2349 MUST_USE_RESULT LOperand* UseOrConstant(HValue* value);
2350 MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value);
2351
2352 // An input operand in a register or a constant operand.
2353 MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value);
2354 MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value);
2355
2356 // An input operand in a constant operand.
2357 MUST_USE_RESULT LOperand* UseConstant(HValue* value);
2358
2359 // An input operand in register, stack slot or a constant operand.
2360 // Will not be moved to a register even if one is freely available.
2361 MUST_USE_RESULT LOperand* UseAny(HValue* value) override;
2362
2363 // Temporary operand that must be in a register.
2364 MUST_USE_RESULT LUnallocated* TempRegister();
2365 MUST_USE_RESULT LUnallocated* TempDoubleRegister();
2366 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2367 MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg);
2368
2369 // Methods for setting up define-use relationships.
2370 // Return the same instruction that they are passed.
2371 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2372 LUnallocated* result);
2373 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2374 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2375 int index);
2376 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2377 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr, Register reg);
2378 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2379 DoubleRegister reg);
2380 LInstruction* AssignEnvironment(LInstruction* instr);
2381 LInstruction* AssignPointerMap(LInstruction* instr);
2382
2383 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2384
2385 // By default we assume that instruction sequences generated for calls
2386 // cannot deoptimize eagerly and we do not attach environment to this
2387 // instruction.
2388 LInstruction* MarkAsCall(
2389 LInstruction* instr, HInstruction* hinstr,
2390 CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY);
2391
2392 void VisitInstruction(HInstruction* current);
2393 void AddInstruction(LInstruction* instr, HInstruction* current);
2394
2395 void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block);
2396 LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr);
2397 LInstruction* DoArithmeticD(Token::Value op,
2398 HArithmeticBinaryOperation* instr);
2399 LInstruction* DoArithmeticT(Token::Value op, HBinaryOperation* instr);
2400
2401 HInstruction* current_instruction_;
2402 HBasicBlock* current_block_;
2403 HBasicBlock* next_block_;
2404 LAllocator* allocator_;
2405
2406 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2407};
2408
2409#undef DECLARE_HYDROGEN_ACCESSOR
2410#undef DECLARE_CONCRETE_INSTRUCTION
2411} // namespace internal
2412} // namespace v8
2413
2414#endif // V8_CRANKSHAFT_S390_LITHIUM_S390_H_