|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
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/. */ |
|
6 |
|
7 #ifndef jit_CompileWrappers_h |
|
8 #define jit_CompileWrappers_h |
|
9 |
|
10 #ifdef JS_ION |
|
11 |
|
12 #include "jscntxt.h" |
|
13 |
|
14 namespace js { |
|
15 namespace jit { |
|
16 |
|
17 class JitRuntime; |
|
18 |
|
19 // During Ion compilation we need access to various bits of the current |
|
20 // compartment, runtime and so forth. However, since compilation can run off |
|
21 // thread while the main thread is actively mutating the VM, this access needs |
|
22 // to be restricted. The classes below give the compiler an interface to access |
|
23 // all necessary information in a threadsafe fashion. |
|
24 |
|
25 class CompileRuntime |
|
26 { |
|
27 JSRuntime *runtime(); |
|
28 |
|
29 public: |
|
30 static CompileRuntime *get(JSRuntime *rt); |
|
31 |
|
32 bool onMainThread(); |
|
33 |
|
34 js::PerThreadData *mainThread(); |
|
35 |
|
36 // &mainThread.ionTop |
|
37 const void *addressOfIonTop(); |
|
38 |
|
39 // rt->mainThread.jitStackLimit; |
|
40 const void *addressOfJitStackLimit(); |
|
41 |
|
42 // &mainThread.ionJSContext |
|
43 const void *addressOfJSContext(); |
|
44 |
|
45 // &mainThread.activation_ |
|
46 const void *addressOfActivation(); |
|
47 |
|
48 // &GetIonContext()->runtime->nativeIterCache.last |
|
49 const void *addressOfLastCachedNativeIterator(); |
|
50 |
|
51 #ifdef JS_GC_ZEAL |
|
52 const void *addressOfGCZeal(); |
|
53 #endif |
|
54 |
|
55 const void *addressOfInterrupt(); |
|
56 |
|
57 #ifdef JS_THREADSAFE |
|
58 const void *addressOfInterruptPar(); |
|
59 #endif |
|
60 |
|
61 const void *addressOfThreadPool(); |
|
62 |
|
63 const JitRuntime *jitRuntime(); |
|
64 |
|
65 // Compilation does not occur off thread when the SPS profiler is enabled. |
|
66 SPSProfiler &spsProfiler(); |
|
67 |
|
68 bool signalHandlersInstalled(); |
|
69 bool jitSupportsFloatingPoint(); |
|
70 bool hadOutOfMemory(); |
|
71 |
|
72 const JSAtomState &names(); |
|
73 const StaticStrings &staticStrings(); |
|
74 const Value &NaNValue(); |
|
75 const Value &positiveInfinityValue(); |
|
76 |
|
77 #ifdef DEBUG |
|
78 bool isInsideNursery(gc::Cell *cell); |
|
79 #endif |
|
80 |
|
81 // DOM callbacks must be threadsafe (and will hopefully be removed soon). |
|
82 const DOMCallbacks *DOMcallbacks(); |
|
83 |
|
84 const MathCache *maybeGetMathCache(); |
|
85 |
|
86 #ifdef JSGC_GENERATIONAL |
|
87 const Nursery &gcNursery(); |
|
88 #endif |
|
89 }; |
|
90 |
|
91 class CompileZone |
|
92 { |
|
93 Zone *zone(); |
|
94 |
|
95 public: |
|
96 static CompileZone *get(Zone *zone); |
|
97 |
|
98 const void *addressOfNeedsBarrier(); |
|
99 |
|
100 // allocator.arenas.getFreeList(allocKind) |
|
101 const void *addressOfFreeListFirst(gc::AllocKind allocKind); |
|
102 const void *addressOfFreeListLast(gc::AllocKind allocKind); |
|
103 }; |
|
104 |
|
105 class CompileCompartment |
|
106 { |
|
107 JSCompartment *compartment(); |
|
108 |
|
109 public: |
|
110 static CompileCompartment *get(JSCompartment *comp); |
|
111 |
|
112 CompileZone *zone(); |
|
113 CompileRuntime *runtime(); |
|
114 |
|
115 const void *addressOfEnumerators(); |
|
116 |
|
117 const CallsiteCloneTable &callsiteClones(); |
|
118 |
|
119 const JitCompartment *jitCompartment(); |
|
120 |
|
121 bool hasObjectMetadataCallback(); |
|
122 |
|
123 // Mirror CompartmentOptions. |
|
124 void setSingletonsAsValues(); |
|
125 }; |
|
126 |
|
127 class JitCompileOptions |
|
128 { |
|
129 public: |
|
130 JitCompileOptions(); |
|
131 JitCompileOptions(JSContext *cx); |
|
132 |
|
133 bool cloneSingletons() const { |
|
134 return cloneSingletons_; |
|
135 } |
|
136 |
|
137 bool spsSlowAssertionsEnabled() const { |
|
138 return spsSlowAssertionsEnabled_; |
|
139 } |
|
140 |
|
141 private: |
|
142 bool cloneSingletons_; |
|
143 bool spsSlowAssertionsEnabled_; |
|
144 }; |
|
145 |
|
146 |
|
147 } // namespace jit |
|
148 } // namespace js |
|
149 |
|
150 #endif // JS_ION |
|
151 |
|
152 #endif // jit_CompileWrappers_h |