From 14e0e0c000234f67613ea65e3fea1e9c3445844a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 9 Oct 2013 10:47:11 +0200 Subject: [PATCH] V4 runtime: add some more counters. Change-Id: I872f259a9fd4580e8faeae664f4d34f59a785c4e Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4runtime.cpp | 18 ++++++++++++++++++ src/qml/jsruntime/qv4runtime_p.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 6e56695..6b3afcc 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -114,6 +114,13 @@ struct RuntimeCounters::Data { typedef QVector Counters; QHash counters; + inline void count(const char *func) { + QVector &cnt = counters[func]; + if (cnt.isEmpty()) + cnt.resize(64); + cnt[0] += 1; + } + inline void count(const char *func, unsigned tag) { QVector &cnt = counters[func]; if (cnt.isEmpty()) @@ -180,6 +187,11 @@ RuntimeCounters::~RuntimeCounters() delete d; } +void RuntimeCounters::count(const char *func) +{ + d->count(func); +} + void RuntimeCounters::count(const char *func, uint tag) { d->count(func, tag); @@ -1077,31 +1089,37 @@ QV4::ReturnedValue __qmljs_to_object(QV4::ExecutionContext *ctx, const QV4::Valu ReturnedValue __qmljs_value_to_double(const ValueRef value) { + TRACE1(value); return Encode(value->toNumber()); } int __qmljs_value_to_int32(const ValueRef value) { + TRACE1(value); return value->toInt32(); } int __qmljs_double_to_int32(const double &d) { + TRACE0(); return Primitive::toInt32(d); } unsigned __qmljs_value_to_uint32(const ValueRef value) { + TRACE1(value); return value->toUInt32(); } unsigned __qmljs_double_to_uint32(const double &d) { + TRACE0(); return Primitive::toUInt32(d); } ReturnedValue __qmljs_value_from_string(String *string) { + TRACE0(); return string->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 2fb641c..4ede7ae 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -72,6 +72,7 @@ public: static RuntimeCounters *instance; + void count(const char *func); void count(const char *func, uint tag); void count(const char *func, uint tag1, uint tag2); @@ -80,9 +81,11 @@ private: Data *d; }; +# define TRACE0() RuntimeCounters::instance->count(Q_FUNC_INFO); # define TRACE1(x) RuntimeCounters::instance->count(Q_FUNC_INFO, x->type()); # define TRACE2(x, y) RuntimeCounters::instance->count(Q_FUNC_INFO, x->type(), y->type()); #else +# define TRACE0() # define TRACE1(x) # define TRACE2(x, y) #endif // QV4_COUNT_RUNTIME_FUNCTIONS -- 2.7.4