Skip to content

Conversation

@BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Jun 13, 2022

In unoptimized code, use a simpler and faster approach to allocating offsets for interp vars.

@BrzVlad BrzVlad requested a review from vargaz as a code owner June 13, 2022 08:21
@ghost ghost assigned BrzVlad Jun 13, 2022
@ghost
Copy link

ghost commented Jun 13, 2022

Tagging subscribers to this area: @BrzVlad
See info in area-owners.md if you want to be subscribed.

Issue Details

In unoptimized code, use a simpler and faster approach to allocating offsets for interp vars.

Author: BrzVlad
Assignees: -
Labels:

area-Codegen-Interpreter-mono

Milestone: -

@BrzVlad BrzVlad force-pushed the feature-interp-tiering-perf branch 4 times, most recently from 69b0a66 to d4d8b18 Compare June 20, 2022 13:45
BrzVlad added 4 commits July 23, 2022 21:02
It is not really true and it serves no purpose here.
Fix bitrotten mono_interp_print_td_code. Don't print IL_SEQ_POINT opcodes since they are too noisy.
We were pushing local that wasn't defined by any instruction, potentially confusing the var offset allocator.
@BrzVlad BrzVlad force-pushed the feature-interp-tiering-perf branch from d4d8b18 to 3206267 Compare July 23, 2022 18:03
@BrzVlad BrzVlad force-pushed the feature-interp-tiering-perf branch 2 times, most recently from a9aef73 to 4edb3bf Compare July 27, 2022 15:18
BrzVlad added 3 commits July 28, 2022 21:56
This is the old offset allocation scheme that we were using originally, before the var offset allocator was added. Vars have the same offset as they would have in IL code, based on their position on the execution stack at the moment when they are pushed. Whenever we push/pop on the execution stack we keep track of the used stack size. Every var pushed on the execution stack will therefore have this stack_offset remembered. Once the entire IL code is traversed and we have all the global locals allocated, the real offset of the execution stack locals can be determined. It is computed as the originally determined stack_offset added with the offset of the execution stack start (size of the global locals space).

With this offset allocator, calls no longer need to store all the call args sregs and the return_offset is always the same as call_args_offset. This is because all vars are directly placed in the right position and no optimizations can move them around. The offset of the return value will therefore be also the offset where all the args are placed.

The limitation with this way of allocating offsets is that we run into the same problems with opcodes that don't have typical stack usage (use values, pop them, store result). This happens with newobj opcodes. The opcode receives the params, and then it needs to call a ctor with these same params and a newly allocated this object. Since we can't use a var offset allocation pass to compute the offset ideally, the newobj opcodes in the case of unoptimized code must move these params around on the stack, in order to make room for `this`.
All calls need to have a dreg (a dummy one if it is void call), in order for unoptimized offset allocator to determine the offset of the call. In unoptimized code, the offset of the first argument is always the same as the offset of the return, if any.
Unoptimized code can't use a global local directly (like the exvar), it must first be pushed to a new var on the execution stack. Add a mov instruction when we start executing the basic block for a handler.
@BrzVlad BrzVlad force-pushed the feature-interp-tiering-perf branch from 4edb3bf to 7f537bb Compare July 28, 2022 18:56
@BrzVlad BrzVlad merged commit 01444f7 into dotnet:main Aug 1, 2022
lambdageek added a commit to lambdageek/runtime that referenced this pull request Aug 2, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants