js/src/jit/RematerializedFrame.cpp

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.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "jit/RematerializedFrame.h"
     8 #include "jit/IonFrames.h"
    10 #include "vm/ArgumentsObject.h"
    12 #include "jsscriptinlines.h"
    13 #include "jit/IonFrames-inl.h"
    15 using namespace js;
    16 using namespace jit;
    18 struct CopyValueToRematerializedFrame
    19 {
    20     Value *slots;
    22     CopyValueToRematerializedFrame(Value *slots)
    23       : slots(slots)
    24     { }
    26     void operator()(const Value &v) {
    27         *slots++ = v;
    28     }
    29 };
    31 RematerializedFrame::RematerializedFrame(JSContext *cx, uint8_t *top, InlineFrameIterator &iter)
    32   : prevUpToDate_(false),
    33     top_(top),
    34     frameNo_(iter.frameNo()),
    35     numActualArgs_(iter.numActualArgs()),
    36     script_(iter.script())
    37 {
    38     CopyValueToRematerializedFrame op(slots_);
    39     iter.readFrameArgsAndLocals(cx, op, op, &scopeChain_, &returnValue_,
    40                                 &argsObj_, &thisValue_, ReadFrame_Actuals);
    41 }
    43 /* static */ RematerializedFrame *
    44 RematerializedFrame::New(JSContext *cx, uint8_t *top, InlineFrameIterator &iter)
    45 {
    46     unsigned numFormals = iter.isFunctionFrame() ? iter.callee()->nargs() : 0;
    47     size_t numBytes = sizeof(RematerializedFrame) +
    48         (Max(numFormals, iter.numActualArgs()) +
    49          iter.script()->nfixed()) * sizeof(Value) -
    50         sizeof(Value); // 1 Value included in sizeof(RematerializedFrame)
    52     void *buf = cx->calloc_(numBytes);
    53     if (!buf)
    54         return nullptr;
    56     return new (buf) RematerializedFrame(cx, top, iter);
    57 }
    59 CallObject &
    60 RematerializedFrame::callObj() const
    61 {
    62     JS_ASSERT(hasCallObj());
    64     JSObject *scope = scopeChain();
    65     while (!scope->is<CallObject>())
    66         scope = scope->enclosingScope();
    67     return scope->as<CallObject>();
    68 }
    70 void
    71 RematerializedFrame::mark(JSTracer *trc)
    72 {
    73     gc::MarkScriptRoot(trc, &script_, "remat ion frame script");
    74     gc::MarkObjectRoot(trc, &scopeChain_, "remat ion frame scope chain");
    75     gc::MarkValueRoot(trc, &returnValue_, "remat ion frame return value");
    76     gc::MarkValueRoot(trc, &thisValue_, "remat ion frame this");
    77     gc::MarkValueRootRange(trc, slots_, slots_ + numActualArgs_ + script_->nfixed(),
    78                            "remat ion frame stack");
    79 }
    81 void
    82 RematerializedFrame::dump()
    83 {
    84     fprintf(stderr, " Rematerialized Optimized Frame%s\n", inlined() ? " (inlined)" : "");
    85     if (isFunctionFrame()) {
    86         fprintf(stderr, "  callee fun: ");
    87 #ifdef DEBUG
    88         js_DumpObject(callee());
    89 #else
    90         fprintf(stderr, "?\n");
    91 #endif
    92     } else {
    93         fprintf(stderr, "  global frame, no callee\n");
    94     }
    96     fprintf(stderr, "  file %s line %u\n",
    97             script()->filename(), (unsigned) script()->lineno());
    99     fprintf(stderr, "  script = %p\n", (void*) script());
   101     if (isFunctionFrame()) {
   102         fprintf(stderr, "  scope chain: ");
   103 #ifdef DEBUG
   104         js_DumpObject(scopeChain());
   105 #else
   106         fprintf(stderr, "?\n");
   107 #endif
   109         if (hasArgsObj()) {
   110             fprintf(stderr, "  args obj: ");
   111 #ifdef DEBUG
   112             js_DumpObject(&argsObj());
   113 #else
   114             fprintf(stderr, "?\n");
   115 #endif
   116         }
   118         fprintf(stderr, "  this: ");
   119 #ifdef DEBUG
   120         js_DumpValue(thisValue());
   121 #else
   122         fprintf(stderr, "?\n");
   123 #endif
   125         for (unsigned i = 0; i < numActualArgs(); i++) {
   126             if (i < numFormalArgs())
   127                 fprintf(stderr, "  formal (arg %d): ", i);
   128             else
   129                 fprintf(stderr, "  overflown (arg %d): ", i);
   130 #ifdef DEBUG
   131             js_DumpValue(argv()[i]);
   132 #else
   133             fprintf(stderr, "?\n");
   134 #endif
   135         }
   137         for (unsigned i = 0; i < script()->nfixed(); i++) {
   138             fprintf(stderr, "  local %d: ", i);
   139 #ifdef DEBUG
   140             js_DumpValue(locals()[i]);
   141 #else
   142             fprintf(stderr, "?\n");
   143 #endif
   144         }
   145     }
   147     fputc('\n', stderr);
   148 }

mercurial