Skip to content

Commit c2e098b

Browse files
monojenkinsBrzVlad
andauthored
[interp] Move from stack based to fully local var based design (#46037)
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 <BrzVlad@users.noreply.github.com>
1 parent 6299cef commit c2e098b

File tree

8 files changed

+4265
-4351
lines changed

8 files changed

+4265
-4351
lines changed

src/mono/mono/mini/interp/interp-internals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ struct InterpMethod {
127127
MonoJitInfo *jinfo;
128128
MonoDomain *domain;
129129

130+
// This doesn't include the size of stack locals
130131
guint32 total_locals_size;
132+
// The size of locals that map to the execution stack
131133
guint32 stack_size;
132134
guint32 alloca_size;
133135
int num_clauses; // clauses
@@ -185,8 +187,6 @@ typedef struct FrameClauseArgs FrameClauseArgs;
185187

186188
/* State of the interpreter main loop */
187189
typedef struct {
188-
stackval *sp;
189-
unsigned char *vt_sp;
190190
const unsigned short *ip;
191191
} InterpState;
192192

0 commit comments

Comments
 (0)