michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jit/Ion.h" michael@0: michael@0: using namespace js; michael@0: using namespace js::jit; michael@0: michael@0: JSRuntime * michael@0: CompileRuntime::runtime() michael@0: { michael@0: return reinterpret_cast(this); michael@0: } michael@0: michael@0: /* static */ CompileRuntime * michael@0: CompileRuntime::get(JSRuntime *rt) michael@0: { michael@0: return reinterpret_cast(rt); michael@0: } michael@0: michael@0: bool michael@0: CompileRuntime::onMainThread() michael@0: { michael@0: return js::CurrentThreadCanAccessRuntime(runtime()); michael@0: } michael@0: michael@0: js::PerThreadData * michael@0: CompileRuntime::mainThread() michael@0: { michael@0: JS_ASSERT(onMainThread()); michael@0: return &runtime()->mainThread; michael@0: } michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfIonTop() michael@0: { michael@0: return &runtime()->mainThread.ionTop; michael@0: } michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfJitStackLimit() michael@0: { michael@0: return &runtime()->mainThread.jitStackLimit; michael@0: } michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfJSContext() michael@0: { michael@0: return &runtime()->mainThread.jitJSContext; michael@0: } michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfActivation() michael@0: { michael@0: return runtime()->mainThread.addressOfActivation(); michael@0: } michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfLastCachedNativeIterator() michael@0: { michael@0: return &runtime()->nativeIterCache.last; michael@0: } michael@0: michael@0: #ifdef JS_GC_ZEAL michael@0: const void * michael@0: CompileRuntime::addressOfGCZeal() michael@0: { michael@0: return &runtime()->gcZeal_; michael@0: } michael@0: #endif michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfInterrupt() michael@0: { michael@0: return &runtime()->interrupt; michael@0: } michael@0: michael@0: #ifdef JS_THREADSAFE michael@0: const void * michael@0: CompileRuntime::addressOfInterruptPar() michael@0: { michael@0: return &runtime()->interruptPar; michael@0: } michael@0: #endif michael@0: michael@0: const void * michael@0: CompileRuntime::addressOfThreadPool() michael@0: { michael@0: return &runtime()->threadPool; michael@0: } michael@0: michael@0: const JitRuntime * michael@0: CompileRuntime::jitRuntime() michael@0: { michael@0: return runtime()->jitRuntime(); michael@0: } michael@0: michael@0: SPSProfiler & michael@0: CompileRuntime::spsProfiler() michael@0: { michael@0: return runtime()->spsProfiler; michael@0: } michael@0: michael@0: bool michael@0: CompileRuntime::signalHandlersInstalled() michael@0: { michael@0: return runtime()->signalHandlersInstalled(); michael@0: } michael@0: michael@0: bool michael@0: CompileRuntime::jitSupportsFloatingPoint() michael@0: { michael@0: return runtime()->jitSupportsFloatingPoint; michael@0: } michael@0: michael@0: bool michael@0: CompileRuntime::hadOutOfMemory() michael@0: { michael@0: return runtime()->hadOutOfMemory; michael@0: } michael@0: michael@0: const JSAtomState & michael@0: CompileRuntime::names() michael@0: { michael@0: return *runtime()->commonNames; michael@0: } michael@0: michael@0: const StaticStrings & michael@0: CompileRuntime::staticStrings() michael@0: { michael@0: return *runtime()->staticStrings; michael@0: } michael@0: michael@0: const Value & michael@0: CompileRuntime::NaNValue() michael@0: { michael@0: return runtime()->NaNValue; michael@0: } michael@0: michael@0: const Value & michael@0: CompileRuntime::positiveInfinityValue() michael@0: { michael@0: return runtime()->positiveInfinityValue; michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: bool michael@0: CompileRuntime::isInsideNursery(gc::Cell *cell) michael@0: { michael@0: return UninlinedIsInsideNursery(runtime(), cell); michael@0: } michael@0: #endif michael@0: michael@0: const DOMCallbacks * michael@0: CompileRuntime::DOMcallbacks() michael@0: { michael@0: return GetDOMCallbacks(runtime()); michael@0: } michael@0: michael@0: const MathCache * michael@0: CompileRuntime::maybeGetMathCache() michael@0: { michael@0: return runtime()->maybeGetMathCache(); michael@0: } michael@0: michael@0: #ifdef JSGC_GENERATIONAL michael@0: const Nursery & michael@0: CompileRuntime::gcNursery() michael@0: { michael@0: return runtime()->gcNursery; michael@0: } michael@0: #endif michael@0: michael@0: Zone * michael@0: CompileZone::zone() michael@0: { michael@0: return reinterpret_cast(this); michael@0: } michael@0: michael@0: /* static */ CompileZone * michael@0: CompileZone::get(Zone *zone) michael@0: { michael@0: return reinterpret_cast(zone); michael@0: } michael@0: michael@0: const void * michael@0: CompileZone::addressOfNeedsBarrier() michael@0: { michael@0: return zone()->addressOfNeedsBarrier(); michael@0: } michael@0: michael@0: const void * michael@0: CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind) michael@0: { michael@0: return &zone()->allocator.arenas.getFreeList(allocKind)->first; michael@0: } michael@0: michael@0: const void * michael@0: CompileZone::addressOfFreeListLast(gc::AllocKind allocKind) michael@0: { michael@0: return &zone()->allocator.arenas.getFreeList(allocKind)->last; michael@0: } michael@0: michael@0: JSCompartment * michael@0: CompileCompartment::compartment() michael@0: { michael@0: return reinterpret_cast(this); michael@0: } michael@0: michael@0: /* static */ CompileCompartment * michael@0: CompileCompartment::get(JSCompartment *comp) michael@0: { michael@0: return reinterpret_cast(comp); michael@0: } michael@0: michael@0: CompileZone * michael@0: CompileCompartment::zone() michael@0: { michael@0: return CompileZone::get(compartment()->zone()); michael@0: } michael@0: michael@0: CompileRuntime * michael@0: CompileCompartment::runtime() michael@0: { michael@0: return CompileRuntime::get(compartment()->runtimeFromAnyThread()); michael@0: } michael@0: michael@0: const void * michael@0: CompileCompartment::addressOfEnumerators() michael@0: { michael@0: return &compartment()->enumerators; michael@0: } michael@0: michael@0: const CallsiteCloneTable & michael@0: CompileCompartment::callsiteClones() michael@0: { michael@0: return compartment()->callsiteClones; michael@0: } michael@0: michael@0: const JitCompartment * michael@0: CompileCompartment::jitCompartment() michael@0: { michael@0: return compartment()->jitCompartment(); michael@0: } michael@0: michael@0: bool michael@0: CompileCompartment::hasObjectMetadataCallback() michael@0: { michael@0: return compartment()->hasObjectMetadataCallback(); michael@0: } michael@0: michael@0: // Note: This function is thread-safe because setSingletonAsValue sets a boolean michael@0: // variable to false, and this boolean variable has no way to be resetted to michael@0: // true. So even if there is a concurrent write, this concurrent write will michael@0: // always have the same value. If there is a concurrent read, then we will michael@0: // clone a singleton instead of using the value which is baked in the JSScript, michael@0: // and this would be an unfortunate allocation, but this will not change the michael@0: // semantics of the JavaScript code which is executed. michael@0: void michael@0: CompileCompartment::setSingletonsAsValues() michael@0: { michael@0: return JS::CompartmentOptionsRef(compartment()).setSingletonsAsValues(); michael@0: } michael@0: michael@0: JitCompileOptions::JitCompileOptions() michael@0: : cloneSingletons_(false), michael@0: spsSlowAssertionsEnabled_(false) michael@0: { michael@0: } michael@0: michael@0: JitCompileOptions::JitCompileOptions(JSContext *cx) michael@0: { michael@0: JS::CompartmentOptions &options = cx->compartment()->options(); michael@0: cloneSingletons_ = options.cloneSingletons(cx); michael@0: spsSlowAssertionsEnabled_ = cx->runtime()->spsProfiler.enabled() && michael@0: cx->runtime()->spsProfiler.slowAssertionsEnabled(); michael@0: }