Commits

Brian Burg committed 87fd3be

UPDATE: xpcom-nsIProbeService
js/src/jsprobemgr.cpp | 15 ++++++++++++---
toolkit/components/probes/ProbeService.cpp | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)

Comments (0)

Files changed (10)

 # HG changeset patch
-# Parent 57a8e1f7cbafbc84e11a6c64f06b1ccfa1fb9213
+# Parent 29627096556a7cb43c84006d8785cfcc81418e57
 Add the ProbeManager class.
 
 diff --git a/js/src/Makefile.in b/js/src/Makefile.in
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jsprobemgr.cpp
-@@ -0,0 +1,1672 @@
+@@ -0,0 +1,1670 @@
 +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */
 +/* vim: set ts=40 sw=4 et tw=99: */
 +/* ***** BEGIN LICENSE BLOCK *****
 +    void *payloadbuf;
 +    void *bufp;
 +
-+    JS_BeginRequest(adminCx);
-+    payloadbuf = JS_malloc(adminCx, order.totalBytes);
-+    JS_EndRequest(adminCx);
++    payloadbuf = rt->malloc_(order.totalBytes);
 +
 +    /* zero the memory for debugging niceness */
 +    memset(payloadbuf, 0L, order.totalBytes);
 +        ProbeValue tmp = curArg;
 +        for (PickItem::TransformVec::iterator it = item->transforms.begin();
 +             it != item->transforms.end(); it++) {
-+            if (!(ProbeFunctionData[*it].fn)(adminCx, &tmp)) {
++            if (!(ProbeFunctionData[*it].fn)(rt, &tmp)) {
 +                PR_LOG(gProbeManagerLog, PR_LOG_ERROR, ("Error when applying transform %d (%s)\n", ProbeFunctionData[*it].transform, ProbeFunctionData[*it].fn_name));
 +            }
 +        }
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jsprobemgr.h
-@@ -0,0 +1,217 @@
+@@ -0,0 +1,221 @@
 +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */
 +/* vim: set ts=40 sw=4 et tw=99: */
 +/* ***** BEGIN LICENSE BLOCK *****
 +    /* TODO: inline everything that this calls, as well (EventQueue.push) */
 +    bool fireProbe(ProbePoint probe, ...);
 +
++    /* use these to avoid reentrancy on a different thread (say, by
++     * triggering a GC or heap resize event on probe runtime) */
++    bool isProbeRuntime(JSRuntime *runtime) const { return runtime == rt; }
++
 +    bool isScriptRunning() const { return m_scriptRunning; }
 +    bool hasPendingScripts() const { return m_pendingScriptCount; }
 +

add-jsprobes-core-definitions

 # HG changeset patch
-# Parent 16163841c9d3b020dc579a8b40cbb890702fcc40
+# Parent 502331c4f3d274c2e6e687cf288d053d596a97a0
 Add the jsprobes.tbl data, as well as core structs in jsprobedefs.h such as ProbeType, ProbeValue, and other useful data.
 
 diff --git a/js/src/Makefile.in b/js/src/Makefile.in
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jsprobedefs.cpp
-@@ -0,0 +1,299 @@
+@@ -0,0 +1,287 @@
 +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */
 +/* vim: set ts=40 sw=4 et tw=99: */
 +/* ***** BEGIN LICENSE BLOCK *****
 +
 +
 +bool
-+script_pcCounters(JSContext *cx, ProbeValue *arg)
-+{
-+    JS_ASSERT(arg);
-+    JS_ASSERT(arg->ty == ProbeType_OwnedPCCountersPtr);
-+    JS_ASSERT(arg->data.as_OwnedPCCountersPtr);
-+
-+    JSScript *script = arg->data.as_JSScriptPtr;
-+    int numBytecodes = script->length;
-+
-+    /* deep copy the pccounters.. */
-+    JSPCCounters *countersOrig = &script->pcCounters;
-+    JSPCCounters *countersCopy = new JSPCCounters();
-+
-+    countersCopy->init(cx, numBytecodes);
-+    size_t nbytes = sizeof(*countersCopy->get(0)) * numBytecodes * JSPCCounters::NUM_COUNTERS;
-+    /* HACK: asking for runMode=0 returns addr of JSPCCounters::counts */
-+    memcpy(countersCopy->get(0), countersOrig->get(0), nbytes);
-+    
-+    PROBE_VALUE_SET(arg, OwnedPCCountersPtr, countersCopy);
-+    return true;
-+}
-+
-+bool
-+runtime_gcBytes(JSContext *cx, ProbeValue *arg)
++runtime_gcBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
 +}
 +
 +bool
-+runtime_gcTriggerBytes(JSContext *cx, ProbeValue *arg)
++runtime_gcTriggerBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
 +}
 +
 +bool
-+runtime_gcLastBytes(JSContext *cx, ProbeValue *arg)
++runtime_gcLastBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
 +}
 +
 +bool
-+runtime_gcMaxBytes(JSContext *cx, ProbeValue *arg)
++runtime_gcMaxBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
 +}
 +
 +bool
-+runtime_gcMaxMallocBytes(JSContext *cx, ProbeValue *arg)
++runtime_gcMaxMallocBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
 +}
 +
 +bool
-+compartment_runtime(JSContext *cx, ProbeValue *arg)
++compartment_runtime(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
 +}
 +
 +bool
-+compartment_gcBytes(JSContext *cx, ProbeValue *arg)
++compartment_gcBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
 +}
 +
 +bool
-+compartment_gcTriggerBytes(JSContext *cx, ProbeValue *arg)
++compartment_gcTriggerBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
 +}
 +
 +bool
-+compartment_gcLastBytes(JSContext *cx, ProbeValue *arg)
++compartment_gcLastBytes(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg);
 +    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
 +    return true;
 +}
 +
++
 +bool
-+env_currentTimeMS(JSContext *cx, ProbeValue *arg)
++compartment_id(JSRuntime *rt, ProbeValue *arg)
++{
++    JS_ASSERT(arg);
++    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
++    JS_ASSERT(arg->data.as_JSCompartmentPtr);
++    PROBE_VALUE_SET(arg, intptr_t, (intptr_t)arg->data.as_JSCompartmentPtr);
++    return true;
++}
++
++
++bool
++env_currentTimeMS(JSRuntime *rt, ProbeValue *arg)
 +{
 +    JS_ASSERT(arg->ty == ProbeType_DummyGlobal);
 +    PROBE_VALUE_SET(arg, double, (double)(PR_Now()/PR_USEC_PER_MSEC));
 +}
 +
 +js::Value
++deserialize_intptr_t(JSContext *cx, ProbeValue v)
++{
++    return js::DoubleValue((double)v.data.as_intptr_t);
++}
++
++js::Value
 +deserialize_int(JSContext *cx, ProbeValue v)
 +{
 +    if (sizeof(int) != sizeof(int32))
 +    return (newStr) ? js::StringValue(newStr) : js::UndefinedValue();
 +}
 +
-+js::Value
-+deserialize_OwnedPCCountersPtr(JSContext *cx, ProbeValue v)
-+{
-+    /* TODO: pack an object with arrays? */
-+    return JSVAL_TRUE;
-+}
-+
 +}
 +}
 diff --git a/js/src/jsprobedefs.h b/js/src/jsprobedefs.h
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jsprobedefs.h
-@@ -0,0 +1,171 @@
+@@ -0,0 +1,172 @@
 +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */
 +/* vim: set ts=40 sw=4 et tw=99: */
 +/* ***** BEGIN LICENSE BLOCK *****
 +struct ProbeValue;
 +
 +typedef js::Value (* JSProbesDeserializeFun)(JSContext *cx, ProbeValue v);
-+typedef bool (* JSProbesTransformFun)(JSContext *cx, ProbeValue *v);
++typedef bool (* JSProbesTransformFun)(JSRuntime *rt, ProbeValue *v);
 +
 +/* Define the enums ProbePoint, ProbeType, ProbeTransform. The values of
 + * the latter two enums are prepended with ProbeType_ and
 +    const ProbeTypeSpec *out_type;
 +};
 +
-+bool runtime_gcBytes(JSContext *cx, ProbeValue *val);
-+bool runtime_gcTriggerBytes(JSContext *cx, ProbeValue *val);
-+bool runtime_gcLastBytes(JSContext *cx, ProbeValue *val);
-+bool runtime_gcMaxBytes(JSContext *cx, ProbeValue *val);
-+bool runtime_gcMaxMallocBytes(JSContext *cx, ProbeValue *val);
-+bool compartment_runtime(JSContext *cx, ProbeValue *val);
-+bool compartment_gcBytes(JSContext *cx, ProbeValue *val);
-+bool compartment_gcTriggerBytes(JSContext *cx, ProbeValue *val);
-+bool compartment_gcLastBytes(JSContext *cx, ProbeValue *val);
-+bool env_currentTimeMS(JSContext *cx, ProbeValue *val);
++bool runtime_gcBytes(JSRuntime *rt, ProbeValue *val);
++bool runtime_gcTriggerBytes(JSRuntime *rt, ProbeValue *val);
++bool runtime_gcLastBytes(JSRuntime *rt, ProbeValue *val);
++bool runtime_gcMaxBytes(JSRuntime *rt, ProbeValue *val);
++bool runtime_gcMaxMallocBytes(JSRuntime *rt, ProbeValue *val);
++bool compartment_runtime(JSRuntime *rt, ProbeValue *val);
++bool compartment_gcBytes(JSRuntime *rt, ProbeValue *val);
++bool compartment_gcTriggerBytes(JSRuntime *rt, ProbeValue *val);
++bool compartment_gcLastBytes(JSRuntime *rt, ProbeValue *val);
++bool compartment_id(JSRuntime *rt, ProbeValue *val);
++bool env_currentTimeMS(JSRuntime *rt, ProbeValue *val);
 +
 +js::Value deserialize_size_t(JSContext *cx, ProbeValue val);
++js::Value deserialize_intptr_t(JSContext *cx, ProbeValue val);
 +js::Value deserialize_int(JSContext *cx, ProbeValue val);
 +js::Value deserialize_double(JSContext *cx, ProbeValue val);
 +js::Value deserialize_OwnedSCBufferPtr(JSContext *cx, ProbeValue val);    
 +js::Value deserialize_OwnedConstCharPtr(JSContext *cx, ProbeValue val);
-+js::Value deserialize_OwnedPCCountersPtr(JSContext *cx, ProbeValue val);
 +    
 +}
 +}
 new file mode 100644
 --- /dev/null
 +++ b/js/src/jsprobes.tbl
-@@ -0,0 +1,227 @@
+@@ -0,0 +1,232 @@
 +/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */
 +/* vim: set ts=40 sw=4 et tw=99: */
 +/* ***** BEGIN LICENSE BLOCK *****
 +
 +/* legend:  ctype,         tyname,                 id,  isleaf,   reifyfn  */
 +
-+PROBE_TYPE(int,            None ,                   0,  false,    NULL)
++PROBE_TYPE(int,            None,                    0,  false,    NULL)
 +PROBE_TYPE(JSCompartment*, JSCompartmentPtr,        1,  false,    NULL)
 +PROBE_TYPE(JSContext*,     JSContextPtr,            2,  false,    NULL)
 +PROBE_TYPE(JSFunction*,    JSFunctionPtr,           3,  false,    NULL)
 +PROBE_TYPE(size_t,         size_t,                 10,   true,    deserialize_size_t)
 +PROBE_TYPE(int,            int,                    11,   true,    deserialize_int)
 +PROBE_TYPE(double,         double,                 12,   true,    deserialize_double)
-+PROBE_TYPE(void*,          OwnedSCBufferPtr,       13,   true,    deserialize_OwnedSCBufferPtr)
-+PROBE_TYPE(const char*,    OwnedConstCharPtr,      14,   true,    deserialize_OwnedConstCharPtr)
-+PROBE_TYPE(JSPCCounters*,  OwnedPCCountersPtr,     15,   true,    deserialize_OwnedPCCountersPtr)
++PROBE_TYPE(intptr_t,       intptr_t,               13,   true,    deserialize_intptr_t)
++PROBE_TYPE(void*,          OwnedSCBufferPtr,       14,   true,    deserialize_OwnedSCBufferPtr)
++PROBE_TYPE(const char*,    OwnedConstCharPtr,      15,   true,    deserialize_OwnedConstCharPtr)
 +PROBE_TYPE(int,            DummyGlobal,            16,  false,    NULL)
 +
 +/* This table defines the names, id, arity, and argument names/types
 + */
 +
 +/* legend:  probename              num    strname                 argc,  arginfo(name, ty)   */
-+PROBE_POINT(GLOBAL_PROBE_ARGS,       0,   "<global probe args>",     1, _ARG_1(_ARG(        env, DummyGlobal)))
-+PROBE_POINT(JS_RUNTIME_CREATE,       1,   "JSRuntime_Create",        1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(JS_RUNTIME_DESTROY,      2,   "JSRuntime_Destroy",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(JS_SHUTDOWN,             3,   "JS_Shutdown",             0, _NO_ARGS)
-+PROBE_POINT(JS_FUNCTION_ENTER,       4,   "JS_EnterFunction",        4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(   function, JSFunctionPtr),
-+                                                                               _ARG(     script, JSScriptPtr),
-+                                                                               _ARG(    counter, int)))
-+PROBE_POINT(JS_FUNCTION_EXIT,        5,   "JS_ExitFunction",         4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(   function, JSFunctionPtr),
-+                                                                               _ARG(     script, JSScriptPtr),
-+                                                                               _ARG(    counter, int)))
-+PROBE_POINT(JS_WILL_EXECUTE_SCRIPT,  6,   "JS_WillExecuteScript",    2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     script, JSScriptPtr)))
-+PROBE_POINT(JS_DID_EXECUTE_SCRIPT,   7,   "JS_DidExecuteScript",     2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     script, JSScriptPtr)))
-+PROBE_POINT(JS_WILL_RESIZE_HEAP,     8,   "JS_WillResizeHeap",       3, _ARG_3(_ARG(compartment, JSCompartmentPtr),
-+                                                                               _ARG(    oldSize, size_t),
-+                                                                               _ARG(    newSize, size_t)))
-+PROBE_POINT(JS_OBJECT_CREATE,        9,   "JS_CreateObject",         2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     object, JSObjectPtr)))
-+PROBE_POINT(JS_OBJECT_RESIZE,       10,   "JS_ResizeObject",         4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     object, JSObjectPtr),
-+                                                                               _ARG(    oldSize, size_t),
-+                                                                               _ARG(    newSize, size_t)))
-+PROBE_POINT(JS_OBJECT_FINALIZE,     11,   "JS_FinalizeObject",       1, _ARG_1(_ARG(     object, JSObjectPtr)))
-+PROBE_POINT(JS_STRING_CREATE,       12,   "JS_CreateString",         3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     string, JSStringPtr),
-+                                                                               _ARG(     length, size_t)))
-+PROBE_POINT(JS_STRING_FINALIZE,     13,   "JS_FinalizeString",       1, _ARG_1(_ARG(     string, JSStringPtr)))
-+PROBE_POINT(JS_WILL_COMPILE_SCRIPT, 14,   "JS_WillCompileScript",    3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(   filename, ConstCharPtr),
-+                                                                               _ARG(     lineno, int)))
-+PROBE_POINT(JS_DID_COMPILE_SCRIPT,  15,   "JS_DidCompileScript",     4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(     script, JSScriptPtr),
-+                                                                               _ARG(   filename, ConstCharPtr),
-+                                                                               _ARG(     lineno, int)))
-+PROBE_POINT(JS_WILL_CALL_NATIVE,    16,   "JS_WillCallNative",       2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(   function, JSFunctionPtr)))
-+PROBE_POINT(JS_DID_CALL_NATIVE,     17,   "JS_DidCallNative",        2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(   function, JSFunctionPtr)))
-+PROBE_POINT(JS_ACQUIRE_MEMORY,      18,   "JS_AcquireMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(    address, VoidPtr),
-+                                                                               _ARG(     nbytes, size_t)))
-+PROBE_POINT(JS_RELEASE_MEMORY,      19,   "JS_ReleaseMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                               _ARG(    address, VoidPtr),
-+                                                                               _ARG(     nbytes, size_t)))
-+PROBE_POINT(GC_DID_START,           20,   "GC_DidStart",             1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_WILL_END,            21,   "GC_DidEnd",               1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_MARK_PHASE_START,    22,   "GC_MarkPhaseStart",       1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_MARK_PHASE_END,      23,   "GC_MarkPhaseEnd",         1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_SWEEP_PHASE_START,   24,   "GC_SweepPhaseStart",      1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_SWEEP_PHASE_END,     25,   "GC_SweepPhaseEnd",        1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(GLOBAL_PROBE_ARGS,          0,   "<global probe args>",     1, _ARG_1(_ARG(        env, DummyGlobal)))
++PROBE_POINT(JS_RUNTIME_CREATE,          1,   "JSRuntime_Create",        1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
++PROBE_POINT(JS_RUNTIME_DESTROY,         2,   "JSRuntime_Destroy",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
++PROBE_POINT(JS_SHUTDOWN,                3,   "JS_Shutdown",             0, _NO_ARGS)
++PROBE_POINT(JS_FUNCTION_ENTER,          4,   "JS_EnterFunction",        4, _ARG_4(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(   function, JSFunctionPtr),
++                                                                                  _ARG(     script, JSScriptPtr),
++                                                                                  _ARG(    counter, int)))
++PROBE_POINT(JS_FUNCTION_EXIT,           5,   "JS_ExitFunction",         4, _ARG_4(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(   function, JSFunctionPtr),
++                                                                                  _ARG(     script, JSScriptPtr),
++                                                                                  _ARG(    counter, int)))
++PROBE_POINT(JS_WILL_EXECUTE_SCRIPT,     6,   "JS_WillExecuteScript",    2, _ARG_2(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     script, JSScriptPtr)))
++PROBE_POINT(JS_DID_EXECUTE_SCRIPT,      7,   "JS_DidExecuteScript",     2, _ARG_2(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     script, JSScriptPtr)))
++PROBE_POINT(JS_WILL_RESIZE_HEAP,        8,   "JS_WillResizeHeap",       3, _ARG_3(_ARG(compartment, JSCompartmentPtr),
++                                                                                  _ARG(    oldSize, size_t),
++                                                                                  _ARG(    newSize, size_t)))
++PROBE_POINT(JS_OBJECT_CREATE,           9,   "JS_CreateObject",         2, _ARG_2(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     object, JSObjectPtr)))
++PROBE_POINT(JS_OBJECT_RESIZE,          10,   "JS_ResizeObject",         4, _ARG_4(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     object, JSObjectPtr),
++                                                                                  _ARG(    oldSize, size_t),
++                                                                                  _ARG(    newSize, size_t)))
++PROBE_POINT(JS_OBJECT_FINALIZE,        11,   "JS_FinalizeObject",       1, _ARG_1(_ARG(     object, JSObjectPtr)))
++PROBE_POINT(JS_STRING_CREATE,          12,   "JS_CreateString",         3, _ARG_3(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     string, JSStringPtr),
++                                                                                  _ARG(     length, size_t)))
++PROBE_POINT(JS_STRING_FINALIZE,        13,   "JS_FinalizeString",       1, _ARG_1(_ARG(     string, JSStringPtr)))
++PROBE_POINT(JS_WILL_COMPILE_SCRIPT,    14,   "JS_WillCompileScript",    3, _ARG_3(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(   filename, ConstCharPtr),
++                                                                                  _ARG(     lineno, int)))
++PROBE_POINT(JS_DID_COMPILE_SCRIPT,     15,   "JS_DidCompileScript",     4, _ARG_4(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(     script, JSScriptPtr),
++                                                                                  _ARG(   filename, ConstCharPtr),
++                                                                                  _ARG(     lineno, int)))
++PROBE_POINT(JS_WILL_CALL_NATIVE,       16,   "JS_WillCallNative",       2, _ARG_2(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(   function, JSFunctionPtr)))
++PROBE_POINT(JS_DID_CALL_NATIVE,        17,   "JS_DidCallNative",        2, _ARG_2(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(   function, JSFunctionPtr)))
++PROBE_POINT(JS_ACQUIRE_MEMORY,         18,   "JS_AcquireMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(    address, VoidPtr),
++                                                                                  _ARG(     nbytes, size_t)))
++PROBE_POINT(JS_RELEASE_MEMORY,         19,   "JS_ReleaseMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
++                                                                                  _ARG(    address, VoidPtr),
++                                                                                  _ARG(     nbytes, size_t)))
++PROBE_POINT(COMPARTMENT_GC_DID_START,  20,   "GC_DidStartCompartment",  2, _ARG_2(_ARG(    runtime, JSRuntimePtr),
++                                                                                  _ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(COMPARTMENT_GC_WILL_END,   21,   "GC_DidEndCompartment",    2, _ARG_2(_ARG(    runtime, JSRuntimePtr),
++                                                                                  _ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(GLOBAL_GC_DID_START,       22,   "GC_DidStartGlobal",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
++PROBE_POINT(GLOBAL_GC_WILL_END,        23,   "GC_DidEndGlobal",         1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
++PROBE_POINT(GC_MARK_PHASE_START,       24,   "GC_MarkPhaseStart",       1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(GC_MARK_PHASE_END,         25,   "GC_MarkPhaseEnd",         1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(GC_SWEEP_PHASE_START,      26,   "GC_SweepPhaseStart",      1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
++PROBE_POINT(GC_SWEEP_PHASE_END,        27,   "GC_SweepPhaseEnd",        1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
 +
 +
 +
 +PROBE_TRANS(compartment_gcBytes,           gcBytes,            7,  JSCompartmentPtr,    size_t)
 +PROBE_TRANS(compartment_gcTriggerBytes,    gcTriggerBytes,     8,  JSCompartmentPtr,    size_t)
 +PROBE_TRANS(compartment_gcLastBytes,       gcLastBytes,        9,  JSCompartmentPtr,    size_t)
-+PROBE_TRANS(env_currentTimeMS,             currentTimeMS,     10,  DummyGlobal,         double)
++PROBE_TRANS(compartment_id,                id,                10,  JSCompartmentPtr,    intptr_t)
++PROBE_TRANS(env_currentTimeMS,             currentTimeMS,     11,  DummyGlobal,         double)
 +
 +/* teardown PROBE_POINT helpers */
 +#undef _NO_ARGS

jsprobes-dispatch-integration

 # HG changeset patch
-# Parent 7bfc54f11fca6e16bf34cb48f554287c932fe566
+# Parent 0f023b51e6b01a6a486fbd56e204c3bafbcfb603
 integrate ProbeManager with jsprobes.h and the js shell (js.cpp)
 
+diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
+--- a/js/src/jsgc.cpp
++++ b/js/src/jsgc.cpp
+@@ -2700,14 +2700,16 @@
+     GCTIMER_BEGIN(rt, comp);
+ 
+     struct AutoGCProbe {
++        JSRuntime *rt;
+         JSCompartment *comp;
+-        AutoGCProbe(JSCompartment *comp) : comp(comp) {
+-            Probes::GCStart(comp);
++        AutoGCProbe(JSRuntime *rt, JSCompartment *comp)
++            : rt(rt), comp(comp) {
++            Probes::GCStart(rt, comp);
+         }
+         ~AutoGCProbe() {
+-            Probes::GCEnd(comp); /* background thread may still be sweeping */
++            Probes::GCEnd(rt, comp); /* background thread may still be sweeping */
+         }
+-    } autoGCProbe(comp);
++    } autoGCProbe(rt, comp);
+ 
+     do {
+         /*
 diff --git a/js/src/jsprobes.h b/js/src/jsprobes.h
 --- a/js/src/jsprobes.h
 +++ b/js/src/jsprobes.h
-@@ -46,8 +46,13 @@
+@@ -45,9 +45,14 @@
+ #endif
  #include "jspubtd.h"
  #include "jsprvtd.h"
- 
++#include "jscompartment.h"
 +#include "jsprobedefs.h"
 +#include "jsprobemgr.h"
-+
+ 
  namespace js {
  
 +    using namespace probes;
  namespace Probes {
  
  /*
+@@ -174,8 +179,8 @@
+  * Multiple compartments' GC will be interleaved during a global collection
+  * (eg, compartment 1 starts, compartment 2 starts, compartment 1 ends, ...)
+  */
+-bool GCStart(JSCompartment *compartment);
+-bool GCEnd(JSCompartment *compartment);
++bool GCStart(JSRuntime *runtime, JSCompartment *compartment);
++bool GCEnd(JSRuntime *runtime, JSCompartment *compartment);
+ 
+ bool GCStartMarkPhase(JSCompartment *compartment);
+ bool GCEndMarkPhase(JSCompartment *compartment);
+@@ -226,8 +231,8 @@
+ bool ETWCalloutEnd(JSContext *cx, JSFunction *fun);
+ bool ETWAcquireMemory(JSContext *cx, void *address, size_t nbytes);
+ bool ETWReleaseMemory(JSContext *cx, void *address, size_t nbytes);
+-bool ETWGCStart(JSCompartment *compartment);
+-bool ETWGCEnd(JSCompartment *compartment);
++bool ETWGCStart(JSRuntime *runtime, JSCompartment *compartment);
++bool ETWGCEnd(JSRuntime *runtime, JSCompartment *compartment);
+ bool ETWGCStartMarkPhase(JSCompartment *compartment);
+ bool ETWGCEndMarkPhase(JSCompartment *compartment);
+ bool ETWGCStartSweepPhase(JSCompartment *compartment);
 @@ -255,6 +260,11 @@
      if (!ETWCreateRuntime(rt))
          ok = false;
      return ok;
  }
  
-@@ -348,6 +367,11 @@
+@@ -348,6 +367,13 @@
      if (ProfilingActive && !ETWResizeHeap(compartment, oldSize, newSize))
          ok = false;
  #endif
 +#ifdef MOZ_JSPROBES
 +    ProbeManager *mgr = ProbeManager::manager();
-+    if (!mgr || !mgr->fireProbe(JS_WILL_RESIZE_HEAP, compartment, oldSize, newSize))
++    if (!mgr 
++        || mgr->isProbeRuntime(compartment->rt) 
++        || !mgr->fireProbe(JS_WILL_RESIZE_HEAP, compartment, oldSize, newSize))
 +        ok = false;
 +#endif
  
      return ok;
  }
-@@ -452,6 +476,11 @@
+@@ -452,6 +478,11 @@
      if (ProfilingActive && !ETWCompileScriptBegin(filename, lineno))
          ok = false;
  #endif
  
      return ok;
  }
-@@ -465,7 +494,11 @@
+@@ -465,7 +496,11 @@
      if (ProfilingActive && !ETWCompileScriptEnd(filename, lineno))
          ok = false;
  #endif
      return ok;
  }
  
-@@ -530,6 +563,11 @@
-     if (ProfilingActive && !ETWGCStart(compartment))
+@@ -522,20 +557,30 @@
+ }
+ 
+ inline bool
+-Probes::GCStart(JSCompartment *compartment)
++Probes::GCStart(JSRuntime *runtime, JSCompartment *compartment)
+ {
+     bool ok = true;
+ 
+ #ifdef MOZ_ETW
+-    if (ProfilingActive && !ETWGCStart(compartment))
++    if (ProfilingActive && !ETWGCStart(runtime, compartment))
          ok = false;
  #endif
 +#ifdef MOZ_JSPROBES
 +    ProbeManager *mgr = ProbeManager::manager();
-+    if (!compartment || !mgr || !mgr->fireProbe(GC_DID_START, compartment))
-+        ok = false;
++    if (!compartment) {
++        if (!mgr || !mgr->fireProbe(GLOBAL_GC_DID_START, runtime))
++            ok = false;
++    } else {
++        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_DID_START, runtime, compartment))
++            ok = false;
++    }
 +#endif
  
      return ok;
  }
-@@ -543,7 +581,11 @@
-     if (ProfilingActive && !ETWGCEnd(compartment))
+ 
+ inline bool
+-Probes::GCEnd(JSCompartment *compartment)
++Probes::GCEnd(JSRuntime *runtime, JSCompartment *compartment)
+ {
+     bool ok = true;
+ 
+@@ -544,6 +589,16 @@
          ok = false;
  #endif
--
+ 
 +#ifdef MOZ_JSPROBES
 +    ProbeManager *mgr = ProbeManager::manager();
-+    if (!compartment || !mgr || !mgr->fireProbe(GC_WILL_END, compartment))
-+        ok = false;
++    if (!compartment) {
++        if (!mgr || !mgr->fireProbe(GLOBAL_GC_WILL_END, runtime))
++            ok = false;
++    } else {
++        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_WILL_END, runtime, compartment))
++            ok = false;
++    }
 +#endif
      return ok;
  }
  
-@@ -556,7 +598,11 @@
+@@ -556,7 +611,11 @@
      if (ProfilingActive && !ETWGCStartMarkPhase(compartment))
          ok = false;
  #endif
      return ok;
  }
  
-@@ -569,6 +615,11 @@
+@@ -569,6 +628,11 @@
      if (ProfilingActive && !ETWGCEndMarkPhase(compartment))
          ok = false;
  #endif
  
      return ok;
  }
-@@ -582,6 +633,11 @@
+@@ -582,6 +646,11 @@
      if (ProfilingActive && !ETWGCStartSweepPhase(compartment))
          ok = false;
  #endif
  
      return ok;
  }
-@@ -595,6 +651,11 @@
+@@ -595,6 +664,11 @@
      if (ProfilingActive && !ETWGCEndSweepPhase(compartment))
          ok = false;
  #endif
 jsprobes-dispatch-integration
 jsshell-integration #+shell
 xpcom-nsIProbeService
-tmp-dispatch
-tmp-defs
-tmp-mgr
-tmp-idl
-tmp-integ
 
 
 

tmp-defs

-# HG changeset patch
-# Parent 60d184c5a9167416dc4abfa49903b96ceb8da08c
-diff --git a/js/src/jsprobedefs.cpp b/js/src/jsprobedefs.cpp
---- a/js/src/jsprobedefs.cpp
-+++ b/js/src/jsprobedefs.cpp
-@@ -129,30 +129,7 @@
- 
- 
- bool
--script_pcCounters(JSContext *cx, ProbeValue *arg)
--{
--    JS_ASSERT(arg);
--    JS_ASSERT(arg->ty == ProbeType_OwnedPCCountersPtr);
--    JS_ASSERT(arg->data.as_OwnedPCCountersPtr);
--
--    JSScript *script = arg->data.as_JSScriptPtr;
--    int numBytecodes = script->length;
--
--    /* deep copy the pccounters.. */
--    JSPCCounters *countersOrig = &script->pcCounters;
--    JSPCCounters *countersCopy = new JSPCCounters();
--
--    countersCopy->init(cx, numBytecodes);
--    size_t nbytes = sizeof(*countersCopy->get(0)) * numBytecodes * JSPCCounters::NUM_COUNTERS;
--    /* HACK: asking for runMode=0 returns addr of JSPCCounters::counts */
--    memcpy(countersCopy->get(0), countersOrig->get(0), nbytes);
--    
--    PROBE_VALUE_SET(arg, OwnedPCCountersPtr, countersCopy);
--    return true;
--}
--
--bool
--runtime_gcBytes(JSContext *cx, ProbeValue *arg)
-+runtime_gcBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
-@@ -162,7 +139,7 @@
- }
- 
- bool
--runtime_gcTriggerBytes(JSContext *cx, ProbeValue *arg)
-+runtime_gcTriggerBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
-@@ -172,7 +149,7 @@
- }
- 
- bool
--runtime_gcLastBytes(JSContext *cx, ProbeValue *arg)
-+runtime_gcLastBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
-@@ -182,7 +159,7 @@
- }
- 
- bool
--runtime_gcMaxBytes(JSContext *cx, ProbeValue *arg)
-+runtime_gcMaxBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
-@@ -192,7 +169,7 @@
- }
- 
- bool
--runtime_gcMaxMallocBytes(JSContext *cx, ProbeValue *arg)
-+runtime_gcMaxMallocBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSRuntimePtr);
-@@ -202,7 +179,7 @@
- }
- 
- bool
--compartment_runtime(JSContext *cx, ProbeValue *arg)
-+compartment_runtime(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
-@@ -212,7 +189,7 @@
- }
- 
- bool
--compartment_gcBytes(JSContext *cx, ProbeValue *arg)
-+compartment_gcBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
-@@ -222,7 +199,7 @@
- }
- 
- bool
--compartment_gcTriggerBytes(JSContext *cx, ProbeValue *arg)
-+compartment_gcTriggerBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
-@@ -232,7 +209,7 @@
- }
- 
- bool
--compartment_gcLastBytes(JSContext *cx, ProbeValue *arg)
-+compartment_gcLastBytes(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg);
-     JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
-@@ -241,8 +218,20 @@
-     return true;
- }
- 
-+
- bool
--env_currentTimeMS(JSContext *cx, ProbeValue *arg)
-+compartment_id(JSRuntime *rt, ProbeValue *arg)
-+{
-+    JS_ASSERT(arg);
-+    JS_ASSERT(arg->ty == ProbeType_JSCompartmentPtr);
-+    JS_ASSERT(arg->data.as_JSCompartmentPtr);
-+    PROBE_VALUE_SET(arg, intptr_t, (intptr_t)arg->data.as_JSCompartmentPtr);
-+    return true;
-+}
-+
-+
-+bool
-+env_currentTimeMS(JSRuntime *rt, ProbeValue *arg)
- {
-     JS_ASSERT(arg->ty == ProbeType_DummyGlobal);
-     PROBE_VALUE_SET(arg, double, (double)(PR_Now()/PR_USEC_PER_MSEC));
-@@ -256,6 +245,12 @@
- }
- 
- js::Value
-+deserialize_intptr_t(JSContext *cx, ProbeValue v)
-+{
-+    return js::DoubleValue((double)v.data.as_intptr_t);
-+}
-+
-+js::Value
- deserialize_int(JSContext *cx, ProbeValue v)
- {
-     if (sizeof(int) != sizeof(int32))
-@@ -288,12 +283,5 @@
-     return (newStr) ? js::StringValue(newStr) : js::UndefinedValue();
- }
- 
--js::Value
--deserialize_OwnedPCCountersPtr(JSContext *cx, ProbeValue v)
--{
--    /* TODO: pack an object with arrays? */
--    return JSVAL_TRUE;
- }
--
- }
--}
-diff --git a/js/src/jsprobedefs.h b/js/src/jsprobedefs.h
---- a/js/src/jsprobedefs.h
-+++ b/js/src/jsprobedefs.h
-@@ -47,7 +47,7 @@
- struct ProbeValue;
- 
- typedef js::Value (* JSProbesDeserializeFun)(JSContext *cx, ProbeValue v);
--typedef bool (* JSProbesTransformFun)(JSContext *cx, ProbeValue *v);
-+typedef bool (* JSProbesTransformFun)(JSRuntime *rt, ProbeValue *v);
- 
- /* Define the enums ProbePoint, ProbeType, ProbeTransform. The values of
-  * the latter two enums are prepended with ProbeType_ and
-@@ -148,23 +148,24 @@
-     const ProbeTypeSpec *out_type;
- };
- 
--bool runtime_gcBytes(JSContext *cx, ProbeValue *val);
--bool runtime_gcTriggerBytes(JSContext *cx, ProbeValue *val);
--bool runtime_gcLastBytes(JSContext *cx, ProbeValue *val);
--bool runtime_gcMaxBytes(JSContext *cx, ProbeValue *val);
--bool runtime_gcMaxMallocBytes(JSContext *cx, ProbeValue *val);
--bool compartment_runtime(JSContext *cx, ProbeValue *val);
--bool compartment_gcBytes(JSContext *cx, ProbeValue *val);
--bool compartment_gcTriggerBytes(JSContext *cx, ProbeValue *val);
--bool compartment_gcLastBytes(JSContext *cx, ProbeValue *val);
--bool env_currentTimeMS(JSContext *cx, ProbeValue *val);
-+bool runtime_gcBytes(JSRuntime *rt, ProbeValue *val);
-+bool runtime_gcTriggerBytes(JSRuntime *rt, ProbeValue *val);
-+bool runtime_gcLastBytes(JSRuntime *rt, ProbeValue *val);
-+bool runtime_gcMaxBytes(JSRuntime *rt, ProbeValue *val);
-+bool runtime_gcMaxMallocBytes(JSRuntime *rt, ProbeValue *val);
-+bool compartment_runtime(JSRuntime *rt, ProbeValue *val);
-+bool compartment_gcBytes(JSRuntime *rt, ProbeValue *val);
-+bool compartment_gcTriggerBytes(JSRuntime *rt, ProbeValue *val);
-+bool compartment_gcLastBytes(JSRuntime *rt, ProbeValue *val);
-+bool compartment_id(JSRuntime *rt, ProbeValue *val);
-+bool env_currentTimeMS(JSRuntime *rt, ProbeValue *val);
- 
- js::Value deserialize_size_t(JSContext *cx, ProbeValue val);
-+js::Value deserialize_intptr_t(JSContext *cx, ProbeValue val);
- js::Value deserialize_int(JSContext *cx, ProbeValue val);
- js::Value deserialize_double(JSContext *cx, ProbeValue val);
- js::Value deserialize_OwnedSCBufferPtr(JSContext *cx, ProbeValue val);    
- js::Value deserialize_OwnedConstCharPtr(JSContext *cx, ProbeValue val);
--js::Value deserialize_OwnedPCCountersPtr(JSContext *cx, ProbeValue val);
-     
- }
- }
-diff --git a/js/src/jsprobes.tbl b/js/src/jsprobes.tbl
---- a/js/src/jsprobes.tbl
-+++ b/js/src/jsprobes.tbl
-@@ -81,7 +81,7 @@
- 
- /* legend:  ctype,         tyname,                 id,  isleaf,   reifyfn  */
- 
--PROBE_TYPE(int,            None ,                   0,  false,    NULL)
-+PROBE_TYPE(int,            None,                    0,  false,    NULL)
- PROBE_TYPE(JSCompartment*, JSCompartmentPtr,        1,  false,    NULL)
- PROBE_TYPE(JSContext*,     JSContextPtr,            2,  false,    NULL)
- PROBE_TYPE(JSFunction*,    JSFunctionPtr,           3,  false,    NULL)
-@@ -96,9 +96,9 @@
- PROBE_TYPE(size_t,         size_t,                 10,   true,    deserialize_size_t)
- PROBE_TYPE(int,            int,                    11,   true,    deserialize_int)
- PROBE_TYPE(double,         double,                 12,   true,    deserialize_double)
--PROBE_TYPE(void*,          OwnedSCBufferPtr,       13,   true,    deserialize_OwnedSCBufferPtr)
--PROBE_TYPE(const char*,    OwnedConstCharPtr,      14,   true,    deserialize_OwnedConstCharPtr)
--PROBE_TYPE(JSPCCounters*,  OwnedPCCountersPtr,     15,   true,    deserialize_OwnedPCCountersPtr)
-+PROBE_TYPE(intptr_t,       intptr_t,               13,   true,    deserialize_intptr_t)
-+PROBE_TYPE(void*,          OwnedSCBufferPtr,       14,   true,    deserialize_OwnedSCBufferPtr)
-+PROBE_TYPE(const char*,    OwnedConstCharPtr,      15,   true,    deserialize_OwnedConstCharPtr)
- PROBE_TYPE(int,            DummyGlobal,            16,  false,    NULL)
- 
- /* This table defines the names, id, arity, and argument names/types
-@@ -121,59 +121,63 @@
-  */
- 
- /* legend:  probename              num    strname                 argc,  arginfo(name, ty)   */
--PROBE_POINT(GLOBAL_PROBE_ARGS,       0,   "<global probe args>",     1, _ARG_1(_ARG(        env, DummyGlobal)))
--PROBE_POINT(JS_RUNTIME_CREATE,       1,   "JSRuntime_Create",        1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
--PROBE_POINT(JS_RUNTIME_DESTROY,      2,   "JSRuntime_Destroy",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
--PROBE_POINT(JS_SHUTDOWN,             3,   "JS_Shutdown",             0, _NO_ARGS)
--PROBE_POINT(JS_FUNCTION_ENTER,       4,   "JS_EnterFunction",        4, _ARG_4(_ARG(    context, JSContextPtr),
--                                                                               _ARG(   function, JSFunctionPtr),
--                                                                               _ARG(     script, JSScriptPtr),
--                                                                               _ARG(    counter, int)))
--PROBE_POINT(JS_FUNCTION_EXIT,        5,   "JS_ExitFunction",         4, _ARG_4(_ARG(    context, JSContextPtr),
--                                                                               _ARG(   function, JSFunctionPtr),
--                                                                               _ARG(     script, JSScriptPtr),
--                                                                               _ARG(    counter, int)))
--PROBE_POINT(JS_WILL_EXECUTE_SCRIPT,  6,   "JS_WillExecuteScript",    2, _ARG_2(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     script, JSScriptPtr)))
--PROBE_POINT(JS_DID_EXECUTE_SCRIPT,   7,   "JS_DidExecuteScript",     2, _ARG_2(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     script, JSScriptPtr)))
--PROBE_POINT(JS_WILL_RESIZE_HEAP,     8,   "JS_WillResizeHeap",       3, _ARG_3(_ARG(compartment, JSCompartmentPtr),
--                                                                               _ARG(    oldSize, size_t),
--                                                                               _ARG(    newSize, size_t)))
--PROBE_POINT(JS_OBJECT_CREATE,        9,   "JS_CreateObject",         2, _ARG_2(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     object, JSObjectPtr)))
--PROBE_POINT(JS_OBJECT_RESIZE,       10,   "JS_ResizeObject",         4, _ARG_4(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     object, JSObjectPtr),
--                                                                               _ARG(    oldSize, size_t),
--                                                                               _ARG(    newSize, size_t)))
--PROBE_POINT(JS_OBJECT_FINALIZE,     11,   "JS_FinalizeObject",       1, _ARG_1(_ARG(     object, JSObjectPtr)))
--PROBE_POINT(JS_STRING_CREATE,       12,   "JS_CreateString",         3, _ARG_3(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     string, JSStringPtr),
--                                                                               _ARG(     length, size_t)))
--PROBE_POINT(JS_STRING_FINALIZE,     13,   "JS_FinalizeString",       1, _ARG_1(_ARG(     string, JSStringPtr)))
--PROBE_POINT(JS_WILL_COMPILE_SCRIPT, 14,   "JS_WillCompileScript",    3, _ARG_3(_ARG(    context, JSContextPtr),
--                                                                               _ARG(   filename, ConstCharPtr),
--                                                                               _ARG(     lineno, int)))
--PROBE_POINT(JS_DID_COMPILE_SCRIPT,  15,   "JS_DidCompileScript",     4, _ARG_4(_ARG(    context, JSContextPtr),
--                                                                               _ARG(     script, JSScriptPtr),
--                                                                               _ARG(   filename, ConstCharPtr),
--                                                                               _ARG(     lineno, int)))
--PROBE_POINT(JS_WILL_CALL_NATIVE,    16,   "JS_WillCallNative",       2, _ARG_2(_ARG(    context, JSContextPtr),
--                                                                               _ARG(   function, JSFunctionPtr)))
--PROBE_POINT(JS_DID_CALL_NATIVE,     17,   "JS_DidCallNative",        2, _ARG_2(_ARG(    context, JSContextPtr),
--                                                                               _ARG(   function, JSFunctionPtr)))
--PROBE_POINT(JS_ACQUIRE_MEMORY,      18,   "JS_AcquireMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
--                                                                               _ARG(    address, VoidPtr),
--                                                                               _ARG(     nbytes, size_t)))
--PROBE_POINT(JS_RELEASE_MEMORY,      19,   "JS_ReleaseMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
--                                                                               _ARG(    address, VoidPtr),
--                                                                               _ARG(     nbytes, size_t)))
--PROBE_POINT(GC_DID_START,           20,   "GC_DidStart",             1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
--PROBE_POINT(GC_WILL_END,            21,   "GC_DidEnd",               1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
--PROBE_POINT(GC_MARK_PHASE_START,    22,   "GC_MarkPhaseStart",       1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
--PROBE_POINT(GC_MARK_PHASE_END,      23,   "GC_MarkPhaseEnd",         1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
--PROBE_POINT(GC_SWEEP_PHASE_START,   24,   "GC_SweepPhaseStart",      1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
--PROBE_POINT(GC_SWEEP_PHASE_END,     25,   "GC_SweepPhaseEnd",        1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GLOBAL_PROBE_ARGS,          0,   "<global probe args>",     1, _ARG_1(_ARG(        env, DummyGlobal)))
-+PROBE_POINT(JS_RUNTIME_CREATE,          1,   "JSRuntime_Create",        1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(JS_RUNTIME_DESTROY,         2,   "JSRuntime_Destroy",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(JS_SHUTDOWN,                3,   "JS_Shutdown",             0, _NO_ARGS)
-+PROBE_POINT(JS_FUNCTION_ENTER,          4,   "JS_EnterFunction",        4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(   function, JSFunctionPtr),
-+                                                                                  _ARG(     script, JSScriptPtr),
-+                                                                                  _ARG(    counter, int)))
-+PROBE_POINT(JS_FUNCTION_EXIT,           5,   "JS_ExitFunction",         4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(   function, JSFunctionPtr),
-+                                                                                  _ARG(     script, JSScriptPtr),
-+                                                                                  _ARG(    counter, int)))
-+PROBE_POINT(JS_WILL_EXECUTE_SCRIPT,     6,   "JS_WillExecuteScript",    2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     script, JSScriptPtr)))
-+PROBE_POINT(JS_DID_EXECUTE_SCRIPT,      7,   "JS_DidExecuteScript",     2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     script, JSScriptPtr)))
-+PROBE_POINT(JS_WILL_RESIZE_HEAP,        8,   "JS_WillResizeHeap",       3, _ARG_3(_ARG(compartment, JSCompartmentPtr),
-+                                                                                  _ARG(    oldSize, size_t),
-+                                                                                  _ARG(    newSize, size_t)))
-+PROBE_POINT(JS_OBJECT_CREATE,           9,   "JS_CreateObject",         2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     object, JSObjectPtr)))
-+PROBE_POINT(JS_OBJECT_RESIZE,          10,   "JS_ResizeObject",         4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     object, JSObjectPtr),
-+                                                                                  _ARG(    oldSize, size_t),
-+                                                                                  _ARG(    newSize, size_t)))
-+PROBE_POINT(JS_OBJECT_FINALIZE,        11,   "JS_FinalizeObject",       1, _ARG_1(_ARG(     object, JSObjectPtr)))
-+PROBE_POINT(JS_STRING_CREATE,          12,   "JS_CreateString",         3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     string, JSStringPtr),
-+                                                                                  _ARG(     length, size_t)))
-+PROBE_POINT(JS_STRING_FINALIZE,        13,   "JS_FinalizeString",       1, _ARG_1(_ARG(     string, JSStringPtr)))
-+PROBE_POINT(JS_WILL_COMPILE_SCRIPT,    14,   "JS_WillCompileScript",    3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(   filename, ConstCharPtr),
-+                                                                                  _ARG(     lineno, int)))
-+PROBE_POINT(JS_DID_COMPILE_SCRIPT,     15,   "JS_DidCompileScript",     4, _ARG_4(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(     script, JSScriptPtr),
-+                                                                                  _ARG(   filename, ConstCharPtr),
-+                                                                                  _ARG(     lineno, int)))
-+PROBE_POINT(JS_WILL_CALL_NATIVE,       16,   "JS_WillCallNative",       2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(   function, JSFunctionPtr)))
-+PROBE_POINT(JS_DID_CALL_NATIVE,        17,   "JS_DidCallNative",        2, _ARG_2(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(   function, JSFunctionPtr)))
-+PROBE_POINT(JS_ACQUIRE_MEMORY,         18,   "JS_AcquireMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(    address, VoidPtr),
-+                                                                                  _ARG(     nbytes, size_t)))
-+PROBE_POINT(JS_RELEASE_MEMORY,         19,   "JS_ReleaseMemory",        3, _ARG_3(_ARG(    context, JSContextPtr),
-+                                                                                  _ARG(    address, VoidPtr),
-+                                                                                  _ARG(     nbytes, size_t)))
-+PROBE_POINT(COMPARTMENT_GC_DID_START,  20,   "GC_DidStartCompartment",  2, _ARG_2(_ARG(    runtime, JSRuntimePtr),
-+                                                                                  _ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(COMPARTMENT_GC_WILL_END,   21,   "GC_DidEndCompartment",    2, _ARG_2(_ARG(    runtime, JSRuntimePtr),
-+                                                                                  _ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GLOBAL_GC_DID_START,       22,   "GC_DidStartGlobal",       1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(GLOBAL_GC_WILL_END,        23,   "GC_DidEndGlobal",         1, _ARG_1(_ARG(    runtime, JSRuntimePtr)))
-+PROBE_POINT(GC_MARK_PHASE_START,       24,   "GC_MarkPhaseStart",       1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_MARK_PHASE_END,         25,   "GC_MarkPhaseEnd",         1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_SWEEP_PHASE_START,      26,   "GC_SweepPhaseStart",      1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
-+PROBE_POINT(GC_SWEEP_PHASE_END,        27,   "GC_SweepPhaseEnd",        1, _ARG_1(_ARG(compartment, JSCompartmentPtr)))
- 
- 
- 
-@@ -199,7 +203,8 @@
- PROBE_TRANS(compartment_gcBytes,           gcBytes,            7,  JSCompartmentPtr,    size_t)
- PROBE_TRANS(compartment_gcTriggerBytes,    gcTriggerBytes,     8,  JSCompartmentPtr,    size_t)
- PROBE_TRANS(compartment_gcLastBytes,       gcLastBytes,        9,  JSCompartmentPtr,    size_t)
--PROBE_TRANS(env_currentTimeMS,             currentTimeMS,     10,  DummyGlobal,         double)
-+PROBE_TRANS(compartment_id,                id,                10,  JSCompartmentPtr,    intptr_t)
-+PROBE_TRANS(env_currentTimeMS,             currentTimeMS,     11,  DummyGlobal,         double)
- 
- /* teardown PROBE_POINT helpers */
- #undef _NO_ARGS

tmp-dispatch

-# HG changeset patch
-# Parent 79dd2ce338433188a2a64a780715789655097c12
-diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
---- a/js/src/jsgc.cpp
-+++ b/js/src/jsgc.cpp
-@@ -2700,14 +2700,16 @@
-     GCTIMER_BEGIN(rt, comp);
- 
-     struct AutoGCProbe {
-+        JSRuntime *rt;
-         JSCompartment *comp;
--        AutoGCProbe(JSCompartment *comp) : comp(comp) {
--            Probes::GCStart(comp);
-+        AutoGCProbe(JSRuntime *rt, JSCompartment *comp)
-+            : rt(rt), comp(comp) {
-+            Probes::GCStart(rt, comp);
-         }
-         ~AutoGCProbe() {
--            Probes::GCEnd(comp); /* background thread may still be sweeping */
-+            Probes::GCEnd(rt, comp); /* background thread may still be sweeping */
-         }
--    } autoGCProbe(comp);
-+    } autoGCProbe(rt, comp);
- 
-     do {
-         /*

tmp-idl

-# HG changeset patch
-# Parent 1e9d1bfd4b6ae675761f66b50e595fe3154f0ddf
-
-diff --git a/toolkit/components/probes/nsIProbeService.idl b/toolkit/components/probes/nsIProbeService.idl
---- a/toolkit/components/probes/nsIProbeService.idl
-+++ b/toolkit/components/probes/nsIProbeService.idl
-@@ -50,31 +50,33 @@
-   /* These constants should be in sync with the probes as numbered in
-    * the file js/src/jsprobes.tbl
-    */
--  const PRInt32 JS_RUNTIME_CREATE      =  1;
--  const PRInt32 JS_RUNTIME_DESTROY     =  2;
--  const PRInt32 JS_SHUTDOWN            =  3;
--  const PRInt32 JS_FUNCTION_ENTER      =  4;
--  const PRInt32 JS_FUNCTION_EXIT       =  5;
--  const PRInt32 JS_WILL_EXECUTE_SCRIPT =  6;
--  const PRInt32 JS_DID_EXECUTE_SCRIPT  =  7;
--  const PRInt32 JS_WILL_RESIZE_HEAP    =  8;
--  const PRInt32 JS_OBJECT_CREATE       =  9;
--  const PRInt32 JS_OBJECT_RESIZE       = 10;
--  const PRInt32 JS_OBJECT_FINALIZE     = 11;
--  const PRInt32 JS_STRING_CREATE       = 12;
--  const PRInt32 JS_STRING_FINALIZE     = 13;
--  const PRInt32 JS_WILL_COMPILE_SCRIPT = 14;
--  const PRInt32 JS_DID_COMPILE_SCRIPT  = 15;
--  const PRInt32 JS_WILL_CALL_NATIVE    = 16;
--  const PRInt32 JS_DID_CALL_NATIVE     = 17;
--  const PRInt32 JS_ACQUIRE_MEMORY      = 18;
--  const PRInt32 JS_RELEASE_MEMORY      = 19;
--  const PRInt32 GC_DID_START           = 20;
--  const PRInt32 GC_WILL_END            = 21;
--  const PRInt32 GC_MARK_PHASE_START    = 22;
--  const PRInt32 GC_MARK_PHASE_END      = 23;
--  const PRInt32 GC_SWEEP_PHASE_START   = 24;
--  const PRInt32 GC_SWEEP_PHASE_END     = 25;
-+  const PRInt32 JS_RUNTIME_CREATE          =  1;
-+  const PRInt32 JS_RUNTIME_DESTROY         =  2;
-+  const PRInt32 JS_SHUTDOWN                =  3;
-+  const PRInt32 JS_FUNCTION_ENTER          =  4;
-+  const PRInt32 JS_FUNCTION_EXIT           =  5;
-+  const PRInt32 JS_WILL_EXECUTE_SCRIPT     =  6;
-+  const PRInt32 JS_DID_EXECUTE_SCRIPT      =  7;
-+  const PRInt32 JS_WILL_RESIZE_HEAP        =  8;
-+  const PRInt32 JS_OBJECT_CREATE           =  9;
-+  const PRInt32 JS_OBJECT_RESIZE           = 10;
-+  const PRInt32 JS_OBJECT_FINALIZE         = 11;
-+  const PRInt32 JS_STRING_CREATE           = 12;
-+  const PRInt32 JS_STRING_FINALIZE         = 13;
-+  const PRInt32 JS_WILL_COMPILE_SCRIPT     = 14;
-+  const PRInt32 JS_DID_COMPILE_SCRIPT      = 15;
-+  const PRInt32 JS_WILL_CALL_NATIVE        = 16;
-+  const PRInt32 JS_DID_CALL_NATIVE         = 17;
-+  const PRInt32 JS_ACQUIRE_MEMORY          = 18;
-+  const PRInt32 JS_RELEASE_MEMORY          = 19;
-+  const PRInt32 COMPARTMENT_GC_DID_START   = 20;
-+  const PRInt32 COMPARTMENT_GC_WILL_END    = 21;
-+  const PRInt32 GLOBAL_GC_DID_START        = 22;
-+  const PRInt32 GLOBAL_GC_WILL_END         = 23;
-+  const PRInt32 GC_MARK_PHASE_START        = 24;
-+  const PRInt32 GC_MARK_PHASE_END          = 25;
-+  const PRInt32 GC_SWEEP_PHASE_START       = 26;
-+  const PRInt32 GC_SWEEP_PHASE_END         = 27;
- 
-   /**
-    * Add a handler that should execute whenever the specified probe is fired. 

tmp-integ

-# HG changeset patch
-# Parent ecb3d8c6331a11fcf95d192b8de951b3b673ccc3
-diff --git a/js/src/jsprobes.h b/js/src/jsprobes.h
---- a/js/src/jsprobes.h
-+++ b/js/src/jsprobes.h
-@@ -45,7 +45,7 @@
- #endif
- #include "jspubtd.h"
- #include "jsprvtd.h"
--
-+#include "jscompartment.h"
- #include "jsprobedefs.h"
- #include "jsprobemgr.h"
- 
-@@ -179,8 +179,8 @@
-  * Multiple compartments' GC will be interleaved during a global collection
-  * (eg, compartment 1 starts, compartment 2 starts, compartment 1 ends, ...)
-  */
--bool GCStart(JSCompartment *compartment);
--bool GCEnd(JSCompartment *compartment);
-+bool GCStart(JSRuntime *runtime, JSCompartment *compartment);
-+bool GCEnd(JSRuntime *runtime, JSCompartment *compartment);
- 
- bool GCStartMarkPhase(JSCompartment *compartment);
- bool GCEndMarkPhase(JSCompartment *compartment);
-@@ -231,8 +231,8 @@
- bool ETWCalloutEnd(JSContext *cx, JSFunction *fun);
- bool ETWAcquireMemory(JSContext *cx, void *address, size_t nbytes);
- bool ETWReleaseMemory(JSContext *cx, void *address, size_t nbytes);
--bool ETWGCStart(JSCompartment *compartment);
--bool ETWGCEnd(JSCompartment *compartment);
-+bool ETWGCStart(JSRuntime *runtime, JSCompartment *compartment);
-+bool ETWGCEnd(JSRuntime *runtime, JSCompartment *compartment);
- bool ETWGCStartMarkPhase(JSCompartment *compartment);
- bool ETWGCEndMarkPhase(JSCompartment *compartment);
- bool ETWGCStartSweepPhase(JSCompartment *compartment);
-@@ -369,7 +369,9 @@
- #endif
- #ifdef MOZ_JSPROBES
-     ProbeManager *mgr = ProbeManager::manager();
--    if (!mgr || !mgr->fireProbe(JS_WILL_RESIZE_HEAP, compartment, oldSize, newSize))
-+    if (!mgr 
-+        || mgr->isProbeRuntime(compartment->rt) 
-+        || !mgr->fireProbe(JS_WILL_RESIZE_HEAP, compartment, oldSize, newSize))
-         ok = false;
- #endif
- 
-@@ -555,25 +557,30 @@
- }
- 
- inline bool
--Probes::GCStart(JSCompartment *compartment)
-+Probes::GCStart(JSRuntime *runtime, JSCompartment *compartment)
- {
-     bool ok = true;
- 
- #ifdef MOZ_ETW
--    if (ProfilingActive && !ETWGCStart(compartment))
-+    if (ProfilingActive && !ETWGCStart(runtime, compartment))
-         ok = false;
- #endif
- #ifdef MOZ_JSPROBES
-     ProbeManager *mgr = ProbeManager::manager();
--    if (!compartment || !mgr || !mgr->fireProbe(GC_DID_START, compartment))
--        ok = false;
-+    if (!compartment) {
-+        if (!mgr || !mgr->fireProbe(GLOBAL_GC_DID_START, runtime))
-+            ok = false;
-+    } else {
-+        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_DID_START, runtime, compartment))
-+            ok = false;
-+    }
- #endif
- 
-     return ok;
- }
- 
- inline bool
--Probes::GCEnd(JSCompartment *compartment)
-+Probes::GCEnd(JSRuntime *runtime, JSCompartment *compartment)
- {
-     bool ok = true;
- 
-@@ -581,10 +588,16 @@
-     if (ProfilingActive && !ETWGCEnd(compartment))
-         ok = false;
- #endif
-+
- #ifdef MOZ_JSPROBES
-     ProbeManager *mgr = ProbeManager::manager();
--    if (!compartment || !mgr || !mgr->fireProbe(GC_WILL_END, compartment))
--        ok = false;
-+    if (!compartment) {
-+        if (!mgr || !mgr->fireProbe(GLOBAL_GC_WILL_END, runtime))
-+            ok = false;
-+    } else {
-+        if (!mgr || !mgr->fireProbe(COMPARTMENT_GC_WILL_END, runtime, compartment))
-+            ok = false;
-+    }
- #endif
-     return ok;
- }

tmp-mgr

-# HG changeset patch
-# Parent 745bea3a1b0f0c57b3cd39a2cab21ecc8a320fc9
-diff --git a/js/src/jsprobemgr.cpp b/js/src/jsprobemgr.cpp
---- a/js/src/jsprobemgr.cpp
-+++ b/js/src/jsprobemgr.cpp
-@@ -1550,9 +1550,7 @@
-     void *payloadbuf;
-     void *bufp;
- 
--    JS_BeginRequest(adminCx);
--    payloadbuf = JS_malloc(adminCx, order.totalBytes);
--    JS_EndRequest(adminCx);
-+    payloadbuf = rt->malloc_(order.totalBytes);
- 
-     /* zero the memory for debugging niceness */
-     memset(payloadbuf, 0L, order.totalBytes);
-@@ -1590,7 +1588,7 @@
-         ProbeValue tmp = curArg;
-         for (PickItem::TransformVec::iterator it = item->transforms.begin();
-              it != item->transforms.end(); it++) {
--            if (!(ProbeFunctionData[*it].fn)(adminCx, &tmp)) {
-+            if (!(ProbeFunctionData[*it].fn)(rt, &tmp)) {
-                 PR_LOG(gProbeManagerLog, PR_LOG_ERROR, ("Error when applying transform %d (%s)\n", ProbeFunctionData[*it].transform, ProbeFunctionData[*it].fn_name));
-             }
-         }
-diff --git a/js/src/jsprobemgr.h b/js/src/jsprobemgr.h
---- a/js/src/jsprobemgr.h
-+++ b/js/src/jsprobemgr.h
-@@ -197,6 +197,10 @@
-     /* TODO: inline everything that this calls, as well (EventQueue.push) */
-     bool fireProbe(ProbePoint probe, ...);
- 
-+    /* use these to avoid reentrancy on a different thread (say, by
-+     * triggering a GC or heap resize event on probe runtime) */
-+    bool isProbeRuntime(JSRuntime *runtime) const { return runtime == rt; }
-+
-     bool isScriptRunning() const { return m_scriptRunning; }
-     bool hasPendingScripts() const { return m_pendingScriptCount; }
- 

xpcom-nsIProbeService

 # User Steve Fink <sfink@mozilla.com>
 # Date 1315439921 25200
 # Node ID 485bc3c84dd3b340bade0754c33d4cc094198e5e
-# Parent a436a98c2aca7b380e8e14424e107ad3d6b61f31
+# Parent 8bc1f38580b72db139376d50b8b62fe62d7ba34a
 [mq]: xpcom-probes
 
+diff --git a/js/src/jsprobemgr.cpp b/js/src/jsprobemgr.cpp
+--- a/js/src/jsprobemgr.cpp
++++ b/js/src/jsprobemgr.cpp
+@@ -246,7 +246,6 @@
+ {
+     JS_ASSERT(item->isSealed());
+     items.push_back(item);
+-    totalBytes += ProbeTypeData[item->leafType].bytes;
+ }
+ 
+ void
+@@ -1313,6 +1312,12 @@
+         jsval curObj = argv[offset];
+         uintN transformCount = (*it)->transforms.size();
+ 
++        /* corner case: there are no transforms (i.e., we are unpacking an actual arg to the probe) */
++        if (transformCount == 0) {
++            argv[offset] = unpackedArgs[(*it)->payloadOffset];
++            continue;
++        }
++
+         for (uintN i = 0; i < transformCount; i++) {
+             ProbeTransform curTransform = (*it)->transforms[i];
+             const char *nextPropName = ProbeFunctionData[curTransform].api_name;
+@@ -1579,8 +1584,12 @@
+         /* if need new argument, pull it off the va_list */
+         else if (item->argn != lastArgn) {
+             JS_ASSERT(item->argn > lastArgn); /* should catch misorderings */
+-            lastArgn = item->argn;
+-            void *curArgp = va_arg(argp, void*);
++            void *curArgp;
++
++            while (item->argn != lastArgn) {
++                curArgp = va_arg(argp, void*);
++                lastArgn++;
++            }
+             curArg = ProbeValue(ty, &curArgp);
+         }
+ 
 diff --git a/toolkit/components/Makefile.in b/toolkit/components/Makefile.in
 --- a/toolkit/components/Makefile.in
 +++ b/toolkit/components/Makefile.in
 +include $(topsrcdir)/config/config.mk
 +include $(topsrcdir)/config/rules.mk
 +include $(topsrcdir)/ipc/chromium/chromium-config.mk
-diff --git a/toolkit/components/probes/ProbeService.cpp b/toolkit/components/probes/ProbeService.cpp
-new file mode 100644
---- /dev/null
-+++ b/toolkit/components/probes/ProbeService.cpp
-@@ -0,0 +1,435 @@
-+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-+ * vim: set ts=8 sw=4 et tw=99 ft=cpp:
-+ *
-+ * ***** BEGIN LICENSE BLOCK *****
-+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
-+ *
-+ * The contents of this file are subject to the Mozilla Public License Version
-+ * 1.1 (the "License"); you may not use this file except in compliance with
-+ * the License. You may obtain a copy of the License at
-+ * http://www.mozilla.org/MPL/
-+ *
-+ * Software distributed under the License is distributed on an "AS IS" basis,
-+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-+ * for the specific language governing rights and limitations under the
-+ * License.
-+ *
-+ * The Original Code is mozilla.org code.
-+ *
-+ * The Initial Developer of the Original Code is
-+ *   the Mozilla Corporation.
-+ *
-+ * Contributor(s):
-+ *   Brian J. Burg <burg@cs.washington.edu> (Original Author)
-+ *
-+ * Alternatively, the contents of this file may be used under the terms of
-+ * either of the GNU General Public License Version 2 or later (the "GPL"),
-+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-+ * in which case the provisions of the GPL or the LGPL are applicable instead
-+ * of those above. If you wish to allow use of your version of this file only
-+ * under the terms of either the GPL or the LGPL, and not to allow others to
-+ * use your version of this file under the terms of the MPL, indicate your
-+ * decision by deleting the provisions above and replace them with the notice
-+ * and other provisions required by the GPL or the LGPL. If you do not delete
-+ * the provisions above, a recipient may use your version of this file under
-+ * the terms of any one of the MPL, the GPL or the LGPL.
-+ *
-+ * ***** END LICENSE BLOCK ***** */
-+
-+#include "ProbeService.h"
-+
-+#include "nsIProbeService.h"
-+#include "nsIObserver.h"
-+#include "nsIObserverService.h"
-+#include "nsIScriptContext.h"
-+#include "nsITimer.h"
-+
-+#include "jsprobemgr.h"
-+#include "mozilla/ModuleUtils.h"
-+#include "nsCOMPtr.h"
-+#include "nsContentUtils.h"
-+#include "nsDOMJSUtils.h"
-+#include "nsInterfaceHashtable.h"
-+#include "nsServiceManagerUtils.h"
-+#include "nsThreadUtils.h"
-+#include "prlog.h"
-+
-+
-+#if PR_LOGGING
-+PRLogModuleInfo *gProbeServiceLog = nsnull;
-+#endif
-+#define LOG(_args) PR_LOG(gProbeServiceLog, PR_LOG_DEBUG, _args)
-+
-+namespace mozilla {
-+
-+class ProbeServiceImpl : public nsIProbeService
-+                       , public nsIObserver
-+{
-+    NS_DECL_ISUPPORTS
-+    NS_DECL_NSIPROBESERVICE
-+    NS_DECL_NSIOBSERVER
-+
-+public:
-+    ProbeServiceImpl();
-+    ~ProbeServiceImpl();
-+
-+    nsresult Init();
-+    /* called to actually reclaim members. */
-+    nsresult Cleanup();
-+
-+    static already_AddRefed<nsIProbeService> CreateInstance();
-+    /* called by the service manager to remove refs, trigger destructor */
-+    static void Shutdown();
-+
-+private:
-+    typedef nsInterfaceHashtable<nsUint32HashKey, nsIProbeMessageListener> ListenerMap;
-+    typedef nsInterfaceHashtable<nsUint32HashKey, nsIScriptContext> ContextMap;
-+
-+    bool mHasShutdown;
-+    nsCOMPtr<nsITimer> mDrainTimer;
-+    js::probes::ScriptCookie mPreviousScript;
-+    ListenerMap mListeners;
-+    ContextMap mListenerContexts;
-+    js::probes::ProbeManager *mManager;
-+
-+    static ProbeServiceImpl *sProbeService;
-+
-+    nsresult DispatchMessage(js::probes::Message *msg);
-+    nsresult DrainMessages();
-+    nsresult StartDrainTimer(PRInt32 inverval);
-+
-+};
-+
-+ProbeServiceImpl* ProbeServiceImpl::sProbeService = NULL;
-+
-+ProbeServiceImpl::ProbeServiceImpl()
-+    : mHasShutdown(false)
-+    , mPreviousScript(-1)
-+    , mManager(NULL)
-+{
-+    if (!gProbeServiceLog) {
-+        gProbeServiceLog = PR_NewLogModule("ProbeServiceImpl");
-+    }
-+
-+    LOG(("ProbeServiceImpl::ProbeServiceImpl"));
-+}
-+
-+nsresult
-+ProbeServiceImpl::Init()
-+{
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+
-+    LOG(("ProbeServiceImpl::Init -- initializing service..."));
-+
-+    nsresult rv;
-+    nsCOMPtr<nsIObserverService> obs =
-+        do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+
-+    rv = obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+
-+    LOG(("ProbeServiceImpl -- Creating timer instance"));
-+    mDrainTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
-+    if (NS_FAILED(rv))
-+        return rv;
-+
-+    mListeners.Init(5);
-+    mListenerContexts.Init(5);
-+    mManager = js::probes::ProbeManager::create();
-+    mManager->start();
-+
-+    LOG(("ProbeServiceImpl::Init -- initialized!"));
-+
-+    return NS_OK;
-+}
-+
-+ProbeServiceImpl::~ProbeServiceImpl()
-+{
-+    Cleanup();
-+    LOG(("ProbeServiceImpl::~ProbeServiceImpl"));
-+}
-+
-+already_AddRefed<nsIProbeService>
-+ProbeServiceImpl::CreateInstance()
-+{
-+    NS_ABORT_IF_FALSE(sProbeService == NULL, "ProbeServiceImpl::CreateInstance may only be called once, via GetService()");
-+    sProbeService = new ProbeServiceImpl();
-+    sProbeService->Init();
-+    /* AddRef each for static reference, and the caller. */
-+    NS_ADDREF(sProbeService);
-+    NS_ADDREF(sProbeService);
-+
-+    LOG(("ProbeServiceImpl::CreateInstance"));
-+
-+    return sProbeService;
-+}
-+
-+nsresult
-+ProbeServiceImpl::Cleanup()
-+{
-+    LOG(("ProbeServiceImpl::Cleanup -- starting cleanup..."));
-+
-+    /* reference for this section: dom/src/threads/nsIDOMThreadService.cpp */
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+
-+/* TODO: kill timer */
-+    LOG(("ProbeServiceImpl -- Cancelling Timer"));
-+    mDrainTimer->Cancel();
-+/* TODO: drain any remaining Messages synchronously */
-+    mListeners.Clear();
-+    mListenerContexts.Clear();
-+    
-+    nsresult rv;
-+    nsCOMPtr<nsIObserverService> obs =
-+        do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+    rv = obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-+    NS_ENSURE_SUCCESS(rv, rv);
-+
-+    LOG(("ProbeServiceImpl::Cleanup -- stopping ProbeManager..."));
-+    /* disables probes and joins handler thread */
-+    mManager->shutdown();
-+    mManager = NULL;
-+
-+    LOG(("ProbeServiceImpl::Cleanup -- done!"));
-+    return NS_OK;
-+}
-+
-+void
-+ProbeServiceImpl::Shutdown()
-+{
-+    LOG(("ProbeServiceImpl::Shutdown"));
-+    NS_IF_RELEASE(sProbeService);
-+}
-+
-+nsresult
-+ProbeServiceImpl::DrainMessages()
-+{
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+
-+    LOG(("ProbeServiceImpl -- Draining messages..."));
-+
-+    nsresult rv;
-+
-+    while (mManager->hasMessages()) {
-+        js::probes::Message *msg = mManager->popMessage();
-+        rv = DispatchMessage(msg);
-+        NS_ENSURE_SUCCESS(rv, rv);
-+    }
-+    /* check timer termination condition */
-+    if (!mManager->hasPendingScripts()) {
-+        LOG(("ProbeServiceImpl -- Cancelling Timer"));
-+        mDrainTimer->Cancel();
-+    }
-+
-+    return NS_OK;
-+}
-+
-+nsresult
-+ProbeServiceImpl::DispatchMessage(js::probes::Message *msg)
-+{
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+    NS_ENSURE_ARG(msg);
-+
-+    LOG(("ProbeServiceImpl::DispatchMessage -- dispatching one message"));
-+    using namespace js::probes;
-+
-+    ScriptCookie cookie = msg->getCookie();
-+
-+    /* lookup listener for this scriptcookie */
-+    nsCOMPtr<nsIProbeMessageListener> listener = mListeners.Get(cookie);
-+    nsCOMPtr<nsIScriptContext> scriptCx = mListenerContexts.Get(cookie);
-+    JSContext *cx = (JSContext *) scriptCx->GetNativeContext();
-+
-+    /* unpack message, using cx */
-+    ScriptCookie outCookie;
-+    jsval outVal;
-+
-+    JSAutoRequest req(cx);
-+    /* put the JSContext onto the context stack. */
-+    nsCxPusher cxPusher;
-+    /* is this right, or should it push a null context? */
-+    cxPusher.Push(cx);
-+
-+    JS_AddValueRoot(cx, &outVal);
-+    msg->unpack(cx, &outVal, &outCookie);
-+
-+    LOG(("ProbeServiceImpl::DispatchMessage -- calling listener"));
-+    /* call nsIProbeMessageListener.onMessage(jsval) */
-+    listener->OnMessage(outVal);
-+
-+    JS_RemoveValueRoot(cx, &outVal);
-+    cxPusher.Pop();
-+
-+    /* if script is different from last (and not first), then
-+       it's time to remove the old listener from the listener map */
-+
-+    if (mListeners.Count() > 1 && mPreviousScript != cookie) {
-+        mListeners.Remove(mPreviousScript);
-+        mListenerContexts.Remove(mPreviousScript);
-+    }
-+
-+    mPreviousScript = cookie;
-+
-+    return NS_OK;
-+}
-+
-+/* note that interval specifies milliseconds */
-+nsresult
-+ProbeServiceImpl::StartDrainTimer(PRInt32 interval)
-+{
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+    NS_ASSERTION(mDrainTimer, "cannot use uninitialized timer");
-+
-+    LOG(("ProbeServiceImpl -- initialized/started timer"));
-+    return mDrainTimer->Init(this, interval, nsITimer::TYPE_REPEATING_SLACK);
-+}
-+
-+// nsIObserver
-+
-+NS_IMETHODIMP
-+ProbeServiceImpl::Observe(nsISupports *subject, const char *topic,
-+                          const PRUnichar *data)
-+{
-+  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+
-+  if (strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
-+      Cleanup();
-+      return NS_OK;
-+  }
-+  else if (strcmp(topic, NS_TIMER_CALLBACK_TOPIC) == 0) {
-+    nsresult rv = DrainMessages();
-+    if (NS_FAILED(rv)) {
-+        LOG(("ProbeServiceImpl -- Cancelling Timer"));
-+        mDrainTimer->Cancel();
-+    }
-+  }
-+  return NS_OK;
-+}
-+
-+
-+/*  PRInt32 addHandler(in PRInt32 probe, in AString dataSpec, in AString handler); */
-+
-+NS_IMETHODIMP
-+ProbeServiceImpl::AddHandler(PRInt32 aProbe, const nsAString &aDataSpec, const nsAString &aHandler, PRInt32 *_rval)
-+{
-+    using namespace js::probes;
-+
-+    LOG(("ProbeServiceImpl::AddHandler"));
-+
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+    NS_ASSERTION(mManager, "Manager is missing!");
-+   
-+    if (aDataSpec.IsEmpty())
-+        return NS_ERROR_INVALID_ARG;
-+    if (aHandler.IsEmpty())
-+        return NS_ERROR_INVALID_ARG;
-+
-+    /* get pointer to buffer contained in |code| */
-+    nsAString::const_iterator specIt;
-+    nsAString::const_iterator handlerIt;
-+    aDataSpec.BeginReading(specIt);
-+    aHandler.BeginReading(handlerIt);
-+
-+    ScriptDescriptor specDesc = { reinterpret_cast<const jschar *>(specIt.get()),
-+                                  aDataSpec.Length(),
-+                                  "dummy-spec-file", 1 };
-+    ScriptDescriptor handlerDesc = { reinterpret_cast<const jschar *>(handlerIt.get()),
-+                                     aHandler.Length(),
-+                                     "dummy-handler-file", 1};
-+    
-+    HandlerCookie cookie;
-+
-+    if (!mManager->addProbeHandler((ProbePoint)aProbe, handlerDesc, specDesc, &cookie))
-+      return NS_ERROR_FAILURE;
-+
-+    *_rval = cookie;
-+    return NS_OK;
-+}
-+
-+/* void removeHandler(in PRInt32 cookie); */
-+
-+NS_IMETHODIMP
-+ProbeServiceImpl::RemoveHandler(PRInt32 cookie)
-+{
-+    LOG(("ProbeServiceImpl::RemoveHandler"));
-+
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+    NS_ASSERTION(mManager, "Manager is missing!");
-+
-+    if (!mManager->removeProbeHandler(cookie))
-+        return NS_ERROR_FAILURE;
-+
-+    return NS_OK;
-+}
-+
-+/* void asyncQuery(in AString code, in nsIProbeMessageListener listener); */
-+
-+NS_IMETHODIMP
-+ProbeServiceImpl::AsyncQuery(const nsAString &code, nsIProbeMessageListener *listener, JSContext *cx)
-+{
-+    using namespace js::probes;
-+
-+    LOG(("ProbeServiceImpl::AsyncQuery"));
-+
-+    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-+    NS_ENSURE_ARG(listener);
-+    NS_ENSURE_ARG(cx);
-+
-+    if (code.IsEmpty())
-+        return NS_ERROR_INVALID_ARG;
-+
-+    // get pointer to buffer contained in |code|
-+    nsAString::const_iterator codeIter;
-+    code.BeginReading(codeIter);
-+
-+    ScriptDescriptor codeDesc = { reinterpret_cast<const jschar *>(codeIter.get()),
-+                                  code.Length(),
-+                                  "dummy-async-query-file", 1 };
-+    ScriptCookie codeCookie;
-+
-+    if (!mManager->runScriptOnce(codeDesc, &codeCookie))
-+        return NS_ERROR_FAILURE;
-+
-+    nsIScriptContext *scriptCx = GetScriptContextFromJSContext(cx);
-+    if (!scriptCx)
-+        return NS_ERROR_FAILURE;
-+
-+    mListeners.Put(codeCookie, listener);
-+    mListenerContexts.Put(codeCookie, scriptCx);
-+    StartDrainTimer(1000);
-+
-+    return NS_OK;
-+}
-+
-+NS_IMPL_THREADSAFE_ISUPPORTS1(ProbeServiceImpl, nsIProbeService)
-+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIProbeService, ProbeServiceImpl::CreateInstance)
-+
-+#define NS_PROBESERVICE_CID \
-+{0x44ac0450, 0xeb4c, 0x4a4d, {0xa1, 0x9c, 0x93, 0x38, 0x91, 0x59, 0xa6, 0x27}}
-+NS_DEFINE_NAMED_CID(NS_PROBESERVICE_CID);
-+
-+const Module::CIDEntry kProbeServiceCIDs[] = {
-+  { &kNS_PROBESERVICE_CID, false, NULL, nsIProbeServiceConstructor },
-+  { NULL }
-+};
-+
-+const Module::ContractIDEntry kProbeServiceContracts[] = {
-+  { "@mozilla.org/base/probes;1", &kNS_PROBESERVICE_CID },
-+  { NULL }
-+};
-+
-+const Module kProbeServiceModule = {
-+  Module::kVersion,
-+  kProbeServiceCIDs,
-+  kProbeServiceContracts,
-+  NULL,
-+  NULL,
-+  NULL,
-+  ProbeServiceImpl::Shutdown
-+};
-+
-+} // namespace mozilla
-+
-+NSMODULE_DEFN(nsProbesModule) = &mozilla::kProbeServiceModule;
 diff --git a/toolkit/components/probes/ProbeService.h b/toolkit/components/probes/ProbeService.h
 new file mode 100644
 --- /dev/null
 new file mode 100644
 --- /dev/null
 +++ b/toolkit/components/probes/nsIProbeService.idl
-@@ -0,0 +1,107 @@
+@@ -0,0 +1,109 @@
 +/* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 +/* ***** BEGIN LICENSE BLOCK *****
 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 +  /* These constants should be in sync with the probes as numbered in
 +   * the file js/src/jsprobes.tbl
 +   */
-+  const PRInt32 JS_RUNTIME_CREATE      =  1;
-+  const PRInt32 JS_RUNTIME_DESTROY     =  2;
-+  const PRInt32 JS_SHUTDOWN            =  3;
-+  const PRInt32 JS_FUNCTION_ENTER      =  4;
-+  const PRInt32 JS_FUNCTION_EXIT       =  5;
-+  const PRInt32 JS_WILL_EXECUTE_SCRIPT =  6;
-+  const PRInt32 JS_DID_EXECUTE_SCRIPT  =  7;
-+  const PRInt32 JS_WILL_RESIZE_HEAP    =  8;
-+  const PRInt32 JS_OBJECT_CREATE       =  9;
-+  const PRInt32 JS_OBJECT_RESIZE       = 10;
-+  const PRInt32 JS_OBJECT_FINALIZE     = 11;
-+  const PRInt32 JS_STRING_CREATE       = 12;
-+  const PRInt32 JS_STRING_FINALIZE     = 13;
-+  const PRInt32 JS_WILL_COMPILE_SCRIPT = 14;
-+  const PRInt32 JS_DID_COMPILE_SCRIPT  = 15;
-+  const PRInt32 JS_WILL_CALL_NATIVE    = 16;
-+  const PRInt32 JS_DID_CALL_NATIVE     = 17;
-+  const PRInt32 JS_ACQUIRE_MEMORY      = 18;
-+  const PRInt32 JS_RELEASE_MEMORY      = 19;
-+  const PRInt32 GC_DID_START           = 20;
-+  const PRInt32 GC_WILL_END            = 21;
-+  const PRInt32 GC_MARK_PHASE_START    = 22;
-+  const PRInt32 GC_MARK_PHASE_END      = 23;
-+  const PRInt32 GC_SWEEP_PHASE_START   = 24;
-+  const PRInt32 GC_SWEEP_PHASE_END     = 25;
++  const PRInt32 JS_RUNTIME_CREATE          =  1;
++  const PRInt32 JS_RUNTIME_DESTROY         =  2;
++  const PRInt32 JS_SHUTDOWN                =  3;
++  const PRInt32 JS_FUNCTION_ENTER          =  4;
++  const PRInt32 JS_FUNCTION_EXIT           =  5;
++  const PRInt32 JS_WILL_EXECUTE_SCRIPT     =  6;
++  const PRInt32 JS_DID_EXECUTE_SCRIPT      =  7;
++  const PRInt32 JS_WILL_RESIZE_HEAP        =  8;
++  const PRInt32 JS_OBJECT_CREATE           =  9;
++  const PRInt32 JS_OBJECT_RESIZE           = 10;
++  const PRInt32 JS_OBJECT_FINALIZE         = 11;
++  const PRInt32 JS_STRING_CREATE           = 12;
++  const PRInt32 JS_STRING_FINALIZE         = 13;
++  const PRInt32 JS_WILL_COMPILE_SCRIPT     = 14;
++  const PRInt32 JS_DID_COMPILE_SCRIPT      = 15;
++  const PRInt32 JS_WILL_CALL_NATIVE        = 16;
++  const PRInt32 JS_DID_CALL_NATIVE         = 17;
++  const PRInt32 JS_ACQUIRE_MEMORY          = 18;
++  const PRInt32 JS_RELEASE_MEMORY          = 19;
++  const PRInt32 COMPARTMENT_GC_DID_START   = 20;
++  const PRInt32 COMPARTMENT_GC_WILL_END    = 21;
++  const PRInt32 GLOBAL_GC_DID_START        = 22;
++  const PRInt32 GLOBAL_GC_WILL_END         = 23;
++  const PRInt32 GC_MARK_PHASE_START        = 24;
++  const PRInt32 GC_MARK_PHASE_END          = 25;
++  const PRInt32 GC_SWEEP_PHASE_START       = 26;
++  const PRInt32 GC_SWEEP_PHASE_END         = 27;
 +
 +  /**
 +   * Add a handler that should execute whenever the specified probe is fired.