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 "jit/RematerializedFrame.h" |
michael@0 | 8 | #include "jit/IonFrames.h" |
michael@0 | 9 | |
michael@0 | 10 | #include "vm/ArgumentsObject.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "jsscriptinlines.h" |
michael@0 | 13 | #include "jit/IonFrames-inl.h" |
michael@0 | 14 | |
michael@0 | 15 | using namespace js; |
michael@0 | 16 | using namespace jit; |
michael@0 | 17 | |
michael@0 | 18 | struct CopyValueToRematerializedFrame |
michael@0 | 19 | { |
michael@0 | 20 | Value *slots; |
michael@0 | 21 | |
michael@0 | 22 | CopyValueToRematerializedFrame(Value *slots) |
michael@0 | 23 | : slots(slots) |
michael@0 | 24 | { } |
michael@0 | 25 | |
michael@0 | 26 | void operator()(const Value &v) { |
michael@0 | 27 | *slots++ = v; |
michael@0 | 28 | } |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | RematerializedFrame::RematerializedFrame(JSContext *cx, uint8_t *top, InlineFrameIterator &iter) |
michael@0 | 32 | : prevUpToDate_(false), |
michael@0 | 33 | top_(top), |
michael@0 | 34 | frameNo_(iter.frameNo()), |
michael@0 | 35 | numActualArgs_(iter.numActualArgs()), |
michael@0 | 36 | script_(iter.script()) |
michael@0 | 37 | { |
michael@0 | 38 | CopyValueToRematerializedFrame op(slots_); |
michael@0 | 39 | iter.readFrameArgsAndLocals(cx, op, op, &scopeChain_, &returnValue_, |
michael@0 | 40 | &argsObj_, &thisValue_, ReadFrame_Actuals); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | /* static */ RematerializedFrame * |
michael@0 | 44 | RematerializedFrame::New(JSContext *cx, uint8_t *top, InlineFrameIterator &iter) |
michael@0 | 45 | { |
michael@0 | 46 | unsigned numFormals = iter.isFunctionFrame() ? iter.callee()->nargs() : 0; |
michael@0 | 47 | size_t numBytes = sizeof(RematerializedFrame) + |
michael@0 | 48 | (Max(numFormals, iter.numActualArgs()) + |
michael@0 | 49 | iter.script()->nfixed()) * sizeof(Value) - |
michael@0 | 50 | sizeof(Value); // 1 Value included in sizeof(RematerializedFrame) |
michael@0 | 51 | |
michael@0 | 52 | void *buf = cx->calloc_(numBytes); |
michael@0 | 53 | if (!buf) |
michael@0 | 54 | return nullptr; |
michael@0 | 55 | |
michael@0 | 56 | return new (buf) RematerializedFrame(cx, top, iter); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | CallObject & |
michael@0 | 60 | RematerializedFrame::callObj() const |
michael@0 | 61 | { |
michael@0 | 62 | JS_ASSERT(hasCallObj()); |
michael@0 | 63 | |
michael@0 | 64 | JSObject *scope = scopeChain(); |
michael@0 | 65 | while (!scope->is<CallObject>()) |
michael@0 | 66 | scope = scope->enclosingScope(); |
michael@0 | 67 | return scope->as<CallObject>(); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void |
michael@0 | 71 | RematerializedFrame::mark(JSTracer *trc) |
michael@0 | 72 | { |
michael@0 | 73 | gc::MarkScriptRoot(trc, &script_, "remat ion frame script"); |
michael@0 | 74 | gc::MarkObjectRoot(trc, &scopeChain_, "remat ion frame scope chain"); |
michael@0 | 75 | gc::MarkValueRoot(trc, &returnValue_, "remat ion frame return value"); |
michael@0 | 76 | gc::MarkValueRoot(trc, &thisValue_, "remat ion frame this"); |
michael@0 | 77 | gc::MarkValueRootRange(trc, slots_, slots_ + numActualArgs_ + script_->nfixed(), |
michael@0 | 78 | "remat ion frame stack"); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | void |
michael@0 | 82 | RematerializedFrame::dump() |
michael@0 | 83 | { |
michael@0 | 84 | fprintf(stderr, " Rematerialized Optimized Frame%s\n", inlined() ? " (inlined)" : ""); |
michael@0 | 85 | if (isFunctionFrame()) { |
michael@0 | 86 | fprintf(stderr, " callee fun: "); |
michael@0 | 87 | #ifdef DEBUG |
michael@0 | 88 | js_DumpObject(callee()); |
michael@0 | 89 | #else |
michael@0 | 90 | fprintf(stderr, "?\n"); |
michael@0 | 91 | #endif |
michael@0 | 92 | } else { |
michael@0 | 93 | fprintf(stderr, " global frame, no callee\n"); |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | fprintf(stderr, " file %s line %u\n", |
michael@0 | 97 | script()->filename(), (unsigned) script()->lineno()); |
michael@0 | 98 | |
michael@0 | 99 | fprintf(stderr, " script = %p\n", (void*) script()); |
michael@0 | 100 | |
michael@0 | 101 | if (isFunctionFrame()) { |
michael@0 | 102 | fprintf(stderr, " scope chain: "); |
michael@0 | 103 | #ifdef DEBUG |
michael@0 | 104 | js_DumpObject(scopeChain()); |
michael@0 | 105 | #else |
michael@0 | 106 | fprintf(stderr, "?\n"); |
michael@0 | 107 | #endif |
michael@0 | 108 | |
michael@0 | 109 | if (hasArgsObj()) { |
michael@0 | 110 | fprintf(stderr, " args obj: "); |
michael@0 | 111 | #ifdef DEBUG |
michael@0 | 112 | js_DumpObject(&argsObj()); |
michael@0 | 113 | #else |
michael@0 | 114 | fprintf(stderr, "?\n"); |
michael@0 | 115 | #endif |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | fprintf(stderr, " this: "); |
michael@0 | 119 | #ifdef DEBUG |
michael@0 | 120 | js_DumpValue(thisValue()); |
michael@0 | 121 | #else |
michael@0 | 122 | fprintf(stderr, "?\n"); |
michael@0 | 123 | #endif |
michael@0 | 124 | |
michael@0 | 125 | for (unsigned i = 0; i < numActualArgs(); i++) { |
michael@0 | 126 | if (i < numFormalArgs()) |
michael@0 | 127 | fprintf(stderr, " formal (arg %d): ", i); |
michael@0 | 128 | else |
michael@0 | 129 | fprintf(stderr, " overflown (arg %d): ", i); |
michael@0 | 130 | #ifdef DEBUG |
michael@0 | 131 | js_DumpValue(argv()[i]); |
michael@0 | 132 | #else |
michael@0 | 133 | fprintf(stderr, "?\n"); |
michael@0 | 134 | #endif |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | for (unsigned i = 0; i < script()->nfixed(); i++) { |
michael@0 | 138 | fprintf(stderr, " local %d: ", i); |
michael@0 | 139 | #ifdef DEBUG |
michael@0 | 140 | js_DumpValue(locals()[i]); |
michael@0 | 141 | #else |
michael@0 | 142 | fprintf(stderr, "?\n"); |
michael@0 | 143 | #endif |
michael@0 | 144 | } |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | fputc('\n', stderr); |
michael@0 | 148 | } |