diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4c29b5a..25618ac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -427,7 +427,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 - #TODO: d_m3RuntimeStackDumps, d_m3EnableOpProfiling + #TODO: d_m3EnableOpTracing, d_m3EnableOpProfiling steps: - uses: actions/checkout@v2 - name: Build @@ -435,7 +435,6 @@ jobs: mkdir build cd build g++ -xc++ -Dd_m3HasWASI -Dd_m3LogsDefined \ - -Dd_m3TraceExec=1 \ -Dd_m3LogParse=1 \ -Dd_m3LogModule=1 \ -Dd_m3LogCompile=1 \ diff --git a/source/m3_config.h b/source/m3_config.h index cbbcdde..ac32814 100644 --- a/source/m3_config.h +++ b/source/m3_config.h @@ -46,28 +46,26 @@ # define d_m3Use32BitSlots 1 # endif -//# ifndef d_m3EnableOptimizations -//# define d_m3EnableOptimizations 0 -//# endif +# ifndef d_m3ProfilerSlotMask +# define d_m3ProfilerSlotMask 0xFFFF +# endif // logging -------------------------------------------------------------------- #ifndef d_m3LogsDefined -# define d_m3EnableOpProfiling 0 -# define d_m3RuntimeStackDumps 0 - -# define d_m3TraceExec (1 && d_m3RuntimeStackDumps && DEBUG) - -# define d_m3LogParse 0 // .wasm binary decoding info -# define d_m3LogModule 0 // Wasm module info -# define d_m3LogCompile 0 // wasm -> metacode generation phase -# define d_m3LogWasmStack 0 // dump the wasm stack when pushed or popped -# define d_m3LogEmit 0 // metacode generation info -# define d_m3LogCodePages 0 // dump metacode pages when released -# define d_m3LogExec 0 // low-level interpreter specific logs -# define d_m3LogRuntime 0 // higher-level runtime information -# define d_m3LogStackTrace 0 // dump the call stack when traps occur -# define d_m3LogNativeStack 0 // track the memory usage of the C-stack +# define d_m3EnableOpProfiling 0 // profiling or tracing can be used +# define d_m3EnableOpTracing 0 // only works with DEBUG + +# define d_m3LogParse 0 // .wasm binary decoding info +# define d_m3LogModule 0 // wasm module info +# define d_m3LogCompile 0 // wasm -> metacode generation phase +# define d_m3LogWasmStack 0 // dump the wasm stack when pushed or popped +# define d_m3LogEmit 0 // metacode generation info +# define d_m3LogCodePages 0 // dump metacode pages when released +# define d_m3LogExec 0 // low-level interpreter specific logs +# define d_m3LogRuntime 0 // higher-level runtime information +# define d_m3LogStackTrace 0 // dump the call stack when traps occur +# define d_m3LogNativeStack 0 // track the memory usage of the C-stack #endif diff --git a/source/m3_emit.c b/source/m3_emit.c index 61a3703..f04fbd1 100644 --- a/source/m3_emit.c +++ b/source/m3_emit.c @@ -53,9 +53,9 @@ M3Result EmitOp (IM3Compilation o, IM3Operation i_operation) // it's OK for page to be null; when compile-walking the bytecode without emitting if (o->page) { -# if d_m3RuntimeStackDumps +# if d_m3EnableOpTracing if (i_operation != op_DumpStack) -# endif +# endif o->numEmits++; result = BridgeToNewPageIfNecessary (o); diff --git a/source/m3_exec.c b/source/m3_exec.c index 480d70f..4affdb0 100644 --- a/source/m3_exec.c +++ b/source/m3_exec.c @@ -404,7 +404,7 @@ d_m3OpDef (PreserveCopySlot_64) } -#if d_m3RuntimeStackDumps +#if d_m3EnableOpTracing //-------------------------------------------------------------------------------------------------------- d_m3OpDef (DumpStack) { @@ -439,19 +439,19 @@ d_m3OpDef (DumpStack) # if d_m3EnableOpProfiling //-------------------------------------------------------------------------------------------------------- -M3ProfilerSlot s_opProfilerCounts [c_m3ProfilerSlotMask + 1] = {}; +static M3ProfilerSlot s_opProfilerCounts [d_m3ProfilerSlotMask + 1] = {}; void ProfileHit (cstr_t i_operationName) { u64 ptr = (u64) i_operationName; - M3ProfilerSlot * slot = & s_opProfilerCounts [ptr & c_m3ProfilerSlotMask]; + M3ProfilerSlot * slot = & s_opProfilerCounts [ptr & d_m3ProfilerSlotMask]; if (slot->opName) { if (slot->opName != i_operationName) { - m3Abort ("profiler slot collision; increase c_m3ProfilerSlotMask"); + m3Abort ("profiler slot collision; increase d_m3ProfilerSlotMask"); } } @@ -469,7 +469,7 @@ void m3_PrintProfilerInfo () { maxSlot->hitCount = 0; - for (u32 i = 0; i <= c_m3ProfilerSlotMask; ++i) + for (u32 i = 0; i <= d_m3ProfilerSlotMask; ++i) { M3ProfilerSlot * slot = & s_opProfilerCounts [i]; diff --git a/source/m3_exec.h b/source/m3_exec.h index 35cfddb..6f74589 100644 --- a/source/m3_exec.h +++ b/source/m3_exec.h @@ -55,14 +55,10 @@ d_m3BeginExternC #define jumpOpDirect(PC) ((IM3Operation)(* PC))( PC + 1, d_m3OpArgs) # if d_m3EnableOpProfiling - -d_m3RetSig profileOp (d_m3OpSig, cstr_t i_operationName); - + d_m3RetSig profileOp (d_m3OpSig, cstr_t i_operationName); # define nextOp() return profileOp (d_m3OpAllArgs, __FUNCTION__) -# elif d_m3TraceExec - -d_m3RetSig debugOp (d_m3OpSig, cstr_t i_operationName); - +# elif d_m3EnableOpTracing + d_m3RetSig debugOp (d_m3OpSig, cstr_t i_operationName); # define nextOp() return debugOp (d_m3OpAllArgs, __FUNCTION__) # else # define nextOp() return nextOpDirect() @@ -913,7 +909,7 @@ d_m3Store_i (i64, i64) //--------------------------------------------------------------------------------------------------------------------- // debug/profiling //--------------------------------------------------------------------------------------------------------------------- -#if d_m3TraceExec +#if d_m3EnableOpTracing d_m3RetSig debugOp (d_m3OpSig, cstr_t i_opcode) { char name [100]; @@ -928,12 +924,11 @@ d_m3RetSig debugOp (d_m3OpSig, cstr_t i_opcode) } # endif -# if d_m3RuntimeStackDumps +# if d_m3EnableOpTracing d_m3OpDecl (DumpStack) # endif # if d_m3EnableOpProfiling -static const u32 c_m3ProfilerSlotMask = 0xFFFF; typedef struct M3ProfilerSlot { diff --git a/source/m3_info.c b/source/m3_info.c index 76e73a8..f54ce94 100644 --- a/source/m3_info.c +++ b/source/m3_info.c @@ -412,7 +412,7 @@ void log_opcode (IM3Compilation o, u8 i_opcode) void emit_stack_dump (IM3Compilation o) { -# if d_m3RuntimeStackDumps +# if d_m3EnableOpTracing if (o->numEmits) { EmitOp (o, op_DumpStack);