From 95046339c81e410b8b82f0712a6200e8f4f6f1b0 Mon Sep 17 00:00:00 2001 From: "haraken@chromium.org" Date: Tue, 5 Mar 2013 12:38:28 +0000 Subject: Expose global state variables for sampling tracing to WebKit We are implementing TRACE_EVENT macros for sampling profiling. It works in the following mechanism: - Chromium defines global state variables for sampling profiling. (i.e. g_trace_state0, g_trace_state1, g_trace_state2 in trace_event.h) - WebKit gets the addresses of the global state variables at the initialization step. (i.e. EventTracer::initialize()) - WebKit updates the global states by using TRACE_EVENT_SAMPLING_STATE() macros every time WebKit changes its state. (e.g. DOM attribute getters/setters/methods) - A sampling thread running in Chrome reads the global states periodically and visualizes the profiling results into about://tracing. In this issue, we make a Chromium side change to implement a WebKit API to get the addresses of the global states. The WebKit patch is here: https://bugs.webkit.org/show_bug.cgi?id=110932 Review URL: https://chromiumcodereview.appspot.com/12316146 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186162 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/webkitplatformsupport_impl.cc | 16 +++++++++++++++- webkit/glue/webkitplatformsupport_impl.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'webkit/glue') diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc index 34e63d2..0064ce9 100644 --- a/webkit/glue/webkitplatformsupport_impl.cc +++ b/webkit/glue/webkitplatformsupport_impl.cc @@ -10,7 +10,6 @@ #include "base/allocator/allocator_extension.h" #include "base/bind.h" -#include "base/debug/trace_event.h" #include "base/memory/discardable_memory.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" @@ -453,6 +452,21 @@ const unsigned char* WebKitPlatformSupportImpl::getTraceCategoryEnabledFlag( return TRACE_EVENT_API_GET_CATEGORY_ENABLED(category_name); } +long* WebKitPlatformSupportImpl::getTraceSamplingState( + const unsigned thread_bucket) { + switch(thread_bucket) { + case 0: + return reinterpret_cast(&TRACE_EVENT_API_THREAD_BUCKET(0)); + case 1: + return reinterpret_cast(&TRACE_EVENT_API_THREAD_BUCKET(1)); + case 2: + return reinterpret_cast(&TRACE_EVENT_API_THREAD_BUCKET(2)); + default: + NOTREACHED() << "Unknown thread bucket type."; + } + return NULL; +} + void WebKitPlatformSupportImpl::addTraceEvent( char phase, const unsigned char* category_enabled, diff --git a/webkit/glue/webkitplatformsupport_impl.h b/webkit/glue/webkitplatformsupport_impl.h index 859309e..0f77447 100644 --- a/webkit/glue/webkitplatformsupport_impl.h +++ b/webkit/glue/webkitplatformsupport_impl.h @@ -6,6 +6,7 @@ #define WEBKIT_PLATFORM_SUPPORT_IMPL_H_ #include "base/compiler_specific.h" +#include "base/debug/trace_event.h" #include "base/platform_file.h" #include "base/threading/thread_local_storage.h" #include "base/timer.h" @@ -88,6 +89,7 @@ class WEBKIT_GLUE_EXPORT WebKitPlatformSupportImpl : const char* name, int sample, int boundary_value); virtual const unsigned char* getTraceCategoryEnabledFlag( const char* category_name); + virtual long* getTraceSamplingState(const unsigned thread_bucket); virtual void addTraceEvent( char phase, const unsigned char* category_enabled, -- cgit v1.1