aionnetwork / aion_fastvm

Aion's FastVM implementation
MIT License
33 stars 15 forks source link

Stack too deep, try removing local variables. #35

Open iamyulong opened 5 years ago

iamyulong commented 5 years ago

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:

aion-camus commented 5 years ago

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.