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.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=79 ft=cpp:
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef gc_Nursery_inl_h
9 #define gc_Nursery_inl_h
11 #ifdef JSGC_GENERATIONAL
13 #include "gc/Nursery.h"
15 #include "gc/Heap.h"
17 namespace js {
18 namespace gc {
20 /*
21 * This structure overlays a Cell in the Nursery and re-purposes its memory
22 * for managing the Nursery collection process.
23 */
24 class RelocationOverlay
25 {
26 friend class MinorCollectionTracer;
28 /* The low bit is set so this should never equal a normal pointer. */
29 static const uintptr_t Relocated = uintptr_t(0xbad0bad1);
31 /* Set to Relocated when moved. */
32 uintptr_t magic_;
34 /* The location |this| was moved to. */
35 Cell *newLocation_;
37 /* A list entry to track all relocated things. */
38 RelocationOverlay *next_;
40 public:
41 static RelocationOverlay *fromCell(Cell *cell) {
42 JS_ASSERT(!cell->isTenured());
43 return reinterpret_cast<RelocationOverlay *>(cell);
44 }
46 bool isForwarded() const {
47 return magic_ == Relocated;
48 }
50 Cell *forwardingAddress() const {
51 JS_ASSERT(isForwarded());
52 return newLocation_;
53 }
55 void forwardTo(Cell *cell) {
56 JS_ASSERT(!isForwarded());
57 magic_ = Relocated;
58 newLocation_ = cell;
59 next_ = nullptr;
60 }
62 RelocationOverlay *next() const {
63 return next_;
64 }
65 };
67 } /* namespace gc */
68 } /* namespace js */
70 template <typename T>
71 MOZ_ALWAYS_INLINE bool
72 js::Nursery::getForwardedPointer(T **ref)
73 {
74 JS_ASSERT(ref);
75 JS_ASSERT(isInside(*ref));
76 const gc::RelocationOverlay *overlay = reinterpret_cast<const gc::RelocationOverlay *>(*ref);
77 if (!overlay->isForwarded())
78 return false;
79 /* This static cast from Cell* restricts T to valid (GC thing) types. */
80 *ref = static_cast<T *>(overlay->forwardingAddress());
81 return true;
82 }
84 #endif /* JSGC_GENERATIONAL */
86 #endif /* gc_Nursery_inl_h */