1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=8 sts=2 et sw=2 tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef jit_BaselineIC_h
#define jit_BaselineIC_h
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include "gc/Barrier.h"
#include "gc/GC.h"
#include "gc/Rooting.h"
#include "jit/BaselineICList.h"
#include "jit/ICState.h"
#include "jit/ICStubSpace.h"
#include "jit/JitCode.h"
#include "jit/JitOptions.h"
#include "jit/Registers.h"
#include "jit/RegisterSets.h"
#include "jit/shared/Assembler-shared.h"
#include "js/TypeDecls.h"
#include "js/Value.h"
#include "vm/ArrayObject.h"
#include "vm/JSScript.h"
class JS_PUBLIC_API JSTracer;
namespace js {
MOZ_COLD void ReportOutOfMemory(JSContext* cx);
namespace jit {
class BaselineFrame;
class CacheIRStubInfo;
class ICScript;
class MacroAssembler;
enum class TailCallVMFunctionId;
enum class VMFunctionId;
// [SMDOC] JIT Inline Caches (ICs)
//
// Baseline Inline Caches are polymorphic caches that aggressively
// share their stub code.
//
// Every polymorphic site contains a linked list of stubs which are
// specific to that site. These stubs are composed of a |StubData|
// structure that stores parametrization information (e.g.
// the shape pointer for a shape-check-and-property-get stub), any
// dynamic information (e.g. warm-up counters), a pointer to the stub code,
// and a pointer to the next stub state in the linked list.
//
// Every BaselineScript keeps an table of |CacheDescriptor| data
// structures, which store the following:
// A pointer to the first StubData in the cache.
// The bytecode PC of the relevant IC.
// The machine-code PC where the call to the stubcode returns.
//
// A diagram:
//
// Control flow Pointers
// =======# ----. .---->
// # | |
// #======> \-----/
//
//
// .---------------------------------------.
// | .-------------------------. |
// | | .----. | |
// Baseline | | | | | |
// JIT Code 0 ^ 1 ^ 2 ^ | | |
// +--------------+ .-->+-----+ +-----+ +-----+ | | |
// | | #=|==>| |==>| |==>| FB | | | |
// | | # | +-----+ +-----+ +-----+ | | |
// | | # | # # # | | |
// |==============|==# | # # # | | |
// |=== IC =======| | # # # | | |
// .->|==============|<===|======#=========#=========# | | |
// | | | | | | |
// | | | | | | |
// | | | | | | |
// | | | | v | |
// | | | | +---------+ | |
// | | | | | Fallback| | |
// | | | | | Stub | | |
// | | | | | Code | | |
// | | | | +---------+ | |
// | +--------------+ | | |
// | |_______ | +---------+ | |
// | | | | Stub |<---/ |
// | IC | \--. | Code | |
// | Descriptor | | +---------+ |
// | Table v | |
// | +-----------------+ | +---------+ |
// \--| Ins | PC | Stub |----/ | Stub |<-------/
// +-----------------+ | Code |
// | ... | +---------+
// +-----------------+
// Shared
// Stub Code
//
class ICStub;
class ICCacheIRStub;
class ICFallbackStub;
#define FORWARD_DECLARE_STUBS(kindName) class IC##kindName;
IC_BASELINE_STUB_KIND_LIST(FORWARD_DECLARE_STUBS)
#undef FORWARD_DECLARE_STUBS
#ifdef JS_JITSPEW
void FallbackICSpew(JSContext* cx, ICFallbackStub* stub, const char* fmt, ...)
MOZ_FORMAT_PRINTF(3, 4);
#else
# define FallbackICSpew(...)
#endif
// An entry in the BaselineScript IC descriptor table. There's one ICEntry per
// IC.
class ICEntry {
// A pointer to the first IC stub for this instruction.
ICStub* firstStub_;
// The PC offset of this IC's bytecode op within the JSScript.
uint32_t pcOffset_;
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
# ifdef JS_64BIT
// On 64-bit architectures, we have 32 bits of alignment padding.
// We fill it with a magic value, and check that value when tracing.
static const uint32_t EXPECTED_TRACE_MAGIC = 0xdeaddead;
uint32_t traceMagic_ = EXPECTED_TRACE_MAGIC;
# endif
#endif
public:
ICEntry(ICStub* firstStub, uint32_t pcOffset)
: firstStub_(firstStub), pcOffset_(pcOffset) {}
ICStub* firstStub() const {
MOZ_ASSERT(firstStub_);
return firstStub_;
}
ICFallbackStub* fallbackStub() const;
void setFirstStub(ICStub* stub) { firstStub_ = stub; }
uint32_t pcOffset() const { return pcOffset_; }
jsbytecode* pc(JSScript* script) const {
return script->offsetToPC(pcOffset());
}
static constexpr size_t offsetOfFirstStub() {
return offsetof(ICEntry, firstStub_);
}
inline ICStub** addressOfFirstStub() { return &firstStub_; }
void trace(JSTracer* trc);
};
// Constant iterator that traverses arbitrary chains of ICStubs.
// No requirements are made of the ICStub used to construct this
// iterator, aside from that the stub be part of a nullptr-terminated
// chain.
// The iterator is considered to be at its end once it has been
// incremented _past_ the last stub. Thus, if 'atEnd()' returns
// true, the '*' and '->' operations are not valid.
class ICStubConstIterator {
friend class ICStub;
friend class ICFallbackStub;
private:
ICStub* currentStub_;
public:
explicit ICStubConstIterator(ICStub* currentStub)
: currentStub_(currentStub) {}
static ICStubConstIterator StartingAt(ICStub* stub) {
return ICStubConstIterator(stub);
}
static ICStubConstIterator End(ICStub* stub) {
return ICStubConstIterator(nullptr);
}
bool operator==(const ICStubConstIterator& other) const {
return currentStub_ == other.currentStub_;
}
bool operator!=(const ICStubConstIterator& other) const {
return !(*this == other);
}
ICStubConstIterator& operator++();
ICStubConstIterator operator++(int) {
ICStubConstIterator oldThis(*this);
++(*this);
return oldThis;
}
ICStub* operator*() const {
MOZ_ASSERT(currentStub_);
return currentStub_;
}
ICStub* operator->() const {
MOZ_ASSERT(currentStub_);
return currentStub_;
}
bool atEnd() const { return currentStub_ == nullptr; }
};
// Iterator that traverses "regular" IC chains that start at an ICEntry
// and are terminated with an ICFallbackStub.
//
// The iterator is considered to be at its end once it is _at_ the
// fallback stub. Thus, unlike the ICStubConstIterator, operators
// '*' and '->' are valid even if 'atEnd()' returns true - they
// will act on the fallback stub.
//
// This iterator also allows unlinking of stubs being traversed.
// Note that 'unlink' does not implicitly advance the iterator -
// it must be advanced explicitly using '++'.
class ICStubIterator {
friend class ICFallbackStub;
private:
ICEntry* icEntry_;
ICFallbackStub* fallbackStub_;
ICCacheIRStub* previousStub_;
ICStub* currentStub_;
bool unlinked_;
explicit ICStubIterator(ICFallbackStub* fallbackStub, bool end = false);
public:
bool operator==(const ICStubIterator& other) const {
// == should only ever be called on stubs from the same chain.
MOZ_ASSERT(icEntry_ == other.icEntry_);
MOZ_ASSERT(fallbackStub_ == other.fallbackStub_);
return currentStub_ == other.currentStub_;
}
bool operator!=(const ICStubIterator& other) const {
return !(*this == other);
}
ICStubIterator& operator++();
ICStubIterator operator++(int) {
ICStubIterator oldThis(*this);
++(*this);
return oldThis;
}
ICStub* operator*() const { return currentStub_; }
ICStub* operator->() const { return currentStub_; }
bool atEnd() const { return currentStub_ == (ICStub*)fallbackStub_; }
void unlink(JSContext* cx);
};
//
// Base class for all IC stubs.
//
class ICStub {
friend class ICFallbackStub;
public:
// TODO(no-TI): move to ICFallbackStub, make enum class.
enum Kind : uint8_t {
INVALID = 0,
#define DEF_ENUM_KIND(kindName) kindName,
IC_BASELINE_STUB_KIND_LIST(DEF_ENUM_KIND)
#undef DEF_ENUM_KIND
LIMIT
};
template <typename T, typename... Args>
static T* New(JSContext* cx, ICStubSpace* space, JitCode* code,
Args&&... args) {
if (!code) {
return nullptr;
}
T* result = space->allocate<T>(code, std::forward<Args>(args)...);
if (!result) {
ReportOutOfMemory(cx);
}
return result;
}
template <typename T, typename... Args>
static T* NewFallback(JSContext* cx, ICStubSpace* space, TrampolinePtr code,
Args&&... args) {
T* result = space->allocate<T>(code, std::forward<Args>(args)...);
if (MOZ_UNLIKELY(!result)) {
ReportOutOfMemory(cx);
}
return result;
}
protected:
// The raw jitcode to call for this stub.
uint8_t* stubCode_;
// Counts the number of times the stub was entered
//
// See Bug 1494473 comment 6 for a mechanism to handle overflow if overflow
// becomes a concern.
uint32_t enteredCount_ = 0;
// Whether this is an ICFallbackStub or an ICCacheIRStub.
bool isFallback_;
ICStub(uint8_t* stubCode, bool isFallback)
: stubCode_(stubCode), isFallback_(isFallback) {
MOZ_ASSERT(stubCode != nullptr);
}
public:
inline bool isFallback() const { return isFallback_; }
inline ICStub* maybeNext() const;
inline const ICFallbackStub* toFallbackStub() const {
MOZ_ASSERT(isFallback());
return reinterpret_cast<const ICFallbackStub*>(this);
}
inline ICFallbackStub* toFallbackStub() {
MOZ_ASSERT(isFallback());
return reinterpret_cast<ICFallbackStub*>(this);
}
ICCacheIRStub* toCacheIRStub() {
MOZ_ASSERT(!isFallback());
return reinterpret_cast<ICCacheIRStub*>(this);
}
const ICCacheIRStub* toCacheIRStub() const {
MOZ_ASSERT(!isFallback());
return reinterpret_cast<const ICCacheIRStub*>(this);
}
bool usesTrampolineCode() const {
// All fallback code is stored in a single JitCode instance, so we can't
// call JitCode::FromExecutable on the raw pointer.
return isFallback();
}
JitCode* jitCode() {
MOZ_ASSERT(!usesTrampolineCode());
return JitCode::FromExecutable(stubCode_);
}
inline uint8_t* rawStubCode() const { return stubCode_; }
uint32_t enteredCount() const { return enteredCount_; }
inline void incrementEnteredCount() { enteredCount_++; }
void resetEnteredCount() { enteredCount_ = 0; }
inline ICFallbackStub* getChainFallback();
inline ICStubConstIterator beginHere() {
return ICStubConstIterator::StartingAt(this);
}
static constexpr size_t offsetOfStubCode() {
return offsetof(ICStub, stubCode_);
}
static constexpr size_t offsetOfEnteredCount() {
return offsetof(ICStub, enteredCount_);
}
};
class ICFallbackStub : public ICStub {
friend class ICStubConstIterator;
protected:
// Fallback stubs need these fields to easily add new stubs to
// the linked list of stubs for an IC.
// The IC entry in JitScript for this linked list of stubs.
ICEntry* icEntry_ = nullptr;
// The state of this IC.
ICState state_{};
Kind kind_;
ICFallbackStub(Kind kind, TrampolinePtr stubCode)
: ICStub(stubCode.value, /* isFallback = */ true), kind_(kind) {
isFallback_ = true;
}
public:
inline ICEntry* icEntry() const { return icEntry_; }
inline Kind kind() const { return kind_; }
#define KIND_METHODS(kindName) \
inline bool is##kindName() const { return kind() == kindName; } \
inline const IC##kindName* to##kindName() const { \
MOZ_ASSERT(is##kindName()); \
return reinterpret_cast<const IC##kindName*>(this); \
} \
inline IC##kindName* to##kindName() { \
MOZ_ASSERT(is##kindName()); \
return reinterpret_cast<IC##kindName*>(this); \
}
IC_BASELINE_STUB_KIND_LIST(KIND_METHODS)
#undef KIND_METHODS
inline size_t numOptimizedStubs() const { return state_.numOptimizedStubs(); }
bool newStubIsFirstStub() const {
return (state_.mode() == ICState::Mode::Specialized &&
numOptimizedStubs() == 0);
}
ICState& state() { return state_; }
void trace(JSTracer* trc);
// The icEntry_ field can't be initialized when the stub is created since we
// won't know the ICEntry address until we add the stub to JitScript. This
// method allows this field to be fixed up at that point.
void fixupICEntry(ICEntry* icEntry) {
MOZ_ASSERT(icEntry_ == nullptr);
icEntry_ = icEntry;
}
// Add a new stub to the IC chain terminated by this fallback stub.
inline void addNewStub(ICCacheIRStub* stub);
ICStubConstIterator beginChainConst() const {
return ICStubConstIterator(icEntry_->firstStub());
}
ICStubIterator beginChain() { return ICStubIterator(this); }
void discardStubs(JSContext* cx);
void clearUsedByTranspiler() { state_.clearUsedByTranspiler(); }
void setUsedByTranspiler() { state_.setUsedByTranspiler(); }
TrialInliningState trialInliningState() const {
return state_.trialInliningState();
}
void setTrialInliningState(TrialInliningState state) {
state_.setTrialInliningState(state);
}
void trackNotAttached();
void unlinkStub(Zone* zone, ICCacheIRStub* prev, ICCacheIRStub* stub);
};
class ICCacheIRStub : public ICStub {
// Pointer to next IC stub.
ICStub* next_ = nullptr;
const CacheIRStubInfo* stubInfo_;
public:
ICCacheIRStub(JitCode* stubCode, const CacheIRStubInfo* stubInfo)
: ICStub(stubCode->raw(), /* isFallback = */ false),
stubInfo_(stubInfo) {}
ICStub* next() const { return next_; }
void setNext(ICStub* stub) { next_ = stub; }
const CacheIRStubInfo* stubInfo() const { return stubInfo_; }
uint8_t* stubDataStart();
void trace(JSTracer* trc);
// Optimized stubs get purged on GC. But some stubs can be active on the
// stack during GC - specifically the ones that can make calls. To ensure
// that these do not get purged, all stubs that can make calls are allocated
// in the fallback stub space.
bool makesGCCalls() const;
bool allocatedInFallbackSpace() const { return makesGCCalls(); }
static constexpr size_t offsetOfNext() {
return offsetof(ICCacheIRStub, next_);
}
};
// Assert stub size is what we expect to catch regressions.
#ifdef JS_64BIT
static_assert(sizeof(ICFallbackStub) == 4 * sizeof(uintptr_t));
static_assert(sizeof(ICCacheIRStub) == 4 * sizeof(uintptr_t));
#else
static_assert(sizeof(ICFallbackStub) == 5 * sizeof(uintptr_t));
static_assert(sizeof(ICCacheIRStub) == 5 * sizeof(uintptr_t));
#endif
inline ICStub* ICStub::maybeNext() const {
return isFallback() ? nullptr : toCacheIRStub()->next();
}
inline void ICFallbackStub::addNewStub(ICCacheIRStub* stub) {
MOZ_ASSERT(stub->next() == nullptr);
stub->setNext(icEntry_->firstStub());
icEntry_->setFirstStub(stub);
state_.trackAttached();
}
inline ICFallbackStub* ICStub::getChainFallback() {
ICStub* lastStub = this;
while (!lastStub->isFallback()) {
lastStub = lastStub->toCacheIRStub()->next();
}
return lastStub->toFallbackStub();
}
AllocatableGeneralRegisterSet BaselineICAvailableGeneralRegs(size_t numInputs);
// ToBool
// JSOp::IfNe
class ICToBool_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICToBool_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::ToBool_Fallback, stubCode) {}
};
// GetElem
// JSOp::GetElem
// JSOp::GetElemSuper
class ICGetElem_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICGetElem_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::GetElem_Fallback, stubCode) {}
};
// SetElem
// JSOp::SetElem
// JSOp::InitElem
class ICSetElem_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICSetElem_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::SetElem_Fallback, stubCode) {}
};
// In
// JSOp::In
class ICIn_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICIn_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::In_Fallback, stubCode) {}
};
// HasOwn
// JSOp::HasOwn
class ICHasOwn_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICHasOwn_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::HasOwn_Fallback, stubCode) {}
};
// CheckPrivateField
// JSOp::CheckPrivateField
class ICCheckPrivateField_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICCheckPrivateField_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::CheckPrivateField_Fallback, stubCode) {}
};
// GetName
// JSOp::GetName
// JSOp::GetGName
class ICGetName_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICGetName_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::GetName_Fallback, stubCode) {}
};
// BindName
// JSOp::BindName
class ICBindName_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICBindName_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::BindName_Fallback, stubCode) {}
};
// GetIntrinsic
// JSOp::GetIntrinsic
class ICGetIntrinsic_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICGetIntrinsic_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::GetIntrinsic_Fallback, stubCode) {}
};
// GetProp
// JSOp::GetProp
// JSOp::GetPropSuper
class ICGetProp_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICGetProp_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::GetProp_Fallback, stubCode) {}
};
// SetProp
// JSOp::SetProp
// JSOp::SetName
// JSOp::SetGName
// JSOp::InitProp
class ICSetProp_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICSetProp_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::SetProp_Fallback, stubCode) {}
};
// Call
// JSOp::Call
// JSOp::CallIgnoresRv
// JSOp::CallIter
// JSOp::FunApply
// JSOp::FunCall
// JSOp::New
// JSOp::SuperCall
// JSOp::Eval
// JSOp::StrictEval
// JSOp::SpreadCall
// JSOp::SpreadNew
// JSOp::SpreadSuperCall
// JSOp::SpreadEval
// JSOp::SpreadStrictEval
class ICCall_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICCall_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::Call_Fallback, stubCode) {}
};
// IC for constructing an iterator from an input value.
class ICGetIterator_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICGetIterator_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::GetIterator_Fallback, stubCode) {}
};
class ICOptimizeSpreadCall_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICOptimizeSpreadCall_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::OptimizeSpreadCall_Fallback, stubCode) {}
};
// InstanceOf
// JSOp::Instanceof
class ICInstanceOf_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICInstanceOf_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::InstanceOf_Fallback, stubCode) {}
};
// TypeOf
// JSOp::Typeof
// JSOp::TypeofExpr
class ICTypeOf_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICTypeOf_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::TypeOf_Fallback, stubCode) {}
};
class ICToPropertyKey_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICToPropertyKey_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::ToPropertyKey_Fallback, stubCode) {}
};
class ICRest_Fallback : public ICFallbackStub {
friend class ICStubSpace;
GCPtrArrayObject templateObject_;
ICRest_Fallback(TrampolinePtr stubCode, ArrayObject* templateObject)
: ICFallbackStub(ICStub::Rest_Fallback, stubCode),
templateObject_(templateObject) {}
public:
GCPtrArrayObject& templateObject() { return templateObject_; }
};
// UnaryArith
// JSOp::BitNot
// JSOp::Pos
// JSOp::Neg
// JSOp::Inc
// JSOp::Dec
// JSOp::ToNumeric
class ICUnaryArith_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICUnaryArith_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(UnaryArith_Fallback, stubCode) {}
};
// Compare
// JSOp::Lt
// JSOp::Le
// JSOp::Gt
// JSOp::Ge
// JSOp::Eq
// JSOp::Ne
// JSOp::StrictEq
// JSOp::StrictNe
class ICCompare_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICCompare_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::Compare_Fallback, stubCode) {}
};
// BinaryArith
// JSOp::Add, JSOp::Sub, JSOp::Mul, JSOp::Div, JSOp::Mod, JSOp::Pow,
// JSOp::BitAnd, JSOp::BitXor, JSOp::BitOr
// JSOp::Lsh, JSOp::Rsh, JSOp::Ursh
class ICBinaryArith_Fallback : public ICFallbackStub {
friend class ICStubSpace;
explicit ICBinaryArith_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(BinaryArith_Fallback, stubCode) {}
};
// JSOp::NewArray
class ICNewArray_Fallback : public ICFallbackStub {
friend class ICStubSpace;
GCPtrArrayObject templateObject_;
explicit ICNewArray_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::NewArray_Fallback, stubCode),
templateObject_(nullptr) {}
public:
GCPtrArrayObject& templateObject() { return templateObject_; }
void setTemplateObject(ArrayObject* obj) { templateObject_ = obj; }
};
// JSOp::NewObject
class ICNewObject_Fallback : public ICFallbackStub {
friend class ICStubSpace;
GCPtrObject templateObject_;
explicit ICNewObject_Fallback(TrampolinePtr stubCode)
: ICFallbackStub(ICStub::NewObject_Fallback, stubCode),
templateObject_(nullptr) {}
public:
GCPtrObject& templateObject() { return templateObject_; }
void setTemplateObject(JSObject* obj) { templateObject_ = obj; }
};
struct IonOsrTempData;
extern bool DoCallFallback(JSContext* cx, BaselineFrame* frame,
ICCall_Fallback* stub, uint32_t argc, Value* vp,
MutableHandleValue res);
extern bool DoSpreadCallFallback(JSContext* cx, BaselineFrame* frame,
ICCall_Fallback* stub, Value* vp,
MutableHandleValue res);
extern bool DoToBoolFallback(JSContext* cx, BaselineFrame* frame,
ICToBool_Fallback* stub, HandleValue arg,
MutableHandleValue ret);
extern bool DoGetElemSuperFallback(JSContext* cx, BaselineFrame* frame,
ICGetElem_Fallback* stub, HandleValue lhs,
HandleValue rhs, HandleValue receiver,
MutableHandleValue res);
extern bool DoGetElemFallback(JSContext* cx, BaselineFrame* frame,
ICGetElem_Fallback* stub, HandleValue lhs,
HandleValue rhs, MutableHandleValue res);
extern bool DoSetElemFallback(JSContext* cx, BaselineFrame* frame,
ICSetElem_Fallback* stub, Value* stack,
HandleValue objv, HandleValue index,
HandleValue rhs);
extern bool DoInFallback(JSContext* cx, BaselineFrame* frame,
ICIn_Fallback* stub, HandleValue key,
HandleValue objValue, MutableHandleValue res);
extern bool DoHasOwnFallback(JSContext* cx, BaselineFrame* frame,
ICHasOwn_Fallback* stub, HandleValue keyValue,
HandleValue objValue, MutableHandleValue res);
extern bool DoCheckPrivateFieldFallback(JSContext* cx, BaselineFrame* frame,
ICCheckPrivateField_Fallback* stub,
HandleValue objValue,
HandleValue keyValue,
MutableHandleValue res);
extern bool DoGetNameFallback(JSContext* cx, BaselineFrame* frame,
ICGetName_Fallback* stub, HandleObject envChain,
MutableHandleValue res);
extern bool DoBindNameFallback(JSContext* cx, BaselineFrame* frame,
ICBindName_Fallback* stub, HandleObject envChain,
MutableHandleValue res);
extern bool DoGetIntrinsicFallback(JSContext* cx, BaselineFrame* frame,
ICGetIntrinsic_Fallback* stub,
MutableHandleValue res);
extern bool DoGetPropFallback(JSContext* cx, BaselineFrame* frame,
ICGetProp_Fallback* stub, MutableHandleValue val,
MutableHandleValue res);
extern bool DoGetPropSuperFallback(JSContext* cx, BaselineFrame* frame,
ICGetProp_Fallback* stub,
HandleValue receiver, MutableHandleValue val,
MutableHandleValue res);
extern bool DoSetPropFallback(JSContext* cx, BaselineFrame* frame,
ICSetProp_Fallback* stub, Value* stack,
HandleValue lhs, HandleValue rhs);
extern bool DoGetIteratorFallback(JSContext* cx, BaselineFrame* frame,
ICGetIterator_Fallback* stub,
HandleValue value, MutableHandleValue res);
extern bool DoOptimizeSpreadCallFallback(JSContext* cx, BaselineFrame* frame,
ICOptimizeSpreadCall_Fallback* stub,
HandleValue value,
MutableHandleValue res);
extern bool DoInstanceOfFallback(JSContext* cx, BaselineFrame* frame,
ICInstanceOf_Fallback* stub, HandleValue lhs,
HandleValue rhs, MutableHandleValue res);
extern bool DoTypeOfFallback(JSContext* cx, BaselineFrame* frame,
ICTypeOf_Fallback* stub, HandleValue val,
MutableHandleValue res);
extern bool DoToPropertyKeyFallback(JSContext* cx, BaselineFrame* frame,
ICToPropertyKey_Fallback* stub,
HandleValue val, MutableHandleValue res);
extern bool DoRestFallback(JSContext* cx, BaselineFrame* frame,
ICRest_Fallback* stub, MutableHandleValue res);
extern bool DoUnaryArithFallback(JSContext* cx, BaselineFrame* frame,
ICUnaryArith_Fallback* stub, HandleValue val,
MutableHandleValue res);
extern bool DoBinaryArithFallback(JSContext* cx, BaselineFrame* frame,
ICBinaryArith_Fallback* stub, HandleValue lhs,
HandleValue rhs, MutableHandleValue ret);
extern bool DoNewArrayFallback(JSContext* cx, BaselineFrame* frame,
ICNewArray_Fallback* stub, uint32_t length,
MutableHandleValue res);
extern bool DoNewObjectFallback(JSContext* cx, BaselineFrame* frame,
ICNewObject_Fallback* stub,
MutableHandleValue res);
extern bool DoCompareFallback(JSContext* cx, BaselineFrame* frame,
ICCompare_Fallback* stub, HandleValue lhs,
HandleValue rhs, MutableHandleValue ret);
} // namespace jit
} // namespace js
#endif /* jit_BaselineIC_h */
|