summaryrefslogtreecommitdiffstats
path: root/V8Binding
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-07-08 11:06:09 -0700
committerGrace Kloba <klobag@google.com>2009-07-08 11:06:09 -0700
commitf3c4e0c2299cab06a5db4e13a784917af8b9ae7a (patch)
treee82d2b58dba93ad6edb1dd18fd78c906d2d7046a /V8Binding
parent939b5797c66ea70736c01eaec2dc694c909035d3 (diff)
downloadexternal_webkit-f3c4e0c2299cab06a5db4e13a784917af8b9ae7a.zip
external_webkit-f3c4e0c2299cab06a5db4e13a784917af8b9ae7a.tar.gz
external_webkit-f3c4e0c2299cab06a5db4e13a784917af8b9ae7a.tar.bz2
Add instrumentation for V8.
Diffstat (limited to 'V8Binding')
-rw-r--r--V8Binding/binding/v8_proxy.cpp42
-rw-r--r--V8Binding/binding/v8_proxy.h10
2 files changed, 52 insertions, 0 deletions
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<v8::Script> V8Proxy::CompileScript(v8::Handle<v8::String> code,
const String& fileName,
int baseLine)
+#ifdef ANDROID_INSTRUMENT
+{
+ android::TimeCounter::start(android::TimeCounter::JavaScriptParseTimeCounter);
+ v8::Handle<v8::Script> script = CompileScriptInternal(code, fileName, baseLine);
+ android::TimeCounter::record(android::TimeCounter::JavaScriptParseTimeCounter, __FUNCTION__);
+ return script;
+}
+
+v8::Handle<v8::Script> V8Proxy::CompileScriptInternal(v8::Handle<v8::String> code,
+ const String& fileName,
+ int baseLine)
+#endif
{
const uint16_t* fileNameString = FromWebCoreString(fileName);
v8::Handle<v8::String> name =
@@ -1095,6 +1111,17 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* n)
v8::Local<v8::Value> V8Proxy::RunScript(v8::Handle<v8::Script> script,
bool inline_code)
+#ifdef ANDROID_INSTRUMENT
+{
+ android::TimeCounter::start(android::TimeCounter::JavaScriptExecuteTimeCounter);
+ v8::Local<v8::Value> result = RunScriptInternal(script, inline_code);
+ android::TimeCounter::record(android::TimeCounter::JavaScriptExecuteTimeCounter, __FUNCTION__);
+ return result;
+}
+
+v8::Local<v8::Value> V8Proxy::RunScriptInternal(v8::Handle<v8::Script> script,
+ bool inline_code)
+#endif
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
@@ -1159,6 +1186,10 @@ v8::Local<v8::Value> V8Proxy::CallFunction(v8::Handle<v8::Function> function,
int argc,
v8::Handle<v8::Value> 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<v8::Value> V8Proxy::CallFunction(v8::Handle<v8::Function> 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<v8::Value> RunScript(v8::Handle<v8::Script> script,
bool inline_code);
+#ifdef ANDROID_INSTRUMENT
+ v8::Local<v8::Value> RunScriptInternal(v8::Handle<v8::Script> script,
+ bool inline_code);
+#endif
+
// Call the function with the given receiver and arguments.
v8::Local<v8::Value> CallFunction(v8::Handle<v8::Function> function,
v8::Handle<v8::Object> receiver,
@@ -359,6 +364,11 @@ class V8Proxy {
static v8::Handle<v8::Script> CompileScript(v8::Handle<v8::String> code,
const String& fileName,
int baseLine);
+#ifdef ANDROID_INSTRUMENT
+ static v8::Handle<v8::Script> CompileScriptInternal(v8::Handle<v8::String> code,
+ const String& fileName,
+ int baseLine);
+#endif
#ifndef NDEBUG
// Checks if a v8 value can be a DOM wrapper