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

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

Powered by Google App Engine
This is Rietveld 408576698