1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jit_CompileWrappers_h
8 #define jit_CompileWrappers_h
12 #include "gc/Pretenuring.h"
13 #include "js/TypeDecls.h"
15 #include "vm/RealmFuses.h"
19 namespace mozilla::non_crypto
{
20 class XorShift128PlusRNG
;
29 class GeckoProfilerRuntime
;
31 struct JSDOMCallbacks
;
34 struct WellKnownSymbols
;
36 using DOMCallbacks
= struct JSDOMCallbacks
;
40 enum class AllocKind
: uint8_t;
50 // During Ion compilation we need access to various bits of the current
51 // compartment, runtime and so forth. However, since compilation can run off
52 // thread while the main thread is mutating the VM, this access needs
53 // to be restricted. The classes below give the compiler an interface to access
54 // all necessary information in a threadsafe fashion.
56 class CompileRuntime
{
60 static CompileRuntime
* get(JSRuntime
* rt
);
63 const uint32_t* addressOfGCZealModeBits();
66 const JitRuntime
* jitRuntime();
68 // Compilation does not occur off thread when the Gecko Profiler is enabled.
69 GeckoProfilerRuntime
& geckoProfiler();
71 bool hadOutOfMemory();
72 bool profilingScripts();
74 const JSAtomState
& names();
75 const PropertyName
* emptyString();
76 const StaticStrings
& staticStrings();
77 const WellKnownSymbols
& wellKnownSymbols();
78 const JSClass
* maybeWindowProxyClass();
80 const void* mainContextPtr();
81 const void* addressOfJitStackLimit();
82 const void* addressOfInterruptBits();
83 const void* addressOfZone();
84 const void* addressOfMegamorphicCache();
85 const void* addressOfMegamorphicSetPropCache();
86 const void* addressOfStringToAtomCache();
87 const void* addressOfLastBufferedWholeCell();
89 bool hasSeenObjectEmulateUndefinedFuseIntact();
90 const void* addressOfHasSeenObjectEmulateUndefinedFuse();
93 const void* addressOfIonBailAfterCounter();
96 // DOM callbacks must be threadsafe (and will hopefully be removed soon).
97 const DOMCallbacks
* DOMcallbacks();
99 bool runtimeMatches(JSRuntime
* rt
);
105 friend class MacroAssembler
;
109 static CompileZone
* get(JS::Zone
* zone
);
111 const JitZone
* jitZone();
113 CompileRuntime
* runtime();
116 const uint32_t* addressOfNeedsIncrementalBarrier();
117 uint32_t* addressOfTenuredAllocCount();
118 gc::FreeSpan
** addressOfFreeList(gc::AllocKind allocKind
);
119 bool allocNurseryObjects();
120 bool allocNurseryStrings();
121 bool allocNurseryBigInts();
122 void* addressOfNurseryPosition();
124 void* addressOfNurseryAllocatedSites();
126 bool canNurseryAllocateStrings();
127 bool canNurseryAllocateBigInts();
129 gc::AllocSite
* catchAllAllocSite(JS::TraceKind traceKind
,
130 gc::CatchAllAllocSite siteKind
);
132 bool hasRealmWithAllocMetadataBuilder();
139 static CompileRealm
* get(JS::Realm
* realm
);
142 CompileRuntime
* runtime();
144 const void* realmPtr() { return realm(); }
146 RealmFuses
& realmFuses() { return realm()->realmFuses
; }
148 const mozilla::non_crypto::XorShift128PlusRNG
*
149 addressOfRandomNumberGenerator();
151 const GlobalObject
* maybeGlobal();
152 const uint32_t* addressOfGlobalWriteBarriered();
155 class JitCompileOptions
{
158 explicit JitCompileOptions(JSContext
* cx
);
160 bool profilerSlowAssertionsEnabled() const {
161 return profilerSlowAssertionsEnabled_
;
164 bool offThreadCompilationAvailable() const {
165 return offThreadCompilationAvailable_
;
169 bool ionBailAfterEnabled() const { return ionBailAfterEnabled_
; }
173 bool profilerSlowAssertionsEnabled_
;
174 bool offThreadCompilationAvailable_
;
176 bool ionBailAfterEnabled_
= false;
183 #endif // jit_CompileWrappers_h