]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Support statementprofiling in the fast interpreter.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Jan 2014 16:02:04 +0000 (16:02 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 9 Jan 2014 14:17:46 +0000 (15:17 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12047 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=5d1056425e3b98f9aed312478e55190a16415c2b

prvm_exec.c
prvm_execprogram.h

index 65ee31b2328a7175f9284c0699a7bb8f5393a6d8..ad11c11316df51d17b3aa3216e0f7a38ebd58116 100644 (file)
@@ -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)
index b87cfcf91b3fb0e74cb822addd1122754391194b..1607bcfe558a65d1e7d79a61c08d65b3ce7b27b1 100644 (file)
@@ -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() \
 #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)
                                {