aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-08-01 15:23:45 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-02 14:00:47 +0000
commit37a43e3e00c55ac44ea79ff748e8d988fd893f7c (patch)
treeb3f07733789c3e2ba056956d08603a2a028bbab1 /src
parent36df81a9893fb5343eb0bfc2e5dbd5e2a8ea3224 (diff)
Add code to count the number of instructions executed
Change-Id: Id62b9561e51a4f8ef5de3dd2c25b2e24a1e85aaf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index ca2d611035..98e553a7f4 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -55,6 +55,7 @@
#include "qv4alloca_p.h"
+#undef COUNT_INSTRUCTIONS
extern "C" {
@@ -293,6 +294,25 @@ Q_NEVER_INLINE static void debug_slowPath(const QV4::Moth::Instr::instr_debug &i
using namespace QV4;
using namespace QV4::Moth;
+#ifdef COUNT_INSTRUCTIONS
+static struct InstrCount {
+ InstrCount() {
+ fprintf(stderr, "Counting instructions...\n");
+ for (int i = 0; i < Instr::LastInstruction; ++i)
+ hits[i] = 0;
+ }
+ ~InstrCount() {
+ fprintf(stderr, "Instruction count:\n");
+#define BLAH(I, FMT) \
+ fprintf(stderr, "%llu : %s\n", hits[Instr::I], #I);
+ FOR_EACH_MOTH_INSTR(BLAH)
+ #undef BLAH
+ }
+ quint64 hits[Instr::LastInstruction];
+ void hit(Instr::Type i) { hits[i]++; }
+} instrCount;
+#endif // COUNT_INSTRUCTIONS
+
#define MOTH_BEGIN_INSTR_COMMON(I) { \
const InstrMeta<int(Instr::I)>::DataType &instr = InstrMeta<int(Instr::I)>::data(*genericInstr); \
code += InstrMeta<int(Instr::I)>::Size; \
@@ -300,8 +320,15 @@ using namespace QV4::Moth;
#ifdef MOTH_THREADED_INTERPRETER
+
+#ifdef COUNT_INSTRUCTIONS
+# define MOTH_BEGIN_INSTR(I) op_##I: \
+ instrCount.hit(Instr::I); \
+ MOTH_BEGIN_INSTR_COMMON(I)
+#else // !COUNT_INSTRUCTIONS
# define MOTH_BEGIN_INSTR(I) op_##I: \
MOTH_BEGIN_INSTR_COMMON(I)
+#endif // COUNT_INSTRUCTIONS
# define MOTH_END_INSTR(I) } \
genericInstr = reinterpret_cast<const Instr *>(code); \