You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using large code bases consting mainly of callbacks into C# code, we started getting StackOverflowExceptions. As they could be fixed by increasing the stack size, they were actually caused by using too much stack space, even though we did not make heavy use of recursion.
Further analysis revealed that the generated IL code uses extremely many local variables. In fact it seems that local variables will be created for every function call. MWE:
When replacing the 1000 with a 1, the code below is generated. My knowledge of IL assembly is highly limited but it seems as though locals 0 and 1 are unused (at least stloc is only called for 2).
It seems that Jurassic allocates three local variables for every function call.
The same problem occurs with calls to functions directly defined in Javascript.
This seems unnecessary. Could Jurassic be optimized to reuse these locals?
The text was updated successfully, but these errors were encountered:
Using large code bases consting mainly of callbacks into C# code, we started getting StackOverflowExceptions. As they could be fixed by increasing the stack size, they were actually caused by using too much stack space, even though we did not make heavy use of recursion.
Further analysis revealed that the generated IL code uses extremely many local variables. In fact it seems that local variables will be created for every function call. MWE:
When replacing the 1000 with a 1, the code below is generated. My knowledge of IL assembly is highly limited but it seems as though locals 0 and 1 are unused (at least
stloc
is only called for 2).Running the script as is leads to the following code:
It seems that Jurassic allocates three local variables for every function call.
The same problem occurs with calls to functions directly defined in Javascript.
This seems unnecessary. Could Jurassic be optimized to reuse these locals?
The text was updated successfully, but these errors were encountered: