js/src/jit/CompileWrappers.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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/. */
     7 #include "jit/Ion.h"
     9 using namespace js;
    10 using namespace js::jit;
    12 JSRuntime *
    13 CompileRuntime::runtime()
    14 {
    15     return reinterpret_cast<JSRuntime *>(this);
    16 }
    18 /* static */ CompileRuntime *
    19 CompileRuntime::get(JSRuntime *rt)
    20 {
    21     return reinterpret_cast<CompileRuntime *>(rt);
    22 }
    24 bool
    25 CompileRuntime::onMainThread()
    26 {
    27     return js::CurrentThreadCanAccessRuntime(runtime());
    28 }
    30 js::PerThreadData *
    31 CompileRuntime::mainThread()
    32 {
    33     JS_ASSERT(onMainThread());
    34     return &runtime()->mainThread;
    35 }
    37 const void *
    38 CompileRuntime::addressOfIonTop()
    39 {
    40     return &runtime()->mainThread.ionTop;
    41 }
    43 const void *
    44 CompileRuntime::addressOfJitStackLimit()
    45 {
    46     return &runtime()->mainThread.jitStackLimit;
    47 }
    49 const void *
    50 CompileRuntime::addressOfJSContext()
    51 {
    52     return &runtime()->mainThread.jitJSContext;
    53 }
    55 const void *
    56 CompileRuntime::addressOfActivation()
    57 {
    58     return runtime()->mainThread.addressOfActivation();
    59 }
    61 const void *
    62 CompileRuntime::addressOfLastCachedNativeIterator()
    63 {
    64     return &runtime()->nativeIterCache.last;
    65 }
    67 #ifdef JS_GC_ZEAL
    68 const void *
    69 CompileRuntime::addressOfGCZeal()
    70 {
    71     return &runtime()->gcZeal_;
    72 }
    73 #endif
    75 const void *
    76 CompileRuntime::addressOfInterrupt()
    77 {
    78     return &runtime()->interrupt;
    79 }
    81 #ifdef JS_THREADSAFE
    82 const void *
    83 CompileRuntime::addressOfInterruptPar()
    84 {
    85     return &runtime()->interruptPar;
    86 }
    87 #endif
    89 const void *
    90 CompileRuntime::addressOfThreadPool()
    91 {
    92     return &runtime()->threadPool;
    93 }
    95 const JitRuntime *
    96 CompileRuntime::jitRuntime()
    97 {
    98     return runtime()->jitRuntime();
    99 }
   101 SPSProfiler &
   102 CompileRuntime::spsProfiler()
   103 {
   104     return runtime()->spsProfiler;
   105 }
   107 bool
   108 CompileRuntime::signalHandlersInstalled()
   109 {
   110     return runtime()->signalHandlersInstalled();
   111 }
   113 bool
   114 CompileRuntime::jitSupportsFloatingPoint()
   115 {
   116     return runtime()->jitSupportsFloatingPoint;
   117 }
   119 bool
   120 CompileRuntime::hadOutOfMemory()
   121 {
   122     return runtime()->hadOutOfMemory;
   123 }
   125 const JSAtomState &
   126 CompileRuntime::names()
   127 {
   128     return *runtime()->commonNames;
   129 }
   131 const StaticStrings &
   132 CompileRuntime::staticStrings()
   133 {
   134     return *runtime()->staticStrings;
   135 }
   137 const Value &
   138 CompileRuntime::NaNValue()
   139 {
   140     return runtime()->NaNValue;
   141 }
   143 const Value &
   144 CompileRuntime::positiveInfinityValue()
   145 {
   146     return runtime()->positiveInfinityValue;
   147 }
   149 #ifdef DEBUG
   150 bool
   151 CompileRuntime::isInsideNursery(gc::Cell *cell)
   152 {
   153     return UninlinedIsInsideNursery(runtime(), cell);
   154 }
   155 #endif
   157 const DOMCallbacks *
   158 CompileRuntime::DOMcallbacks()
   159 {
   160     return GetDOMCallbacks(runtime());
   161 }
   163 const MathCache *
   164 CompileRuntime::maybeGetMathCache()
   165 {
   166     return runtime()->maybeGetMathCache();
   167 }
   169 #ifdef JSGC_GENERATIONAL
   170 const Nursery &
   171 CompileRuntime::gcNursery()
   172 {
   173     return runtime()->gcNursery;
   174 }
   175 #endif
   177 Zone *
   178 CompileZone::zone()
   179 {
   180     return reinterpret_cast<Zone *>(this);
   181 }
   183 /* static */ CompileZone *
   184 CompileZone::get(Zone *zone)
   185 {
   186     return reinterpret_cast<CompileZone *>(zone);
   187 }
   189 const void *
   190 CompileZone::addressOfNeedsBarrier()
   191 {
   192     return zone()->addressOfNeedsBarrier();
   193 }
   195 const void *
   196 CompileZone::addressOfFreeListFirst(gc::AllocKind allocKind)
   197 {
   198     return &zone()->allocator.arenas.getFreeList(allocKind)->first;
   199 }
   201 const void *
   202 CompileZone::addressOfFreeListLast(gc::AllocKind allocKind)
   203 {
   204     return &zone()->allocator.arenas.getFreeList(allocKind)->last;
   205 }
   207 JSCompartment *
   208 CompileCompartment::compartment()
   209 {
   210     return reinterpret_cast<JSCompartment *>(this);
   211 }
   213 /* static */ CompileCompartment *
   214 CompileCompartment::get(JSCompartment *comp)
   215 {
   216     return reinterpret_cast<CompileCompartment *>(comp);
   217 }
   219 CompileZone *
   220 CompileCompartment::zone()
   221 {
   222     return CompileZone::get(compartment()->zone());
   223 }
   225 CompileRuntime *
   226 CompileCompartment::runtime()
   227 {
   228     return CompileRuntime::get(compartment()->runtimeFromAnyThread());
   229 }
   231 const void *
   232 CompileCompartment::addressOfEnumerators()
   233 {
   234     return &compartment()->enumerators;
   235 }
   237 const CallsiteCloneTable &
   238 CompileCompartment::callsiteClones()
   239 {
   240     return compartment()->callsiteClones;
   241 }
   243 const JitCompartment *
   244 CompileCompartment::jitCompartment()
   245 {
   246     return compartment()->jitCompartment();
   247 }
   249 bool
   250 CompileCompartment::hasObjectMetadataCallback()
   251 {
   252     return compartment()->hasObjectMetadataCallback();
   253 }
   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 }
   268 JitCompileOptions::JitCompileOptions()
   269   : cloneSingletons_(false),
   270     spsSlowAssertionsEnabled_(false)
   271 {
   272 }
   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