Bug 650161 - Allow JS_GetScriptFilename() to work while we are compacting r=terrence

This commit is contained in:
Jon Coppeard 2014-10-03 10:04:19 +01:00
parent 43b5e6a717
commit 40ba5d1f27
3 changed files with 11 additions and 1 deletions

View File

@ -1176,6 +1176,11 @@ JSScript::scriptSource() const {
return scriptSourceUnwrap().source();
}
js::ScriptSource *
JSScript::maybeForwardedScriptSource() const {
return UncheckedUnwrap(MaybeForwarded(sourceObject()))->as<ScriptSourceObject>().source();
}
bool
JSScript::initScriptCounts(JSContext *cx)
{

View File

@ -1410,8 +1410,10 @@ class JSScript : public js::gc::TenuredCell
}
js::ScriptSourceObject &scriptSourceUnwrap() const;
js::ScriptSource *scriptSource() const;
js::ScriptSource *maybeForwardedScriptSource() const;
bool mutedErrors() const { return scriptSource()->mutedErrors(); }
const char *filename() const { return scriptSource()->filename(); }
const char *maybeForwardedFilename() const { return maybeForwardedScriptSource()->filename(); }
public:

View File

@ -129,7 +129,10 @@ JS_GetFunctionScript(JSContext *cx, HandleFunction fun)
JS_PUBLIC_API(const char *)
JS_GetScriptFilename(JSScript *script)
{
return script->filename();
// This is called from ThreadStackHelper which can be called from another
// thread or inside a signal hander, so we need to be careful in case a
// copmacting GC is currently moving things around.
return script->maybeForwardedFilename();
}
JS_PUBLIC_API(const char16_t *)