Skip to content

Commit

Permalink
[interp] Move from stack based to fully local var based design (#46037)
Browse files Browse the repository at this point in the history
Instead of having instructions that push and pop from the stack, every instruction has explicit dreg and sregs.

While the purpose of this PR is mainly to make it easier to implement more advanced optimization in the future, it also has noticeable performance implications. The code is simplified because we no longer need to update and save the SP. However, the code for each instruction is bloated due to the addition of explicit source and destination offsets. This is counteracted by the reduction of the total number of instructions, since ldloc/stloc and moves become redundant and they are mostly optimized away, even in this implementation state. Here are the total number of executed opcodes as part of running the corlib test suite with the interp https://gist.github.com/BrzVlad/d62f504930b75cba4b870e6dbd947e90.

Co-authored-by: BrzVlad <[email protected]>
  • Loading branch information
monojenkins and BrzVlad authored Jan 8, 2021
1 parent 6299cef commit c2e098b
Show file tree
Hide file tree
Showing 8 changed files with 4,265 additions and 4,351 deletions.
4 changes: 2 additions & 2 deletions src/mono/mono/mini/interp/interp-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ struct InterpMethod {
MonoJitInfo *jinfo;
MonoDomain *domain;

// This doesn't include the size of stack locals
guint32 total_locals_size;
// The size of locals that map to the execution stack
guint32 stack_size;
guint32 alloca_size;
int num_clauses; // clauses
Expand Down Expand Up @@ -185,8 +187,6 @@ typedef struct FrameClauseArgs FrameClauseArgs;

/* State of the interpreter main loop */
typedef struct {
stackval *sp;
unsigned char *vt_sp;
const unsigned short *ip;
} InterpState;

Expand Down
Loading

0 comments on commit c2e098b

Please sign in to comment.