From f3c4e0c2299cab06a5db4e13a784917af8b9ae7a Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Wed, 8 Jul 2009 11:06:09 -0700 Subject: Add instrumentation for V8. --- V8Binding/binding/v8_proxy.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ V8Binding/binding/v8_proxy.h | 10 ++++++++++ 2 files changed, 52 insertions(+) (limited to 'V8Binding') diff --git a/V8Binding/binding/v8_proxy.cpp b/V8Binding/binding/v8_proxy.cpp index c68837d..2d5ee4c 100644 --- a/V8Binding/binding/v8_proxy.cpp +++ b/V8Binding/binding/v8_proxy.cpp @@ -57,6 +57,10 @@ #include "CString.h" +#ifdef ANDROID_INSTRUMENT +#include "TimeCounter.h" +#endif + namespace WebCore { // Static utility context. @@ -976,6 +980,18 @@ void V8Proxy::DisconnectEventListeners() v8::Handle V8Proxy::CompileScript(v8::Handle code, const String& fileName, int baseLine) +#ifdef ANDROID_INSTRUMENT +{ + android::TimeCounter::start(android::TimeCounter::JavaScriptParseTimeCounter); + v8::Handle script = CompileScriptInternal(code, fileName, baseLine); + android::TimeCounter::record(android::TimeCounter::JavaScriptParseTimeCounter, __FUNCTION__); + return script; +} + +v8::Handle V8Proxy::CompileScriptInternal(v8::Handle code, + const String& fileName, + int baseLine) +#endif { const uint16_t* fileNameString = FromWebCoreString(fileName); v8::Handle name = @@ -1095,6 +1111,17 @@ v8::Local V8Proxy::evaluate(const ScriptSourceCode& source, Node* n) v8::Local V8Proxy::RunScript(v8::Handle script, bool inline_code) +#ifdef ANDROID_INSTRUMENT +{ + android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter); + v8::Local result = RunScriptInternal(script, inline_code); + android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__); + return result; +} + +v8::Local V8Proxy::RunScriptInternal(v8::Handle script, + bool inline_code) +#endif { if (script.IsEmpty()) return v8::Local(); @@ -1159,6 +1186,10 @@ v8::Local V8Proxy::CallFunction(v8::Handle function, int argc, v8::Handle args[]) { +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter); +#endif + // For now, we don't put any artificial limitations on the depth // of recursion that stems from calling functions. This is in // contrast to the script evaluations. @@ -1180,6 +1211,9 @@ v8::Local V8Proxy::CallFunction(v8::Handle function, if (v8::V8::IsDead()) HandleFatalErrorInV8(); +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__); +#endif return result; } @@ -2168,6 +2202,10 @@ void V8Proxy::InitContextIfNeeded() if (!m_context.IsEmpty()) return; +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::start(android::TimeCounter::JavaScriptInitTimeCounter); +#endif + // Create a handle scope for all local handles. v8::HandleScope handle_scope; @@ -2272,6 +2310,10 @@ void V8Proxy::InitContextIfNeeded() SetSecurityToken(); m_frame->loader()->dispatchWindowObjectAvailable(); + +#ifdef ANDROID_INSTRUMENT + android::TimeCounter::record(android::TimeCounter::JavaScriptInitTimeCounter, __FUNCTION__); +#endif } diff --git a/V8Binding/binding/v8_proxy.h b/V8Binding/binding/v8_proxy.h index 708f63d..08cf621 100644 --- a/V8Binding/binding/v8_proxy.h +++ b/V8Binding/binding/v8_proxy.h @@ -254,6 +254,11 @@ class V8Proxy { v8::Local RunScript(v8::Handle script, bool inline_code); +#ifdef ANDROID_INSTRUMENT + v8::Local RunScriptInternal(v8::Handle script, + bool inline_code); +#endif + // Call the function with the given receiver and arguments. v8::Local CallFunction(v8::Handle function, v8::Handle receiver, @@ -359,6 +364,11 @@ class V8Proxy { static v8::Handle CompileScript(v8::Handle code, const String& fileName, int baseLine); +#ifdef ANDROID_INSTRUMENT + static v8::Handle CompileScriptInternal(v8::Handle code, + const String& fileName, + int baseLine); +#endif #ifndef NDEBUG // Checks if a v8 value can be a DOM wrapper -- cgit v1.1