2011-10-25 23:07:42 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2013-04-16 20:47:10 +00:00
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-09-09 23:52:55 +00:00
|
|
|
|
2013-06-20 00:59:46 +00:00
|
|
|
#ifndef jsscriptinlines_h
|
|
|
|
#define jsscriptinlines_h
|
2009-09-09 23:52:55 +00:00
|
|
|
|
2013-07-24 00:34:50 +00:00
|
|
|
#include "jsscript.h"
|
|
|
|
|
2013-08-08 17:37:11 +00:00
|
|
|
#include "jit/AsmJSLink.h"
|
2013-08-13 15:16:38 +00:00
|
|
|
#include "jit/BaselineJIT.h"
|
2013-08-08 23:07:22 +00:00
|
|
|
#include "vm/ScopeObject.h"
|
2010-11-16 23:34:24 +00:00
|
|
|
|
2013-06-07 00:48:12 +00:00
|
|
|
#include "jscompartmentinlines.h"
|
|
|
|
|
2013-01-26 15:03:19 +00:00
|
|
|
#include "vm/Shape-inl.h"
|
2011-07-08 18:16:25 +00:00
|
|
|
|
2010-11-16 23:34:24 +00:00
|
|
|
namespace js {
|
|
|
|
|
2011-11-14 21:03:50 +00:00
|
|
|
inline
|
2012-06-21 02:14:35 +00:00
|
|
|
Bindings::Bindings()
|
2014-02-12 17:46:24 +00:00
|
|
|
: callObjShape_(nullptr), bindingArrayAndFlag_(TEMPORARY_STORAGE_BIT),
|
|
|
|
numArgs_(0), numBlockScoped_(0), numVars_(0)
|
2011-11-14 21:03:50 +00:00
|
|
|
{}
|
|
|
|
|
2012-08-06 14:56:45 +00:00
|
|
|
inline
|
2013-04-30 22:40:40 +00:00
|
|
|
AliasedFormalIter::AliasedFormalIter(JSScript *script)
|
2013-12-19 18:01:25 +00:00
|
|
|
: begin_(script->bindingArray()),
|
2012-08-06 14:56:45 +00:00
|
|
|
p_(begin_),
|
2013-12-19 18:01:25 +00:00
|
|
|
end_(begin_ + (script->funHasAnyAliasedFormal() ? script->numArgs() : 0)),
|
2012-08-06 14:56:45 +00:00
|
|
|
slot_(CallObject::RESERVED_SLOTS)
|
2012-06-29 18:42:42 +00:00
|
|
|
{
|
2012-08-06 14:56:45 +00:00
|
|
|
settle();
|
2012-06-29 18:42:42 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 21:11:08 +00:00
|
|
|
inline void
|
2012-03-25 07:48:45 +00:00
|
|
|
ScriptCounts::destroy(FreeOp *fop)
|
2011-12-16 21:11:08 +00:00
|
|
|
{
|
2012-03-25 07:48:45 +00:00
|
|
|
fop->free_(pcCountsVector);
|
2012-11-16 17:14:06 +00:00
|
|
|
fop->delete_(ionCounts);
|
2011-12-16 21:11:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 11:54:13 +00:00
|
|
|
void
|
|
|
|
SetFrameArgumentsObject(JSContext *cx, AbstractFramePtr frame,
|
|
|
|
HandleScript script, JSObject *argsobj);
|
|
|
|
|
2014-01-09 16:13:25 +00:00
|
|
|
inline JSFunction *
|
|
|
|
LazyScript::functionDelazifying(JSContext *cx) const
|
|
|
|
{
|
|
|
|
if (function_ && !function_->getOrCreateScript(cx))
|
|
|
|
return nullptr;
|
|
|
|
return function_;
|
|
|
|
}
|
|
|
|
|
2010-11-16 23:34:24 +00:00
|
|
|
} // namespace js
|
2009-09-10 14:22:20 +00:00
|
|
|
|
2014-01-09 16:13:25 +00:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::functionDelazifying() const
|
|
|
|
{
|
2014-02-01 22:31:57 +00:00
|
|
|
if (function_ && function_->isInterpretedLazy()) {
|
2014-01-09 16:13:25 +00:00
|
|
|
function_->setUnlazifiedScript(const_cast<JSScript *>(this));
|
2014-02-01 22:31:57 +00:00
|
|
|
// If this script has a LazyScript, make sure the LazyScript has a
|
|
|
|
// reference to the script when delazifying its canonical function.
|
|
|
|
if (lazyScript && !lazyScript->maybeScript())
|
|
|
|
lazyScript->initScript(const_cast<JSScript *>(this));
|
|
|
|
}
|
2014-01-09 16:13:25 +00:00
|
|
|
return function_;
|
|
|
|
}
|
|
|
|
|
2011-12-15 23:27:58 +00:00
|
|
|
inline void
|
|
|
|
JSScript::setFunction(JSFunction *fun)
|
|
|
|
{
|
2013-06-10 18:16:57 +00:00
|
|
|
JS_ASSERT(fun->isTenured());
|
2011-12-15 23:27:58 +00:00
|
|
|
function_ = fun;
|
|
|
|
}
|
|
|
|
|
2014-01-09 16:13:25 +00:00
|
|
|
inline void
|
|
|
|
JSScript::ensureNonLazyCanonicalFunction(JSContext *cx)
|
|
|
|
{
|
|
|
|
// Infallibly delazify the canonical script.
|
2014-02-14 12:17:53 +00:00
|
|
|
if (function_ && function_->isInterpretedLazy())
|
2014-01-09 16:13:25 +00:00
|
|
|
functionDelazifying();
|
|
|
|
}
|
|
|
|
|
2009-09-10 14:22:20 +00:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::getFunction(size_t index)
|
|
|
|
{
|
2013-06-18 06:53:49 +00:00
|
|
|
JSFunction *fun = &getObject(index)->as<JSFunction>();
|
2013-03-15 01:44:03 +00:00
|
|
|
JS_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
|
2013-06-18 06:53:49 +00:00
|
|
|
return fun;
|
2009-09-10 14:22:20 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 22:52:39 +00:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::getCallerFunction()
|
|
|
|
{
|
2013-12-11 02:22:28 +00:00
|
|
|
JS_ASSERT(savedCallerFun());
|
2011-07-07 22:52:39 +00:00
|
|
|
return getFunction(0);
|
|
|
|
}
|
|
|
|
|
2013-02-21 13:56:54 +00:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::functionOrCallerFunction()
|
|
|
|
{
|
2014-01-09 16:13:25 +00:00
|
|
|
if (functionNonDelazifying())
|
|
|
|
return functionNonDelazifying();
|
2013-12-11 02:22:28 +00:00
|
|
|
if (savedCallerFun())
|
2013-02-21 13:56:54 +00:00
|
|
|
return getCallerFunction();
|
2013-10-07 16:44:28 +00:00
|
|
|
return nullptr;
|
2013-02-21 13:56:54 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 20:59:41 +00:00
|
|
|
inline js::RegExpObject *
|
2009-09-10 14:22:20 +00:00
|
|
|
JSScript::getRegExp(size_t index)
|
|
|
|
{
|
2012-04-11 06:51:12 +00:00
|
|
|
js::ObjectArray *arr = regexps();
|
Bug 708735 - Use <stdint.h> types in JSAPI and throughout SpiderMonkey. Continue to provide the {u,}int{8,16,32,64} and JS{Uint,Int}{8,16,32,64} integer types through a single header, however, for a simpler backout strategy -- and also to ease the transition for embedders. r=timeless on switching the jsd API to use the <stdint.h> types, r=luke, r=dmandelin
2011-12-09 03:54:10 +00:00
|
|
|
JS_ASSERT(uint32_t(index) < arr->length);
|
2009-09-09 23:52:55 +00:00
|
|
|
JSObject *obj = arr->vector[index];
|
2013-06-17 00:39:43 +00:00
|
|
|
JS_ASSERT(obj->is<js::RegExpObject>());
|
2012-02-03 20:59:41 +00:00
|
|
|
return (js::RegExpObject *) obj;
|
2009-09-09 23:52:55 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 17:58:56 +00:00
|
|
|
inline js::RegExpObject *
|
|
|
|
JSScript::getRegExp(jsbytecode *pc)
|
|
|
|
{
|
|
|
|
JS_ASSERT(containsPC(pc) && containsPC(pc + sizeof(uint32_t)));
|
|
|
|
return getRegExp(GET_UINT32_INDEX(pc));
|
|
|
|
}
|
|
|
|
|
2012-07-03 17:24:35 +00:00
|
|
|
inline js::GlobalObject &
|
2011-06-06 15:32:41 +00:00
|
|
|
JSScript::global() const
|
|
|
|
{
|
2012-07-03 17:24:35 +00:00
|
|
|
/*
|
|
|
|
* A JSScript always marks its compartment's global (via bindings) so we
|
|
|
|
* can assert that maybeGlobal is non-null here.
|
|
|
|
*/
|
|
|
|
return *compartment()->maybeGlobal();
|
2011-06-06 15:32:41 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 02:10:46 +00:00
|
|
|
inline JSPrincipals *
|
|
|
|
JSScript::principals()
|
|
|
|
{
|
|
|
|
return compartment()->principals;
|
|
|
|
}
|
|
|
|
|
2013-02-26 21:42:43 +00:00
|
|
|
inline JSFunction *
|
2014-02-14 12:17:53 +00:00
|
|
|
JSScript::donorFunction() const
|
|
|
|
{
|
2013-12-11 02:22:28 +00:00
|
|
|
if (!isCallsiteClone())
|
2013-10-07 16:44:28 +00:00
|
|
|
return nullptr;
|
2013-06-18 06:53:49 +00:00
|
|
|
return &enclosingScopeOrOriginalFunction_->as<JSFunction>();
|
2013-02-26 21:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2014-02-14 12:17:53 +00:00
|
|
|
JSScript::setIsCallsiteClone(JSObject *fun)
|
|
|
|
{
|
2013-12-11 02:22:28 +00:00
|
|
|
JS_ASSERT(shouldCloneAtCallsite());
|
|
|
|
shouldCloneAtCallsite_ = false;
|
|
|
|
isCallsiteClone_ = true;
|
|
|
|
JS_ASSERT(isCallsiteClone());
|
2013-06-18 06:53:49 +00:00
|
|
|
JS_ASSERT(fun->is<JSFunction>());
|
2013-02-26 21:42:43 +00:00
|
|
|
enclosingScopeOrOriginalFunction_ = fun;
|
|
|
|
}
|
|
|
|
|
2013-08-13 15:16:38 +00:00
|
|
|
inline void
|
2014-02-14 12:17:53 +00:00
|
|
|
JSScript::setBaselineScript(JSContext *maybecx, js::jit::BaselineScript *baselineScript)
|
|
|
|
{
|
2013-08-13 15:16:38 +00:00
|
|
|
#ifdef JS_ION
|
|
|
|
if (hasBaselineScript())
|
2013-08-27 10:50:16 +00:00
|
|
|
js::jit::BaselineScript::writeBarrierPre(tenuredZone(), baseline);
|
2013-08-13 15:16:38 +00:00
|
|
|
#endif
|
2014-04-15 11:24:42 +00:00
|
|
|
MOZ_ASSERT(!hasIonScript());
|
2013-08-13 15:16:38 +00:00
|
|
|
baseline = baselineScript;
|
|
|
|
updateBaselineOrIonRaw();
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:59:46 +00:00
|
|
|
#endif /* jsscriptinlines_h */
|