From 40ba5d1f27eefc92e1813357433b5e1f294b0695 Mon Sep 17 00:00:00 2001 From: Jon Coppeard Date: Fri, 3 Oct 2014 10:04:19 +0100 Subject: [PATCH] Bug 650161 - Allow JS_GetScriptFilename() to work while we are compacting r=terrence --- js/src/jsscript.cpp | 5 +++++ js/src/jsscript.h | 2 ++ js/src/vm/OldDebugAPI.cpp | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index c82c9e8d603d..46879cac4586 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -1176,6 +1176,11 @@ JSScript::scriptSource() const { return scriptSourceUnwrap().source(); } +js::ScriptSource * +JSScript::maybeForwardedScriptSource() const { + return UncheckedUnwrap(MaybeForwarded(sourceObject()))->as().source(); +} + bool JSScript::initScriptCounts(JSContext *cx) { diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 0b0c6e8141e8..11d77afcef76 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -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: diff --git a/js/src/vm/OldDebugAPI.cpp b/js/src/vm/OldDebugAPI.cpp index 209e9ca0d551..392b4126618d 100644 --- a/js/src/vm/OldDebugAPI.cpp +++ b/js/src/vm/OldDebugAPI.cpp @@ -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 *)