• 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...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
fuzzer Loading commit data...
inspector Loading commit data...
intl Loading commit data...
js-perf-test Loading commit data...
memory Loading commit data...
message Loading commit data...
mjsunit Loading commit data...
mkgrokdump Loading commit data...
mozilla Loading commit data...
preparser Loading commit data...
test262 Loading commit data...
torque Loading commit data...
unittests Loading commit data...
wasm-js Loading commit data...
wasm-spec-tests Loading commit data...
webkit Loading commit data...
BUILD.gn Loading commit data...
OWNERS Loading commit data...