Sat, 03 Jan 2015 20:18:00 +0100
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 "jscompartment.h" |
michael@0 | 8 | #include "jsgc.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "gc/GCInternals.h" |
michael@0 | 11 | #include "js/HashTable.h" |
michael@0 | 12 | #include "vm/Runtime.h" |
michael@0 | 13 | |
michael@0 | 14 | #include "jscntxtinlines.h" |
michael@0 | 15 | #include "jsgcinlines.h" |
michael@0 | 16 | |
michael@0 | 17 | using namespace js; |
michael@0 | 18 | using namespace js::gc; |
michael@0 | 19 | |
michael@0 | 20 | void |
michael@0 | 21 | js::TraceRuntime(JSTracer *trc) |
michael@0 | 22 | { |
michael@0 | 23 | JS_ASSERT(!IS_GC_MARKING_TRACER(trc)); |
michael@0 | 24 | |
michael@0 | 25 | MinorGC(trc->runtime(), JS::gcreason::EVICT_NURSERY); |
michael@0 | 26 | AutoPrepareForTracing prep(trc->runtime(), WithAtoms); |
michael@0 | 27 | MarkRuntime(trc); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | static void |
michael@0 | 31 | IterateCompartmentsArenasCells(JSRuntime *rt, Zone *zone, void *data, |
michael@0 | 32 | JSIterateCompartmentCallback compartmentCallback, |
michael@0 | 33 | IterateArenaCallback arenaCallback, |
michael@0 | 34 | IterateCellCallback cellCallback) |
michael@0 | 35 | { |
michael@0 | 36 | for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) |
michael@0 | 37 | (*compartmentCallback)(rt, data, comp); |
michael@0 | 38 | |
michael@0 | 39 | for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) { |
michael@0 | 40 | JSGCTraceKind traceKind = MapAllocToTraceKind(AllocKind(thingKind)); |
michael@0 | 41 | size_t thingSize = Arena::thingSize(AllocKind(thingKind)); |
michael@0 | 42 | |
michael@0 | 43 | for (ArenaIter aiter(zone, AllocKind(thingKind)); !aiter.done(); aiter.next()) { |
michael@0 | 44 | ArenaHeader *aheader = aiter.get(); |
michael@0 | 45 | (*arenaCallback)(rt, data, aheader->getArena(), traceKind, thingSize); |
michael@0 | 46 | for (CellIterUnderGC iter(aheader); !iter.done(); iter.next()) |
michael@0 | 47 | (*cellCallback)(rt, data, iter.getCell(), traceKind, thingSize); |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | void |
michael@0 | 53 | js::IterateZonesCompartmentsArenasCells(JSRuntime *rt, void *data, |
michael@0 | 54 | IterateZoneCallback zoneCallback, |
michael@0 | 55 | JSIterateCompartmentCallback compartmentCallback, |
michael@0 | 56 | IterateArenaCallback arenaCallback, |
michael@0 | 57 | IterateCellCallback cellCallback) |
michael@0 | 58 | { |
michael@0 | 59 | AutoPrepareForTracing prop(rt, WithAtoms); |
michael@0 | 60 | |
michael@0 | 61 | for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { |
michael@0 | 62 | (*zoneCallback)(rt, data, zone); |
michael@0 | 63 | IterateCompartmentsArenasCells(rt, zone, data, |
michael@0 | 64 | compartmentCallback, arenaCallback, cellCallback); |
michael@0 | 65 | } |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | void |
michael@0 | 69 | js::IterateZoneCompartmentsArenasCells(JSRuntime *rt, Zone *zone, void *data, |
michael@0 | 70 | IterateZoneCallback zoneCallback, |
michael@0 | 71 | JSIterateCompartmentCallback compartmentCallback, |
michael@0 | 72 | IterateArenaCallback arenaCallback, |
michael@0 | 73 | IterateCellCallback cellCallback) |
michael@0 | 74 | { |
michael@0 | 75 | AutoPrepareForTracing prop(rt, WithAtoms); |
michael@0 | 76 | |
michael@0 | 77 | (*zoneCallback)(rt, data, zone); |
michael@0 | 78 | IterateCompartmentsArenasCells(rt, zone, data, |
michael@0 | 79 | compartmentCallback, arenaCallback, cellCallback); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | void |
michael@0 | 83 | js::IterateChunks(JSRuntime *rt, void *data, IterateChunkCallback chunkCallback) |
michael@0 | 84 | { |
michael@0 | 85 | AutoPrepareForTracing prep(rt, SkipAtoms); |
michael@0 | 86 | |
michael@0 | 87 | for (js::GCChunkSet::Range r = rt->gcChunkSet.all(); !r.empty(); r.popFront()) |
michael@0 | 88 | chunkCallback(rt, data, r.front()); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | void |
michael@0 | 92 | js::IterateScripts(JSRuntime *rt, JSCompartment *compartment, |
michael@0 | 93 | void *data, IterateScriptCallback scriptCallback) |
michael@0 | 94 | { |
michael@0 | 95 | MinorGC(rt, JS::gcreason::EVICT_NURSERY); |
michael@0 | 96 | AutoPrepareForTracing prep(rt, SkipAtoms); |
michael@0 | 97 | |
michael@0 | 98 | if (compartment) { |
michael@0 | 99 | for (CellIterUnderGC i(compartment->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) { |
michael@0 | 100 | JSScript *script = i.get<JSScript>(); |
michael@0 | 101 | if (script->compartment() == compartment) |
michael@0 | 102 | scriptCallback(rt, data, script); |
michael@0 | 103 | } |
michael@0 | 104 | } else { |
michael@0 | 105 | for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) { |
michael@0 | 106 | for (CellIterUnderGC i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) |
michael@0 | 107 | scriptCallback(rt, data, i.get<JSScript>()); |
michael@0 | 108 | } |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | void |
michael@0 | 113 | js::IterateGrayObjects(Zone *zone, GCThingCallback cellCallback, void *data) |
michael@0 | 114 | { |
michael@0 | 115 | MinorGC(zone->runtimeFromMainThread(), JS::gcreason::EVICT_NURSERY); |
michael@0 | 116 | AutoPrepareForTracing prep(zone->runtimeFromMainThread(), SkipAtoms); |
michael@0 | 117 | |
michael@0 | 118 | for (size_t finalizeKind = 0; finalizeKind <= FINALIZE_OBJECT_LAST; finalizeKind++) { |
michael@0 | 119 | for (CellIterUnderGC i(zone, AllocKind(finalizeKind)); !i.done(); i.next()) { |
michael@0 | 120 | JSObject *obj = i.get<JSObject>(); |
michael@0 | 121 | if (obj->isMarked(GRAY)) |
michael@0 | 122 | cellCallback(data, obj); |
michael@0 | 123 | } |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | JS_PUBLIC_API(void) |
michael@0 | 128 | JS_IterateCompartments(JSRuntime *rt, void *data, |
michael@0 | 129 | JSIterateCompartmentCallback compartmentCallback) |
michael@0 | 130 | { |
michael@0 | 131 | JS_ASSERT(!rt->isHeapBusy()); |
michael@0 | 132 | |
michael@0 | 133 | AutoTraceSession session(rt); |
michael@0 | 134 | |
michael@0 | 135 | for (CompartmentsIter c(rt, WithAtoms); !c.done(); c.next()) |
michael@0 | 136 | (*compartmentCallback)(rt, data, c); |
michael@0 | 137 | } |