Source

jsprobes-patches / jsprobes-dispatch-integration

Full commit
# HG changeset patch
# Parent 2f1255e1bd6628c8e3fab895e0bd15af8987161c
integrate ProbeManager with jsprobes.h and the js shell (js.cpp)

diff --git a/js/src/gc/Statistics.cpp b/js/src/gc/Statistics.cpp
--- a/js/src/gc/Statistics.cpp
+++ b/js/src/gc/Statistics.cpp
@@ -256,13 +256,13 @@
     slices.clearAndFree();
     nonincrementalReason = NULL;
 
-    Probes::GCStart();
+    Probes::GCStart(runtime, compartment);
 }
 
 void
 Statistics::endGC()
 {
-    Probes::GCEnd();
+    Probes::GCEnd(runtime, compartment);
     crash::SnapshotGCStack();
 
     for (int i = 0; i < PHASE_LIMIT; i++)
diff --git a/js/src/jsprobes.cpp b/js/src/jsprobes.cpp
--- a/js/src/jsprobes.cpp
+++ b/js/src/jsprobes.cpp
@@ -279,6 +279,11 @@
     if (!ETWCreateRuntime(rt))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(JS_RUNTIME_CREATE, rt))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -291,6 +296,11 @@
     if (!ETWDestroyRuntime(rt))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(JS_RUNTIME_DESTROY, rt))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -303,6 +313,11 @@
     if (!ETWShutdown())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(JS_SHUTDOWN))
+        ok = false;
+#endif
 
     Probes::removeAllJITWatchers(NULL);
 
diff --git a/js/src/jsprobes.h b/js/src/jsprobes.h
--- a/js/src/jsprobes.h
+++ b/js/src/jsprobes.h
@@ -47,6 +47,9 @@
 #include "jsprvtd.h"
 #include "jsscript.h"
 #include "jsobj.h"
+#include "jscompartment.h"
+#include "jsprobedefs.h"
+#include "jsprobemgr.h"
 
 #ifdef JS_METHODJIT
 #include "methodjit/MethodJIT.h"
@@ -59,6 +62,8 @@
 struct JSActiveFrame;
 }
 
+using namespace probes;
+
 namespace Probes {
 
 /*
@@ -197,8 +202,8 @@
  * Multiple compartments' GC will be interleaved during a global collection
  * (eg, compartment 1 starts, compartment 2 starts, compartment 1 ends, ...)
  */
-bool GCStart();
-bool GCEnd();
+bool GCStart(JSRuntime *rt, JSCompartment *compartment);
+bool GCEnd(JSRuntime *rt, JSCompartment *compartment);
 
 bool GCStartMarkPhase();
 bool GCEndMarkPhase();
@@ -424,7 +429,6 @@
     if (ProfilingActive && !ETWEnterJSFun(cx, fun, script, counter))
         ok = false;
 #endif
-
     return ok;
 }
 
@@ -459,6 +463,13 @@
     if (ProfilingActive && !ETWResizeHeap(compartment, oldSize, newSize))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr 
+        || mgr->isProbeRuntime(compartment->rt) 
+        || !mgr->fireProbe(JS_WILL_RESIZE_HEAP, compartment, oldSize, newSize))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -574,6 +585,11 @@
     if (ProfilingActive && !ETWCompileScriptBegin(filename, lineno))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(JS_WILL_COMPILE_SCRIPT, cx, filename, lineno))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -587,7 +603,11 @@
     if (ProfilingActive && !ETWCompileScriptEnd(filename, lineno))
         ok = false;
 #endif
-
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(JS_DID_COMPILE_SCRIPT, cx, script, filename, lineno))
+        ok = false;
+#endif
     return ok;
 }
 
@@ -644,7 +664,7 @@
 }
 
 inline bool
-Probes::GCStart()
+Probes::GCStart(JSRuntime *rt, JSCompartment *compartment)
 {
     bool ok = true;
 
@@ -652,12 +672,22 @@
     if (ProfilingActive && !ETWGCStart())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!compartment) {
+        if (!mgr || !mgr->fireProbe(GLOBAL_GC_DID_START, rt))
+            ok = false;
+    } else {
+        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_DID_START, rt))
+            ok = false;
+    }
+#endif
 
     return ok;
 }
 
 inline bool
-Probes::GCEnd()
+Probes::GCEnd(JSRuntime *rt, JSCompartment *compartment)
 {
     bool ok = true;
 
@@ -665,6 +695,16 @@
     if (ProfilingActive && !ETWGCEnd())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!compartment) {
+        if (!mgr || !mgr->fireProbe(GLOBAL_GC_WILL_END, rt))
+            ok = false;
+    } else {
+        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_WILL_END, rt))
+            ok = false;
+    }
+#endif
 
     return ok;
 }
@@ -678,6 +718,11 @@
     if (ProfilingActive && !ETWGCStartMarkPhase())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(GC_MARK_PHASE_START))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -691,6 +736,11 @@
     if (ProfilingActive && !ETWGCEndMarkPhase())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(GC_MARK_PHASE_END))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -704,6 +754,11 @@
     if (ProfilingActive && !ETWGCStartSweepPhase())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(GC_MARK_PHASE_START))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -717,6 +772,11 @@
     if (ProfilingActive && !ETWGCEndSweepPhase())
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr || !mgr->fireProbe(GC_MARK_PHASE_END))
+        ok = false;
+#endif
 
     return ok;
 }