Hi, as a follow on from my earlier
post on adding dynamic instrumentation to mozilla, just wanted to let
you all know that we have now put up a patch for Brendan Gregg's
Javascript probes that will apply on top of the infrastructure patch
we posted earlier 
All of the probes listed in Brendan's Blog on JavaScript and DTrace will work:
Demo of the Javascript probes in action
But we have changed the namespace to be in sync with the other mozilla probes, so you will need to change the probe names in the script appropriately, for example:
Change: javascript*:::function-entry to trace_mozilla*:::js_function-entry
Applying the Javascript patch
Follow the instructions below to apply the Mozilla Infrastructure and layout patch:
Adding Dtrace probes to Mozilla
Then apply the Mozilla Javascript probe patch:
Apply mozilla-js.diff downloaded from bug 370906
$ cd mozilla $ gpatch -p0 -i mozilla-js.diff
Rebuild mozilla as described above, not forgetting to run ./configure –enable-dtrace before hand. Test the probes have been applied by running the newly patched firefox-bin and listing the probes as described below.
Available Javascript Probes
To list the available javascript probes once the patch is applied and mozilla rebuilt with --enable-dtrace, just type:
$ cd mozilla/dist/bin $ export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH" $ ./firefox-bin &
$ dtrace -n
'trace_mozilla*:::js*' -l
ID PROVIDER MODULE FUNCTION NAME
35 trace_mozilla1815 libmozjs.so jsdtrace_execute_done js_execute-done 35 trace_mozilla1815 libmozjs.so jsdtrace_execute_done jsdtrace_execute_start 35 trace_mozilla1815 libmozjs.so jsdtrace_execute_done js_execute-done
:
Example
js_funcalls.d
This script counts all of the
javascript function calls that are being executed by firefox and
lists the originating file for the javascript code, listed under FUNC
and FILE respectively. You could use a predicate to exclude
javascript being used by the browser's chrome UI if you wished, but
this simple script just counts all of the function calls. See
Brendan's blog for lots more examples 
#pragma D option quiet
dtrace:::BEGIN
{
printf("Tracing...Hit Ctrl-C to end.\n"
}
trace_mozilla*:::js_function-entry
{
@funcs[basename(copyinstr(arg0)), copyinstr(arg2)] = count();
}
dtrace:::END
{
printf("%-32s %-36s %8s\n", "FILE", "FUNC","CALLS"
printa("%-32s %-36s %@8d\n", @funcs);
}
$ dtrace -s js_funcalls.d
FILE FUNC CALLS
autocomplete.xml createEvent 1
autocomplete.xml dispatchEvent 1
: browser.xml QueryInterface 130
nsSessionStore.js QueryInterface 987
nsSessionStore.js getNext 988
nsSessionStore.js hasMoreElements 990
;