JS Stack Overflow / Increase #3150
Replies: 5 comments
-
|
Posted at 2019-11-01 by @gfwilliams I'm afraid you can't increase the stack without rebuilding the firmware to decrease the amount of JsVars available. Which board are you running on? The interpreter is recursive-descent, so it does use up a bunch of stack for each function call. About 10 levels deep does sound about right. There are few ways around having so many stacked calls though:
|
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-01 by @allObjects I use Pixle.js. I take a look what I can do without rebuilding firmware. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-04 by @gfwilliams Ok, just changing the variables value will be enough: https://github.com/espruino/Espruino/blob/master/boards/PIXLJS.py#L25 If you've got Linux (or Windows 10 with 'Linux on Windows' installed) then it should be pretty straightforward to rebuild - or @jumjum's firmware builder should work too |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-04 by @allObjects @gfwilliams, thanks for your detailed response. I eliminated some functions and added some ifs - to de-modularize increasing dependency and tighter coupling - to get temporarily over the issue - not the preferred SW best practice. Since it is in (the infrastructure) framework, it is manageable. When increasing application complexity without going more asynchronous, I expect it to happen again. Is there a way to ask the Interpreter how much stack space is left and a rough/average break down into number of nested function calls? Another question is how do fat arrow functions compare to standard functions? I know about some limitation but that may be different in the Espruino context with interpretation on the source / no byte/intermediate code. Regarding minification, which is not directly stack / nested calling related but share the memory restrictions: does the Esprima minification take this into consideration? Using google's closure compiler service for JavaScript has often a negative effect: this and undefined and some other constructs that are great w/ byte code but not with source interpretation, and the compiler is so smart that it requires some tricking to keep it from resolving and substituting. I'm aware of the some of the penalty by using a variable vs a constant, but memory is absolute, (execution) time can be stretched. |
Beta Was this translation helpful? Give feedback.
-
|
Posted at 2019-11-07 by @gfwilliams
I don't believe there is at the moment, no :(
They use slightly more storage sometimes because they store the value of
I'm not sure I understand? It doesn't take anything Espruino-specific into account I'm afraid. You can also try |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-11-01 by @allObjects
After I got over some memory inpasses - putting stuff in functions rather than execute on upload / level 0 - and setting to Save on send - write directly into the flash rather than RAM - I hit a next wall. Interpreter complains about:
I know that i'm not in an infinite recursion... Packing things in a timeout did not help to cut the calling hierarchy. Interestingly, it is on a return. The call is triggered by a watched button release.
How can I increase the stack?
Console output:
Beta Was this translation helpful? Give feedback.
All reactions