js/src/gc/Barrier.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 "gc/Barrier.h"
     9 #include "jscompartment.h"
    10 #include "jsobj.h"
    12 #include "gc/Zone.h"
    14 namespace js {
    16 #ifdef DEBUG
    18 bool
    19 HeapValue::preconditionForSet(Zone *zone)
    20 {
    21     if (!value.isMarkable())
    22         return true;
    24     return ZoneOfValue(value) == zone ||
    25            zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value));
    26 }
    28 bool
    29 HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot)
    30 {
    31     return kind == Slot
    32          ? &owner->getSlotRef(slot) == this
    33          : &owner->getDenseElement(slot) == (const Value *)this;
    34 }
    36 bool
    37 HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot)
    38 {
    39     bool ok = kind == Slot
    40             ? &owner->getSlotRef(slot) == this
    41             : &owner->getDenseElement(slot) == (const Value *)this;
    42     return ok && owner->zone() == zone;
    43 }
    45 void
    46 HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target)
    47 {
    48     JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target);
    49     JS_ASSERT_IF(kind == Element,
    50                  static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target);
    51 }
    53 bool
    54 RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone)
    55 {
    56     return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting();
    57 }
    58 #endif // DEBUG
    60 bool
    61 StringIsPermanentAtom(JSString *str)
    62 {
    63     return str->isPermanentAtom();
    64 }
    66 } // namespace js

mercurial