Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Automatically growing the stack #4344
Hello, thanks for a great project.
I'm using the
I've tried setting a bigger stack value, but eventually the program eats through it and I'd rather keep the stack size down for simple tasks.
This is not currently possible. Memory growth replaces the entire ArrayBuffer with a new bigger one, which keeps all pointers still valid (they are just indexes). But the stack is a specific area inside of memory. Growing it by replacing it would make existing pointers invalid.
This could be done by allowing split stacks, which I think LLVM has some support for, but I'm not sure if it's complete, and it would also require runtime stuff on our side, which we don't have yet.
It's probably best to see where your app is using so much stack, and if it's possible to make it use less (e.g. by turning recursion into a manual stack).
Thanks for your prompt response.
In this case, I didn't write the application and so I wouldn't know how to modify the source to be less aggressive on the stack. I did manage to find a solution in the end which basically involved letting it run out of stack/heap space and then reinitializing with higher values. I had to make a few small changes to the generated code for this to work and the code that wraps this is quite involved, but I'm happy to share more details if anyone's interested.
The gist of it is here: https://github.com/tuzz/sentient.js/commit/2d5c3987d64c0e327d585f198dd6b81070c878aa
I'll close this now as this is no longer an issue for me.