js/src/gc/GCInternals.h

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 #ifndef gc_GCInternals_h
michael@0 8 #define gc_GCInternals_h
michael@0 9
michael@0 10 #include "jscntxt.h"
michael@0 11 #include "jsworkers.h"
michael@0 12
michael@0 13 #include "gc/Zone.h"
michael@0 14 #include "vm/Runtime.h"
michael@0 15
michael@0 16 namespace js {
michael@0 17 namespace gc {
michael@0 18
michael@0 19 void
michael@0 20 MarkPersistentRootedChains(JSTracer *trc);
michael@0 21
michael@0 22 void
michael@0 23 MarkRuntime(JSTracer *trc, bool useSavedRoots = false);
michael@0 24
michael@0 25 void
michael@0 26 BufferGrayRoots(GCMarker *gcmarker);
michael@0 27
michael@0 28 class AutoCopyFreeListToArenas
michael@0 29 {
michael@0 30 JSRuntime *runtime;
michael@0 31 ZoneSelector selector;
michael@0 32
michael@0 33 public:
michael@0 34 AutoCopyFreeListToArenas(JSRuntime *rt, ZoneSelector selector);
michael@0 35 ~AutoCopyFreeListToArenas();
michael@0 36 };
michael@0 37
michael@0 38 struct AutoFinishGC
michael@0 39 {
michael@0 40 AutoFinishGC(JSRuntime *rt);
michael@0 41 };
michael@0 42
michael@0 43 /*
michael@0 44 * This class should be used by any code that needs to exclusive access to the
michael@0 45 * heap in order to trace through it...
michael@0 46 */
michael@0 47 class AutoTraceSession
michael@0 48 {
michael@0 49 public:
michael@0 50 AutoTraceSession(JSRuntime *rt, HeapState state = Tracing);
michael@0 51 ~AutoTraceSession();
michael@0 52
michael@0 53 protected:
michael@0 54 AutoLockForExclusiveAccess lock;
michael@0 55 JSRuntime *runtime;
michael@0 56
michael@0 57 private:
michael@0 58 AutoTraceSession(const AutoTraceSession&) MOZ_DELETE;
michael@0 59 void operator=(const AutoTraceSession&) MOZ_DELETE;
michael@0 60
michael@0 61 HeapState prevState;
michael@0 62 };
michael@0 63
michael@0 64 struct AutoPrepareForTracing
michael@0 65 {
michael@0 66 AutoFinishGC finish;
michael@0 67 AutoTraceSession session;
michael@0 68 AutoCopyFreeListToArenas copy;
michael@0 69
michael@0 70 AutoPrepareForTracing(JSRuntime *rt, ZoneSelector selector);
michael@0 71 };
michael@0 72
michael@0 73 class IncrementalSafety
michael@0 74 {
michael@0 75 const char *reason_;
michael@0 76
michael@0 77 IncrementalSafety(const char *reason) : reason_(reason) {}
michael@0 78
michael@0 79 public:
michael@0 80 static IncrementalSafety Safe() { return IncrementalSafety(nullptr); }
michael@0 81 static IncrementalSafety Unsafe(const char *reason) { return IncrementalSafety(reason); }
michael@0 82
michael@0 83 typedef void (IncrementalSafety::* ConvertibleToBool)();
michael@0 84 void nonNull() {}
michael@0 85
michael@0 86 operator ConvertibleToBool() const {
michael@0 87 return reason_ == nullptr ? &IncrementalSafety::nonNull : 0;
michael@0 88 }
michael@0 89
michael@0 90 const char *reason() {
michael@0 91 JS_ASSERT(reason_);
michael@0 92 return reason_;
michael@0 93 }
michael@0 94 };
michael@0 95
michael@0 96 IncrementalSafety
michael@0 97 IsIncrementalGCSafe(JSRuntime *rt);
michael@0 98
michael@0 99 #ifdef JS_GC_ZEAL
michael@0 100 void
michael@0 101 StartVerifyPreBarriers(JSRuntime *rt);
michael@0 102
michael@0 103 void
michael@0 104 EndVerifyPreBarriers(JSRuntime *rt);
michael@0 105
michael@0 106 void
michael@0 107 StartVerifyPostBarriers(JSRuntime *rt);
michael@0 108
michael@0 109 void
michael@0 110 EndVerifyPostBarriers(JSRuntime *rt);
michael@0 111
michael@0 112 void
michael@0 113 FinishVerifier(JSRuntime *rt);
michael@0 114
michael@0 115 class AutoStopVerifyingBarriers
michael@0 116 {
michael@0 117 JSRuntime *runtime;
michael@0 118 bool restartPreVerifier;
michael@0 119 bool restartPostVerifier;
michael@0 120 MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
michael@0 121
michael@0 122 public:
michael@0 123 AutoStopVerifyingBarriers(JSRuntime *rt, bool isShutdown
michael@0 124 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
michael@0 125 : runtime(rt)
michael@0 126 {
michael@0 127 restartPreVerifier = !isShutdown && rt->gcVerifyPreData;
michael@0 128 restartPostVerifier = !isShutdown && rt->gcVerifyPostData && JS::IsGenerationalGCEnabled(rt);
michael@0 129 if (rt->gcVerifyPreData)
michael@0 130 EndVerifyPreBarriers(rt);
michael@0 131 if (rt->gcVerifyPostData)
michael@0 132 EndVerifyPostBarriers(rt);
michael@0 133 MOZ_GUARD_OBJECT_NOTIFIER_INIT;
michael@0 134 }
michael@0 135
michael@0 136 ~AutoStopVerifyingBarriers() {
michael@0 137 if (restartPreVerifier)
michael@0 138 StartVerifyPreBarriers(runtime);
michael@0 139 if (restartPostVerifier)
michael@0 140 StartVerifyPostBarriers(runtime);
michael@0 141 }
michael@0 142 };
michael@0 143 #else
michael@0 144 struct AutoStopVerifyingBarriers
michael@0 145 {
michael@0 146 AutoStopVerifyingBarriers(JSRuntime *, bool) {}
michael@0 147 };
michael@0 148 #endif /* JS_GC_ZEAL */
michael@0 149
michael@0 150 } /* namespace gc */
michael@0 151 } /* namespace js */
michael@0 152
michael@0 153 #endif /* gc_GCInternals_h */

mercurial