-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial MaxStack calculation #93244
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection-emit Issue DetailsThis is initial MaxStack calculation for simple (no branching) instructions, basically private void UpdateStackSize(OpCode opCode)
{
_currentStack += GetStackChangeFor(opCode.StackBehaviourPush) + GetStackChangeFor(opCode.StackBehaviourPop);
if (_currentStack > _maxStackSize)
{
_maxStackSize = _currentStack;
}
} This calculation will be updated as needed when branching IL.Emit overloads implemented. Contributes to #92975
|
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Show resolved
Hide resolved
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
…t/ILGeneratorImpl.cs Co-authored-by: Aaron Robinson <arobins@microsoft.com>
...ries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblySaveILGeneratorTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Emit/src/System/Reflection/Emit/ILGeneratorImpl.cs
Outdated
Show resolved
Hide resolved
...ries/System.Reflection.Emit/tests/PersistableAssemblyBuilder/AssemblySaveILGeneratorTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending API approval.
Note there are some unaccounted test failures. Perhaps rebase\merge to latest since I see some recent JIT fixes went in. |
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Primitives/ref/System.Reflection.Primitives.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs
Outdated
Show resolved
Hide resolved
* Add initial MaxStack calculation and tests * Apply suggestions from code review Co-authored-by: Aaron Robinson <arobins@microsoft.com> * Make OpCode.StackChange() public and use the method * Apply the approved API shape * Add doc, update the ref API ordering * Add more doc info, add test * Update doc remarks --------- Co-authored-by: Aaron Robinson <arobins@microsoft.com>
This is initial MaxStack calculation for simple (no branching) instructions, basically
UpdateStackSize(OpCode opCode)
will be called for eachOpCode
emit and updates the_currentStack
based on itsStackBehaviourPush
,StackBehaviourPop
values.This calculation will be updated as needed when branching IL.Emit overloads implemented.
As I cannot use the internal OpCode.StackChange() method created
int GetStackChangeFor(StackBehaviour stackBehaviour)
methodContributes to #92975
Fixes #93419