js/src/jsscriptinlines.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 jsscriptinlines_h
michael@0 8 #define jsscriptinlines_h
michael@0 9
michael@0 10 #include "jsscript.h"
michael@0 11
michael@0 12 #include "jit/AsmJSLink.h"
michael@0 13 #include "jit/BaselineJIT.h"
michael@0 14 #include "jit/IonAnalysis.h"
michael@0 15 #include "vm/ScopeObject.h"
michael@0 16
michael@0 17 #include "jscompartmentinlines.h"
michael@0 18
michael@0 19 #include "vm/Shape-inl.h"
michael@0 20
michael@0 21 namespace js {
michael@0 22
michael@0 23 inline
michael@0 24 Bindings::Bindings()
michael@0 25 : callObjShape_(nullptr), bindingArrayAndFlag_(TEMPORARY_STORAGE_BIT),
michael@0 26 numArgs_(0), numBlockScoped_(0), numVars_(0)
michael@0 27 {}
michael@0 28
michael@0 29 inline
michael@0 30 AliasedFormalIter::AliasedFormalIter(JSScript *script)
michael@0 31 : begin_(script->bindingArray()),
michael@0 32 p_(begin_),
michael@0 33 end_(begin_ + (script->funHasAnyAliasedFormal() ? script->numArgs() : 0)),
michael@0 34 slot_(CallObject::RESERVED_SLOTS)
michael@0 35 {
michael@0 36 settle();
michael@0 37 }
michael@0 38
michael@0 39 inline void
michael@0 40 ScriptCounts::destroy(FreeOp *fop)
michael@0 41 {
michael@0 42 fop->free_(pcCountsVector);
michael@0 43 fop->delete_(ionCounts);
michael@0 44 }
michael@0 45
michael@0 46 void
michael@0 47 SetFrameArgumentsObject(JSContext *cx, AbstractFramePtr frame,
michael@0 48 HandleScript script, JSObject *argsobj);
michael@0 49
michael@0 50 inline JSFunction *
michael@0 51 LazyScript::functionDelazifying(JSContext *cx) const
michael@0 52 {
michael@0 53 if (function_ && !function_->getOrCreateScript(cx))
michael@0 54 return nullptr;
michael@0 55 return function_;
michael@0 56 }
michael@0 57
michael@0 58 } // namespace js
michael@0 59
michael@0 60 inline JSFunction *
michael@0 61 JSScript::functionDelazifying() const
michael@0 62 {
michael@0 63 if (function_ && function_->isInterpretedLazy()) {
michael@0 64 function_->setUnlazifiedScript(const_cast<JSScript *>(this));
michael@0 65 // If this script has a LazyScript, make sure the LazyScript has a
michael@0 66 // reference to the script when delazifying its canonical function.
michael@0 67 if (lazyScript && !lazyScript->maybeScript())
michael@0 68 lazyScript->initScript(const_cast<JSScript *>(this));
michael@0 69 }
michael@0 70 return function_;
michael@0 71 }
michael@0 72
michael@0 73 inline void
michael@0 74 JSScript::setFunction(JSFunction *fun)
michael@0 75 {
michael@0 76 JS_ASSERT(fun->isTenured());
michael@0 77 function_ = fun;
michael@0 78 }
michael@0 79
michael@0 80 inline void
michael@0 81 JSScript::ensureNonLazyCanonicalFunction(JSContext *cx)
michael@0 82 {
michael@0 83 // Infallibly delazify the canonical script.
michael@0 84 if (function_ && function_->isInterpretedLazy())
michael@0 85 functionDelazifying();
michael@0 86 }
michael@0 87
michael@0 88 inline JSFunction *
michael@0 89 JSScript::getFunction(size_t index)
michael@0 90 {
michael@0 91 JSFunction *fun = &getObject(index)->as<JSFunction>();
michael@0 92 JS_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
michael@0 93 return fun;
michael@0 94 }
michael@0 95
michael@0 96 inline JSFunction *
michael@0 97 JSScript::getCallerFunction()
michael@0 98 {
michael@0 99 JS_ASSERT(savedCallerFun());
michael@0 100 return getFunction(0);
michael@0 101 }
michael@0 102
michael@0 103 inline JSFunction *
michael@0 104 JSScript::functionOrCallerFunction()
michael@0 105 {
michael@0 106 if (functionNonDelazifying())
michael@0 107 return functionNonDelazifying();
michael@0 108 if (savedCallerFun())
michael@0 109 return getCallerFunction();
michael@0 110 return nullptr;
michael@0 111 }
michael@0 112
michael@0 113 inline js::RegExpObject *
michael@0 114 JSScript::getRegExp(size_t index)
michael@0 115 {
michael@0 116 js::ObjectArray *arr = regexps();
michael@0 117 JS_ASSERT(uint32_t(index) < arr->length);
michael@0 118 JSObject *obj = arr->vector[index];
michael@0 119 JS_ASSERT(obj->is<js::RegExpObject>());
michael@0 120 return (js::RegExpObject *) obj;
michael@0 121 }
michael@0 122
michael@0 123 inline js::RegExpObject *
michael@0 124 JSScript::getRegExp(jsbytecode *pc)
michael@0 125 {
michael@0 126 JS_ASSERT(containsPC(pc) && containsPC(pc + sizeof(uint32_t)));
michael@0 127 return getRegExp(GET_UINT32_INDEX(pc));
michael@0 128 }
michael@0 129
michael@0 130 inline js::GlobalObject &
michael@0 131 JSScript::global() const
michael@0 132 {
michael@0 133 /*
michael@0 134 * A JSScript always marks its compartment's global (via bindings) so we
michael@0 135 * can assert that maybeGlobal is non-null here.
michael@0 136 */
michael@0 137 return *compartment()->maybeGlobal();
michael@0 138 }
michael@0 139
michael@0 140 inline JSPrincipals *
michael@0 141 JSScript::principals()
michael@0 142 {
michael@0 143 return compartment()->principals;
michael@0 144 }
michael@0 145
michael@0 146 inline JSFunction *
michael@0 147 JSScript::donorFunction() const
michael@0 148 {
michael@0 149 if (!isCallsiteClone())
michael@0 150 return nullptr;
michael@0 151 return &enclosingScopeOrOriginalFunction_->as<JSFunction>();
michael@0 152 }
michael@0 153
michael@0 154 inline void
michael@0 155 JSScript::setIsCallsiteClone(JSObject *fun)
michael@0 156 {
michael@0 157 JS_ASSERT(shouldCloneAtCallsite());
michael@0 158 shouldCloneAtCallsite_ = false;
michael@0 159 isCallsiteClone_ = true;
michael@0 160 JS_ASSERT(isCallsiteClone());
michael@0 161 JS_ASSERT(fun->is<JSFunction>());
michael@0 162 enclosingScopeOrOriginalFunction_ = fun;
michael@0 163 }
michael@0 164
michael@0 165 inline void
michael@0 166 JSScript::setBaselineScript(JSContext *maybecx, js::jit::BaselineScript *baselineScript)
michael@0 167 {
michael@0 168 #ifdef JS_ION
michael@0 169 if (hasBaselineScript())
michael@0 170 js::jit::BaselineScript::writeBarrierPre(tenuredZone(), baseline);
michael@0 171 #endif
michael@0 172 MOZ_ASSERT(!hasIonScript());
michael@0 173 baseline = baselineScript;
michael@0 174 updateBaselineOrIonRaw();
michael@0 175 }
michael@0 176
michael@0 177 inline bool
michael@0 178 JSScript::ensureHasAnalyzedArgsUsage(JSContext *cx)
michael@0 179 {
michael@0 180 if (analyzedArgsUsage())
michael@0 181 return true;
michael@0 182 #ifdef JS_ION
michael@0 183 return js::jit::AnalyzeArgumentsUsage(cx, this);
michael@0 184 #else
michael@0 185 MOZ_CRASH();
michael@0 186 #endif
michael@0 187 }
michael@0 188
michael@0 189 #endif /* jsscriptinlines_h */

mercurial