зеркало из https://github.com/mozilla/gecko-dev.git
Bug 804558 - Make JSScript::loadSource GC-safe. r=terrence
This commit is contained in:
Родитель
f370bc35f7
Коммит
04b113155e
|
@ -620,8 +620,12 @@ JSString *
|
|||
js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lambdaParen)
|
||||
{
|
||||
StringBuffer out(cx);
|
||||
RootedScript script(cx);
|
||||
|
||||
if (fun->isInterpreted() && fun->script()->isGeneratorExp) {
|
||||
if (fun->isInterpreted())
|
||||
script = fun->script();
|
||||
|
||||
if (fun->isInterpreted() && script->isGeneratorExp) {
|
||||
if ((!bodyOnly && !out.append("function genexp() {")) ||
|
||||
!out.append("\n [generator expression]\n") ||
|
||||
(!bodyOnly && !out.append("}"))) {
|
||||
|
@ -643,13 +647,12 @@ js::FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lamb
|
|||
}
|
||||
}
|
||||
bool haveSource = fun->isInterpreted() && !fun->isSelfHostedBuiltin();
|
||||
if (haveSource && !fun->script()->scriptSource()->hasSourceData() &&
|
||||
!fun->script()->loadSource(cx, &haveSource))
|
||||
if (haveSource && !script->scriptSource()->hasSourceData() &&
|
||||
!JSScript::loadSource(cx, script, &haveSource))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (haveSource) {
|
||||
RootedScript script(cx, fun->script());
|
||||
RootedString srcStr(cx, script->sourceData(cx));
|
||||
if (!srcStr)
|
||||
return NULL;
|
||||
|
|
|
@ -1041,20 +1041,20 @@ JSScript::setScriptSource(ScriptSource *ss)
|
|||
scriptSource_ = ss;
|
||||
}
|
||||
|
||||
bool
|
||||
JSScript::loadSource(JSContext *cx, bool *worked)
|
||||
/* static */ bool
|
||||
JSScript::loadSource(JSContext *cx, HandleScript script, bool *worked)
|
||||
{
|
||||
JS_ASSERT(!scriptSource_->hasSourceData());
|
||||
JS_ASSERT(!script->scriptSource_->hasSourceData());
|
||||
*worked = false;
|
||||
if (!cx->runtime->sourceHook || !scriptSource_->sourceRetrievable())
|
||||
if (!cx->runtime->sourceHook || !script->scriptSource_->sourceRetrievable())
|
||||
return true;
|
||||
jschar *src = NULL;
|
||||
uint32_t length;
|
||||
if (!cx->runtime->sourceHook(cx, this, &src, &length))
|
||||
if (!cx->runtime->sourceHook(cx, script, &src, &length))
|
||||
return false;
|
||||
if (!src)
|
||||
return true;
|
||||
ScriptSource *ss = scriptSource();
|
||||
ScriptSource *ss = script->scriptSource();
|
||||
ss->setSource(src, length);
|
||||
*worked = true;
|
||||
return true;
|
||||
|
|
|
@ -575,7 +575,7 @@ struct JSScript : public js::gc::Cell
|
|||
|
||||
JSFlatString *sourceData(JSContext *cx);
|
||||
|
||||
bool loadSource(JSContext *cx, bool *worked);
|
||||
static bool loadSource(JSContext *cx, js::HandleScript scr, bool *worked);
|
||||
|
||||
js::ScriptSource *scriptSource() {
|
||||
return scriptSource_;
|
||||
|
|
Загрузка…
Ссылка в новой задаче