From 5d1056425e3b98f9aed312478e55190a16415c2b Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 8 Jan 2014 16:02:04 +0000 Subject: [PATCH] Support statementprofiling in the fast interpreter. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12047 d7cf8633-e32d-0410-b094-e92efae38249 --- prvm_exec.c | 6 +++--- prvm_execprogram.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/prvm_exec.c b/prvm_exec.c index 65ee31b2..ad11c113 100644 --- a/prvm_exec.c +++ b/prvm_exec.c @@ -793,7 +793,7 @@ void MVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessag chooseexecprogram: cachedpr_trace = prog->trace; - if (prvm_statementprofiling.integer || prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0 || (prvm_coverage.integer & 4)) + if (prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0) { #define PRVMSLOWINTERPRETER 1 if (prvm_timeprofiling.integer) @@ -900,7 +900,7 @@ void CLVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa chooseexecprogram: cachedpr_trace = prog->trace; - if (prvm_statementprofiling.integer || prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0 || (prvm_coverage.integer & 4)) + if (prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0) { #define PRVMSLOWINTERPRETER 1 if (prvm_timeprofiling.integer) @@ -1011,7 +1011,7 @@ void PRVM_ExecuteProgram (prvm_prog_t *prog, func_t fnum, const char *errormessa chooseexecprogram: cachedpr_trace = prog->trace; - if (prvm_statementprofiling.integer || prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0 || (prvm_coverage.integer & 4)) + if (prog->trace || prog->watch_global_type != ev_void || prog->watch_field_type != ev_void || prog->break_statement >= 0) { #define PRVMSLOWINTERPRETER 1 if (prvm_timeprofiling.integer) diff --git a/prvm_execprogram.h b/prvm_execprogram.h index b87cfcf9..1607bcfe 100644 --- a/prvm_execprogram.h +++ b/prvm_execprogram.h @@ -1,6 +1,14 @@ -// NEED to reset startst after calling this! +// NEED to reset startst after calling this! startst may or may not be clobbered! #define ADVANCE_PROFILE_BEFORE_JUMP() \ - prog->xfunction->profile += (st - startst) + prog->xfunction->profile += (st - startst); \ + if (prvm_statementprofiling.integer || (prvm_coverage.integer & 4)) { \ + /* All statements from startst+1 to st have been hit. */ \ + while (++startst <= st) { \ + if (prog->statement_profile[startst - cached_statements]++ == 0 && (prvm_coverage.integer & 4)) \ + PRVM_StatementCoverageEvent(prog, prog->xfunction, startst - cached_statements); \ + } \ + /* Observe: startst now is clobbered (now at st+1)! */ \ + } #ifdef PRVMTIMEPROFILING #define PRE_ERROR() \ @@ -140,8 +148,6 @@ #if PRVMSLOWINTERPRETER if (prog->trace) PRVM_PrintStatement(prog, st); - if (prog->statement_profile[st - cached_statements]++ == 0 && (prvm_coverage.integer & 4)) - PRVM_StatementCoverageEvent(prog, prog->xfunction, st - cached_statements); if (prog->break_statement >= 0) if ((st - cached_statements) == prog->break_statement) { -- 2.39.2