Source

jsprobes-patches / js-run-probes

Full commit
# HG changeset patch
# Parent ccb7bba43d25882e6b3c4e6623d1fb5fbc4833c8

diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -526,7 +526,10 @@
         return false;
 
     /* Run function until JSOP_STOP, JSOP_RETURN or error. */
-    JSBool ok = RunScript(cx, fun->script(), fp);
+    JSScript *script = fun->script();
+    Probes::startExecution(cx, script);
+    JSBool ok = RunScript(cx, script, fp);
+    Probes::stopExecution(cx, script);
 
     /* Propagate the return value out. */
     args.rval() = fp->returnValue();
diff --git a/js/src/jsprobedefs.cpp b/js/src/jsprobedefs.cpp
--- a/js/src/jsprobedefs.cpp
+++ b/js/src/jsprobedefs.cpp
@@ -206,6 +206,34 @@
     return true;
 }
 
+bool
+env_currentTimeUS(JSRuntime *rt, ProbeValue *arg)
+{
+    JS_ASSERT(arg->ty == ProbeType_DummyGlobal);
+    PROBE_VALUE_SET(arg, double, (double)PR_Now());
+    return true;
+}
+
+bool
+env_threadId(JSRuntime *rt, ProbeValue *arg)
+{
+    JS_ASSERT(arg->ty == ProbeType_DummyGlobal);
+    PROBE_VALUE_SET(arg, intptr_t, (intptr_t)PR_GetCurrentThread());
+    return true;
+}
+
+bool
+context_to_compartment(JSRuntime *rt, ProbeValue *arg)
+{
+    JS_ASSERT(arg);
+    JS_ASSERT(arg->ty == ProbeType_JSContextPtr);
+    JS_ASSERT(arg->data.as_JSContextPtr);
+    PROBE_VALUE_SET(arg, intptr_t,
+                    (intptr_t)arg->data.as_JSContextPtr->compartment);
+    return true;
+}
+
+
 js::Value
 deserialize_size_t(JSContext *cx, ProbeValue v)
 {
diff --git a/js/src/jsprobedefs.h b/js/src/jsprobedefs.h
--- a/js/src/jsprobedefs.h
+++ b/js/src/jsprobedefs.h
@@ -155,6 +155,9 @@
 bool compartment_gcTriggerBytes(JSRuntime *rt, ProbeValue *val);
 bool compartment_id(JSRuntime *rt, ProbeValue *val);
 bool env_currentTimeMS(JSRuntime *rt, ProbeValue *val);
+bool env_currentTimeUS(JSRuntime *rt, ProbeValue *val);
+bool env_threadId(JSRuntime *rt, ProbeValue *val);
+bool context_to_compartment(JSRuntime *rt, ProbeValue *val);
 
 js::Value deserialize_size_t(JSContext *cx, ProbeValue val);
 js::Value deserialize_intptr_t(JSContext *cx, ProbeValue val);
diff --git a/js/src/jsprobes.h b/js/src/jsprobes.h
--- a/js/src/jsprobes.h
+++ b/js/src/jsprobes.h
@@ -834,6 +834,13 @@
     if (ProfilingActive && !ETWStartExecution(cx, script))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr
+        || mgr->isProbeRuntime(cx->compartment->rt) 
+        || !mgr->fireProbe(JS_WILL_EXECUTE_SCRIPT, cx, script))
+        ok = false;
+#endif
 
     return ok;
 }
@@ -852,6 +859,13 @@
     if (ProfilingActive && !ETWStopExecution(cx, script))
         ok = false;
 #endif
+#ifdef MOZ_JSPROBES
+    ProbeManager *mgr = ProbeManager::manager();
+    if (!mgr
+        || mgr->isProbeRuntime(cx->compartment->rt) 
+        || !mgr->fireProbe(JS_DID_EXECUTE_SCRIPT, cx, script))
+        ok = false;
+#endif
 
     return ok;
 }
diff --git a/js/src/jsprobes.tbl b/js/src/jsprobes.tbl
--- a/js/src/jsprobes.tbl
+++ b/js/src/jsprobes.tbl
@@ -202,6 +202,9 @@
 PROBE_TRANS(compartment_gcTriggerBytes,    gcTriggerBytes,     6,  JSCompartmentPtr,    size_t)
 PROBE_TRANS(compartment_id,                id,                 7,  JSCompartmentPtr,    intptr_t)
 PROBE_TRANS(env_currentTimeMS,             currentTimeMS,      8,  DummyGlobal,         double)
+PROBE_TRANS(env_currentTimeUS,             currentTimeUS,      9,  DummyGlobal,         double)
+PROBE_TRANS(env_threadId,                  threadId,          10,  DummyGlobal,         intptr_t)
+PROBE_TRANS(context_to_compartment,        compartment,       11,  JSContextPtr,        JSCompartmentPtr)
 
 /* teardown PROBE_POINT helpers */
 #undef _NO_ARGS
diff --git a/toolkit/components/probes/ProbeService.cpp b/toolkit/components/probes/ProbeService.cpp
--- a/toolkit/components/probes/ProbeService.cpp
+++ b/toolkit/components/probes/ProbeService.cpp
@@ -401,7 +401,7 @@
 
     mListeners.Put(codeCookie, listener);
     mListenerContexts.Put(codeCookie, scriptCx);
-    StartDrainTimer(1000);
+    StartDrainTimer(400);
 
     return NS_OK;
 }