Bug 822831 - Do not use Unrooted in a signal handler. r=billm
☠☠ backed out by 86a66542eaaf ☠ ☠
authorSteve Fink <sfink@mozilla.com>
Tue, 18 Dec 2012 17:33:25 -0800
changeset 125594 f7fee43555d8239fd483ea0efc66a0fefe4cd6f2
parent 125593 39bf5d23ebe9fdc8db946c2f2d37e2d536245d6e
child 125595 86a66542eaaff9858b2b2c69553f18bd194c18c8
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs822831
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 822831 - Do not use Unrooted in a signal handler. r=billm
js/src/jsdbgapi.cpp
js/src/jsdbgapi.h
js/src/jsfriendapi.h
js/src/vm/SPSProfiler.cpp
js/src/vm/SPSProfiler.h
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -321,17 +321,17 @@ JS_ClearAllWatchPoints(JSContext *cx)
             wpmap->clear();
     }
     return true;
 }
 
 /************************************************************************/
 
 JS_PUBLIC_API(unsigned)
-JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc)
+JS_PCToLineNumber(JSContext *cx, RawScript script, jsbytecode *pc)
 {
     return js::PCToLineNumber(script, pc);
 }
 
 JS_PUBLIC_API(jsbytecode *)
 JS_LineNumberToPC(JSContext *cx, JSScript *script, unsigned lineno)
 {
     return js_LineNumberToPC(script, lineno);
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -136,18 +136,19 @@ JS_ClearWatchPoint(JSContext *cx, JSObje
 extern JS_PUBLIC_API(JSBool)
 JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
 JS_ClearAllWatchPoints(JSContext *cx);
 
 /************************************************************************/
 
+// RawScript because this needs to be callable from a signal handler
 extern JS_PUBLIC_API(unsigned)
-JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
+JS_PCToLineNumber(JSContext *cx, RawScript script, jsbytecode *pc);
 
 extern JS_PUBLIC_API(jsbytecode *)
 JS_LineNumberToPC(JSContext *cx, JSScript *script, unsigned lineno);
 
 extern JS_PUBLIC_API(jsbytecode *)
 JS_EndPC(JSContext *cx, JSScript *script);
 
 extern JS_PUBLIC_API(JSBool)
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -672,18 +672,20 @@ class ProfileEntry
 
 JS_FRIEND_API(void)
 SetRuntimeProfilingStack(JSRuntime *rt, ProfileEntry *stack, uint32_t *size,
                          uint32_t max);
 
 JS_FRIEND_API(void)
 EnableRuntimeProfilingStack(JSRuntime *rt, bool enabled);
 
+// Use RawScript rather than UnrootedScript because it may be called from a
+// signal handler
 JS_FRIEND_API(jsbytecode*)
-ProfilingGetPC(JSRuntime *rt, JSScript *script, void *ip);
+ProfilingGetPC(JSRuntime *rt, RawScript script, void *ip);
 
 #ifdef JS_THREADSAFE
 JS_FRIEND_API(void *)
 GetOwnerThread(const JSContext *cx);
 
 JS_FRIEND_API(bool)
 ContextHasOutstandingRequests(const JSContext *cx);
 #endif
--- a/js/src/vm/SPSProfiler.cpp
+++ b/js/src/vm/SPSProfiler.cpp
@@ -218,18 +218,20 @@ JMChunkInfo::JMChunkInfo(mjit::JSActiveF
   : mainStart(frame->mainCodeStart),
     mainEnd(frame->mainCodeEnd),
     stubStart(frame->stubCodeStart),
     stubEnd(frame->stubCodeEnd),
     pcLengths(pcLengths),
     chunk(chunk)
 {}
 
+// Use RawScript instead of UnrootedScript because this may be called from a
+// signal handler
 jsbytecode*
-SPSProfiler::ipToPC(UnrootedScript script, size_t ip)
+SPSProfiler::ipToPC(RawScript script, size_t ip)
 {
     if (!jminfo.initialized())
         return NULL;
 
     JITInfoMap::Ptr ptr = jminfo.lookup(script);
     if (!ptr)
         return NULL;
     JMScriptInfo *info = ptr->value;
--- a/js/src/vm/SPSProfiler.h
+++ b/js/src/vm/SPSProfiler.h
@@ -229,26 +229,26 @@ class SPSProfiler
 
     bool registerMJITCode(mjit::JITChunk *chunk,
                           mjit::JSActiveFrame *outerFrame,
                           mjit::JSActiveFrame **inlineFrames);
     void discardMJITCode(mjit::JITScript *jscr,
                          mjit::JITChunk *chunk, void* address);
     bool registerICCode(mjit::JITChunk *chunk, UnrootedScript script, jsbytecode* pc,
                         void *start, size_t size);
-    jsbytecode *ipToPC(UnrootedScript script, size_t ip);
+    jsbytecode *ipToPC(RawScript script, size_t ip);
 
   private:
     JMChunkInfo *registerScript(mjit::JSActiveFrame *frame,
                                 mjit::PCLengthEntry *lenths,
                                 mjit::JITChunk *chunk);
     void unregisterScript(UnrootedScript script, mjit::JITChunk *chunk);
   public:
 #else
-    jsbytecode *ipToPC(UnrootedScript script, size_t ip) { return NULL; }
+    jsbytecode *ipToPC(RawScript script, size_t ip) { return NULL; }
 #endif
 
     void setProfilingStack(ProfileEntry *stack, uint32_t *size, uint32_t max);
     const char *profileString(JSContext *cx, UnrootedScript script, UnrootedFunction maybeFun);
     void onScriptFinalized(UnrootedScript script);
 
     /* meant to be used for testing, not recommended to call in normal code */
     size_t stringsCount() { return strings.count(); }