Bumping manifests a=b2g-bump
[gecko.git] / js / src / jsscriptinlines.h
blob65fbf13e99457d5ec80e36b4851f4c77640d5c6d
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 #ifndef jsscriptinlines_h
8 #define jsscriptinlines_h
10 #include "jsscript.h"
12 #include "asmjs/AsmJSLink.h"
13 #include "jit/BaselineJIT.h"
14 #include "jit/IonAnalysis.h"
15 #include "vm/ScopeObject.h"
17 #include "jscompartmentinlines.h"
19 #include "vm/Shape-inl.h"
21 namespace js {
23 inline
24 Bindings::Bindings()
25 : callObjShape_(nullptr), bindingArrayAndFlag_(TEMPORARY_STORAGE_BIT),
26 numArgs_(0), numBlockScoped_(0),
27 numBodyLevelLexicals_(0), numUnaliasedBodyLevelLexicals_(0),
28 numVars_(0), numUnaliasedVars_(0)
31 inline
32 AliasedFormalIter::AliasedFormalIter(JSScript* script)
33 : begin_(script->bindingArray()),
34 p_(begin_),
35 end_(begin_ + (script->funHasAnyAliasedFormal() ? script->numArgs() : 0)),
36 slot_(CallObject::RESERVED_SLOTS)
38 settle();
41 inline void
42 ScriptCounts::destroy(FreeOp* fop)
44 fop->free_(pcCountsVector);
45 fop->delete_(ionCounts);
48 void
49 SetFrameArgumentsObject(JSContext* cx, AbstractFramePtr frame,
50 HandleScript script, JSObject* argsobj);
52 inline JSFunction*
53 LazyScript::functionDelazifying(JSContext* cx) const
55 if (function_ && !function_->getOrCreateScript(cx))
56 return nullptr;
57 return function_;
60 } // namespace js
62 inline JSFunction*
63 JSScript::functionDelazifying() const
65 if (function_ && function_->isInterpretedLazy()) {
66 function_->setUnlazifiedScript(const_cast<JSScript*>(this));
67 // If this script has a LazyScript, make sure the LazyScript has a
68 // reference to the script when delazifying its canonical function.
69 if (lazyScript && !lazyScript->maybeScript())
70 lazyScript->initScript(const_cast<JSScript*>(this));
72 return function_;
75 inline void
76 JSScript::setFunction(JSFunction* fun)
78 MOZ_ASSERT(fun->isTenured());
79 function_ = fun;
82 inline void
83 JSScript::ensureNonLazyCanonicalFunction(JSContext* cx)
85 // Infallibly delazify the canonical script.
86 if (function_ && function_->isInterpretedLazy())
87 functionDelazifying();
90 inline JSFunction*
91 JSScript::getFunction(size_t index)
93 JSFunction* fun = &getObject(index)->as<JSFunction>();
94 MOZ_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
95 return fun;
98 inline JSFunction*
99 JSScript::getCallerFunction()
101 MOZ_ASSERT(savedCallerFun());
102 return getFunction(0);
105 inline JSFunction*
106 JSScript::functionOrCallerFunction()
108 if (functionNonDelazifying())
109 return functionNonDelazifying();
110 if (savedCallerFun())
111 return getCallerFunction();
112 return nullptr;
115 inline js::RegExpObject*
116 JSScript::getRegExp(size_t index)
118 js::ObjectArray* arr = regexps();
119 MOZ_ASSERT(uint32_t(index) < arr->length);
120 JSObject* obj = arr->vector[index];
121 MOZ_ASSERT(obj->is<js::RegExpObject>());
122 return (js::RegExpObject*) obj;
125 inline js::RegExpObject*
126 JSScript::getRegExp(jsbytecode* pc)
128 MOZ_ASSERT(containsPC(pc) && containsPC(pc + sizeof(uint32_t)));
129 return getRegExp(GET_UINT32_INDEX(pc));
132 inline js::GlobalObject&
133 JSScript::global() const
136 * A JSScript always marks its compartment's global (via bindings) so we
137 * can assert that maybeGlobal is non-null here.
139 return *compartment()->maybeGlobal();
142 inline JSPrincipals*
143 JSScript::principals()
145 return compartment()->principals;
148 inline JSFunction*
149 JSScript::donorFunction() const
151 if (!isCallsiteClone())
152 return nullptr;
153 return &enclosingScopeOrOriginalFunction_->as<JSFunction>();
156 inline void
157 JSScript::setIsCallsiteClone(JSObject* fun)
159 MOZ_ASSERT(shouldCloneAtCallsite());
160 shouldCloneAtCallsite_ = false;
161 isCallsiteClone_ = true;
162 MOZ_ASSERT(isCallsiteClone());
163 MOZ_ASSERT(fun->is<JSFunction>());
164 enclosingScopeOrOriginalFunction_ = fun;
167 inline void
168 JSScript::setBaselineScript(JSContext* maybecx, js::jit::BaselineScript* baselineScript)
170 if (hasBaselineScript())
171 js::jit::BaselineScript::writeBarrierPre(zone(), baseline);
172 MOZ_ASSERT(!hasIonScript());
173 baseline = baselineScript;
174 updateBaselineOrIonRaw(maybecx);
177 inline bool
178 JSScript::ensureHasAnalyzedArgsUsage(JSContext* cx)
180 if (analyzedArgsUsage())
181 return true;
182 return js::jit::AnalyzeArgumentsUsage(cx, this);
185 inline bool
186 JSScript::isDebuggee() const
188 return compartment_->debugObservesAllExecution() || hasDebugScript_;
191 #endif /* jsscriptinlines_h */