js/src/jit/CompileWrappers.cpp

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:5b8892a83aaf
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 #include "jit/Ion.h"
8
9 using namespace js;
10 using namespace js::jit;
11
12 JSRuntime *
13 CompileRuntime::runtime()
14 {
15 return reinterpret_cast<JSRuntime *>(this);
16 }
17
18 /* static */ CompileRuntime *
19 CompileRuntime::get(JSRuntime *rt)
20 {
21 return reinterpret_cast<CompileRuntime *>(rt);
22 }
23
24 bool
25 CompileRuntime::onMainThread()
26 {
27 return js::CurrentThreadCanAccessRuntime(runtime());
28 }
29
30 js::PerThreadData *
31 CompileRuntime::mainThread()
32 {
33 JS_ASSERT(onMainThread());
34 return &runtime()->mainThread;
35 }
36
37 const void *
38 CompileRuntime::addressOfIonTop()
39 {
40 return &runtime()->mainThread.ionTop;
41 }
42
43 const void *
44 CompileRuntime::addressOfJitStackLimit()
45 {
46 return &runtime()->mainThread.jitStackLimit;
47 }
48
49 const void *
50 CompileRuntime::addressOfJSContext()
51 {
52 return &runtime()->mainThread.jitJSContext;
53 }
54
55 const void *
56 CompileRuntime::addressOfActivation()
57 {
58 return runtime()->mainThread.addressOfActivation();
59 }
60
61 const void *
62 CompileRuntime::addressOfLastCachedNativeIterator()
63 {
64 return &runtime()->nativeIterCache.last;
65 }
66
67 #ifdef JS_GC_ZEAL
68 const void *
69 CompileRuntime::addressOfGCZeal()
70 {
71 return &runtime()->gcZeal_;
72 }
73 #endif
74
75 const void *
76 CompileRuntime::addressOfInterrupt()
77 {
78 return &runtime()->interrupt;
79 }
80
81 #ifdef JS_THREADSAFE
82 const void *
83 CompileRuntime::addressOfInterruptPar()
84 {
85 return &runtime()->interruptPar;
86 }
87 #endif
88
89 const void *
90 CompileRuntime::addressOfThreadPool()
91 {
92 return &runtime()->threadPool;
93 }
94
95 const JitRuntime *
96 CompileRuntime::jitRuntime()
97 {
98 return runtime()->jitRuntime();
99 }
100
101 SPSProfiler &
102 CompileRuntime::spsProfiler()
103 {
104 return runtime()->spsProfiler;
105 }
106
107 bool
108 CompileRuntime::signalHandlersInstalled()
109 {
110 return runtime()->signalHandlersInstalled();
111 }
112
113 bool
114 CompileRuntime::jitSupportsFloatingPoint()
115 {
116 return runtime()->jitSupportsFloatingPoint;
117 }
118
119 bool
120 CompileRuntime::hadOutOfMemory()
121 {
122 return runtime()->hadOutOfMemory;
123 }
124
125 const JSAtomState &
126 CompileRuntime::names()
127 {
128 return *runtime()->commonNames;
129 }
130
131 const StaticStrings &
132 CompileRuntime::staticStrings()
133 {
134 return *runtime()->staticStrings;
135 }
136
137 const Value &
138 CompileRuntime::NaNValue()
139 {
140 return runtime()->NaNValue;
141 }
142
143 const Value &
144 CompileRuntime::positiveInfinityValue()
145 {
146 return runtime()->positiveInfinityValue;
147 }
148
149 #ifdef DEBUG
150 bool
151 CompileRuntime::isInsideNursery(gc::Cell *cell)
152 {
153 return UninlinedIsInsideNursery(runtime(), cell);
154 }
155 #endif
156
157 const DOMCallbacks *
158 CompileRuntime::DOMcallbacks()
159 {
160 return GetDOMCallbacks(runtime());
161 }
162
163 const MathCache *
164 CompileRuntime::maybeGetMathCache()
165 {
166 return runtime()->maybeGetMathCache();
167 }
168
169 #ifdef JSGC_GENERATIONAL
170 const Nursery &
171 CompileRuntime::gcNursery()
172 {
173 return runtime()->gcNursery;
174 }
175 #endif
176
177 Zone *
178 CompileZone::zone()
179 {
180 return reinterpret_cast<Zone *>(this);
181 }
182
183 /* static */ CompileZone *
184 CompileZone::get(Zone *zone)
185 {
186 return reinterpret_cast<CompileZone *>(zone);
187 }
188
189 const void *
190 CompileZone::addressOfNeedsBarrier()
191 {
192 return zone()->addressOfNeedsBarrier();
193 }
194
195 const void *
196 CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind)
197 {
198 return &zone()->allocator.arenas.getFreeList(allocKind)->first;
199 }
200
201 const void *
202 CompileZone::addressOfFreeListLast(gc::AllocKind allocKind)
203 {
204 return &zone()->allocator.arenas.getFreeList(allocKind)->last;
205 }
206
207 JSCompartment *
208 CompileCompartment::compartment()
209 {
210 return reinterpret_cast<JSCompartment *>(this);
211 }
212
213 /* static */ CompileCompartment *
214 CompileCompartment::get(JSCompartment *comp)
215 {
216 return reinterpret_cast<CompileCompartment *>(comp);
217 }
218
219 CompileZone *
220 CompileCompartment::zone()
221 {
222 return CompileZone::get(compartment()->zone());
223 }
224
225 CompileRuntime *
226 CompileCompartment::runtime()
227 {
228 return CompileRuntime::get(compartment()->runtimeFromAnyThread());
229 }
230
231 const void *
232 CompileCompartment::addressOfEnumerators()
233 {
234 return &compartment()->enumerators;
235 }
236
237 const CallsiteCloneTable &
238 CompileCompartment::callsiteClones()
239 {
240 return compartment()->callsiteClones;
241 }
242
243 const JitCompartment *
244 CompileCompartment::jitCompartment()
245 {
246 return compartment()->jitCompartment();
247 }
248
249 bool
250 CompileCompartment::hasObjectMetadataCallback()
251 {
252 return compartment()->hasObjectMetadataCallback();
253 }
254
255 // Note: This function is thread-safe because setSingletonAsValue sets a boolean
256 // variable to false, and this boolean variable has no way to be resetted to
257 // true. So even if there is a concurrent write, this concurrent write will
258 // always have the same value. If there is a concurrent read, then we will
259 // clone a singleton instead of using the value which is baked in the JSScript,
260 // and this would be an unfortunate allocation, but this will not change the
261 // semantics of the JavaScript code which is executed.
262 void
263 CompileCompartment::setSingletonsAsValues()
264 {
265 return JS::CompartmentOptionsRef(compartment()).setSingletonsAsValues();
266 }
267
268 JitCompileOptions::JitCompileOptions()
269 : cloneSingletons_(false),
270 spsSlowAssertionsEnabled_(false)
271 {
272 }
273
274 JitCompileOptions::JitCompileOptions(JSContext *cx)
275 {
276 JS::CompartmentOptions &options = cx->compartment()->options();
277 cloneSingletons_ = options.cloneSingletons(cx);
278 spsSlowAssertionsEnabled_ = cx->runtime()->spsProfiler.enabled() &&
279 cx->runtime()->spsProfiler.slowAssertionsEnabled();
280 }

mercurial