зеркало из https://github.com/mozilla/gecko-dev.git
Bug 444845, js hooks to control vtune, r=sayrer
This commit is contained in:
Родитель
24b24a3218
Коммит
ec10e9a4f4
|
@ -106,6 +106,7 @@ MOZ_MEMORY = @MOZ_MEMORY@
|
|||
MOZ_JPROF = @MOZ_JPROF@
|
||||
MOZ_SHARK = @MOZ_SHARK@
|
||||
MOZ_CALLGRIND = @MOZ_CALLGRIND@
|
||||
MOZ_VTUNE = @MOZ_VTUNE@
|
||||
DEHYDRA_PATH = @DEHYDRA_PATH@
|
||||
|
||||
MOZ_XPCTOOLS = @MOZ_XPCTOOLS@
|
||||
|
|
14
configure.in
14
configure.in
|
@ -6459,13 +6459,24 @@ dnl ========================================================
|
|||
dnl callgrind
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(callgrind,
|
||||
[ --enable-callgrind Enable callgrind profiling],
|
||||
[ --enable-callgrind Enable callgrind profiling],
|
||||
MOZ_CALLGRIND=1,
|
||||
MOZ_CALLGRIND= )
|
||||
if test -n "$MOZ_CALLGRIND"; then
|
||||
AC_DEFINE(MOZ_CALLGRIND)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl vtune
|
||||
dnl ========================================================
|
||||
MOZ_ARG_ENABLE_BOOL(vtune,
|
||||
[ --enable-vtune Enable vtune profiling],
|
||||
MOZ_VTUNE=1,
|
||||
MOZ_VTUNE= )
|
||||
if test -n "$MOZ_VTUNE"; then
|
||||
AC_DEFINE(MOZ_VTUNE)
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Enable static checking using gcc-dehydra
|
||||
dnl ========================================================
|
||||
|
@ -7861,6 +7872,7 @@ AC_SUBST(MOZ_LEAKY)
|
|||
AC_SUBST(MOZ_JPROF)
|
||||
AC_SUBST(MOZ_SHARK)
|
||||
AC_SUBST(MOZ_CALLGRIND)
|
||||
AC_SUBST(MOZ_VTUNE)
|
||||
AC_SUBST(MOZ_XPCTOOLS)
|
||||
AC_SUBST(MOZ_JSLOADER)
|
||||
AC_SUBST(MOZ_USE_NATIVE_UCONV)
|
||||
|
|
|
@ -3114,6 +3114,16 @@ static JSFunctionSpec CallgrindFunctions[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_VTUNE
|
||||
static JSFunctionSpec VtuneFunctions[] = {
|
||||
{"startVtune", js_StartVtune, 1, 0, 0},
|
||||
{"stopVtune", js_StopVtune, 0, 0, 0},
|
||||
{"pauseVtune", js_PauseVtune, 0, 0, 0},
|
||||
{"resumeVtune", js_ResumeVtune, 0, 0, 0},
|
||||
{nsnull, nsnull, 0, 0, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsJSContext::InitClasses(void *aGlobalObj)
|
||||
{
|
||||
|
@ -3156,6 +3166,11 @@ nsJSContext::InitClasses(void *aGlobalObj)
|
|||
::JS_DefineFunctions(mContext, globalObj, CallgrindFunctions);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_VTUNE
|
||||
// Attempt to initialize Vtune functions
|
||||
::JS_DefineFunctions(mContext, globalObj, VtuneFunctions);
|
||||
#endif
|
||||
|
||||
JSOptionChangedCallback(js_options_dot_str, this);
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -308,6 +308,12 @@ CXXFLAGS += -F/System/Library/PrivateFrameworks
|
|||
LDFLAGS += -F/System/Library/PrivateFrameworks -framework CHUD
|
||||
endif
|
||||
|
||||
ifdef MOZ_VTUNE
|
||||
CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
|
||||
EXTRA_DSO_LDOPTS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
|
||||
LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
|
||||
endif
|
||||
|
||||
LDFLAGS += $(pathsubst -l%,$(NSPR_STATIC_PATH)/%.a,$(NSPR_LIBS))
|
||||
|
||||
# BeOS and HP-UX do not require the extra linking of "-lm"
|
||||
|
|
|
@ -97,6 +97,11 @@ endif
|
|||
ifdef MOZ_CALLGRIND
|
||||
DEFINES += -DMOZ_CALLGRIND
|
||||
endif
|
||||
ifdef MOZ_VTUNE
|
||||
DEFINES += -DMOZ_VTUNE
|
||||
CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
|
||||
OTHER_LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
|
||||
endif
|
||||
|
||||
ifndef NO_LIBM
|
||||
LDFLAGS += -lm
|
||||
|
|
|
@ -2834,6 +2834,12 @@ static JSFunctionSpec shell_functions[] = {
|
|||
JS_FS("stopCallgrind", js_StopCallgrind, 0,0,0),
|
||||
JS_FS("dumpCallgrind", js_DumpCallgrind, 1,0,0),
|
||||
#endif
|
||||
#ifdef MOZ_VTUNE
|
||||
JS_FS("startVtune", js_StartVtune, 1,0,0),
|
||||
JS_FS("stopVtune", js_StopVtune, 0,0,0),
|
||||
JS_FS("pauseVtune", js_PauseVtune, 0,0,0),
|
||||
JS_FS("resumeVtune", js_ResumeVtune, 0,0,0),
|
||||
#endif
|
||||
#ifdef DEBUG_ARRAYS
|
||||
JS_FS("arrayInfo", js_ArrayInfo, 1,0,0),
|
||||
#endif
|
||||
|
@ -2914,7 +2920,13 @@ static const char *const shell_help_messages[] = {
|
|||
#ifdef MOZ_CALLGRIND
|
||||
"startCallgrind() Start callgrind instrumentation.\n",
|
||||
"stopCallgrind() Stop callgrind instumentation.",
|
||||
"dumpCallgrind() Dump callgrind counters.\n",
|
||||
"dumpCallgrind([name]) Dump callgrind counters.\n",
|
||||
#endif
|
||||
#ifdef MOZ_VTUNE
|
||||
"startVtune([filename]) Start vtune instrumentation.\n",
|
||||
"stopVtune() Stop vtune instumentation.",
|
||||
"pauseVtune() Pause vtune collection.\n",
|
||||
"resumeVtune() Resume vtune collection.\n",
|
||||
#endif
|
||||
#ifdef DEBUG_ARRAYS
|
||||
"arrayInfo(a1, a2, ...) Report statistics about arrays.",
|
||||
|
|
|
@ -1843,3 +1843,123 @@ js_DumpCallgrind(JSContext *cx, JSObject *obj,
|
|||
}
|
||||
|
||||
#endif /* MOZ_CALLGRIND */
|
||||
|
||||
#ifdef MOZ_VTUNE
|
||||
#include <VTuneApi.h>
|
||||
|
||||
static const char *vtuneErrorMessages[] = {
|
||||
"unknown, error #0",
|
||||
"invalid 'max samples' field",
|
||||
"invalid 'samples per buffer' field",
|
||||
"invalid 'sample interval' field",
|
||||
"invalid path",
|
||||
"sample file in use",
|
||||
"invalid 'number of events' field",
|
||||
"unknown, error #7",
|
||||
"internal error",
|
||||
"bad event name",
|
||||
"VTStopSampling called without calling VTStartSampling",
|
||||
"no events selected for event-based sampling",
|
||||
"events selected cannot be run together",
|
||||
"no sampling parameters",
|
||||
"sample database already exists",
|
||||
"sampling already started",
|
||||
"time-based sampling not supported",
|
||||
"invalid 'sampling parameters size' field",
|
||||
"invalid 'event size' field",
|
||||
"sampling file already bound",
|
||||
"invalid event path",
|
||||
"invalid license",
|
||||
"invalid 'global options' field",
|
||||
|
||||
};
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_StartVtune(JSContext *cx, JSObject *obj,
|
||||
uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
VTUNE_EVENT events[] = {
|
||||
{ 1000000, 0, 0, 0, "CPU_CLK_UNHALTED.CORE" },
|
||||
{ 1000000, 0, 0, 0, "INST_RETIRED.ANY" },
|
||||
};
|
||||
|
||||
U32 n_events = sizeof(events) / sizeof(VTUNE_EVENT);
|
||||
char *default_filename = "mozilla-vtune.tb5";
|
||||
JSString *str;
|
||||
U32 status;
|
||||
|
||||
VTUNE_SAMPLING_PARAMS params = {
|
||||
sizeof(VTUNE_SAMPLING_PARAMS),
|
||||
sizeof(VTUNE_EVENT),
|
||||
0, 0, /* Reserved fields */
|
||||
1, /* Initialize in "paused" state */
|
||||
0, /* Max samples, or 0 for "continuous" */
|
||||
4096, /* Samples per buffer */
|
||||
0.1, /* Sampling interval in ms */
|
||||
1, /* 1 for event-based sampling, 0 for time-based */
|
||||
|
||||
n_events,
|
||||
events,
|
||||
default_filename,
|
||||
};
|
||||
|
||||
if (argc > 0 && JSVAL_IS_STRING(argv[0])) {
|
||||
str = JSVAL_TO_STRING(argv[0]);
|
||||
params.tb5Filename = js_DeflateString(cx,
|
||||
JSSTRING_CHARS(str),
|
||||
JSSTRING_LENGTH(str));
|
||||
}
|
||||
|
||||
status = VTStartSampling(¶ms);
|
||||
|
||||
if (params.tb5Filename != default_filename)
|
||||
JS_free(cx, params.tb5Filename);
|
||||
|
||||
if (status != 0) {
|
||||
if (status == VTAPI_MULTIPLE_RUNS)
|
||||
VTStopSampling(0);
|
||||
if (status < sizeof(vtuneErrorMessages))
|
||||
JS_ReportError(cx, "Vtune setup error: %s",
|
||||
vtuneErrorMessages[status]);
|
||||
else
|
||||
JS_ReportError(cx, "Vtune setup error: %d",
|
||||
status);
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_StopVtune(JSContext *cx, JSObject *obj,
|
||||
uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
U32 status = VTStopSampling(1);
|
||||
if (status) {
|
||||
if (status < sizeof(vtuneErrorMessages))
|
||||
JS_ReportError(cx, "Vtune shutdown error: %s",
|
||||
vtuneErrorMessages[status]);
|
||||
else
|
||||
JS_ReportError(cx, "Vtune shutdown error: %d",
|
||||
status);
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_PauseVtune(JSContext *cx, JSObject *obj,
|
||||
uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
VTPause();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSBool)
|
||||
js_ResumeVtune(JSContext *cx, JSObject *obj,
|
||||
uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
VTResume();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#endif /* MOZ_VTUNE */
|
||||
|
|
|
@ -475,6 +475,26 @@ js_DumpCallgrind(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
#endif /* MOZ_CALLGRIND */
|
||||
|
||||
#ifdef MOZ_VTUNE
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_StartVtune(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_StopVtune(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_PauseVtune(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
js_ResumeVtune(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval);
|
||||
|
||||
#endif /* MOZ_VTUNE */
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdbgapi_h___ */
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
#include "prmem.h"
|
||||
#include "plbase64.h"
|
||||
|
||||
#if defined(MOZ_SHARK) || defined(MOZ_CALLGRIND)
|
||||
#if defined(MOZ_SHARK) || defined(MOZ_CALLGRIND) || defined(MOZ_VTUNE)
|
||||
#include "jsdbgapi.h"
|
||||
#endif
|
||||
|
||||
|
@ -286,6 +286,12 @@ static JSFunctionSpec gGlobalFun[] = {
|
|||
{"startCallgrind", js_StartCallgrind, 0,0,0},
|
||||
{"stopCallgrind", js_StopCallgrind, 0,0,0},
|
||||
{"dumpCallgrind", js_DumpCallgrind, 1,0,0},
|
||||
#endif
|
||||
#ifdef MOZ_VTUNE
|
||||
{"startVtune", js_StartVtune, 1,0,0},
|
||||
{"stopVtune", js_StopVtune, 0,0,0},
|
||||
{"pauseVtune", js_PauseVtune, 0,0,0},
|
||||
{"resumeVtune", js_ResumeVtune, 0,0,0},
|
||||
#endif
|
||||
{nsnull,nsnull,0,0,0}
|
||||
};
|
||||
|
|
|
@ -77,6 +77,11 @@ endif
|
|||
ifdef MOZ_CALLGRIND
|
||||
DEFINES += -DMOZ_CALLGRIND
|
||||
endif
|
||||
ifdef MOZ_VTUNE
|
||||
DEFINES += -DMOZ_VTUNE
|
||||
CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
|
||||
LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
|
||||
endif
|
||||
#
|
||||
# Line editing support. If your OS supplies the readline library, define
|
||||
# JS_READLINE to get line editing in the xpcshell.
|
||||
|
|
Загрузка…
Ссылка в новой задаче