From: divverent Date: Wed, 8 Jan 2014 16:02:04 +0000 (+0000) Subject: Support statementprofiling in the fast interpreter. X-Git-Tag: xonotic-v0.8.0~88 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=756ddc8e8580aa688c3387305d635aa0a87d3100;p=xonotic%2Fdarkplaces.git Support statementprofiling in the fast interpreter. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12047 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=5d1056425e3b98f9aed312478e55190a16415c2b --- 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) {