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: #ifndef jit_CompileWrappers_h michael@0: #define jit_CompileWrappers_h michael@0: michael@0: #ifdef JS_ION michael@0: michael@0: #include "jscntxt.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class JitRuntime; michael@0: michael@0: // During Ion compilation we need access to various bits of the current michael@0: // compartment, runtime and so forth. However, since compilation can run off michael@0: // thread while the main thread is actively mutating the VM, this access needs michael@0: // to be restricted. The classes below give the compiler an interface to access michael@0: // all necessary information in a threadsafe fashion. michael@0: michael@0: class CompileRuntime michael@0: { michael@0: JSRuntime *runtime(); michael@0: michael@0: public: michael@0: static CompileRuntime *get(JSRuntime *rt); michael@0: michael@0: bool onMainThread(); michael@0: michael@0: js::PerThreadData *mainThread(); michael@0: michael@0: // &mainThread.ionTop michael@0: const void *addressOfIonTop(); michael@0: michael@0: // rt->mainThread.jitStackLimit; michael@0: const void *addressOfJitStackLimit(); michael@0: michael@0: // &mainThread.ionJSContext michael@0: const void *addressOfJSContext(); michael@0: michael@0: // &mainThread.activation_ michael@0: const void *addressOfActivation(); michael@0: michael@0: // &GetIonContext()->runtime->nativeIterCache.last michael@0: const void *addressOfLastCachedNativeIterator(); michael@0: michael@0: #ifdef JS_GC_ZEAL michael@0: const void *addressOfGCZeal(); michael@0: #endif michael@0: michael@0: const void *addressOfInterrupt(); michael@0: michael@0: #ifdef JS_THREADSAFE michael@0: const void *addressOfInterruptPar(); michael@0: #endif michael@0: michael@0: const void *addressOfThreadPool(); michael@0: michael@0: const JitRuntime *jitRuntime(); michael@0: michael@0: // Compilation does not occur off thread when the SPS profiler is enabled. michael@0: SPSProfiler &spsProfiler(); michael@0: michael@0: bool signalHandlersInstalled(); michael@0: bool jitSupportsFloatingPoint(); michael@0: bool hadOutOfMemory(); michael@0: michael@0: const JSAtomState &names(); michael@0: const StaticStrings &staticStrings(); michael@0: const Value &NaNValue(); michael@0: const Value &positiveInfinityValue(); michael@0: michael@0: #ifdef DEBUG michael@0: bool isInsideNursery(gc::Cell *cell); michael@0: #endif michael@0: michael@0: // DOM callbacks must be threadsafe (and will hopefully be removed soon). michael@0: const DOMCallbacks *DOMcallbacks(); michael@0: michael@0: const MathCache *maybeGetMathCache(); michael@0: michael@0: #ifdef JSGC_GENERATIONAL michael@0: const Nursery &gcNursery(); michael@0: #endif michael@0: }; michael@0: michael@0: class CompileZone michael@0: { michael@0: Zone *zone(); michael@0: michael@0: public: michael@0: static CompileZone *get(Zone *zone); michael@0: michael@0: const void *addressOfNeedsBarrier(); michael@0: michael@0: // allocator.arenas.getFreeList(allocKind) michael@0: const void *addressOfFreeListFirst(gc::AllocKind allocKind); michael@0: const void *addressOfFreeListLast(gc::AllocKind allocKind); michael@0: }; michael@0: michael@0: class CompileCompartment michael@0: { michael@0: JSCompartment *compartment(); michael@0: michael@0: public: michael@0: static CompileCompartment *get(JSCompartment *comp); michael@0: michael@0: CompileZone *zone(); michael@0: CompileRuntime *runtime(); michael@0: michael@0: const void *addressOfEnumerators(); michael@0: michael@0: const CallsiteCloneTable &callsiteClones(); michael@0: michael@0: const JitCompartment *jitCompartment(); michael@0: michael@0: bool hasObjectMetadataCallback(); michael@0: michael@0: // Mirror CompartmentOptions. michael@0: void setSingletonsAsValues(); michael@0: }; michael@0: michael@0: class JitCompileOptions michael@0: { michael@0: public: michael@0: JitCompileOptions(); michael@0: JitCompileOptions(JSContext *cx); michael@0: michael@0: bool cloneSingletons() const { michael@0: return cloneSingletons_; michael@0: } michael@0: michael@0: bool spsSlowAssertionsEnabled() const { michael@0: return spsSlowAssertionsEnabled_; michael@0: } michael@0: michael@0: private: michael@0: bool cloneSingletons_; michael@0: bool spsSlowAssertionsEnabled_; michael@0: }; michael@0: michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif // JS_ION michael@0: michael@0: #endif // jit_CompileWrappers_h