1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/CompileWrappers.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,280 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "jit/Ion.h" 1.11 + 1.12 +using namespace js; 1.13 +using namespace js::jit; 1.14 + 1.15 +JSRuntime * 1.16 +CompileRuntime::runtime() 1.17 +{ 1.18 + return reinterpret_cast<JSRuntime *>(this); 1.19 +} 1.20 + 1.21 +/* static */ CompileRuntime * 1.22 +CompileRuntime::get(JSRuntime *rt) 1.23 +{ 1.24 + return reinterpret_cast<CompileRuntime *>(rt); 1.25 +} 1.26 + 1.27 +bool 1.28 +CompileRuntime::onMainThread() 1.29 +{ 1.30 + return js::CurrentThreadCanAccessRuntime(runtime()); 1.31 +} 1.32 + 1.33 +js::PerThreadData * 1.34 +CompileRuntime::mainThread() 1.35 +{ 1.36 + JS_ASSERT(onMainThread()); 1.37 + return &runtime()->mainThread; 1.38 +} 1.39 + 1.40 +const void * 1.41 +CompileRuntime::addressOfIonTop() 1.42 +{ 1.43 + return &runtime()->mainThread.ionTop; 1.44 +} 1.45 + 1.46 +const void * 1.47 +CompileRuntime::addressOfJitStackLimit() 1.48 +{ 1.49 + return &runtime()->mainThread.jitStackLimit; 1.50 +} 1.51 + 1.52 +const void * 1.53 +CompileRuntime::addressOfJSContext() 1.54 +{ 1.55 + return &runtime()->mainThread.jitJSContext; 1.56 +} 1.57 + 1.58 +const void * 1.59 +CompileRuntime::addressOfActivation() 1.60 +{ 1.61 + return runtime()->mainThread.addressOfActivation(); 1.62 +} 1.63 + 1.64 +const void * 1.65 +CompileRuntime::addressOfLastCachedNativeIterator() 1.66 +{ 1.67 + return &runtime()->nativeIterCache.last; 1.68 +} 1.69 + 1.70 +#ifdef JS_GC_ZEAL 1.71 +const void * 1.72 +CompileRuntime::addressOfGCZeal() 1.73 +{ 1.74 + return &runtime()->gcZeal_; 1.75 +} 1.76 +#endif 1.77 + 1.78 +const void * 1.79 +CompileRuntime::addressOfInterrupt() 1.80 +{ 1.81 + return &runtime()->interrupt; 1.82 +} 1.83 + 1.84 +#ifdef JS_THREADSAFE 1.85 +const void * 1.86 +CompileRuntime::addressOfInterruptPar() 1.87 +{ 1.88 + return &runtime()->interruptPar; 1.89 +} 1.90 +#endif 1.91 + 1.92 +const void * 1.93 +CompileRuntime::addressOfThreadPool() 1.94 +{ 1.95 + return &runtime()->threadPool; 1.96 +} 1.97 + 1.98 +const JitRuntime * 1.99 +CompileRuntime::jitRuntime() 1.100 +{ 1.101 + return runtime()->jitRuntime(); 1.102 +} 1.103 + 1.104 +SPSProfiler & 1.105 +CompileRuntime::spsProfiler() 1.106 +{ 1.107 + return runtime()->spsProfiler; 1.108 +} 1.109 + 1.110 +bool 1.111 +CompileRuntime::signalHandlersInstalled() 1.112 +{ 1.113 + return runtime()->signalHandlersInstalled(); 1.114 +} 1.115 + 1.116 +bool 1.117 +CompileRuntime::jitSupportsFloatingPoint() 1.118 +{ 1.119 + return runtime()->jitSupportsFloatingPoint; 1.120 +} 1.121 + 1.122 +bool 1.123 +CompileRuntime::hadOutOfMemory() 1.124 +{ 1.125 + return runtime()->hadOutOfMemory; 1.126 +} 1.127 + 1.128 +const JSAtomState & 1.129 +CompileRuntime::names() 1.130 +{ 1.131 + return *runtime()->commonNames; 1.132 +} 1.133 + 1.134 +const StaticStrings & 1.135 +CompileRuntime::staticStrings() 1.136 +{ 1.137 + return *runtime()->staticStrings; 1.138 +} 1.139 + 1.140 +const Value & 1.141 +CompileRuntime::NaNValue() 1.142 +{ 1.143 + return runtime()->NaNValue; 1.144 +} 1.145 + 1.146 +const Value & 1.147 +CompileRuntime::positiveInfinityValue() 1.148 +{ 1.149 + return runtime()->positiveInfinityValue; 1.150 +} 1.151 + 1.152 +#ifdef DEBUG 1.153 +bool 1.154 +CompileRuntime::isInsideNursery(gc::Cell *cell) 1.155 +{ 1.156 + return UninlinedIsInsideNursery(runtime(), cell); 1.157 +} 1.158 +#endif 1.159 + 1.160 +const DOMCallbacks * 1.161 +CompileRuntime::DOMcallbacks() 1.162 +{ 1.163 + return GetDOMCallbacks(runtime()); 1.164 +} 1.165 + 1.166 +const MathCache * 1.167 +CompileRuntime::maybeGetMathCache() 1.168 +{ 1.169 + return runtime()->maybeGetMathCache(); 1.170 +} 1.171 + 1.172 +#ifdef JSGC_GENERATIONAL 1.173 +const Nursery & 1.174 +CompileRuntime::gcNursery() 1.175 +{ 1.176 + return runtime()->gcNursery; 1.177 +} 1.178 +#endif 1.179 + 1.180 +Zone * 1.181 +CompileZone::zone() 1.182 +{ 1.183 + return reinterpret_cast<Zone *>(this); 1.184 +} 1.185 + 1.186 +/* static */ CompileZone * 1.187 +CompileZone::get(Zone *zone) 1.188 +{ 1.189 + return reinterpret_cast<CompileZone *>(zone); 1.190 +} 1.191 + 1.192 +const void * 1.193 +CompileZone::addressOfNeedsBarrier() 1.194 +{ 1.195 + return zone()->addressOfNeedsBarrier(); 1.196 +} 1.197 + 1.198 +const void * 1.199 +CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind) 1.200 +{ 1.201 + return &zone()->allocator.arenas.getFreeList(allocKind)->first; 1.202 +} 1.203 + 1.204 +const void * 1.205 +CompileZone::addressOfFreeListLast(gc::AllocKind allocKind) 1.206 +{ 1.207 + return &zone()->allocator.arenas.getFreeList(allocKind)->last; 1.208 +} 1.209 + 1.210 +JSCompartment * 1.211 +CompileCompartment::compartment() 1.212 +{ 1.213 + return reinterpret_cast<JSCompartment *>(this); 1.214 +} 1.215 + 1.216 +/* static */ CompileCompartment * 1.217 +CompileCompartment::get(JSCompartment *comp) 1.218 +{ 1.219 + return reinterpret_cast<CompileCompartment *>(comp); 1.220 +} 1.221 + 1.222 +CompileZone * 1.223 +CompileCompartment::zone() 1.224 +{ 1.225 + return CompileZone::get(compartment()->zone()); 1.226 +} 1.227 + 1.228 +CompileRuntime * 1.229 +CompileCompartment::runtime() 1.230 +{ 1.231 + return CompileRuntime::get(compartment()->runtimeFromAnyThread()); 1.232 +} 1.233 + 1.234 +const void * 1.235 +CompileCompartment::addressOfEnumerators() 1.236 +{ 1.237 + return &compartment()->enumerators; 1.238 +} 1.239 + 1.240 +const CallsiteCloneTable & 1.241 +CompileCompartment::callsiteClones() 1.242 +{ 1.243 + return compartment()->callsiteClones; 1.244 +} 1.245 + 1.246 +const JitCompartment * 1.247 +CompileCompartment::jitCompartment() 1.248 +{ 1.249 + return compartment()->jitCompartment(); 1.250 +} 1.251 + 1.252 +bool 1.253 +CompileCompartment::hasObjectMetadataCallback() 1.254 +{ 1.255 + return compartment()->hasObjectMetadataCallback(); 1.256 +} 1.257 + 1.258 +// Note: This function is thread-safe because setSingletonAsValue sets a boolean 1.259 +// variable to false, and this boolean variable has no way to be resetted to 1.260 +// true. So even if there is a concurrent write, this concurrent write will 1.261 +// always have the same value. If there is a concurrent read, then we will 1.262 +// clone a singleton instead of using the value which is baked in the JSScript, 1.263 +// and this would be an unfortunate allocation, but this will not change the 1.264 +// semantics of the JavaScript code which is executed. 1.265 +void 1.266 +CompileCompartment::setSingletonsAsValues() 1.267 +{ 1.268 + return JS::CompartmentOptionsRef(compartment()).setSingletonsAsValues(); 1.269 +} 1.270 + 1.271 +JitCompileOptions::JitCompileOptions() 1.272 + : cloneSingletons_(false), 1.273 + spsSlowAssertionsEnabled_(false) 1.274 +{ 1.275 +} 1.276 + 1.277 +JitCompileOptions::JitCompileOptions(JSContext *cx) 1.278 +{ 1.279 + JS::CompartmentOptions &options = cx->compartment()->options(); 1.280 + cloneSingletons_ = options.cloneSingletons(cx); 1.281 + spsSlowAssertionsEnabled_ = cx->runtime()->spsProfiler.enabled() && 1.282 + cx->runtime()->spsProfiler.slowAssertionsEnabled(); 1.283 +}