Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / js / src / jit / CompileWrappers.h
blobde23af7106ce4cfa376c8b8123de70f072f99fd8
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
10 #include <stdint.h>
12 #include "gc/Pretenuring.h"
13 #include "js/TypeDecls.h"
14 #include "vm/Realm.h"
15 #include "vm/RealmFuses.h"
17 struct JSAtomState;
19 namespace mozilla::non_crypto {
20 class XorShift128PlusRNG;
23 namespace JS {
24 enum class TraceKind;
27 namespace js {
29 class GeckoProfilerRuntime;
30 class GlobalObject;
31 struct JSDOMCallbacks;
32 class PropertyName;
33 class StaticStrings;
34 struct WellKnownSymbols;
36 using DOMCallbacks = struct JSDOMCallbacks;
38 namespace gc {
40 enum class AllocKind : uint8_t;
42 class FreeSpan;
44 } // namespace gc
46 namespace jit {
48 class JitRuntime;
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 {
57 JSRuntime* runtime();
59 public:
60 static CompileRuntime* get(JSRuntime* rt);
62 #ifdef JS_GC_ZEAL
63 const uint32_t* addressOfGCZealModeBits();
64 #endif
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();
92 #ifdef DEBUG
93 const void* addressOfIonBailAfterCounter();
94 #endif
96 // DOM callbacks must be threadsafe (and will hopefully be removed soon).
97 const DOMCallbacks* DOMcallbacks();
99 bool runtimeMatches(JSRuntime* rt);
102 class JitZone;
104 class CompileZone {
105 friend class MacroAssembler;
106 JS::Zone* zone();
108 public:
109 static CompileZone* get(JS::Zone* zone);
111 const JitZone* jitZone();
113 CompileRuntime* runtime();
114 bool isAtomsZone();
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();
135 class CompileRealm {
136 JS::Realm* realm();
138 public:
139 static CompileRealm* get(JS::Realm* realm);
141 CompileZone* zone();
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 {
156 public:
157 JitCompileOptions();
158 explicit JitCompileOptions(JSContext* cx);
160 bool profilerSlowAssertionsEnabled() const {
161 return profilerSlowAssertionsEnabled_;
164 bool offThreadCompilationAvailable() const {
165 return offThreadCompilationAvailable_;
168 #ifdef DEBUG
169 bool ionBailAfterEnabled() const { return ionBailAfterEnabled_; }
170 #endif
172 private:
173 bool profilerSlowAssertionsEnabled_;
174 bool offThreadCompilationAvailable_;
175 #ifdef DEBUG
176 bool ionBailAfterEnabled_ = false;
177 #endif
180 } // namespace jit
181 } // namespace js
183 #endif // jit_CompileWrappers_h