Skip to content

Commit

Permalink
[mono][interp] Small code refactoring for SSA (#97249)
Browse files Browse the repository at this point in the history
* [mono][interp] Move optimization related code out of transform.c

Use interp_ prefix for non-static methods within interpreter (mono_interp seems rather long)
Use interp_ prefix, instead of .._interp_..., for consistency.
Use ins everywhere in method names for consistency, instead of inst.

* [mono][interp] Pass ref to var storage in interp inst

In order to facilitate overwritting of sregs/dreg during instruction iterations.

Also enable iterating only on sregs.

* [mono][interp] Print invalid il offset in aligned fashion

* [mono][interp] Remove irrelevant stats

* [mono][interp] Renaming of local to var

Local can have multiple meanings. Use it to refer to IL locals from now. All IL locals are vars. Vars can be local (single bblock use) or global.

* [mono][interp] Remove flags and use bit fields instead

Makes the code clearer and it is easier to maintain.
  • Loading branch information
BrzVlad committed Jan 20, 2024
1 parent ff93f2d commit fcbcfcc
Show file tree
Hide file tree
Showing 8 changed files with 3,105 additions and 3,049 deletions.
1 change: 1 addition & 0 deletions src/mono/mono/mini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ set(interp_sources
interp/mintops.h
interp/mintops.c
interp/transform.c
interp/transform-opt.c
interp/tiering.h
interp/tiering.c
interp/jiterpreter.c
Expand Down
8 changes: 0 additions & 8 deletions src/mono/mono/mini/interp/interp-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,7 @@ typedef struct {
gint64 methods_transformed;
gint64 cprop_time;
gint64 super_instructions_time;
gint32 stloc_nps;
gint32 movlocs;
gint32 copy_propagations;
gint32 constant_folds;
gint32 ldlocas_removed;
gint32 killed_instructions;
gint32 emitted_instructions;
gint32 super_instructions;
gint32 added_pop_count;
gint32 inlined_methods;
gint32 inline_failures;
} MonoInterpStats;
Expand Down
8 changes: 0 additions & 8 deletions src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8690,14 +8690,6 @@ register_interp_stats (void)
mono_counters_register ("Methods transformed", MONO_COUNTER_INTERP | MONO_COUNTER_LONG, &mono_interp_stats.methods_transformed);
mono_counters_register ("Total cprop time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.cprop_time);
mono_counters_register ("Total super instructions time", MONO_COUNTER_INTERP | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &mono_interp_stats.super_instructions_time);
mono_counters_register ("STLOC_NP count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.stloc_nps);
mono_counters_register ("MOVLOC count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.movlocs);
mono_counters_register ("Copy propagations", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.copy_propagations);
mono_counters_register ("Added pop count", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.added_pop_count);
mono_counters_register ("Constant folds", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.constant_folds);
mono_counters_register ("Ldlocas removed", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.ldlocas_removed);
mono_counters_register ("Super instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.super_instructions);
mono_counters_register ("Killed instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.killed_instructions);
mono_counters_register ("Emitted instructions", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.emitted_instructions);
mono_counters_register ("Methods inlined", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inlined_methods);
mono_counters_register ("Inline failures", MONO_COUNTER_INTERP | MONO_COUNTER_INT, &mono_interp_stats.inline_failures);
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/interp/jiterpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ build_address_taken_bitset (TransformData *td, InterpBasicBlock *bb, guint32 bit
for (InterpInst *ins = bb->first_ins; ins != NULL; ins = ins->next) {
if (ins->opcode == MINT_LDLOCA_S) {
InterpMethod *imethod = td->rtm;
InterpLocal *loc = &td->locals[ins->sregs[0]];
InterpVar *loc = &td->vars [ins->sregs[0]];

// Allocate on demand so if a method contains no ldlocas we don't allocate the bitset
if (!imethod->address_taken_bits)
Expand Down
Loading

0 comments on commit fcbcfcc

Please sign in to comment.