зеркало из https://github.com/mozilla/gecko-dev.git
Bug 562144: Make DTrace hooks pretty. (r=sayrer)
This commit is contained in:
Родитель
a053a26298
Коммит
f574b6dcec
|
@ -33,7 +33,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
#include "javascript-trace.h"
|
||||
#endif
|
||||
#include "jspubtd.h"
|
||||
#include "jsprvtd.h"
|
||||
|
||||
|
@ -78,4 +80,91 @@ jsdtrace_execute_done(JSScript *script);
|
|||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
namespace js {
|
||||
|
||||
class DTrace {
|
||||
public:
|
||||
/*
|
||||
* If |lval| is provided to the enter/exit methods, it is tested to see if
|
||||
* it is a function as a predicate to the dtrace event emission.
|
||||
*/
|
||||
static void enterJSFun(const JSContext *cx, const JSStackFrame *fp, const JSFunction *fun,
|
||||
const JSStackFrame *dfp, jsuint argc, const jsval *argv,
|
||||
const jsval *lval = NULL);
|
||||
static void exitJSFun(const JSContext *cx, const JSStackFrame *fp, const JSFunction *fun,
|
||||
const jsval *rval, const jsval *lval = NULL);
|
||||
|
||||
static void finalizeObject(const JSObject *obj);
|
||||
|
||||
class ExecutionScope {
|
||||
const JSScript *script;
|
||||
void startExecution();
|
||||
void endExecution();
|
||||
public:
|
||||
explicit ExecutionScope(const JSScript *script) : script(script) { startExecution(); }
|
||||
~ExecutionScope() { endExecution(); }
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
inline void
|
||||
DTrace::enterJSFun(const JSContext *cx, const JSStackFrame *fp, const JSFunction *fun,
|
||||
const JSStackFrame *dfp, jsuint argc, const jsval *argv,
|
||||
const jsval *lval)
|
||||
{
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (!lval || VALUE_IS_FUNCTION(cx, lval)) {
|
||||
if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
|
||||
jsdtrace_function_entry(cx, &frame, fun);
|
||||
if (JAVASCRIPT_FUNCTION_INFO_ENABLED())
|
||||
jsdtrace_function_info(cx, &frame, frame.down, fun);
|
||||
if (JAVASCRIPT_FUNCTION_ARGS_ENABLED())
|
||||
jsdtrace_function_args(cx, &frame, fun, frame.argc, frame.argv);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
DTrace::exitJSFun(const JSContext *cx, const JSStackFrame *fp, const JSFunction *fun,
|
||||
const jsval *rval, const jsval *lval)
|
||||
{
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (!lval || VALUE_IS_FUNCTION(cx, lval)) {
|
||||
if (JAVASCRIPT_FUNCTION_RVAL_ENABLED())
|
||||
jsdtrace_function_rval(cx, fp, fun, rval);
|
||||
if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
|
||||
jsdtrace_function_return(cx, fp, fun);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
DTrace::finalizeObject(const JSObject *obj)
|
||||
{
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (JAVASCRIPT_OBJECT_FINALIZE_ENABLED())
|
||||
jsdtrace_object_finalize(obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
DTrace::ExecutionScope::startExecution()
|
||||
{
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (JAVASCRIPT_EXECUTE_START_ENABLED())
|
||||
jsdtrace_execute_start(script);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void
|
||||
DTrace::ExecutionScope::endExecution()
|
||||
{
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (JAVASCRIPT_EXECUTE_END_ENABLED())
|
||||
jsdtrace_execute_done(script);
|
||||
#endif
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* _JSDTRACE_H */
|
||||
|
|
|
@ -84,10 +84,7 @@
|
|||
#include "jsxml.h"
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
#include "jsdtracef.h"
|
||||
#endif
|
||||
|
||||
#include "jscntxtinlines.h"
|
||||
#include "jsobjinlines.h"
|
||||
|
||||
|
@ -2520,10 +2517,7 @@ FinalizeObject(JSContext *cx, JSObject *obj, unsigned thingKind)
|
|||
if (clasp->finalize)
|
||||
clasp->finalize(cx, obj);
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (JAVASCRIPT_OBJECT_FINALIZE_ENABLED())
|
||||
jsdtrace_object_finalize(obj);
|
||||
#endif
|
||||
DTrace::finalizeObject(obj);
|
||||
|
||||
if (JS_LIKELY(obj->isNative())) {
|
||||
JSScope *scope = obj->scope();
|
||||
|
|
|
@ -81,10 +81,7 @@
|
|||
#include "jsscopeinlines.h"
|
||||
#include "jsscriptinlines.h"
|
||||
#include "jsstrinlines.h"
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
#include "jsdtracef.h"
|
||||
#endif
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
#include "jsxml.h"
|
||||
|
@ -814,15 +811,7 @@ js_Invoke(JSContext *cx, uintN argc, jsval *vp, uintN flags)
|
|||
if (hook)
|
||||
hookData = hook(cx, &frame, JS_TRUE, 0, cx->debugHooks->callHookData);
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
/* DTrace function entry, non-inlines */
|
||||
if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
|
||||
jsdtrace_function_entry(cx, &frame, fun);
|
||||
if (JAVASCRIPT_FUNCTION_INFO_ENABLED())
|
||||
jsdtrace_function_info(cx, &frame, frame.down, fun);
|
||||
if (JAVASCRIPT_FUNCTION_ARGS_ENABLED())
|
||||
jsdtrace_function_args(cx, &frame, fun, frame.argc, frame.argv);
|
||||
#endif
|
||||
DTrace::enterJSFun(cx, &frame, fun, frame.down, frame.argc, frame.argv);
|
||||
|
||||
/* Call the function, either a native method or an interpreted script. */
|
||||
if (native) {
|
||||
|
@ -842,13 +831,7 @@ js_Invoke(JSContext *cx, uintN argc, jsval *vp, uintN flags)
|
|||
ok = js_Interpret(cx);
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
/* DTrace function return, non-inlines */
|
||||
if (JAVASCRIPT_FUNCTION_RVAL_ENABLED())
|
||||
jsdtrace_function_rval(cx, &frame, fun, &frame.rval);
|
||||
if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
|
||||
jsdtrace_function_return(cx, &frame, fun);
|
||||
#endif
|
||||
DTrace::exitJSFun(cx, &frame, fun, &frame.rval);
|
||||
|
||||
out:
|
||||
if (hookData) {
|
||||
|
@ -948,20 +931,7 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
|
|||
|
||||
LeaveTrace(cx);
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
struct JSDNotifyGuard {
|
||||
JSScript *script;
|
||||
JSDNotifyGuard(JSScript *s) : script(s) {
|
||||
if (JAVASCRIPT_EXECUTE_START_ENABLED())
|
||||
jsdtrace_execute_start(script);
|
||||
}
|
||||
~JSDNotifyGuard() {
|
||||
if (JAVASCRIPT_EXECUTE_DONE_ENABLED())
|
||||
jsdtrace_execute_done(script);
|
||||
}
|
||||
|
||||
} jsdNotifyGuard(script);
|
||||
#endif
|
||||
DTrace::ExecutionScope executionScope(script);
|
||||
|
||||
JSInterpreterHook hook = cx->debugHooks->executeHook;
|
||||
void *hookData = NULL;
|
||||
|
|
|
@ -93,10 +93,7 @@
|
|||
#include "jsxdrapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
#include "jsdtracef.h"
|
||||
#endif
|
||||
|
||||
#include "jsatominlines.h"
|
||||
#include "jsobjinlines.h"
|
||||
#include "jsscriptinlines.h"
|
||||
|
|
|
@ -258,13 +258,7 @@ BEGIN_CASE(JSOP_STOP)
|
|||
*/
|
||||
fp->putActivationObjects(cx);
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
/* DTrace function return, inlines */
|
||||
if (JAVASCRIPT_FUNCTION_RVAL_ENABLED())
|
||||
jsdtrace_function_rval(cx, fp, fp->fun, &fp->rval);
|
||||
if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
|
||||
jsdtrace_function_return(cx, fp, fp->fun);
|
||||
#endif
|
||||
DTrace::exitJSFun(cx, fp, fp->fun, &fp->rval);
|
||||
|
||||
/* Restore context version only if callee hasn't set version. */
|
||||
if (JS_LIKELY(cx->version == currentVersion)) {
|
||||
|
@ -2163,15 +2157,7 @@ BEGIN_CASE(JSOP_APPLY)
|
|||
inlineCallCount++;
|
||||
JS_RUNTIME_METER(rt, inlineCalls);
|
||||
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
/* DTrace function entry, inlines */
|
||||
if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
|
||||
jsdtrace_function_entry(cx, fp, fun);
|
||||
if (JAVASCRIPT_FUNCTION_INFO_ENABLED())
|
||||
jsdtrace_function_info(cx, fp, fp->down, fun);
|
||||
if (JAVASCRIPT_FUNCTION_ARGS_ENABLED())
|
||||
jsdtrace_function_args(cx, fp, fun, fp->argc, fp->argv);
|
||||
#endif
|
||||
DTrace::enterJSFun(cx, fp, fun, fp->down, fp->argc, fp->argv);
|
||||
|
||||
#ifdef JS_TRACER
|
||||
if (TraceRecorder *tr = TRACE_RECORDER(cx)) {
|
||||
|
@ -2205,30 +2191,13 @@ BEGIN_CASE(JSOP_APPLY)
|
|||
}
|
||||
|
||||
if (fun->flags & JSFUN_FAST_NATIVE) {
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
/* DTrace function entry, non-inlines */
|
||||
if (VALUE_IS_FUNCTION(cx, lval)) {
|
||||
if (JAVASCRIPT_FUNCTION_ENTRY_ENABLED())
|
||||
jsdtrace_function_entry(cx, NULL, fun);
|
||||
if (JAVASCRIPT_FUNCTION_INFO_ENABLED())
|
||||
jsdtrace_function_info(cx, NULL, fp, fun);
|
||||
if (JAVASCRIPT_FUNCTION_ARGS_ENABLED())
|
||||
jsdtrace_function_args(cx, fp, fun, argc, vp+2);
|
||||
}
|
||||
#endif
|
||||
DTrace::enterJSFun(cx, NULL, fun, fp, argc, vp + 2, &lval);
|
||||
|
||||
JS_ASSERT(fun->u.n.extra == 0);
|
||||
JS_ASSERT(JSVAL_IS_OBJECT(vp[1]) ||
|
||||
PRIMITIVE_THIS_TEST(fun, vp[1]));
|
||||
ok = ((JSFastNative) fun->u.n.native)(cx, argc, vp);
|
||||
#ifdef INCLUDE_MOZILLA_DTRACE
|
||||
if (VALUE_IS_FUNCTION(cx, lval)) {
|
||||
if (JAVASCRIPT_FUNCTION_RVAL_ENABLED())
|
||||
jsdtrace_function_rval(cx, NULL, fun, vp);
|
||||
if (JAVASCRIPT_FUNCTION_RETURN_ENABLED())
|
||||
jsdtrace_function_return(cx, NULL, fun);
|
||||
}
|
||||
#endif
|
||||
DTrace::exitJSFun(cx, NULL, fun, vp, &lval);
|
||||
regs.sp = vp + 1;
|
||||
if (!ok) {
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче