Bug 898263 (part 4) - Move |JSTrapStatus| and related function typedefs out of jsprvtd.h. r=jorendorff.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 08 Aug 2013 21:30:15 -0700
changeset 142126 23451f2c9946d471b5f15362cb649ec64107e93e
parent 142125 f376300694fb4a9343c5cbf3a5c7de3470eb87c7
child 142127 46859f60fd6335653a9274172f447dd468a58273
push id25084
push usercbook@mozilla.com
push dateMon, 12 Aug 2013 09:28:56 +0000
treeherdermozilla-central@f057fca09627 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs898263
milestone26.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 898263 (part 4) - Move |JSTrapStatus| and related function typedefs out of jsprvtd.h. r=jorendorff.
dom/base/nsJSEnvironment.cpp
js/src/jsdbgapi.cpp
js/src/jsdbgapi.h
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsprvtd.h
js/src/jswatchpoint.h
js/src/vm/Runtime.h
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -38,31 +38,30 @@
 #include "nsIContent.h"
 #include "nsCycleCollector.h"
 #include "nsNetUtil.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsIXULRuntime.h"
 
 #include "xpcpublic.h"
 
-#include "jsdbgapi.h"           // for JS_ClearWatchPointsForObject
+#include "jsdbgapi.h"
 #include "jswrapper.h"
 #include "nsIArray.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "prmem.h"
 #include "WrapperFactory.h"
 #include "nsGlobalWindow.h"
 #include "nsScriptNameSpaceManager.h"
 #include "StructuredCloneTags.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ImageDataBinding.h"
 
 #include "nsJSPrincipals.h"
-#include "jsdbgapi.h"
 
 #ifdef XP_MACOSX
 // AssertMacros.h defines 'check' and conflicts with AccessCheck.h
 #undef check
 #endif
 #include "AccessCheck.h"
 
 #ifdef MOZ_JSDEBUGGER
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -925,24 +925,40 @@ JS_DumpCompartmentPCCounts(JSContext *cx
                 fprintf(stdout, "--- END Asm.js Module ---\n");
             }
         }
     }
 #endif
 }
 
 JS_FRIEND_API(bool)
+js::CanCallContextDebugHandler(JSContext *cx)
+{
+    return !!cx->runtime()->debugHooks.debuggerHandler;
+}
+
+static JSTrapStatus
+CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval)
+{
+    if (!cx->runtime()->debugHooks.debuggerHandler)
+        return JSTRAP_RETURN;
+
+    return cx->runtime()->debugHooks.debuggerHandler(cx, script, bc, rval,
+                                                     cx->runtime()->debugHooks.debuggerHandlerData);
+}
+
+JS_FRIEND_API(bool)
 js_CallContextDebugHandler(JSContext *cx)
 {
     NonBuiltinScriptFrameIter iter(cx);
     JS_ASSERT(!iter.done());
 
     RootedValue rval(cx);
     RootedScript script(cx, iter.script());
-    switch (js::CallContextDebugHandler(cx, script, iter.pc(), rval.address())) {
+    switch (CallContextDebugHandler(cx, script, iter.pc(), rval.address())) {
       case JSTRAP_ERROR:
         JS_ClearPendingException(cx);
         return false;
       case JSTRAP_THROW:
         JS_SetPendingException(cx, rval);
         return false;
       case JSTRAP_RETURN:
       case JSTRAP_CONTINUE:
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jsdbgapi_h
 #define jsdbgapi_h
+
 /*
  * JS debugger API.
  */
 
 #include "jsprvtd.h"
 
 namespace js { class StackFrame; }
 
@@ -44,16 +45,65 @@ FormatStackDump(JSContext *cx, char *buf
 JS_FRIEND_API(void) js_DumpValue(const js::Value &val);
 JS_FRIEND_API(void) js_DumpId(jsid id);
 JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL);
 # endif
 
 JS_FRIEND_API(void)
 js_DumpBacktrace(JSContext *cx);
 
+typedef enum JSTrapStatus {
+    JSTRAP_ERROR,
+    JSTRAP_CONTINUE,
+    JSTRAP_RETURN,
+    JSTRAP_THROW,
+    JSTRAP_LIMIT
+} JSTrapStatus;
+
+typedef JSTrapStatus
+(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
+                  jsval closure);
+
+typedef JSTrapStatus
+(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
+                    void *closure);
+
+typedef JSTrapStatus
+(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
+                      void *closure);
+
+typedef JSTrapStatus
+(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
+                void *closure);
+
+typedef bool
+(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old,
+                        jsval *newp, void *closure);
+
+/* called just after script creation */
+typedef void
+(* JSNewScriptHook)(JSContext  *cx,
+                    const char *filename,  /* URL of script */
+                    unsigned   lineno,     /* first line */
+                    JSScript   *script,
+                    JSFunction *fun,
+                    void       *callerdata);
+
+/* called just before script destruction */
+typedef void
+(* JSDestroyScriptHook)(JSFreeOp *fop,
+                        JSScript *script,
+                        void     *callerdata);
+
+typedef void
+(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str,
+                    size_t length, void **listenerTSData, void *closure);
+
+
+
 extern JS_PUBLIC_API(JSCompartment *)
 JS_EnterCompartmentOfScript(JSContext *cx, JSScript *target);
 
 extern JS_PUBLIC_API(JSString *)
 JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent);
 
 /*
  * Currently, we only support runtime-wide debugging. In the future, we should
@@ -225,19 +275,18 @@ extern JS_PUBLIC_API(JSVersion)
 JS_GetScriptVersion(JSContext *cx, JSScript *script);
 
 extern JS_PUBLIC_API(bool)
 JS_GetScriptIsSelfHosted(JSScript *script);
 
 /************************************************************************/
 
 /*
- * Hook setters for script creation and destruction, see jsprvtd.h for the
- * typedefs.  These macros provide binary compatibility and newer, shorter
- * synonyms.
+ * Hook setters for script creation and destruction.  These macros provide
+ * binary compatibility and newer, shorter synonyms.
  */
 #define JS_SetNewScriptHook     JS_SetNewScriptHookProc
 #define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
 
 extern JS_PUBLIC_API(void)
 JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
 
 extern JS_PUBLIC_API(void)
@@ -447,13 +496,18 @@ extern JS_PUBLIC_API(void)
 JS_DumpCompartmentBytecode(JSContext *cx);
 
 extern JS_PUBLIC_API(void)
 JS_DumpPCCounts(JSContext *cx, JSScript *script);
 
 extern JS_PUBLIC_API(void)
 JS_DumpCompartmentPCCounts(JSContext *cx);
 
+namespace js {
+extern JS_FRIEND_API(bool)
+CanCallContextDebugHandler(JSContext *cx);
+}
+
 /* Call the context debug handler on the topmost scripted frame. */
 extern JS_FRIEND_API(bool)
 js_CallContextDebugHandler(JSContext *cx);
 
 #endif /* jsdbgapi_h */
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -757,32 +757,16 @@ js::DumpHeapComplete(JSRuntime *rt, FILE
 }
 
 JS_FRIEND_API(const JSStructuredCloneCallbacks *)
 js::GetContextStructuredCloneCallbacks(JSContext *cx)
 {
     return cx->runtime()->structuredCloneCallbacks;
 }
 
-JS_FRIEND_API(bool)
-js::CanCallContextDebugHandler(JSContext *cx)
-{
-    return !!cx->runtime()->debugHooks.debuggerHandler;
-}
-
-JS_FRIEND_API(JSTrapStatus)
-js::CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval)
-{
-    if (!cx->runtime()->debugHooks.debuggerHandler)
-        return JSTRAP_RETURN;
-
-    return cx->runtime()->debugHooks.debuggerHandler(cx, script, bc, rval,
-                                                   cx->runtime()->debugHooks.debuggerHandlerData);
-}
-
 #ifdef JS_THREADSAFE
 JS_FRIEND_API(bool)
 js::ContextHasOutstandingRequests(const JSContext *cx)
 {
     return cx->outstandingRequests > 0;
 }
 #endif
 
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -774,22 +774,16 @@ typedef void
  */
 JS_FRIEND_API(void)
 SetActivityCallback(JSRuntime *rt, ActivityCallback cb, void *arg);
 
 extern JS_FRIEND_API(const JSStructuredCloneCallbacks *)
 GetContextStructuredCloneCallbacks(JSContext *cx);
 
 extern JS_FRIEND_API(bool)
-CanCallContextDebugHandler(JSContext *cx);
-
-extern JS_FRIEND_API(JSTrapStatus)
-CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval);
-
-extern JS_FRIEND_API(bool)
 IsContextRunningJS(JSContext *cx);
 
 typedef void
 (* AnalysisPurgeCallback)(JSRuntime *rt, JS::Handle<JSFlatString*> desc);
 
 extern JS_FRIEND_API(AnalysisPurgeCallback)
 SetAnalysisPurgeCallback(JSRuntime *rt, AnalysisPurgeCallback callback);
 
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -61,64 +61,16 @@ struct IdValuePair
     IdValuePair() {}
     IdValuePair(jsid idArg)
       : id(idArg), value(UndefinedValue())
     {}
 };
 
 } /* namespace js */
 
-/* "Friend" types used by jscntxt.h and jsdbgapi.h. */
-typedef enum JSTrapStatus {
-    JSTRAP_ERROR,
-    JSTRAP_CONTINUE,
-    JSTRAP_RETURN,
-    JSTRAP_THROW,
-    JSTRAP_LIMIT
-} JSTrapStatus;
-
-typedef JSTrapStatus
-(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
-                  jsval closure);
-
-typedef JSTrapStatus
-(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
-                    void *closure);
-
-typedef JSTrapStatus
-(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
-                      void *closure);
-
-typedef JSTrapStatus
-(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
-                void *closure);
-
-typedef bool
-(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old,
-                        jsval *newp, void *closure);
-
-/* called just after script creation */
-typedef void
-(* JSNewScriptHook)(JSContext  *cx,
-                    const char *filename,  /* URL of script */
-                    unsigned   lineno,     /* first line */
-                    JSScript   *script,
-                    JSFunction *fun,
-                    void       *callerdata);
-
-/* called just before script destruction */
-typedef void
-(* JSDestroyScriptHook)(JSFreeOp *fop,
-                        JSScript *script,
-                        void     *callerdata);
-
-typedef void
-(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str,
-                    size_t length, void **listenerTSData, void *closure);
-
 /* js::ObjectOps function pointer typedefs. */
 
 /*
  * A generic type for functions mapping an object to another object, or null
  * if an error or exception was thrown on cx.
  */
 typedef JSObject *
 (* JSObjectOp)(JSContext *cx, JS::Handle<JSObject*> obj);
--- a/js/src/jswatchpoint.h
+++ b/js/src/jswatchpoint.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef jswatchpoint_h
 #define jswatchpoint_h
 
 #include "jsalloc.h"
 #include "jsapi.h"
+#include "jsdbgapi.h"
 #include "jsfriendapi.h"
 #include "jsprvtd.h"
 
 #include "gc/Barrier.h"
 #include "js/HashTable.h"
 
 namespace js {
 
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -1258,17 +1258,17 @@ struct JSRuntime : public JS::shadow::Ru
     mozilla::LinkedList<JSContext> contextList;
 
     bool hasContexts() const {
         return !contextList.isEmpty();
     }
 
     JS_SourceHook       sourceHook;
 
-    /* Per runtime debug hooks -- see jsprvtd.h and jsdbgapi.h. */
+    /* Per runtime debug hooks -- see jsdbgapi.h. */
     JSDebugHooks        debugHooks;
 
     /* If true, new compartments are initially in debug mode. */
     bool                debugMode;
 
     /* SPS profiling metadata */
     js::SPSProfiler     spsProfiler;