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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "gc/Barrier.h"
michael@0 8
michael@0 9 #include "jscompartment.h"
michael@0 10 #include "jsobj.h"
michael@0 11
michael@0 12 #include "gc/Zone.h"
michael@0 13
michael@0 14 namespace js {
michael@0 15
michael@0 16 #ifdef DEBUG
michael@0 17
michael@0 18 bool
michael@0 19 HeapValue::preconditionForSet(Zone *zone)
michael@0 20 {
michael@0 21 if (!value.isMarkable())
michael@0 22 return true;
michael@0 23
michael@0 24 return ZoneOfValue(value) == zone ||
michael@0 25 zone->runtimeFromAnyThread()->isAtomsZone(ZoneOfValue(value));
michael@0 26 }
michael@0 27
michael@0 28 bool
michael@0 29 HeapSlot::preconditionForSet(JSObject *owner, Kind kind, uint32_t slot)
michael@0 30 {
michael@0 31 return kind == Slot
michael@0 32 ? &owner->getSlotRef(slot) == this
michael@0 33 : &owner->getDenseElement(slot) == (const Value *)this;
michael@0 34 }
michael@0 35
michael@0 36 bool
michael@0 37 HeapSlot::preconditionForSet(Zone *zone, JSObject *owner, Kind kind, uint32_t slot)
michael@0 38 {
michael@0 39 bool ok = kind == Slot
michael@0 40 ? &owner->getSlotRef(slot) == this
michael@0 41 : &owner->getDenseElement(slot) == (const Value *)this;
michael@0 42 return ok && owner->zone() == zone;
michael@0 43 }
michael@0 44
michael@0 45 void
michael@0 46 HeapSlot::preconditionForWriteBarrierPost(JSObject *obj, Kind kind, uint32_t slot, Value target)
michael@0 47 {
michael@0 48 JS_ASSERT_IF(kind == Slot, obj->getSlotAddressUnchecked(slot)->get() == target);
michael@0 49 JS_ASSERT_IF(kind == Element,
michael@0 50 static_cast<HeapSlot *>(obj->getDenseElements() + slot)->get() == target);
michael@0 51 }
michael@0 52
michael@0 53 bool
michael@0 54 RuntimeFromMainThreadIsHeapMajorCollecting(JS::shadow::Zone *shadowZone)
michael@0 55 {
michael@0 56 return shadowZone->runtimeFromMainThread()->isHeapMajorCollecting();
michael@0 57 }
michael@0 58 #endif // DEBUG
michael@0 59
michael@0 60 bool
michael@0 61 StringIsPermanentAtom(JSString *str)
michael@0 62 {
michael@0 63 return str->isPermanentAtom();
michael@0 64 }
michael@0 65
michael@0 66 } // namespace js

mercurial