- Revision
- 144701
- Author
- [email protected]
- Date
- 2013-03-04 17:42:20 -0800 (Mon, 04 Mar 2013)
Log Message
[chromium] Implement TRACE_EVENT macros for sampling profiling
https://bugs.webkit.org/show_bug.cgi?id=110932
Reviewed by Adam Barth.
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.
This patch implements (1) a WebKit API to get the addresses of
the global states and (2) the TRACE_EVENT_SAMPLING_STATE() macro.
Source/Platform:
* chromium/public/Platform.h:
(Platform):
(WebKit::Platform::getTraceSamplingState):
Source/WebCore:
No tests. The sampling profiler is not enabled in Chrome by default.
I manually inserted TRACE_EVENT_SAMPLING_STATE() macros and
confirmed that the sampling profiling is working as expected.
* platform/EventTracer.cpp:
(WebCore::EventTracer::initialize):
(WebCore::EventTracer::getTraceCategoryEnabledFlag):
(WebCore):
* platform/EventTracer.h:
(WebCore):
(EventTracer):
* platform/chromium/EventTracerChromium.cpp:
(WebCore):
(WebCore::EventTracer::initialize):
* platform/chromium/TraceEvent.h:
Source/WebKit/chromium:
* src/WebKit.cpp:
(WebKit::initializeWithoutV8):
Modified Paths
Diff
Modified: trunk/Source/Platform/ChangeLog (144700 => 144701)
--- trunk/Source/Platform/ChangeLog 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/Platform/ChangeLog 2013-03-05 01:42:20 UTC (rev 144701)
@@ -1,3 +1,33 @@
+2013-02-26 Kentaro Hara <[email protected]>
+
+ [chromium] Implement TRACE_EVENT macros for sampling profiling
+ https://bugs.webkit.org/show_bug.cgi?id=110932
+
+ Reviewed by Adam Barth.
+
+ 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.
+
+ This patch implements (1) a WebKit API to get the addresses of
+ the global states and (2) the TRACE_EVENT_SAMPLING_STATE() macro.
+
+ * chromium/public/Platform.h:
+ (Platform):
+ (WebKit::Platform::getTraceSamplingState):
+
2013-03-04 Jochen Eisinger <[email protected]>
[chromium] remove deprecated hyphenation methods from Platform
Modified: trunk/Source/Platform/chromium/public/Platform.h (144700 => 144701)
--- trunk/Source/Platform/chromium/public/Platform.h 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/Platform/chromium/public/Platform.h 2013-03-05 01:42:20 UTC (rev 144701)
@@ -377,6 +377,14 @@
// addTraceEvent is expected to be called by the trace event macros.
virtual const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) { return 0; }
+ typedef long int TraceEventAPIAtomicWord;
+
+ // Get a pointer to a global state of the given thread. An embedder is
+ // expected to update the global state as the state of the embedder changes.
+ // A sampling thread in the Chromium side reads the global state periodically
+ // and reflects the sampling profiled results into about:tracing.
+ virtual TraceEventAPIAtomicWord* getTraceSamplingState(const unsigned bucketName) { return 0; }
+
// Add a trace event to the platform tracing system. Depending on the actual
// enabled state, this event may be recorded or dropped.
// - phase specifies the type of event:
Modified: trunk/Source/WebCore/ChangeLog (144700 => 144701)
--- trunk/Source/WebCore/ChangeLog 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebCore/ChangeLog 2013-03-05 01:42:20 UTC (rev 144701)
@@ -1,3 +1,45 @@
+2013-02-26 Kentaro Hara <[email protected]>
+
+ [chromium] Implement TRACE_EVENT macros for sampling profiling
+ https://bugs.webkit.org/show_bug.cgi?id=110932
+
+ Reviewed by Adam Barth.
+
+ 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.
+
+ This patch implements (1) a WebKit API to get the addresses of
+ the global states and (2) the TRACE_EVENT_SAMPLING_STATE() macro.
+
+ No tests. The sampling profiler is not enabled in Chrome by default.
+ I manually inserted TRACE_EVENT_SAMPLING_STATE() macros and
+ confirmed that the sampling profiling is working as expected.
+
+ * platform/EventTracer.cpp:
+ (WebCore::EventTracer::initialize):
+ (WebCore::EventTracer::getTraceCategoryEnabledFlag):
+ (WebCore):
+ * platform/EventTracer.h:
+ (WebCore):
+ (EventTracer):
+ * platform/chromium/EventTracerChromium.cpp:
+ (WebCore):
+ (WebCore::EventTracer::initialize):
+ * platform/chromium/TraceEvent.h:
+
2013-03-04 Chris Fleizach <[email protected]>
Support WebSpeech - Speech Synthesis
Modified: trunk/Source/WebCore/platform/EventTracer.cpp (144700 => 144701)
--- trunk/Source/WebCore/platform/EventTracer.cpp 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebCore/platform/EventTracer.cpp 2013-03-05 01:42:20 UTC (rev 144701)
@@ -33,11 +33,18 @@
namespace WebCore {
+void EventTracer::initialize()
+{
+ // On x86 and ARM, "*p = v" with 32 bit sizes is done atomically.
+ ASSERT(sizeof(TraceEventAPIAtomicWord) == 4);
+ return;
+}
+
const unsigned char* EventTracer::getTraceCategoryEnabledFlag(const char*)
{
return 0;
}
-
+
void EventTracer::addTraceEvent(char,
const unsigned char*,
const char*,
Modified: trunk/Source/WebCore/platform/EventTracer.h (144700 => 144701)
--- trunk/Source/WebCore/platform/EventTracer.h 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebCore/platform/EventTracer.h 2013-03-05 01:42:20 UTC (rev 144701)
@@ -33,8 +33,15 @@
namespace WebCore {
+typedef long int TraceEventAPIAtomicWord;
+
+extern TraceEventAPIAtomicWord* traceSamplingState0;
+extern TraceEventAPIAtomicWord* traceSamplingState1;
+extern TraceEventAPIAtomicWord* traceSamplingState2;
+
class EventTracer {
public:
+ static void initialize();
static const unsigned char* getTraceCategoryEnabledFlag(const char*);
static void addTraceEvent(char phase,
const unsigned char* categoryEnabledFlag,
Modified: trunk/Source/WebCore/platform/chromium/EventTracerChromium.cpp (144700 => 144701)
--- trunk/Source/WebCore/platform/chromium/EventTracerChromium.cpp 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebCore/platform/chromium/EventTracerChromium.cpp 2013-03-05 01:42:20 UTC (rev 144701)
@@ -35,6 +35,17 @@
namespace WebCore {
+TraceEventAPIAtomicWord* traceSamplingState0;
+TraceEventAPIAtomicWord* traceSamplingState1;
+TraceEventAPIAtomicWord* traceSamplingState2;
+
+void EventTracer::initialize()
+{
+ traceSamplingState0 = WebKit::Platform::current()->getTraceSamplingState(0);
+ traceSamplingState1 = WebKit::Platform::current()->getTraceSamplingState(1);
+ traceSamplingState2 = WebKit::Platform::current()->getTraceSamplingState(2);
+}
+
const unsigned char* EventTracer::getTraceCategoryEnabledFlag(const char* categoryName)
{
return WebKit::Platform::current()->getTraceCategoryEnabledFlag(categoryName);
Modified: trunk/Source/WebCore/platform/chromium/TraceEvent.h (144700 => 144701)
--- trunk/Source/WebCore/platform/chromium/TraceEvent.h 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebCore/platform/chromium/TraceEvent.h 2013-03-05 01:42:20 UTC (rev 144701)
@@ -427,6 +427,16 @@
category, name, id, TRACE_EVENT_FLAG_COPY, \
arg1_name, arg1_val, arg2_name, arg2_val)
+// Updates a global state with 'name'. The sampling thread will read
+// the value periodically. STATE0 is for the main thread.
+// STATE1 and STATE2 will be preserved for other threads.
+#define TRACE_EVENT_SAMPLING_STATE0(name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(name, 0)
+#define TRACE_EVENT_SAMPLING_STATE1(name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(name, 1)
+#define TRACE_EVENT_SAMPLING_STATE2(name) \
+ INTERNAL_TRACE_EVENT_SAMPLING_STATE(name, 2)
+
////////////////////////////////////////////////////////////////////////////////
// Implementation specific tracing API definitions.
@@ -537,6 +547,19 @@
} while (0)
#endif
+// Implementation detail: internal macro to update a global state for
+// the sampling profiler.
+// FIXME: The current implementation uses only one global variable,
+// and thus cannot trace states of multiple threads.
+#if COMPILER(MSVC7_OR_LOWER)
+#define INTERNAL_TRACE_EVENT_SAMPLING_STATE(ignore) ((void)0)
+#else
+#define INTERNAL_TRACE_EVENT_SAMPLING_STATE(name, threadBucket) \
+ do { \
+ *WebCore::traceSamplingState##threadBucket = reinterpret_cast<TraceEventAPIAtomicWord>("WebKit\0" name); \
+ } while (0);
+#endif
+
// Notes regarding the following definitions:
// New values can be added and propagated to third party libraries, but existing
// definitions must never be changed, because third party libraries may use old
@@ -551,6 +574,7 @@
#define TRACE_EVENT_PHASE_ASYNC_END ('F')
#define TRACE_EVENT_PHASE_METADATA ('M')
#define TRACE_EVENT_PHASE_COUNTER ('C')
+#define TRACE_EVENT_PHASE_SAMPLE ('P')
// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
#define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
Modified: trunk/Source/WebKit/chromium/ChangeLog (144700 => 144701)
--- trunk/Source/WebKit/chromium/ChangeLog 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebKit/chromium/ChangeLog 2013-03-05 01:42:20 UTC (rev 144701)
@@ -1,3 +1,32 @@
+2013-02-26 Kentaro Hara <[email protected]>
+
+ [chromium] Implement TRACE_EVENT macros for sampling profiling
+ https://bugs.webkit.org/show_bug.cgi?id=110932
+
+ Reviewed by Adam Barth.
+
+ 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.
+
+ This patch implements (1) a WebKit API to get the addresses of
+ the global states and (2) the TRACE_EVENT_SAMPLING_STATE() macro.
+
+ * src/WebKit.cpp:
+ (WebKit::initializeWithoutV8):
+
2013-03-04 James Robinson <[email protected]>
[chromium] Roll chromium DEPS 185662 -> 185963
Modified: trunk/Source/WebKit/chromium/src/WebKit.cpp (144700 => 144701)
--- trunk/Source/WebKit/chromium/src/WebKit.cpp 2013-03-05 01:17:07 UTC (rev 144700)
+++ trunk/Source/WebKit/chromium/src/WebKit.cpp 2013-03-05 01:42:20 UTC (rev 144701)
@@ -31,6 +31,7 @@
#include "config.h"
#include "WebKit.h"
+#include "EventTracer.h"
#include "ImageDecodingStore.h"
#include "LayoutTestSupport.h"
#include "Logging.h"
@@ -156,6 +157,8 @@
// this, initializing this lazily probably doesn't buy us much.
WebCore::UTF8Encoding();
+ WebCore::EventTracer::initialize();
+
#if ENABLE(INDEXED_DATABASE)
WebCore::setIDBFactoryBackendInterfaceCreateFunction(WebKit::IDBFactoryBackendProxy::create);
#endif