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