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