DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (777e60ca8853)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sts=4 et sw=4 tw=99:
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "jit/Ion.h"

using namespace js;
using namespace js::jit;

JSRuntime*
CompileRuntime::runtime()
{
    return reinterpret_cast<JSRuntime*>(this);
}

/* static */ CompileRuntime*
CompileRuntime::get(JSRuntime* rt)
{
    return reinterpret_cast<CompileRuntime*>(rt);
}

bool
CompileRuntime::onMainThread()
{
    return js::CurrentThreadCanAccessRuntime(runtime());
}

js::PerThreadData*
CompileRuntime::mainThread()
{
    JS_ASSERT(onMainThread());
    return &runtime()->mainThread;
}

const void*
CompileRuntime::addressOfIonTop()
{
    return &runtime()->mainThread.ionTop;
}

const void*
CompileRuntime::addressOfJitStackLimit()
{
    return &runtime()->mainThread.jitStackLimit;
}

const void*
CompileRuntime::addressOfJSContext()
{
    return &runtime()->mainThread.jitJSContext;
}

const void*
CompileRuntime::addressOfActivation()
{
    return runtime()->mainThread.addressOfActivation();
}

const void*
CompileRuntime::addressOfLastCachedNativeIterator()
{
    return &runtime()->nativeIterCache.last;
}

#ifdef JS_GC_ZEAL
const void*
CompileRuntime::addressOfGCZeal()
{
    return &runtime()->gcZeal_;
}
#endif

const void*
CompileRuntime::addressOfInterrupt()
{
    return &runtime()->interrupt;
}

#ifdef JS_THREADSAFE
const void*
CompileRuntime::addressOfInterruptPar()
{
    return &runtime()->interruptPar;
}
#endif

const void*
CompileRuntime::addressOfThreadPool()
{
    return &runtime()->threadPool;
}

const JitRuntime*
CompileRuntime::jitRuntime()
{
    return runtime()->jitRuntime();
}

SPSProfiler&
CompileRuntime::spsProfiler()
{
    return runtime()->spsProfiler;
}

bool
CompileRuntime::signalHandlersInstalled()
{
    return runtime()->signalHandlersInstalled();
}

bool
CompileRuntime::jitSupportsFloatingPoint()
{
    return runtime()->jitSupportsFloatingPoint;
}

bool
CompileRuntime::hadOutOfMemory()
{
    return runtime()->hadOutOfMemory;
}

const JSAtomState&
CompileRuntime::names()
{
    return *runtime()->commonNames;
}

const StaticStrings&
CompileRuntime::staticStrings()
{
    return *runtime()->staticStrings;
}

const Value&
CompileRuntime::NaNValue()
{
    return runtime()->NaNValue;
}

const Value&
CompileRuntime::positiveInfinityValue()
{
    return runtime()->positiveInfinityValue;
}

#ifdef DEBUG
bool
CompileRuntime::isInsideNursery(gc::Cell* cell)
{
    return UninlinedIsInsideNursery(runtime(), cell);
}
#endif

const DOMCallbacks*
CompileRuntime::DOMcallbacks()
{
    return GetDOMCallbacks(runtime());
}

const MathCache*
CompileRuntime::maybeGetMathCache()
{
    return runtime()->maybeGetMathCache();
}

#ifdef JSGC_GENERATIONAL
const Nursery&
CompileRuntime::gcNursery()
{
    return runtime()->gcNursery;
}
#endif

Zone*
CompileZone::zone()
{
    return reinterpret_cast<Zone*>(this);
}

/* static */ CompileZone*
CompileZone::get(Zone* zone)
{
    return reinterpret_cast<CompileZone*>(zone);
}

const void*
CompileZone::addressOfNeedsBarrier()
{
    return zone()->addressOfNeedsBarrier();
}

const void*
CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind)
{
    return &zone()->allocator.arenas.getFreeList(allocKind)->first;
}

const void*
CompileZone::addressOfFreeListLast(gc::AllocKind allocKind)
{
    return &zone()->allocator.arenas.getFreeList(allocKind)->last;
}

JSCompartment*
CompileCompartment::compartment()
{
    return reinterpret_cast<JSCompartment*>(this);
}

/* static */ CompileCompartment*
CompileCompartment::get(JSCompartment* comp)
{
    return reinterpret_cast<CompileCompartment*>(comp);
}

CompileZone*
CompileCompartment::zone()
{
    return CompileZone::get(compartment()->zone());
}

CompileRuntime*
CompileCompartment::runtime()
{
    return CompileRuntime::get(compartment()->runtimeFromAnyThread());
}

const void*
CompileCompartment::addressOfEnumerators()
{
    return &compartment()->enumerators;
}

const CallsiteCloneTable&
CompileCompartment::callsiteClones()
{
    return compartment()->callsiteClones;
}

const JitCompartment*
CompileCompartment::jitCompartment()
{
    return compartment()->jitCompartment();
}

bool
CompileCompartment::hasObjectMetadataCallback()
{
    return compartment()->hasObjectMetadataCallback();
}

// Note: This function is thread-safe because setSingletonAsValue sets a boolean
// variable to false, and this boolean variable has no way to be resetted to
// true. So even if there is a concurrent write, this concurrent write will
// always have the same value.  If there is a concurrent read, then we will
// clone a singleton instead of using the value which is baked in the JSScript,
// and this would be an unfortunate allocation, but this will not change the
// semantics of the JavaScript code which is executed.
void
CompileCompartment::setSingletonsAsValues()
{
    return JS::CompartmentOptionsRef(compartment()).setSingletonsAsValues();
}

JitCompileOptions::JitCompileOptions()
  : cloneSingletons_(false),
    spsSlowAssertionsEnabled_(false)
{
}

JitCompileOptions::JitCompileOptions(JSContext* cx)
{
    JS::CompartmentOptions& options = cx->compartment()->options();
    cloneSingletons_ = options.cloneSingletons(cx);
    spsSlowAssertionsEnabled_ = cx->runtime()->spsProfiler.enabled() &&
                                cx->runtime()->spsProfiler.slowAssertionsEnabled();
}