mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 06:45:42 +00:00
Bug 791850 - Cleanup of lazy script handling. r=bhackett
--HG-- extra : rebase_source : eb676d1a38675f0c556e2f367465a726085eefcc
This commit is contained in:
parent
ab68f3ae01
commit
5b87b80c39
@ -85,7 +85,7 @@ GetBailedJSScript(JSContext *cx)
|
||||
switch (GetCalleeTokenTag(frame->calleeToken())) {
|
||||
case CalleeToken_Function: {
|
||||
JSFunction *fun = CalleeTokenToFunction(frame->calleeToken());
|
||||
return fun->script().get(nogc);
|
||||
return fun->nonLazyScript().get(nogc);
|
||||
}
|
||||
case CalleeToken_Script:
|
||||
return CalleeTokenToScript(frame->calleeToken());
|
||||
@ -197,7 +197,7 @@ PushInlinedFrame(JSContext *cx, StackFrame *callerFrame)
|
||||
const Value &calleeVal = regs.sp[-callerArgc - 2];
|
||||
|
||||
RootedFunction fun(cx, calleeVal.toObject().toFunction());
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
CallArgs inlineArgs = CallArgsFromSp(callerArgc, regs.sp);
|
||||
|
||||
// Bump the stack pointer to make it look like the inline args have been pushed, but they will
|
||||
|
@ -311,7 +311,7 @@ CodeGenerator::visitLambda(LLambda *lir)
|
||||
|
||||
JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2);
|
||||
masm.store32(Imm32(u.word), Address(output, offsetof(JSFunction, nargs)));
|
||||
masm.storePtr(ImmGCPtr(fun->script().unsafeGet()),
|
||||
masm.storePtr(ImmGCPtr(fun->nonLazyScript().unsafeGet()),
|
||||
Address(output, JSFunction::offsetOfNativeOrScript()));
|
||||
masm.storePtr(scopeChain, Address(output, JSFunction::offsetOfEnvironment()));
|
||||
masm.storePtr(ImmGCPtr(fun->displayAtom()), Address(output, JSFunction::offsetOfAtom()));
|
||||
@ -926,7 +926,7 @@ CodeGenerator::visitCallKnown(LCallKnown *call)
|
||||
|
||||
// If the function is known to be uncompilable, only emit the call to InvokeFunction.
|
||||
ExecutionMode executionMode = gen->info().executionMode();
|
||||
RootedScript targetScript(cx, target->script());
|
||||
RootedScript targetScript(cx, target->nonLazyScript());
|
||||
if (GetIonScript(targetScript, executionMode) == ION_DISABLED_SCRIPT) {
|
||||
if (!emitCallInvokeFunction(call, calleereg, call->numActualArgs(), unusedStack))
|
||||
return false;
|
||||
|
@ -54,7 +54,7 @@ static inline bool CanIonCompile(JSContext *cx, HandleFunction fun, ExecutionMod
|
||||
{
|
||||
if (!fun->isInterpreted())
|
||||
return false;
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
return CanIonCompile(script, cmode);
|
||||
}
|
||||
|
||||
|
@ -1564,7 +1564,7 @@ ion::FastInvoke(JSContext *cx, HandleFunction fun, CallArgsList &args)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return IonExec_Error);
|
||||
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
IonScript *ion = script->ionScript();
|
||||
IonCode *code = ion->method();
|
||||
void *jitcode = code->raw();
|
||||
|
@ -204,7 +204,7 @@ IonBuilder::canInlineTarget(JSFunction *target)
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedScript inlineScript(cx, target->script());
|
||||
RootedScript inlineScript(cx, target->nonLazyScript());
|
||||
ExecutionMode executionMode = info().executionMode();
|
||||
if (!CanIonCompile(inlineScript, executionMode)) {
|
||||
IonSpew(IonSpew_Inlining, "Cannot inline due to disable Ion compilation");
|
||||
@ -2835,7 +2835,7 @@ IonBuilder::jsop_call_inline(HandleFunction callee, uint32 argc, bool constructi
|
||||
|
||||
// Compilation information is allocated for the duration of the current tempLifoAlloc
|
||||
// lifetime.
|
||||
RootedScript calleeScript(cx, callee->script());
|
||||
RootedScript calleeScript(cx, callee->nonLazyScript());
|
||||
CompileInfo *info = cx->tempLifoAlloc().new_<CompileInfo>(calleeScript.get(), callee,
|
||||
(jsbytecode *)NULL, constructing,
|
||||
SequentialExecution);
|
||||
@ -2930,7 +2930,7 @@ IonBuilder::makeInliningDecision(AutoObjectVector &targets, uint32 argc)
|
||||
if (!target->isInterpreted())
|
||||
return false;
|
||||
|
||||
script = target->script();
|
||||
script = target->nonLazyScript();
|
||||
uint32_t calleeUses = script->getUseCount();
|
||||
|
||||
if (target->nargs < argc) {
|
||||
@ -3549,7 +3549,7 @@ IonBuilder::createThisScriptedSingleton(HandleFunction target, HandleObject prot
|
||||
types::TypeObject *type = proto->getNewType(cx, target);
|
||||
if (!type)
|
||||
return NULL;
|
||||
if (!types::TypeScript::ThisTypes(target->script().unsafeGet())->hasType(types::Type::ObjectType(type)))
|
||||
if (!types::TypeScript::ThisTypes(target->nonLazyScript().unsafeGet())->hasType(types::Type::ObjectType(type)))
|
||||
return NULL;
|
||||
|
||||
RootedObject templateObject(cx, js_CreateThisForFunctionWithProto(cx, target, proto));
|
||||
|
@ -1624,7 +1624,7 @@ GenerateScopeChainGuard(MacroAssembler &masm, JSObject *scopeObj,
|
||||
CallObject *callObj = &scopeObj->asCall();
|
||||
if (!callObj->isForEval()) {
|
||||
RawFunction fun = &callObj->callee();
|
||||
RawScript script = fun->script().get(nogc);
|
||||
RawScript script = fun->nonLazyScript().get(nogc);
|
||||
if (!script->funHasExtensibleScope)
|
||||
return;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ MarkIonJSFrame(JSTracer *trc, const IonFrameIterator &frame)
|
||||
// is now NULL or recompiled). Manually trace it here.
|
||||
IonScript::Trace(trc, ionScript);
|
||||
} else if (CalleeTokenIsFunction(layout->calleeToken())) {
|
||||
ionScript = CalleeTokenToFunction(layout->calleeToken())->script()->ion;
|
||||
ionScript = CalleeTokenToFunction(layout->calleeToken())->nonLazyScript()->ion;
|
||||
} else {
|
||||
ionScript = CalleeTokenToScript(layout->calleeToken())->ion;
|
||||
}
|
||||
@ -926,7 +926,7 @@ InlineFrameIterator::findNextFrame()
|
||||
si_.nextFrame();
|
||||
|
||||
callee_ = funval.toObject().toFunction();
|
||||
script_ = callee_->script().get(nogc);
|
||||
script_ = callee_->nonLazyScript().get(nogc);
|
||||
pc_ = script_->code + si_.pcOffset();
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ ScriptFromCalleeToken(CalleeToken token)
|
||||
case CalleeToken_Script:
|
||||
return CalleeTokenToScript(token);
|
||||
case CalleeToken_Function:
|
||||
return CalleeTokenToFunction(token)->script().get(nogc);
|
||||
return CalleeTokenToFunction(token)->nonLazyScript().get(nogc);
|
||||
}
|
||||
JS_NOT_REACHED("invalid callee token tag");
|
||||
return NULL;
|
||||
|
@ -556,7 +556,7 @@ bool
|
||||
TypeInferenceOracle::canEnterInlinedFunction(JSFunction *target)
|
||||
{
|
||||
AssertCanGC();
|
||||
RootedScript script(cx, target->script());
|
||||
RootedScript script(cx, target->nonLazyScript());
|
||||
if (!script->hasAnalysis() || !script->analysis()->ranInference())
|
||||
return false;
|
||||
|
||||
|
@ -41,8 +41,8 @@ static inline bool
|
||||
ShouldMonitorReturnType(JSFunction *fun)
|
||||
{
|
||||
return fun->isInterpreted() &&
|
||||
(!fun->script()->hasAnalysis() ||
|
||||
!fun->script()->analysis()->ranInference());
|
||||
(!fun->nonLazyScript()->hasAnalysis() ||
|
||||
!fun->nonLazyScript()->analysis()->ranInference());
|
||||
}
|
||||
|
||||
bool
|
||||
@ -50,23 +50,22 @@ InvokeFunction(JSContext *cx, JSFunction *fun, uint32 argc, Value *argv, Value *
|
||||
{
|
||||
Value fval = ObjectValue(*fun);
|
||||
|
||||
if (fun->isInterpretedLazy()) {
|
||||
Rooted<JSFunction*> rootedFun(cx, fun);
|
||||
if (!InitializeLazyFunctionScript(cx, rootedFun))
|
||||
return false;
|
||||
}
|
||||
|
||||
// In order to prevent massive bouncing between Ion and JM, see if we keep
|
||||
// hitting functions that are uncompilable.
|
||||
|
||||
if (fun->isInterpreted() && !fun->script()->canIonCompile()) {
|
||||
JSScript *script = GetTopIonJSScript(cx);
|
||||
if (script->hasIonScript() && ++script->ion->slowCallCount >= js_IonOptions.slowCallLimit) {
|
||||
AutoFlushCache afc("InvokeFunction");
|
||||
if (fun->isInterpreted()) {
|
||||
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx).unsafeGet())
|
||||
return false;
|
||||
if (!fun->nonLazyScript()->canIonCompile()) {
|
||||
JSScript *script = GetTopIonJSScript(cx);
|
||||
if (script->hasIonScript() &&
|
||||
++script->ion->slowCallCount >= js_IonOptions.slowCallLimit)
|
||||
{
|
||||
AutoFlushCache afc("InvokeFunction");
|
||||
|
||||
// Poison the script so we don't try to run it again. This will
|
||||
// trigger invalidation.
|
||||
ForbidCompilation(cx, script);
|
||||
// Poison the script so we don't try to run it again. This will
|
||||
// trigger invalidation.
|
||||
ForbidCompilation(cx, script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,10 +97,10 @@ InvokeConstructor(JSContext *cx, JSObject *obj, uint32 argc, Value *argv, Value
|
||||
bool needsMonitor;
|
||||
|
||||
if (obj->isFunction()) {
|
||||
if (obj->toFunction()->isInterpretedLazy()) {
|
||||
Rooted<JSFunction*> rootedFun(cx, obj->toFunction());
|
||||
if (!InitializeLazyFunctionScript(cx, rootedFun))
|
||||
return false;
|
||||
if (obj->toFunction()->isInterpretedLazy() &&
|
||||
!obj->toFunction()->getOrCreateScript(cx).unsafeGet())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
needsMonitor = ShouldMonitorReturnType(obj->toFunction());
|
||||
} else {
|
||||
|
@ -4871,8 +4871,8 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobjArg, JSRawObject parentArg
|
||||
* script, we cannot clone it without breaking the compiler's assumptions.
|
||||
*/
|
||||
RootedFunction fun(cx, funobj->toFunction());
|
||||
if (fun->isInterpreted() && (fun->script()->enclosingStaticScope() ||
|
||||
(fun->script()->compileAndGo && !parent->isGlobal())))
|
||||
if (fun->isInterpreted() && (fun->nonLazyScript()->enclosingStaticScope() ||
|
||||
(fun->nonLazyScript()->compileAndGo && !parent->isGlobal())))
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_BAD_CLONE_FUNOBJ_SCOPE);
|
||||
return NULL;
|
||||
|
@ -431,7 +431,7 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext *cx, Handle<PropertyName*> na
|
||||
return false;
|
||||
|
||||
RootedFunction sourceFun(cx, funVal.toObject().toFunction());
|
||||
Rooted<JSScript*> sourceScript(cx, sourceFun->script());
|
||||
Rooted<JSScript*> sourceScript(cx, sourceFun->nonLazyScript());
|
||||
JS_ASSERT(!sourceScript->enclosingStaticScope());
|
||||
RawScript cscript = CloneScript(cx, NullPtr(), targetFun, sourceScript);
|
||||
if (!cscript)
|
||||
|
@ -401,13 +401,13 @@ JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun)
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun)
|
||||
{
|
||||
return fun->script()->bindings.count() > 0;
|
||||
return fun->nonLazyScript()->bindings.count() > 0;
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(uintptr_t *)
|
||||
JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp)
|
||||
{
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
BindingVector bindings(cx);
|
||||
if (!FillBindingVector(script, &bindings))
|
||||
return NULL;
|
||||
@ -449,7 +449,7 @@ JS_PUBLIC_API(JSScript *)
|
||||
JS_GetFunctionScript(JSContext *cx, JSFunction *fun)
|
||||
{
|
||||
AutoAssertNoGC nogc;
|
||||
return fun->maybeScript().get(nogc);
|
||||
return fun->maybeNonLazyScript().get(nogc);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSNative)
|
||||
@ -1013,7 +1013,7 @@ JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun)
|
||||
size_t nbytes = sizeof *fun;
|
||||
nbytes += JS_GetObjectTotalSize(cx, fun);
|
||||
if (fun->isInterpreted())
|
||||
nbytes += JS_GetScriptTotalSize(cx, fun->script().get(nogc));
|
||||
nbytes += JS_GetScriptTotalSize(cx, fun->nonLazyScript().get(nogc));
|
||||
if (fun->displayAtom())
|
||||
nbytes += GetAtomTotalSize(cx, fun->displayAtom());
|
||||
return nbytes;
|
||||
|
@ -368,7 +368,7 @@ js::IsObjectInContextCompartment(RawObject obj, const JSContext *cx)
|
||||
JS_FRIEND_API(bool)
|
||||
js::IsOriginalScriptFunction(JSFunction *fun)
|
||||
{
|
||||
return fun->script()->function() == fun;
|
||||
return fun->nonLazyScript()->function() == fun;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSScript *)
|
||||
@ -382,7 +382,7 @@ js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext *cx)
|
||||
return NULL;
|
||||
|
||||
JSFunction *scriptedCaller = fp->fun();
|
||||
RootedScript outermost(cx, scriptedCaller->script());
|
||||
RootedScript outermost(cx, scriptedCaller->nonLazyScript());
|
||||
for (StaticScopeIter i(scriptedCaller); !i.done(); i++) {
|
||||
if (i.type() == StaticScopeIter::FUNCTION)
|
||||
outermost = i.funScript();
|
||||
|
@ -91,7 +91,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
|
||||
* check any calls that were inlined.
|
||||
*/
|
||||
if (fun->isInterpreted()) {
|
||||
fun->script()->uninlineable = true;
|
||||
fun->getOrCreateScript(cx)->uninlineable = true;
|
||||
MarkTypeObjectFlags(cx, fun, OBJECT_FLAG_UNINLINEABLE);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ fun_getProperty(JSContext *cx, HandleObject obj_, HandleId id, MutableHandleValu
|
||||
if (inlined) {
|
||||
mjit::JITChunk *chunk = fp->prev()->jit()->chunk(prevpc);
|
||||
RawFunction fun = chunk->inlineFrames()[inlined->inlineIndex].fun;
|
||||
fun->script()->uninlineable = true;
|
||||
fun->nonLazyScript()->uninlineable = true;
|
||||
MarkTypeObjectFlags(cx, fun, OBJECT_FLAG_UNINLINEABLE);
|
||||
}
|
||||
}
|
||||
@ -321,7 +321,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
RootedValue v(cx);
|
||||
if (JSID_IS_ATOM(id, cx->names().length)) {
|
||||
//FIXME: bug 810715 - deal with lazy interpreted functions with default args
|
||||
uint16_t defaults = fun->hasScript() ? fun->script()->ndefaults : 0;
|
||||
uint16_t defaults = fun->hasScript() ? fun->nonLazyScript()->ndefaults : 0;
|
||||
v.setInt32(fun->nargs - defaults - fun->hasRest());
|
||||
} else {
|
||||
v.setString(fun->atom() == NULL ? cx->runtime->emptyString : fun->atom());
|
||||
@ -344,7 +344,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
|
||||
PropertyOp getter;
|
||||
StrictPropertyOp setter;
|
||||
unsigned attrs = JSPROP_PERMANENT;
|
||||
if (fun->isInterpretedLazy() && !InitializeLazyFunctionScript(cx, fun))
|
||||
if (fun->isInterpretedLazy() && !fun->getOrCreateScript(cx).unsafeGet())
|
||||
return false;
|
||||
if (fun->isInterpreted() ? fun->inStrictMode() : fun->isBoundFunction()) {
|
||||
JSObject *throwTypeError = fun->global().getThrowTypeError();
|
||||
@ -398,7 +398,7 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
firstword = !!fun->atom();
|
||||
flagsword = (fun->nargs << 16) | fun->flags;
|
||||
atom = fun->atom();
|
||||
script = fun->script();
|
||||
script = fun->nonLazyScript();
|
||||
} else {
|
||||
fun = js_NewFunction(cx, NullPtr(), NULL, 0, JSFunction::INTERPRETED, NullPtr(), NullPtr());
|
||||
if (!fun)
|
||||
@ -425,8 +425,8 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
||||
script->setFunction(fun);
|
||||
if (!JSFunction::setTypeForScriptedFunction(cx, fun))
|
||||
return false;
|
||||
JS_ASSERT(fun->nargs == fun->script()->bindings.numArgs());
|
||||
RootedScript script(cx, fun->script());
|
||||
JS_ASSERT(fun->nargs == fun->nonLazyScript()->bindings.numArgs());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
js_CallNewScriptHook(cx, script, fun);
|
||||
objp.set(fun);
|
||||
}
|
||||
@ -452,7 +452,7 @@ js::CloneInterpretedFunction(JSContext *cx, HandleObject enclosingScope, HandleF
|
||||
if (!clone)
|
||||
return NULL;
|
||||
|
||||
RootedScript srcScript(cx, srcFun->script());
|
||||
RootedScript srcScript(cx, srcFun->nonLazyScript());
|
||||
RawScript clonedScript = CloneScript(cx, enclosingScope, clone, srcScript);
|
||||
if (!clonedScript)
|
||||
return NULL;
|
||||
@ -465,25 +465,11 @@ js::CloneInterpretedFunction(JSContext *cx, HandleObject enclosingScope, HandleF
|
||||
if (!JSFunction::setTypeForScriptedFunction(cx, clone))
|
||||
return NULL;
|
||||
|
||||
RootedScript cloneScript(cx, clone->script());
|
||||
RootedScript cloneScript(cx, clone->nonLazyScript());
|
||||
js_CallNewScriptHook(cx, cloneScript, clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
bool
|
||||
js::InitializeLazyFunctionScript(JSContext *cx, HandleFunction fun)
|
||||
{
|
||||
JS_ASSERT(fun->isInterpretedLazy());
|
||||
JSFunctionSpec *fs = static_cast<JSFunctionSpec *>(fun->getExtendedSlot(0).toPrivate());
|
||||
RootedAtom funAtom(cx, Atomize(cx, fs->selfHostedName, strlen(fs->selfHostedName)));
|
||||
if (!funAtom)
|
||||
return false;
|
||||
Rooted<PropertyName *> funName(cx, funAtom->asPropertyName());
|
||||
if (!cx->runtime->cloneSelfHostedFunctionScript(cx, funName, fun))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* [[HasInstance]] internal method for Function objects: fetch the .prototype
|
||||
* property of its 'this' parameter, and walks the prototype chain of v (only
|
||||
@ -575,7 +561,7 @@ FindBody(JSContext *cx, HandleFunction fun, StableCharPtr chars, size_t length,
|
||||
// We don't need principals, since those are only used for error reporting.
|
||||
CompileOptions options(cx);
|
||||
options.setFileAndLine("internal-findBody", 0)
|
||||
.setVersion(fun->script()->getVersion());
|
||||
.setVersion(fun->nonLazyScript()->getVersion());
|
||||
TokenStream ts(cx, options, chars, length, NULL);
|
||||
JS_ASSERT(chars[0] == '(');
|
||||
int nest = 0;
|
||||
@ -626,7 +612,7 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
||||
RootedScript script(cx);
|
||||
|
||||
if (fun->hasScript()) {
|
||||
script = fun->script();
|
||||
script = fun->nonLazyScript();
|
||||
if (script->isGeneratorExp) {
|
||||
if ((!bodyOnly && !out.append("function genexp() {")) ||
|
||||
!out.append("\n [generator expression]\n") ||
|
||||
@ -1057,6 +1043,19 @@ JSFunction::getBoundFunctionArgumentCount() const
|
||||
return getSlot(JSSLOT_BOUND_FUNCTION_ARGS_COUNT).toPrivateUint32();
|
||||
}
|
||||
|
||||
bool
|
||||
JSFunction::initializeLazyScript(JSContext *cx)
|
||||
{
|
||||
JS_ASSERT(isInterpretedLazy());
|
||||
JSFunctionSpec *fs = static_cast<JSFunctionSpec *>(getExtendedSlot(0).toPrivate());
|
||||
RootedAtom funAtom(cx, Atomize(cx, fs->selfHostedName, strlen(fs->selfHostedName)));
|
||||
if (!funAtom)
|
||||
return false;
|
||||
Rooted<PropertyName *> funName(cx, funAtom->asPropertyName());
|
||||
Rooted<JSFunction*> self(cx, this);
|
||||
return cx->runtime->cloneSelfHostedFunctionScript(cx, funName, self);
|
||||
}
|
||||
|
||||
/* ES5 15.3.4.5.1 and 15.3.4.5.2. */
|
||||
JSBool
|
||||
js::CallOrConstructBoundFunction(JSContext *cx, unsigned argc, Value *vp)
|
||||
@ -1116,7 +1115,7 @@ fun_isGenerator(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
bool result = false;
|
||||
if (fun->hasScript()) {
|
||||
RawScript script = fun->script().get(nogc);
|
||||
RawScript script = fun->nonLazyScript().get(nogc);
|
||||
JS_ASSERT(script->length != 0);
|
||||
result = script->isGenerator;
|
||||
}
|
||||
@ -1484,7 +1483,7 @@ js_CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
||||
clone->nargs = fun->nargs;
|
||||
clone->flags = fun->flags & ~JSFunction::EXTENDED;
|
||||
if (fun->isInterpreted()) {
|
||||
clone->initScript(fun->script().unsafeGet());
|
||||
clone->initScript(fun->nonLazyScript().unsafeGet());
|
||||
clone->initEnvironment(parent);
|
||||
} else {
|
||||
clone->initNative(fun->native(), fun->jitInfo());
|
||||
@ -1517,7 +1516,7 @@ js_CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
||||
* no enclosing lexical scope (only the global scope).
|
||||
*/
|
||||
if (clone->isInterpreted()) {
|
||||
RootedScript script(cx, clone->script());
|
||||
RootedScript script(cx, clone->nonLazyScript());
|
||||
JS_ASSERT(script->compartment() == fun->compartment());
|
||||
JS_ASSERT_IF(script->compartment() != cx->compartment,
|
||||
!script->enclosingStaticScope());
|
||||
@ -1535,7 +1534,7 @@ js_CloneFunctionObject(JSContext *cx, HandleFunction fun, HandleObject parent,
|
||||
|
||||
GlobalObject *global = script->compileAndGo ? &script->global() : NULL;
|
||||
|
||||
script = clone->script();
|
||||
script = clone->nonLazyScript();
|
||||
js_CallNewScriptHook(cx, script, clone);
|
||||
Debugger::onNewScript(cx, script, global);
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ struct JSFunction : public JSObject
|
||||
} u;
|
||||
private:
|
||||
js::HeapPtrAtom atom_; /* name for diagnostics and decompiling */
|
||||
|
||||
bool initializeLazyScript(JSContext *cx);
|
||||
public:
|
||||
|
||||
/* A function can be classified as either native (C++) or interpreted (JS): */
|
||||
@ -176,11 +178,36 @@ struct JSFunction : public JSObject
|
||||
static inline size_t offsetOfEnvironment() { return offsetof(JSFunction, u.i.env_); }
|
||||
static inline size_t offsetOfAtom() { return offsetof(JSFunction, atom_); }
|
||||
|
||||
js::Return<JSScript*> script() const {
|
||||
js::Return<JSScript*> getOrCreateScript(JSContext *cx) {
|
||||
JS_ASSERT(isInterpreted());
|
||||
if (isInterpretedLazy()) {
|
||||
js::RootedFunction self(cx, this);
|
||||
js::MaybeCheckStackRoots(cx);
|
||||
if (!initializeLazyScript(cx))
|
||||
return js::NullPtr();
|
||||
}
|
||||
JS_ASSERT(hasScript());
|
||||
return JS::HandleScript::fromMarkedLocation(&u.i.script_);
|
||||
}
|
||||
|
||||
bool maybeGetOrCreateScript(JSContext *cx, js::MutableHandle<JSScript*> script) {
|
||||
if (isNative()) {
|
||||
script.set(NULL);
|
||||
return true;
|
||||
}
|
||||
script.set(getOrCreateScript(cx).unsafeGet());
|
||||
return hasScript();
|
||||
}
|
||||
|
||||
js::Return<JSScript*> nonLazyScript() const {
|
||||
JS_ASSERT(hasScript());
|
||||
return JS::HandleScript::fromMarkedLocation(&u.i.script_);
|
||||
}
|
||||
|
||||
js::Return<JSScript*> maybeNonLazyScript() const {
|
||||
return isInterpreted() ? nonLazyScript() : JS::NullPtr();
|
||||
}
|
||||
|
||||
js::HeapPtrScript &mutableScript() {
|
||||
JS_ASSERT(isInterpreted());
|
||||
return *(js::HeapPtrScript *)&u.i.script_;
|
||||
@ -189,10 +216,6 @@ struct JSFunction : public JSObject
|
||||
inline void setScript(JSScript *script_);
|
||||
inline void initScript(JSScript *script_);
|
||||
|
||||
js::Return<JSScript*> maybeScript() const {
|
||||
return isInterpreted() ? script() : JS::NullPtr();
|
||||
}
|
||||
|
||||
JSNative native() const {
|
||||
JS_ASSERT(isNative());
|
||||
return u.n.native;
|
||||
@ -344,9 +367,6 @@ XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope,
|
||||
extern JSObject *
|
||||
CloneInterpretedFunction(JSContext *cx, HandleObject enclosingScope, HandleFunction fun);
|
||||
|
||||
bool
|
||||
InitializeLazyFunctionScript(JSContext *cx, HandleFunction fun);
|
||||
|
||||
/*
|
||||
* Report an error that call.thisv is not compatible with the specified class,
|
||||
* assuming that the method (clasp->name).prototype.<name of callee function>
|
||||
|
@ -19,7 +19,7 @@
|
||||
inline bool
|
||||
JSFunction::inStrictMode() const
|
||||
{
|
||||
return script()->strictModeCode;
|
||||
return nonLazyScript()->strictModeCode;
|
||||
}
|
||||
|
||||
inline void
|
||||
|
@ -1320,13 +1320,9 @@ TypeConstraintCall::newType(JSContext *cx, TypeSet *source, Type type)
|
||||
return;
|
||||
}
|
||||
|
||||
if (callee->isInterpretedLazy()) {
|
||||
RootedFunction fun(cx, callee);
|
||||
if (!InitializeLazyFunctionScript(cx, fun))
|
||||
return;
|
||||
}
|
||||
|
||||
RootedScript calleeScript(cx, callee->script());
|
||||
RootedScript calleeScript(cx, callee->getOrCreateScript(cx));
|
||||
if (!calleeScript)
|
||||
return;
|
||||
if (!calleeScript->ensureHasTypes(cx))
|
||||
return;
|
||||
|
||||
@ -1403,16 +1399,10 @@ TypeConstraintPropagateThis::newType(JSContext *cx, TypeSet *source, Type type)
|
||||
return;
|
||||
}
|
||||
|
||||
if (callee->isInterpretedLazy()) {
|
||||
RootedFunction fun(cx, callee);
|
||||
if (!InitializeLazyFunctionScript(cx, fun))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!callee->script()->ensureHasTypes(cx))
|
||||
if (!(callee->getOrCreateScript(cx).unsafeGet() && callee->nonLazyScript()->ensureHasTypes(cx)))
|
||||
return;
|
||||
|
||||
TypeSet *thisTypes = TypeScript::ThisTypes(callee->script().unsafeGet());
|
||||
TypeSet *thisTypes = TypeScript::ThisTypes(callee->nonLazyScript().unsafeGet());
|
||||
if (this->types)
|
||||
this->types->addSubset(cx, thisTypes);
|
||||
else
|
||||
@ -3396,7 +3386,7 @@ TypeObject::setFlags(JSContext *cx, TypeObjectFlags flags)
|
||||
if (singleton) {
|
||||
/* Make sure flags are consistent with persistent object state. */
|
||||
JS_ASSERT_IF(flags & OBJECT_FLAG_UNINLINEABLE,
|
||||
interpretedFunction->script()->uninlineable);
|
||||
interpretedFunction->nonLazyScript()->uninlineable);
|
||||
JS_ASSERT_IF(flags & OBJECT_FLAG_ITERATED,
|
||||
singleton->lastProperty()->hasObjectFlag(BaseShape::ITERATED_SINGLETON));
|
||||
}
|
||||
@ -4636,7 +4626,7 @@ AnalyzeNewScriptProperties(JSContext *cx, TypeObject *type, JSFunction *fun,
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
if (!script->ensureRanAnalysis(cx) || !script->ensureRanInference(cx)) {
|
||||
pbaseobj.set(NULL);
|
||||
cx->compartment->types.setPendingNukeTypes(cx);
|
||||
@ -4774,7 +4764,7 @@ AnalyzePoppedThis(JSContext *cx, Vector<SSAUseChain *> *pendingPoppedThis,
|
||||
TypeObject *type, JSFunction *fun, MutableHandleObject pbaseobj,
|
||||
Vector<TypeNewScript::Initializer> *initializerList)
|
||||
{
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
ScriptAnalysis *analysis = script->analysis();
|
||||
|
||||
while (!pendingPoppedThis->empty()) {
|
||||
@ -5219,7 +5209,7 @@ types::TypeMonitorCallSlow(JSContext *cx, HandleObject callee, const CallArgs &a
|
||||
bool constructing)
|
||||
{
|
||||
unsigned nargs = callee->toFunction()->nargs;
|
||||
RootedScript script(cx, callee->toFunction()->script());
|
||||
RootedScript script(cx, callee->toFunction()->nonLazyScript());
|
||||
|
||||
if (!constructing)
|
||||
TypeScript::SetThis(cx, script, args.thisv());
|
||||
@ -5545,8 +5535,8 @@ JSScript::makeAnalysis(JSContext *cx)
|
||||
/* static */ bool
|
||||
JSFunction::setTypeForScriptedFunction(JSContext *cx, HandleFunction fun, bool singleton)
|
||||
{
|
||||
JS_ASSERT(fun->script().unsafeGet());
|
||||
JS_ASSERT(fun->script()->function() == fun);
|
||||
JS_ASSERT(fun->nonLazyScript().unsafeGet());
|
||||
JS_ASSERT(fun->nonLazyScript()->function() == fun);
|
||||
|
||||
if (!cx->typeInferenceEnabled())
|
||||
return true;
|
||||
@ -5696,8 +5686,7 @@ JSObject::makeLazyType(JSContext *cx)
|
||||
RootedObject self(cx, this);
|
||||
/* De-lazification of functions can GC, so we need to do it up here. */
|
||||
if (self->isFunction() && self->toFunction()->isInterpretedLazy()) {
|
||||
RootedFunction fun(cx, self->toFunction());
|
||||
if (!InitializeLazyFunctionScript(cx, fun))
|
||||
if (!self->toFunction()->getOrCreateScript(cx).unsafeGet())
|
||||
return NULL;
|
||||
}
|
||||
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(getClass());
|
||||
@ -5724,7 +5713,7 @@ JSObject::makeLazyType(JSContext *cx)
|
||||
|
||||
if (self->isFunction() && self->toFunction()->isInterpreted()) {
|
||||
type->interpretedFunction = self->toFunction();
|
||||
if (type->interpretedFunction->script()->uninlineable)
|
||||
if (type->interpretedFunction->nonLazyScript()->uninlineable)
|
||||
type->flags |= OBJECT_FLAG_UNINLINEABLE;
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ TypeMonitorCall(JSContext *cx, const js::CallArgs &args, bool constructing)
|
||||
if (callee->isFunction()) {
|
||||
JSFunction *fun = callee->toFunction();
|
||||
if (fun->isInterpreted()) {
|
||||
js::RootedScript script(cx, fun->script());
|
||||
js::RootedScript script(cx, fun->nonLazyScript());
|
||||
if (!script->ensureRanAnalysis(cx))
|
||||
return false;
|
||||
if (cx->typeInferenceEnabled())
|
||||
@ -703,7 +703,7 @@ UseNewTypeForClone(JSFunction *fun)
|
||||
* instance a singleton type and clone the underlying script.
|
||||
*/
|
||||
|
||||
RawScript script = fun->script().get(nogc);
|
||||
RawScript script = fun->nonLazyScript().get(nogc);
|
||||
|
||||
if (script->length >= 50)
|
||||
return false;
|
||||
|
@ -368,7 +368,8 @@ js::InvokeKernel(JSContext *cx, CallArgs args, MaybeConstruct construct)
|
||||
if (fun->isNative())
|
||||
return CallJSNative(cx, fun->native(), args);
|
||||
|
||||
if (fun->isInterpretedLazy() && !InitializeLazyFunctionScript(cx, fun))
|
||||
RootedScript script(cx, fun->getOrCreateScript(cx));
|
||||
if (!script)
|
||||
return false;
|
||||
|
||||
if (!TypeMonitorCall(cx, args, construct))
|
||||
@ -380,7 +381,6 @@ js::InvokeKernel(JSContext *cx, CallArgs args, MaybeConstruct construct)
|
||||
return false;
|
||||
|
||||
/* Run function until JSOP_STOP, JSOP_RETURN or error. */
|
||||
RootedScript script(cx, fun->script());
|
||||
JSBool ok = RunScript(cx, script, ifg.fp());
|
||||
|
||||
/* Propagate the return value out. */
|
||||
@ -2346,9 +2346,9 @@ BEGIN_CASE(JSOP_FUNCALL)
|
||||
|
||||
InitialFrameFlags initial = construct ? INITIAL_CONSTRUCT : INITIAL_NONE;
|
||||
bool newType = cx->typeInferenceEnabled() && UseNewType(cx, script, regs.pc);
|
||||
if (fun->isInterpretedLazy() && !InitializeLazyFunctionScript(cx, fun))
|
||||
RawScript funScript = fun->getOrCreateScript(cx).unsafeGet();
|
||||
if (!funScript)
|
||||
goto error;
|
||||
RawScript funScript = fun->script().unsafeGet();
|
||||
if (!cx->stack.pushInlineFrame(cx, regs, args, *fun, funScript, initial))
|
||||
goto error;
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ class FastInvokeGuard
|
||||
JSFunction *fun = fval.toObject().toFunction();
|
||||
if (fun->hasScript()) {
|
||||
fun_ = fun;
|
||||
script_ = fun->script();
|
||||
script_ = fun->nonLazyScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1033,7 +1033,7 @@ class FastInvokeGuard
|
||||
bool invoke(JSContext *cx) {
|
||||
#ifdef JS_ION
|
||||
if (useIon_ && fun_) {
|
||||
JS_ASSERT(fun_->script() == script_);
|
||||
JS_ASSERT(fun_->nonLazyScript() == script_);
|
||||
|
||||
ion::MethodStatus status = ion::CanEnterUsingFastInvoke(cx, script_, args_.length());
|
||||
if (status == ion::Method_Error)
|
||||
|
@ -2366,7 +2366,7 @@ js_CreateThisForFunctionWithProto(JSContext *cx, HandleObject callee, JSObject *
|
||||
}
|
||||
|
||||
if (res && cx->typeInferenceEnabled()) {
|
||||
RootedScript script(cx, callee->toFunction()->script());
|
||||
RootedScript script(cx, callee->toFunction()->nonLazyScript());
|
||||
TypeScript::SetThis(cx, script, types::Type::ObjectType(res));
|
||||
}
|
||||
|
||||
@ -2397,7 +2397,7 @@ js_CreateThisForFunction(JSContext *cx, HandleObject callee, bool newType)
|
||||
if (!JSObject::setSingletonType(cx, nobj))
|
||||
return NULL;
|
||||
|
||||
RootedScript calleeScript(cx, callee->toFunction()->script());
|
||||
RootedScript calleeScript(cx, callee->toFunction()->nonLazyScript());
|
||||
TypeScript::SetThis(cx, calleeScript, types::Type::ObjectType(nobj));
|
||||
|
||||
return nobj;
|
||||
@ -5240,7 +5240,7 @@ dumpValue(const Value &v)
|
||||
fputs("<unnamed function", stderr);
|
||||
}
|
||||
if (fun->hasScript()) {
|
||||
JSScript *script = fun->script().get(nogc);
|
||||
JSScript *script = fun->nonLazyScript().get(nogc);
|
||||
fprintf(stderr, " (%s:%u)",
|
||||
script->filename ? script->filename : "", script->lineno);
|
||||
}
|
||||
|
@ -1129,7 +1129,7 @@ js_NewPrinter(JSContext *cx, const char *name, JSFunction *fun,
|
||||
jp->localNames = NULL;
|
||||
jp->decompiledOpcodes = NULL;
|
||||
if (fun && fun->hasScript()) {
|
||||
if (!SetPrinterLocalNames(cx, fun->script().unsafeGet(), jp)) {
|
||||
if (!SetPrinterLocalNames(cx, fun->nonLazyScript().unsafeGet(), jp)) {
|
||||
js_DestroyPrinter(jp);
|
||||
return NULL;
|
||||
}
|
||||
@ -1785,7 +1785,7 @@ GetArgOrVarAtom(JSPrinter *jp, unsigned slot)
|
||||
{
|
||||
LOCAL_ASSERT_RV(jp->fun, NULL);
|
||||
LOCAL_ASSERT_RV(slot < jp->script->bindings.count(), NULL);
|
||||
LOCAL_ASSERT_RV(jp->script == jp->fun->script().unsafeGet(), NULL);
|
||||
LOCAL_ASSERT_RV(jp->script == jp->fun->nonLazyScript().unsafeGet(), NULL);
|
||||
JSAtom *name = (*jp->localNames)[slot].name();
|
||||
#if !JS_HAS_DESTRUCTURING
|
||||
LOCAL_ASSERT_RV(name, NULL);
|
||||
@ -4744,10 +4744,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
|
||||
*/
|
||||
LifoAllocScope las(&cx->tempLifoAlloc());
|
||||
outerLocalNames = jp->localNames;
|
||||
if (!SetPrinterLocalNames(cx, fun->script().unsafeGet(), jp))
|
||||
if (!SetPrinterLocalNames(cx, fun->nonLazyScript().unsafeGet(), jp))
|
||||
return NULL;
|
||||
|
||||
inner = fun->script().unsafeGet();
|
||||
inner = fun->nonLazyScript().unsafeGet();
|
||||
if (!InitSprintStack(cx, &ss2, jp, StackDepth(inner))) {
|
||||
js_delete(jp->localNames);
|
||||
jp->localNames = outerLocalNames;
|
||||
@ -5618,7 +5618,7 @@ js_DecompileFunctionBody(JSPrinter *jp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
script = jp->fun->script().unsafeGet();
|
||||
script = jp->fun->nonLazyScript().unsafeGet();
|
||||
return DecompileBody(jp, script, script->code);
|
||||
}
|
||||
|
||||
@ -5655,7 +5655,7 @@ js_DecompileFunction(JSPrinter *jp)
|
||||
jp->indent -= 4;
|
||||
js_printf(jp, "\t}");
|
||||
} else {
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
#if JS_HAS_DESTRUCTURING
|
||||
SprintStack ss(cx);
|
||||
#endif
|
||||
|
@ -665,7 +665,7 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
|
||||
/* Code the nested function's enclosing scope. */
|
||||
uint32_t funEnclosingScopeIndex = 0;
|
||||
if (mode == XDR_ENCODE) {
|
||||
StaticScopeIter ssi((*objp)->toFunction()->script()->enclosingStaticScope());
|
||||
StaticScopeIter ssi((*objp)->toFunction()->nonLazyScript()->enclosingStaticScope());
|
||||
if (ssi.done() || ssi.type() == StaticScopeIter::FUNCTION) {
|
||||
JS_ASSERT(ssi.done() == !fun);
|
||||
funEnclosingScopeIndex = UINT32_MAX;
|
||||
@ -1872,7 +1872,7 @@ JSScript::enclosingScriptsCompiledSuccessfully() const
|
||||
RawFunction fun = enclosing->toFunction();
|
||||
if (!fun->hasScript())
|
||||
return false;
|
||||
enclosing = fun->script()->enclosingScope_;
|
||||
enclosing = fun->nonLazyScript()->enclosingScope_;
|
||||
} else {
|
||||
enclosing = enclosing->asStaticBlock().enclosingStaticScope();
|
||||
}
|
||||
@ -2212,7 +2212,7 @@ js::CloneScript(JSContext *cx, HandleObject enclosingScope, HandleFunction fun,
|
||||
} else if (obj->isFunction()) {
|
||||
RootedFunction innerFun(cx, obj->toFunction());
|
||||
|
||||
StaticScopeIter ssi(innerFun->script()->enclosingStaticScope());
|
||||
StaticScopeIter ssi(innerFun->nonLazyScript()->enclosingStaticScope());
|
||||
RootedObject enclosingScope(cx);
|
||||
if (!ssi.done() && ssi.type() == StaticScopeIter::BLOCK)
|
||||
enclosingScope = objects[FindBlockIndex(src, ssi.block())];
|
||||
|
@ -2369,7 +2369,7 @@ LambdaIsGetElem(JSObject &lambda)
|
||||
if (!fun->hasScript())
|
||||
return NULL;
|
||||
|
||||
RawScript script = fun->script().get(nogc);
|
||||
RawScript script = fun->nonLazyScript().get(nogc);
|
||||
jsbytecode *pc = script->code;
|
||||
|
||||
/*
|
||||
|
@ -295,7 +295,7 @@ mjit::Compiler::scanInlineCalls(uint32_t index, uint32_t depth)
|
||||
okay = false;
|
||||
break;
|
||||
}
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
|
||||
/*
|
||||
* Don't inline calls to scripts which haven't been analyzed.
|
||||
@ -394,7 +394,7 @@ mjit::Compiler::scanInlineCalls(uint32_t index, uint32_t depth)
|
||||
continue;
|
||||
|
||||
JSFunction *fun = obj->toFunction();
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
|
||||
CompileStatus status = addInlineFrame(script, nextDepth, index, pc);
|
||||
if (status != Compile_Okay)
|
||||
|
@ -200,7 +200,7 @@ stubs::FixupArity(VMFrame &f, uint32_t nactual)
|
||||
*/
|
||||
InitialFrameFlags initial = oldfp->initialFlags();
|
||||
RootedFunction fun(cx, oldfp->fun());
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
void *ncode = oldfp->nativeReturnAddress();
|
||||
|
||||
/* Pop the inline frame. */
|
||||
@ -285,11 +285,10 @@ UncachedInlineCall(VMFrame &f, InitialFrameFlags initial,
|
||||
CallArgs args = CallArgsFromSp(argc, f.regs.sp);
|
||||
RootedFunction newfun(cx, args.callee().toFunction());
|
||||
|
||||
if (newfun->isInterpretedLazy() && !InitializeLazyFunctionScript(cx, newfun))
|
||||
RootedScript newscript(cx, newfun->getOrCreateScript(cx));
|
||||
if (!newscript)
|
||||
return false;
|
||||
|
||||
RootedScript newscript(cx, newfun->script());
|
||||
|
||||
bool construct = InitialFrameFlagsAreConstructing(initial);
|
||||
|
||||
RootedScript fscript(cx, f.script());
|
||||
|
@ -1069,7 +1069,7 @@ VMFrame::script()
|
||||
{
|
||||
AutoAssertNoGC nogc;
|
||||
if (regs.inlined())
|
||||
return chunk()->inlineFrames()[regs.inlined()->inlineIndex].fun->script();
|
||||
return chunk()->inlineFrames()[regs.inlined()->inlineIndex].fun->nonLazyScript();
|
||||
return fp()->script();
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1001,7 @@ class CallCompiler : public BaseCompiler
|
||||
/* Guard that it's the same script. */
|
||||
Address scriptAddr(ic.funObjReg, JSFunction::offsetOfNativeOrScript());
|
||||
Jump funGuard = masm.branchPtr(Assembler::NotEqual, scriptAddr,
|
||||
ImmPtr(obj->toFunction()->script().get(nogc)));
|
||||
ImmPtr(obj->toFunction()->nonLazyScript().get(nogc)));
|
||||
Jump done = masm.jump();
|
||||
|
||||
LinkerHelper linker(masm, JSC::JAEGER_CODE);
|
||||
@ -1250,7 +1250,7 @@ class CallCompiler : public BaseCompiler
|
||||
!ic.hasIonStub() &&
|
||||
ic.frameSize.isStatic() &&
|
||||
ic.frameSize.staticArgc() <= ion::SNAPSHOT_MAX_NARGS &&
|
||||
fun->hasScript() && fun->script()->hasIonScript())
|
||||
fun->hasScript() && fun->nonLazyScript()->hasIonScript())
|
||||
{
|
||||
if (!generateIonStub())
|
||||
THROWV(NULL);
|
||||
@ -1261,7 +1261,7 @@ class CallCompiler : public BaseCompiler
|
||||
|
||||
AutoAssertNoGC nogc;
|
||||
JS_ASSERT(fun);
|
||||
JSScript *script = fun->script().get(nogc);
|
||||
JSScript *script = fun->nonLazyScript().get(nogc);
|
||||
JS_ASSERT(script);
|
||||
|
||||
uint32_t flags = callingNew ? StackFrame::CONSTRUCTING : 0;
|
||||
@ -1280,7 +1280,8 @@ class CallCompiler : public BaseCompiler
|
||||
} else if (ic.fastGuardedObject &&
|
||||
!ic.hasJsFunCheck &&
|
||||
!ic.fastGuardedNative &&
|
||||
ic.fastGuardedObject->toFunction()->script() == fun->script()) {
|
||||
ic.fastGuardedObject->toFunction()->nonLazyScript() == fun->nonLazyScript())
|
||||
{
|
||||
/*
|
||||
* Note: Multiple "function guard" stubs are not yet
|
||||
* supported, thus the fastGuardedNative check.
|
||||
@ -1432,7 +1433,7 @@ ic::GenerateArgumentCheckStub(VMFrame &f)
|
||||
JITScript *jit = f.jit();
|
||||
StackFrame *fp = f.fp();
|
||||
JSFunction *fun = fp->fun();
|
||||
JSScript *script = fun->script().get(nogc);
|
||||
JSScript *script = fun->nonLazyScript().get(nogc);
|
||||
|
||||
if (jit->argsCheckPool)
|
||||
jit->resetArgsCheck();
|
||||
|
@ -2217,7 +2217,7 @@ frameCountersOffset(VMFrame &f)
|
||||
uint32_t index = cx->regs().inlined()->inlineIndex;
|
||||
InlineFrame *frames = f.chunk()->inlineFrames();
|
||||
for (unsigned i = 0; i < index; i++)
|
||||
offset += frames[i].fun->script()->length;
|
||||
offset += frames[i].fun->nonLazyScript()->length;
|
||||
}
|
||||
|
||||
jsbytecode *pc;
|
||||
|
@ -250,7 +250,7 @@ Recompiler::expandInlineFrames(JSCompartment *compartment,
|
||||
uint8_t* codeStart = (uint8_t *)chunk->code.m_code.executableAddress();
|
||||
|
||||
InlineFrame *inner = &chunk->inlineFrames()[inlined->inlineIndex];
|
||||
jsbytecode *innerpc = inner->fun->script()->code + inlined->pcOffset;
|
||||
jsbytecode *innerpc = inner->fun->nonLazyScript()->code + inlined->pcOffset;
|
||||
|
||||
StackFrame *innerfp = expandInlineFrameChain(fp, inner);
|
||||
|
||||
|
@ -1623,7 +1623,7 @@ stubs::CheckArgumentTypes(VMFrame &f)
|
||||
{
|
||||
StackFrame *fp = f.fp();
|
||||
JSFunction *fun = fp->fun();
|
||||
RootedScript fscript(f.cx, fun->script());
|
||||
RootedScript fscript(f.cx, fun->nonLazyScript());
|
||||
RecompilationMonitor monitor(f.cx);
|
||||
|
||||
{
|
||||
@ -1651,7 +1651,7 @@ stubs::AssertArgumentTypes(VMFrame &f)
|
||||
AutoAssertNoGC nogc;
|
||||
StackFrame *fp = f.fp();
|
||||
JSFunction *fun = fp->fun();
|
||||
RawScript script = fun->script().get(nogc);
|
||||
RawScript script = fun->nonLazyScript().get(nogc);
|
||||
|
||||
/*
|
||||
* Don't check the type of 'this' for constructor frames, the 'this' value
|
||||
|
@ -1456,7 +1456,8 @@ ValueToScript(JSContext *cx, jsval v, JSFunction **funp = NULL)
|
||||
if (!fun)
|
||||
return NULL;
|
||||
|
||||
RootedScript script(cx, fun->maybeScript());
|
||||
RootedScript script(cx);
|
||||
fun->maybeGetOrCreateScript(cx, &script);
|
||||
if (!script)
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_SCRIPTS_ONLY);
|
||||
|
||||
@ -1924,8 +1925,9 @@ DisassembleScript(JSContext *cx, JSScript *script_, JSFunction *fun, bool lines,
|
||||
if (obj->isFunction()) {
|
||||
Sprint(sp, "\n");
|
||||
RawFunction fun = obj->toFunction();
|
||||
RawScript nested = fun->maybeScript().unsafeGet();
|
||||
if (!DisassembleScript(cx, nested, fun, lines, recursive, sp))
|
||||
RootedScript script(cx);
|
||||
fun->maybeGetOrCreateScript(cx, &script);
|
||||
if (!DisassembleScript(cx, script.get(), fun, lines, recursive, sp))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2351,7 +2353,7 @@ Clone(JSContext *cx, unsigned argc, jsval *vp)
|
||||
}
|
||||
if (funobj->compartment() != cx->compartment) {
|
||||
JSFunction *fun = funobj->toFunction();
|
||||
if (fun->hasScript() && fun->script()->compileAndGo) {
|
||||
if (fun->hasScript() && fun->nonLazyScript()->compileAndGo) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
|
||||
"function", "compile-and-go");
|
||||
return false;
|
||||
|
@ -74,7 +74,7 @@ ArgumentsObject::element(uint32_t i) const
|
||||
const Value &v = data()->args[i];
|
||||
if (v.isMagic(JS_FORWARD_TO_CALL_OBJECT)) {
|
||||
CallObject &callobj = getFixedSlot(MAYBE_CALL_SLOT).toObject().asCall();
|
||||
for (AliasedFormalIter fi(callobj.callee().script().get(nogc)); ; fi++) {
|
||||
for (AliasedFormalIter fi(callobj.callee().nonLazyScript().get(nogc)); ; fi++) {
|
||||
if (fi.frameIndex() == i)
|
||||
return callobj.aliasedVar(fi);
|
||||
}
|
||||
@ -90,7 +90,7 @@ ArgumentsObject::setElement(uint32_t i, const Value &v)
|
||||
HeapValue &lhs = data()->args[i];
|
||||
if (lhs.isMagic(JS_FORWARD_TO_CALL_OBJECT)) {
|
||||
CallObject &callobj = getFixedSlot(MAYBE_CALL_SLOT).toObject().asCall();
|
||||
for (AliasedFormalIter fi(callobj.callee().script().get(nogc)); ; fi++) {
|
||||
for (AliasedFormalIter fi(callobj.callee().nonLazyScript().get(nogc)); ; fi++) {
|
||||
if (fi.frameIndex() == i) {
|
||||
callobj.setAliasedVar(fi, v);
|
||||
return;
|
||||
|
@ -2731,7 +2731,7 @@ DebuggerScript_getChildScripts(JSContext *cx, unsigned argc, Value *vp)
|
||||
obj = objects->vector[i];
|
||||
if (obj->isFunction()) {
|
||||
fun = static_cast<JSFunction *>(obj.get());
|
||||
funScript = fun->script();
|
||||
funScript = fun->nonLazyScript();
|
||||
s = dbg->wrapScript(cx, funScript);
|
||||
if (!s || !js_NewbornArrayPush(cx, result, ObjectValue(*s)))
|
||||
return false;
|
||||
@ -3445,7 +3445,7 @@ DebuggerFrame_getScript(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (fp->isFunctionFrame() && !fp->isEvalFrame()) {
|
||||
JSFunction &callee = fp->callee();
|
||||
if (callee.isInterpreted()) {
|
||||
RootedScript script(cx, callee.script());
|
||||
RootedScript script(cx, callee.nonLazyScript());
|
||||
scriptObject = debug->wrapScript(cx, script);
|
||||
if (!scriptObject)
|
||||
return false;
|
||||
@ -3925,11 +3925,11 @@ DebuggerObject_getParameterNames(JSContext *cx, unsigned argc, Value *vp)
|
||||
result->ensureDenseArrayInitializedLength(cx, 0, fun->nargs);
|
||||
|
||||
if (fun->isInterpreted()) {
|
||||
JS_ASSERT(fun->nargs == fun->script()->bindings.numArgs());
|
||||
JS_ASSERT(fun->nargs == fun->nonLazyScript()->bindings.numArgs());
|
||||
|
||||
if (fun->nargs > 0) {
|
||||
BindingVector bindings(cx);
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
if (!FillBindingVector(script, &bindings))
|
||||
return false;
|
||||
for (size_t i = 0; i < fun->nargs; i++) {
|
||||
@ -3967,7 +3967,7 @@ DebuggerObject_getScript(JSContext *cx, unsigned argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
RootedObject scriptObject(cx, dbg->wrapScript(cx, script));
|
||||
if (!scriptObject)
|
||||
return false;
|
||||
|
@ -405,7 +405,7 @@ GlobalObject::initFunctionAndObjectClasses(JSContext *cx)
|
||||
* Notify any debuggers about the creation of the script for
|
||||
* |Function.prototype| -- after all initialization, for simplicity.
|
||||
*/
|
||||
RootedScript functionProtoScript(cx, functionProto->script());
|
||||
RootedScript functionProtoScript(cx, functionProto->nonLazyScript());
|
||||
js_CallNewScriptHook(cx, functionProtoScript, functionProto);
|
||||
return functionProto;
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ SPSProfiler::discardMJITCode(mjit::JITScript *jscr,
|
||||
|
||||
unregisterScript(jscr->script, chunk);
|
||||
for (unsigned i = 0; i < chunk->nInlineFrames; i++)
|
||||
unregisterScript(chunk->inlineFrames()[i].fun->script().get(nogc), chunk);
|
||||
unregisterScript(chunk->inlineFrames()[i].fun->nonLazyScript().get(nogc), chunk);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -42,7 +42,7 @@ StaticScopeIter::operator++(int)
|
||||
obj = obj->asStaticBlock().enclosingStaticScope();
|
||||
} else if (onNamedLambda || !obj->toFunction()->isNamedLambda()) {
|
||||
onNamedLambda = false;
|
||||
obj = obj->toFunction()->script()->enclosingStaticScope();
|
||||
obj = obj->toFunction()->nonLazyScript()->enclosingStaticScope();
|
||||
} else {
|
||||
onNamedLambda = true;
|
||||
}
|
||||
@ -86,7 +86,7 @@ StaticScopeIter::funScript() const
|
||||
{
|
||||
AutoAssertNoGC nogc;
|
||||
JS_ASSERT(type() == FUNCTION);
|
||||
return obj->toFunction()->script().get(nogc);
|
||||
return obj->toFunction()->nonLazyScript().get(nogc);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -1040,7 +1040,7 @@ ScopeIter::settle()
|
||||
CallObject &callobj = cur_->asCall();
|
||||
type_ = callobj.isForEval() ? StrictEvalScope : Call;
|
||||
hasScopeObject_ = true;
|
||||
JS_ASSERT_IF(type_ == Call, callobj.callee().script() == fp_->script());
|
||||
JS_ASSERT_IF(type_ == Call, callobj.callee().nonLazyScript() == fp_->script());
|
||||
} else {
|
||||
JS_ASSERT(!cur_->isScope());
|
||||
JS_ASSERT(fp_->isGlobalFrame() || fp_->isDebuggerFrame());
|
||||
@ -1122,7 +1122,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
/* Handle unaliased formals, vars, and consts at function scope. */
|
||||
if (scope->isCall() && !scope->asCall().isForEval()) {
|
||||
CallObject &callobj = scope->asCall();
|
||||
RootedScript script(cx, callobj.callee().script());
|
||||
RootedScript script(cx, callobj.callee().nonLazyScript());
|
||||
if (!script->ensureHasTypes(cx))
|
||||
return false;
|
||||
|
||||
@ -1247,7 +1247,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
static bool isMissingArgumentsBinding(ScopeObject &scope)
|
||||
{
|
||||
return isFunctionScope(scope) &&
|
||||
!scope.asCall().callee().script()->argumentsHasVarBinding();
|
||||
!scope.asCall().callee().nonLazyScript()->argumentsHasVarBinding();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1265,7 +1265,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
if (!isArguments(cx, id) || !isFunctionScope(scope))
|
||||
return true;
|
||||
|
||||
if (scope.asCall().callee().script()->needsArgsObj())
|
||||
if (scope.asCall().callee().nonLazyScript()->needsArgsObj())
|
||||
return true;
|
||||
|
||||
StackFrame *maybefp = cx->runtime->debugScopes->hasLiveFrame(scope);
|
||||
@ -1399,7 +1399,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
* they must be manually appended here.
|
||||
*/
|
||||
if (scope.isCall() && !scope.asCall().isForEval()) {
|
||||
RootedScript script(cx, scope.asCall().callee().script());
|
||||
RootedScript script(cx, scope.asCall().callee().nonLazyScript());
|
||||
for (BindingIter bi(script); bi; bi++) {
|
||||
if (!bi->aliased() && !props.append(NameToId(bi->name())))
|
||||
return false;
|
||||
@ -1438,7 +1438,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
||||
* a manual search is necessary.
|
||||
*/
|
||||
if (!found && scope->isCall() && !scope->asCall().isForEval()) {
|
||||
RootedScript script(cx, scope->asCall().callee().script());
|
||||
RootedScript script(cx, scope->asCall().callee().nonLazyScript());
|
||||
for (BindingIter bi(script); bi; bi++) {
|
||||
if (!bi->aliased() && NameToId(bi->name()) == id) {
|
||||
found = true;
|
||||
|
@ -139,7 +139,7 @@ StackFrame::initCallFrame(JSContext *cx, JSFunction &callee,
|
||||
LOWERED_CALL_APPLY |
|
||||
OVERFLOW_ARGS |
|
||||
UNDERFLOW_ARGS)) == 0);
|
||||
JS_ASSERT(callee.script() == script);
|
||||
JS_ASSERT(callee.nonLazyScript() == script);
|
||||
|
||||
/* Initialize stack frame members. */
|
||||
flags_ = FUNCTION | HAS_PREVPC | HAS_SCOPECHAIN | HAS_BLOCKCHAIN | flagsArg;
|
||||
@ -413,7 +413,7 @@ ContextStack::getCallFrame(JSContext *cx, MaybeReportError report, const CallArg
|
||||
JSFunction *fun, JSScript *script, StackFrame::Flags *flags) const
|
||||
{
|
||||
AssertCanGC();
|
||||
JS_ASSERT(fun->script() == script);
|
||||
JS_ASSERT(fun->nonLazyScript() == script);
|
||||
unsigned nformal = fun->nargs;
|
||||
|
||||
Value *firstUnused = args.end();
|
||||
@ -458,7 +458,7 @@ ContextStack::pushInlineFrame(JSContext *cx, FrameRegs ®s, const CallArgs &ar
|
||||
JS_ASSERT(onTop());
|
||||
JS_ASSERT(regs.sp == args.end());
|
||||
/* Cannot assert callee == args.callee() since this is called from LeaveTree. */
|
||||
JS_ASSERT(callee.script() == script);
|
||||
JS_ASSERT(callee.nonLazyScript() == script);
|
||||
|
||||
StackFrame::Flags flags = ToFrameFlags(initial);
|
||||
StackFrame *fp = getCallFrame(cx, report, args, &callee, script, &flags);
|
||||
@ -495,8 +495,8 @@ ContextStack::getFixupFrame(JSContext *cx, MaybeReportError report,
|
||||
{
|
||||
AssertCanGC();
|
||||
JS_ASSERT(onTop());
|
||||
JS_ASSERT(fun->script() == args.callee().toFunction()->script());
|
||||
JS_ASSERT(fun->script() == script);
|
||||
JS_ASSERT(fun->nonLazyScript() == args.callee().toFunction()->nonLazyScript());
|
||||
JS_ASSERT(fun->nonLazyScript() == script);
|
||||
|
||||
StackFrame::Flags flags = ToFrameFlags(initial);
|
||||
StackFrame *fp = getCallFrame(cx, report, args, fun, script, &flags);
|
||||
@ -564,7 +564,7 @@ ContextStack::currentScript(jsbytecode **ppc,
|
||||
mjit::JITChunk *chunk = fp->jit()->chunk(regs.pc);
|
||||
JS_ASSERT(inlined->inlineIndex < chunk->nInlineFrames);
|
||||
mjit::InlineFrame *frame = &chunk->inlineFrames()[inlined->inlineIndex];
|
||||
RawScript script = frame->fun->script().get(nogc);
|
||||
RawScript script = frame->fun->nonLazyScript().get(nogc);
|
||||
if (!allowCrossCompartment && script->compartment() != cx_->compartment)
|
||||
return NULL;
|
||||
if (ppc)
|
||||
|
@ -249,7 +249,7 @@ AssertDynamicScopeMatchesStaticScope(JSScript *script, JSObject *scope)
|
||||
scope = &scope->asClonedBlock().enclosingScope();
|
||||
break;
|
||||
case StaticScopeIter::FUNCTION:
|
||||
JS_ASSERT(scope->asCall().callee().script() == i.funScript());
|
||||
JS_ASSERT(scope->asCall().callee().nonLazyScript() == i.funScript());
|
||||
scope = &scope->asCall().enclosingScope();
|
||||
break;
|
||||
case StaticScopeIter::NAMED_LAMBDA:
|
||||
@ -363,7 +363,7 @@ StackFrame::epilogue(JSContext *cx)
|
||||
JS_ASSERT(isNonEvalFunctionFrame());
|
||||
|
||||
if (fun()->isHeavyweight())
|
||||
JS_ASSERT_IF(hasCallObj(), scopeChain()->asCall().callee().script() == script);
|
||||
JS_ASSERT_IF(hasCallObj(), scopeChain()->asCall().callee().nonLazyScript() == script);
|
||||
else
|
||||
AssertDynamicScopeMatchesStaticScope(script, scopeChain());
|
||||
|
||||
@ -903,7 +903,7 @@ ContextStack::ensureOnTop(JSContext *cx, MaybeReportError report, unsigned nvars
|
||||
|
||||
if (fun) {
|
||||
AutoCompartment ac(cx, fun);
|
||||
fun->script()->uninlineable = true;
|
||||
fun->nonLazyScript()->uninlineable = true;
|
||||
types::MarkTypeObjectFlags(cx, fun, types::OBJECT_FLAG_UNINLINEABLE);
|
||||
}
|
||||
}
|
||||
@ -991,7 +991,7 @@ ContextStack::pushInvokeFrame(JSContext *cx, MaybeReportError report,
|
||||
JS_ASSERT(onTop());
|
||||
JS_ASSERT(space().firstUnused() == args.end());
|
||||
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedScript script(cx, fun->nonLazyScript());
|
||||
|
||||
StackFrame::Flags flags = ToFrameFlags(initial);
|
||||
StackFrame *fp = getCallFrame(cx, report, args, fun, script, &flags);
|
||||
|
@ -612,7 +612,7 @@ class StackFrame
|
||||
return isFunctionFrame()
|
||||
? isEvalFrame()
|
||||
? u.evalScript
|
||||
: (JSScript*)fun()->script().unsafeGet()
|
||||
: (JSScript*)fun()->nonLazyScript().unsafeGet()
|
||||
: exec.script;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user