Skip to content
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

Stack too deep, try removing local variables. #35

Open
iamyulong opened this issue Nov 30, 2018 · 1 comment
Open

Stack too deep, try removing local variables. #35

iamyulong opened this issue Nov 30, 2018 · 1 comment

Comments

@iamyulong
Copy link
Contributor

iamyulong commented Nov 30, 2018

DApp developers will get the following error message, if there are too many local variables.

Stack too deep, try removing local variables.

This is a common issue for stack-based virtual machine, specifically FastVM and EVM. Only the top N stack items can be read/written; therefore, all high level languages on top of it has to limit the number of local variables which are stored on the stack.

Both Aion and Ethereum's solidity have the same limit on number of local stack items where local variables can occupate. However, the actual number of local variables are typically less in Aion's platfrom, because some local variable may take more than one stack item. For example, variable of address type will take two 128-bit stack items in Aion, while only one 256-bit stack item in Ethereum.

I believe the only solution to make Aion Solidity support more local variables is to update the FastVM by:

  • Introduce DUP17-DUP32 and SWAP17-SWAP32;
  • OR add new opcodes DUPX and SWAPX which take on argument specifying the N-th stack item to operate on.
  • OR add new opcodes DUP + (1 byte offset) and SWAP + (1 byte offset) which take a number of arguments as specified in the next byte.
@aion-camus
Copy link
Contributor

solution one would have the lowest cost. DUPX's max depth is up to 256*16 bytes = 4KB, cache miss should be under consideration. data access from ddr will cost much more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants