Rewrite manifestJson to execute "stacklessly" inside evaluate()#1142
Draft
johnbartholomew wants to merge 9 commits intogoogle:masterfrom
Draft
Rewrite manifestJson to execute "stacklessly" inside evaluate()#1142johnbartholomew wants to merge 9 commits intogoogle:masterfrom
johnbartholomew wants to merge 9 commits intogoogle:masterfrom
Conversation
This gets rid of the mutual recursion between manifestJson() and evaluate(), turning the manifestJson processing into a part of the interpreter's main loop. It should remove one avenue for native stack overflows during execution. The Interpreter needed to be able to convert things to JSON anyway, as this is the behaviour of string coercion (for string concatenation), and also the behaviour when using the 'error' operator/statement.
Closed
sbarzowski
approved these changes
Jun 23, 2024
Contributor
|
I think it's a good idea and the code looks reasonable. What is missing? |
MrG9090
approved these changes
Nov 6, 2024
MrG9090
approved these changes
Nov 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This gets rid of the mutual recursion between
manifestJsonandevaluate, turning themanifestJsonprocessing into a part of the interpreter's main loop. It should remove one avenue for native stack overflows during execution. Of course, the runtime still tracks its own internal call stack depth and can safely abort.The Interpreter needed to be able to convert things to JSON anyway, as this is the behaviour of string coercion (for string concatenation), and also the behaviour when using the
erroroperator/statement.Some general notes:
Interpreter::evaluatewas already a really long function; this makes it even longer.Framestruct gets even bigger.TL;DR: This is not ready yet, and might never be ready. But hey, it's been fun to make. Consider it just a sketch or prototype for now.
Edit - Note that there is still potentially deep recursion in some other pieces of the interpreter code. For example, code dealing with
HeapExtendedObject(e.g.,objectFieldsAux,objectInvariants,countLeaves,findObject) needs to recurse through the object inheritance tree. Not sure that's a problem though.