You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like only single subtraction is need, but this is not true. Pointers address bytes but uint256 type is 32 bytes in size. Therefore, additional division by 32 (shr rdi, 5) is needed to compute the stack height. Knowing this, we can request the stack height in bytes (stack size?). That eliminates the need for the division.
Obviously, we could track stack height with an integer because instruction implementations do not need to know the value (only stack requirement check does).
boolcheck3(uint256* bottom, int stack_height)
{
return stack_height >= 2;
}
Most of EVM instruction need to check EVM stack height before execution to report stack overflow/underflow errors.
In the current implementation the stack height value is computed by subtracting stack top and stack bottom pointers.
It looks like only single subtraction is need, but this is not true. Pointers address bytes but
uint256
type is 32 bytes in size. Therefore, additional division by 32 (shr rdi, 5
) is needed to compute the stack height. Knowing this, we can request the stack height in bytes (stack size?). That eliminates the need for the division.Obviously, we could track stack height with an integer because instruction implementations do not need to know the value (only stack requirement check does).
https://godbolt.org/z/qaE3zn3Ye
The text was updated successfully, but these errors were encountered: