Skip to content

Commit

Permalink
vm: If popCount == _stack.Count in ExitBlock, just clear the stack an…
Browse files Browse the repository at this point in the history
…d return
  • Loading branch information
PaddiM8 committed Dec 9, 2024
1 parent 154228a commit 56b1a0c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Vm/InstructionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,14 +655,19 @@ private void UnpackUpper(byte count)

private void ExitBlock(byte popCount)
{
if (_stack.Count == 1)
if (_stack.Count == popCount)
{
while (_stack.Any())
Pop();

return;
}

var returnValue = _stack.Pop();
var returnValue = _stack.PopObject() as RuntimeObject;
for (byte i = 0; i < popCount; i++)
Pop();

_stack.Push(returnValue);
_stack.Push(returnValue ?? RuntimeNil.Value);
}

private void Ret()
Expand Down

0 comments on commit 56b1a0c

Please sign in to comment.