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

VM tweak to allow large hard-coded arrays. #72

Merged
merged 4 commits into from
Apr 1, 2018
Merged

VM tweak to allow large hard-coded arrays. #72

merged 4 commits into from
Apr 1, 2018

Conversation

SirTony
Copy link
Contributor

@SirTony SirTony commented Mar 28, 2018

As it is, the VM will try to push all elements of a hard-coded array to the stack ahead of the NewArray instruction, which causes stack overflow exceptions if the array has ≥250 elements at most, which is a problem when hard-coding a lookup table for e.g. CRC-16-CCITT.

This change modifies the compiler to insert a new FlushArr instruction after every 32 elements (if the array is has more than 32 elements) to avoid overflows. This can be easily adjusted by changing this line:

Edit: I've realized it's both simpler and more sensible to just initialize arrays the same way objects are created. It solves the problem and minimizes the stack space required to create arbitrarily large arrays. Implementation has been changed accordingly. No new instructions needed.

@Rohansi Rohansi merged commit 1c5fc81 into Rohansi:master Apr 1, 2018
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

Successfully merging this pull request may close these issues.

2 participants