diff --git a/rts/Interpreter.c b/rts/Interpreter.c index 4e9ab74bde978c945a89d29e00b13731d9bb0794..1393c7e077101173b70c5b64fe7f132231678e2c 100644 --- a/rts/Interpreter.c +++ b/rts/Interpreter.c @@ -182,6 +182,8 @@ int rts_stop_on_exception = 0; #if defined(INTERP_STATS) +#define N_CODES 128 + /* Hacky stats, for tuning the interpreter ... */ int it_unknown_entries[N_CLOSURE_TYPES]; int it_total_unknown_entries; @@ -195,8 +197,8 @@ int it_slides; int it_insns; int it_BCO_entries; -int it_ofreq[27]; -int it_oofreq[27][27]; +int it_ofreq[N_CODES]; +int it_oofreq[N_CODES][N_CODES]; int it_lastopc; @@ -210,9 +212,9 @@ void interp_startup ( void ) for (i = 0; i < N_CLOSURE_TYPES; i++) it_unknown_entries[i] = 0; it_slides = it_insns = it_BCO_entries = 0; - for (i = 0; i < 27; i++) it_ofreq[i] = 0; - for (i = 0; i < 27; i++) - for (j = 0; j < 27; j++) + for (i = 0; i < N_CODES; i++) it_ofreq[i] = 0; + for (i = 0; i < N_CODES; i++) + for (j = 0; j < N_CODES; j++) it_oofreq[i][j] = 0; it_lastopc = 0; } @@ -234,14 +236,14 @@ void interp_shutdown ( void ) } debugBelch("%d insns, %d slides, %d BCO_entries\n", it_insns, it_slides, it_BCO_entries); - for (i = 0; i < 27; i++) + for (i = 0; i < N_CODES; i++) debugBelch("opcode %2d got %d\n", i, it_ofreq[i] ); for (k = 1; k < 20; k++) { o_max = 0; i_max = j_max = 0; - for (i = 0; i < 27; i++) { - for (j = 0; j < 27; j++) { + for (i = 0; i < N_CODES; i++) { + for (j = 0; j < N_CODES; j++) { if (it_oofreq[i][j] > o_max) { o_max = it_oofreq[i][j]; i_max = i; j_max = j; @@ -259,6 +261,12 @@ void interp_shutdown ( void ) #else // !INTERP_STATS +void interp_startup( void ){ +} + +void interp_shutdown( void ){ +} + #define INTERP_TICK(n) /* nothing */ #endif @@ -419,7 +427,7 @@ eval: eval_obj: obj = UNTAG_CLOSURE(tagged_obj); - INTERP_TICK(it_total_evals); + INTERP_TICK(it_total_entries); IF_DEBUG(interpreter, debugBelch( @@ -1098,7 +1106,7 @@ run_BCO: INTERP_TICK(it_insns); #if defined(INTERP_STATS) - ASSERT( (int)instrs[bciPtr] >= 0 && (int)instrs[bciPtr] < 27 ); + ASSERT( (int)instrs[bciPtr] >= 0 && (int)instrs[bciPtr] < N_CODES ); it_ofreq[ (int)instrs[bciPtr] ] ++; it_oofreq[ it_lastopc ][ (int)instrs[bciPtr] ] ++; it_lastopc = (int)instrs[bciPtr]; diff --git a/rts/Interpreter.h b/rts/Interpreter.h index fa341f26fe83cae6bfda3a394792c2578316c29f..65d5bd15d6d68ed3cecb70bb54cd847e2fc34c83 100644 --- a/rts/Interpreter.h +++ b/rts/Interpreter.h @@ -9,3 +9,5 @@ #pragma once RTS_PRIVATE Capability *interpretBCO (Capability* cap); +void interp_startup ( void ); +void interp_shutdown ( void ); diff --git a/rts/RtsMain.c b/rts/RtsMain.c index d2fd460ee2a4063ff71dac8822aade6900e9d8ad..8210a5e878b0b535e0368efc0eb8eb71d277aa00 100644 --- a/rts/RtsMain.c +++ b/rts/RtsMain.c @@ -17,6 +17,7 @@ #include "Prelude.h" #include "Task.h" #include "Excn.h" +#include "Interpreter.h" #if defined(DEBUG) # include "Printer.h" /* for printing */ @@ -56,6 +57,8 @@ int hs_main ( int argc, char *argv[], // program args hs_init_ghc(&argc, &argv, rts_config); + interp_startup(); + BEGIN_WINDOWS_VEH_HANDLER // kick off the computation by creating the main thread with a pointer @@ -96,6 +99,8 @@ int hs_main ( int argc, char *argv[], // program args END_WINDOWS_VEH_HANDLER + interp_shutdown(); + shutdownHaskellAndExit(exit_status, 0 /* !fastExit */); // No code beyond this point. Dead code elimination will remove it }