Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/x87/lithium-x87.h

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

Powered by Google App Engine
This is Rietveld 408576698