Bug 786801 - Fix perf regression from adab1fdcfe0a by using currentScript again (r=jorendorff)

--HG--
extra : rebase_source : e04b138fa3f68ec893e546a601318923b6655aff
This commit is contained in:
Luke Wagner 2012-09-19 15:35:42 -07:00
parent e435199147
commit 31ed2ae6c2
3 changed files with 22 additions and 12 deletions

View File

@ -2450,15 +2450,14 @@ unsigned
js_InferFlags(JSContext *cx, unsigned defaultFlags)
{
/*
* Use ScriptFrameIter since we intentionally want to look across
* compartment boundaries in the case of cross-compartment property access.
* We intentionally want to look across compartment boundaries to correctly
* handle the case of cross-compartment property access.
*/
ScriptFrameIter i(cx);
if (i.done())
jsbytecode *pc;
JSScript *script = cx->stack.currentScript(&pc, ContextStack::ALLOW_CROSS_COMPARTMENT);
if (!script)
return defaultFlags;
jsbytecode *pc = i.pc();
JSScript *script = i.script();
const JSCodeSpec *cs = &js_CodeSpec[*pc];
uint32_t format = cs->format;
unsigned flags = 0;

View File

@ -516,7 +516,8 @@ ContextStack::popFrameAfterOverflow()
}
inline JSScript *
ContextStack::currentScript(jsbytecode **ppc) const
ContextStack::currentScript(jsbytecode **ppc,
MaybeAllowCrossCompartment allowCrossCompartment) const
{
if (ppc)
*ppc = NULL;
@ -531,7 +532,7 @@ ContextStack::currentScript(jsbytecode **ppc) const
if (fp->beginsIonActivation()) {
JSScript *script = NULL;
ion::GetPcScript(cx_, &script, ppc);
if (script->compartment() != cx_->compartment)
if (!allowCrossCompartment && script->compartment() != cx_->compartment)
return NULL;
return script;
}
@ -544,7 +545,7 @@ ContextStack::currentScript(jsbytecode **ppc) const
JS_ASSERT(inlined->inlineIndex < chunk->nInlineFrames);
mjit::InlineFrame *frame = &chunk->inlineFrames()[inlined->inlineIndex];
JSScript *script = frame->fun->script();
if (script->compartment() != cx_->compartment)
if (!allowCrossCompartment && script->compartment() != cx_->compartment)
return NULL;
if (ppc)
*ppc = script->code + inlined->pcOffset;
@ -553,7 +554,7 @@ ContextStack::currentScript(jsbytecode **ppc) const
#endif
JSScript *script = fp->script();
if (script->compartment() != cx_->compartment)
if (!allowCrossCompartment && script->compartment() != cx_->compartment)
return NULL;
if (ppc)

View File

@ -1588,8 +1588,18 @@ class ContextStack
/* Pop a partially-pushed frame after hitting the limit before throwing. */
void popFrameAfterOverflow();
/* Get the topmost script and optional pc on the stack. */
inline JSScript *currentScript(jsbytecode **pc = NULL) const;
/*
* Get the topmost script and optional pc on the stack. By default, this
* function only returns a JSScript in the current compartment, returning
* NULL if the current script is in a different compartment. This behavior
* can be overridden by passing ALLOW_CROSS_COMPARTMENT.
*/
enum MaybeAllowCrossCompartment {
DONT_ALLOW_CROSS_COMPARTMENT = false,
ALLOW_CROSS_COMPARTMENT = true
};
inline JSScript *currentScript(jsbytecode **pc = NULL,
MaybeAllowCrossCompartment = DONT_ALLOW_CROSS_COMPARTMENT) const;
/* Get the scope chain for the topmost scripted call on the stack. */
inline HandleObject currentScriptedScopeChain() const;