2011-10-25 16:07:42 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2013-04-16 13:47:10 -07:00
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-05-21 04:12:37 -07: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 16:52:55 -07:00
|
|
|
|
2013-06-19 17:59:46 -07:00
|
|
|
#ifndef jsscriptinlines_h
|
|
|
|
#define jsscriptinlines_h
|
2009-09-09 16:52:55 -07:00
|
|
|
|
2013-07-23 17:34:50 -07:00
|
|
|
#include "jsscript.h"
|
|
|
|
|
2013-08-08 10:37:11 -07:00
|
|
|
#include "jit/AsmJSLink.h"
|
2013-08-13 08:16:38 -07:00
|
|
|
#include "jit/BaselineJIT.h"
|
2013-08-08 16:07:22 -07:00
|
|
|
#include "vm/ScopeObject.h"
|
2010-11-16 15:34:24 -08:00
|
|
|
|
2013-06-06 17:48:12 -07:00
|
|
|
#include "jscompartmentinlines.h"
|
|
|
|
|
2013-01-26 07:03:19 -08:00
|
|
|
#include "vm/Shape-inl.h"
|
2011-07-08 11:16:25 -07:00
|
|
|
|
2010-11-16 15:34:24 -08:00
|
|
|
namespace js {
|
|
|
|
|
2011-11-14 13:03:50 -08:00
|
|
|
inline
|
2012-06-20 19:14:35 -07:00
|
|
|
Bindings::Bindings()
|
2013-10-07 09:44:28 -07:00
|
|
|
: callObjShape_(nullptr), bindingArrayAndFlag_(TEMPORARY_STORAGE_BIT), numArgs_(0), numVars_(0)
|
2011-11-14 13:03:50 -08:00
|
|
|
{}
|
|
|
|
|
2012-08-06 07:56:45 -07:00
|
|
|
inline
|
2013-04-30 15:40:40 -07:00
|
|
|
AliasedFormalIter::AliasedFormalIter(JSScript *script)
|
2013-12-19 10:01:25 -08:00
|
|
|
: begin_(script->bindingArray()),
|
2012-08-06 07:56:45 -07:00
|
|
|
p_(begin_),
|
2013-12-19 10:01:25 -08:00
|
|
|
end_(begin_ + (script->funHasAnyAliasedFormal() ? script->numArgs() : 0)),
|
2012-08-06 07:56:45 -07:00
|
|
|
slot_(CallObject::RESERVED_SLOTS)
|
2012-06-29 11:42:42 -07:00
|
|
|
{
|
2012-08-06 07:56:45 -07:00
|
|
|
settle();
|
2012-06-29 11:42:42 -07:00
|
|
|
}
|
|
|
|
|
2011-12-16 13:11:08 -08:00
|
|
|
inline void
|
2012-03-25 00:48:45 -07:00
|
|
|
ScriptCounts::destroy(FreeOp *fop)
|
2011-12-16 13:11:08 -08:00
|
|
|
{
|
2012-03-25 00:48:45 -07:00
|
|
|
fop->free_(pcCountsVector);
|
2012-11-16 09:14:06 -08:00
|
|
|
fop->delete_(ionCounts);
|
2011-12-16 13:11:08 -08:00
|
|
|
}
|
|
|
|
|
2013-02-20 03:54:13 -08:00
|
|
|
void
|
|
|
|
SetFrameArgumentsObject(JSContext *cx, AbstractFramePtr frame,
|
|
|
|
HandleScript script, JSObject *argsobj);
|
|
|
|
|
2010-11-16 15:34:24 -08:00
|
|
|
} // namespace js
|
2009-09-10 07:22:20 -07:00
|
|
|
|
2011-12-15 15:27:58 -08:00
|
|
|
inline void
|
|
|
|
JSScript::setFunction(JSFunction *fun)
|
|
|
|
{
|
2013-06-10 11:16:57 -07:00
|
|
|
JS_ASSERT(fun->isTenured());
|
2011-12-15 15:27:58 -08:00
|
|
|
function_ = fun;
|
|
|
|
}
|
|
|
|
|
2009-09-10 07:22:20 -07:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::getFunction(size_t index)
|
|
|
|
{
|
2013-06-17 23:53:49 -07:00
|
|
|
JSFunction *fun = &getObject(index)->as<JSFunction>();
|
2013-03-14 18:44:03 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
JS_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
|
|
|
|
#endif
|
2013-06-17 23:53:49 -07:00
|
|
|
return fun;
|
2009-09-10 07:22:20 -07:00
|
|
|
}
|
|
|
|
|
2011-07-07 15:52:39 -07:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::getCallerFunction()
|
|
|
|
{
|
2013-12-10 18:22:28 -08:00
|
|
|
JS_ASSERT(savedCallerFun());
|
2011-07-07 15:52:39 -07:00
|
|
|
return getFunction(0);
|
|
|
|
}
|
|
|
|
|
2013-02-21 05:56:54 -08:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::functionOrCallerFunction()
|
|
|
|
{
|
|
|
|
if (function())
|
|
|
|
return function();
|
2013-12-10 18:22:28 -08:00
|
|
|
if (savedCallerFun())
|
2013-02-21 05:56:54 -08:00
|
|
|
return getCallerFunction();
|
2013-10-07 09:44:28 -07:00
|
|
|
return nullptr;
|
2013-02-21 05:56:54 -08:00
|
|
|
}
|
|
|
|
|
2012-02-03 12:59:41 -08:00
|
|
|
inline js::RegExpObject *
|
2009-09-10 07:22:20 -07:00
|
|
|
JSScript::getRegExp(size_t index)
|
|
|
|
{
|
2012-04-10 23:51:12 -07: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-08 19:54:10 -08:00
|
|
|
JS_ASSERT(uint32_t(index) < arr->length);
|
2009-09-09 16:52:55 -07:00
|
|
|
JSObject *obj = arr->vector[index];
|
2013-06-16 17:39:43 -07:00
|
|
|
JS_ASSERT(obj->is<js::RegExpObject>());
|
2012-02-03 12:59:41 -08:00
|
|
|
return (js::RegExpObject *) obj;
|
2009-09-09 16:52:55 -07:00
|
|
|
}
|
|
|
|
|
2012-07-03 10:24:35 -07:00
|
|
|
inline js::GlobalObject &
|
2011-06-06 08:32:41 -07:00
|
|
|
JSScript::global() const
|
|
|
|
{
|
2012-07-03 10:24:35 -07:00
|
|
|
/*
|
|
|
|
* A JSScript always marks its compartment's global (via bindings) so we
|
|
|
|
* can assert that maybeGlobal is non-null here.
|
|
|
|
*/
|
2013-12-19 10:01:25 -08:00
|
|
|
js::AutoThreadSafeAccess ts(this);
|
2012-07-03 10:24:35 -07:00
|
|
|
return *compartment()->maybeGlobal();
|
2011-06-06 08:32:41 -07:00
|
|
|
}
|
|
|
|
|
2013-01-30 18:10:46 -08:00
|
|
|
inline JSPrincipals *
|
|
|
|
JSScript::principals()
|
|
|
|
{
|
|
|
|
return compartment()->principals;
|
|
|
|
}
|
|
|
|
|
2013-02-26 13:42:43 -08:00
|
|
|
inline JSFunction *
|
|
|
|
JSScript::originalFunction() const {
|
2013-12-10 18:22:28 -08:00
|
|
|
if (!isCallsiteClone())
|
2013-10-07 09:44:28 -07:00
|
|
|
return nullptr;
|
2013-06-17 23:53:49 -07:00
|
|
|
return &enclosingScopeOrOriginalFunction_->as<JSFunction>();
|
2013-02-26 13:42:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2013-12-10 18:22:28 -08:00
|
|
|
JSScript::setIsCallsiteClone(JSObject *fun) {
|
|
|
|
JS_ASSERT(shouldCloneAtCallsite());
|
|
|
|
shouldCloneAtCallsite_ = false;
|
|
|
|
isCallsiteClone_ = true;
|
|
|
|
JS_ASSERT(isCallsiteClone());
|
2013-06-17 23:53:49 -07:00
|
|
|
JS_ASSERT(fun->is<JSFunction>());
|
2013-02-26 13:42:43 -08:00
|
|
|
enclosingScopeOrOriginalFunction_ = fun;
|
|
|
|
}
|
|
|
|
|
2013-08-13 08:16:38 -07:00
|
|
|
inline void
|
2013-12-16 10:53:02 -08:00
|
|
|
JSScript::setBaselineScript(JSContext *maybecx, js::jit::BaselineScript *baselineScript) {
|
2013-08-13 08:16:38 -07:00
|
|
|
#ifdef JS_ION
|
|
|
|
if (hasBaselineScript())
|
2013-08-27 03:50:16 -07:00
|
|
|
js::jit::BaselineScript::writeBarrierPre(tenuredZone(), baseline);
|
2013-08-13 08:16:38 -07:00
|
|
|
#endif
|
2013-12-16 10:53:02 -08:00
|
|
|
mozilla::Maybe<js::AutoLockForCompilation> lock;
|
|
|
|
if (maybecx)
|
|
|
|
lock.construct(maybecx);
|
2013-08-13 08:16:38 -07:00
|
|
|
baseline = baselineScript;
|
|
|
|
updateBaselineOrIonRaw();
|
|
|
|
}
|
|
|
|
|
2013-06-19 17:59:46 -07:00
|
|
|
#endif /* jsscriptinlines_h */
|