X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=prvm_execprogram.h;h=6578d78902de24c88a91ea591cf09366eaeaa7f6;hb=64843c60c24afc1a93596c5d1c629a1c8973db5c;hp=b87cfcf91b3fb0e74cb822addd1122754391194b;hpb=66c17456052bcd458a64c76802d04618bd464d05;p=xonotic%2Fdarkplaces.git diff --git a/prvm_execprogram.h b/prvm_execprogram.h index b87cfcf9..6578d789 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() \ @@ -117,15 +125,15 @@ { if (prog->watch_global_type != ev_void) { - prvm_eval_t *f = PRVM_GLOBALFIELDVALUE(prog->watch_global); + prvm_eval_t *g = PRVM_GLOBALFIELDVALUE(prog->watch_global); prog->xstatement = st + 1 - cached_statements; - PRVM_Watchpoint(prog, 1, "Global watchpoint hit by engine", prog->watch_global_type, &prog->watch_global_value, f); + PRVM_Watchpoint(prog, 1, "Global watchpoint hit by engine", prog->watch_global_type, &prog->watch_global_value, g); } if (prog->watch_field_type != ev_void && prog->watch_edict < prog->max_edicts) { - prvm_eval_t *f = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field); + prvm_eval_t *g = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field); prog->xstatement = st + 1 - cached_statements; - PRVM_Watchpoint(prog, 1, "Entityfield watchpoint hit by engine", prog->watch_field_type, &prog->watch_edictfield_value, f); + PRVM_Watchpoint(prog, 1, "Entityfield watchpoint hit by engine", prog->watch_field_type, &prog->watch_edictfield_value, g); } } #endif @@ -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) { @@ -476,21 +482,21 @@ goto cleanup; } - newf = &prog->functions[OPA->function]; - if (newf->callcount++ == 0 && (prvm_coverage.integer & 1)) - PRVM_FunctionCoverageEvent(prog, newf); + enterfunc = &prog->functions[OPA->function]; + if (enterfunc->callcount++ == 0 && (prvm_coverage.integer & 1)) + PRVM_FunctionCoverageEvent(prog, enterfunc); - if (newf->first_statement < 0) + if (enterfunc->first_statement < 0) { // negative first_statement values are built in functions - int builtinnumber = -newf->first_statement; + int builtinnumber = -enterfunc->first_statement; prog->xfunction->builtinsprofile++; if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber]) { prog->builtins[builtinnumber](prog); #ifdef PRVMTIMEPROFILING tm = Sys_DirtyTime(); - newf->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0; + enterfunc->tprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0; prog->xfunction->tbprofile += (tm - starttm >= 0 && tm - starttm < 1800) ? (tm - starttm) : 0; starttm = tm; #endif @@ -515,7 +521,7 @@ prog->error_cmd("No such builtin #%i in %s; most likely cause: outdated engine build. Try updating!", builtinnumber, prog->name); } else - st = cached_statements + PRVM_EnterFunction(prog, newf); + st = cached_statements + PRVM_EnterFunction(prog, enterfunc); startst = st; DISPATCH_OPCODE(); @@ -834,15 +840,15 @@ { if (prog->watch_global_type != ev_void) { - prvm_eval_t *f = PRVM_GLOBALFIELDVALUE(prog->watch_global); + prvm_eval_t *g = PRVM_GLOBALFIELDVALUE(prog->watch_global); prog->xstatement = st - cached_statements; - PRVM_Watchpoint(prog, 0, "Global watchpoint hit", prog->watch_global_type, &prog->watch_global_value, f); + PRVM_Watchpoint(prog, 0, "Global watchpoint hit", prog->watch_global_type, &prog->watch_global_value, g); } if (prog->watch_field_type != ev_void && prog->watch_edict < prog->max_edicts) { - prvm_eval_t *f = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field); + prvm_eval_t *g = PRVM_EDICTFIELDVALUE(prog->edicts + prog->watch_edict, prog->watch_field); prog->xstatement = st - cached_statements; - PRVM_Watchpoint(prog, 0, "Entityfield watchpoint hit", prog->watch_field_type, &prog->watch_edictfield_value, f); + PRVM_Watchpoint(prog, 0, "Entityfield watchpoint hit", prog->watch_field_type, &prog->watch_edictfield_value, g); } } #endif