• Toon Verwaest's avatar
    [json] Make json parsing iterative · 4b60b40a
    Toon Verwaest authored
    This avoids the need to throw range errors when we run out of stack, limiting
    us only by available memory.
    
    The main parser loop is implemented by two subloops.
    
    The first subloop finishes whenever it generates primitive values, empty
    arrays, or empty objects. If a non-empty object or array is started, the loop
    continues to parse its first member.
    
    The second subloop consumes produced values and either adds them to the parent
    array or object, or returns it. The second loop finishes whenever a next value
    needs to be produced. When the loop itself produces a finished array or object,
    the loop continues.
    
    Exceptions are handled by moving the cursor to end-of-input. Upon end-of-input,
    the first loop sets the continuation to "kFail". That causes the second loop to
    tear down continuation stack and related handle scopes, resulting in an empty
    handle.
    
    The CL additionally buffers all named properties and elements so we can
    immediately allocate a correctly shaped object. For object elements we'll take
    flat array or dictionary encoding depending on what is more efficient.
    
    This means that element handles are now allocated in their parent HandleScope,
    rather than having local handlescopes per-property (of big objects); which is
    why I've adjusted the handle-count test to not allocate as many properties. In
    the future it would be nice to not have to allocate (as many) handles since
    almost everything in the JSON graph will survive JSON parsing...
    
    Bug: chromium:710383
    Change-Id: Ia3a7fd0ac260fb1c0e5f929276792b2f8e5fc0ca
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1609802Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
    Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
    Commit-Queue: Toon Verwaest <verwaest@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#61533}
    4b60b40a
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.vpython Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
INFRA_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...