ladybird/Libraries/LibJS
Andreas Kling a3db2d1986 LibJS: Support source text access in JSON.parse revivers
The JSON.parse-with-source proposal (now part of ES2026) gives a
reviver a third "context" argument. For a primitive value that was
not modified by an earlier reviver call, the context has a "source"
property holding the matched JSON source text; for objects, arrays,
and forward-modified values it is an empty object.

We already had JSON.rawJSON and JSON.isRawJSON, but the reviver only
received two arguments. Implement the missing half by building a JSON
Parse Record snapshot while parsing: each primitive records the
trimmed raw token from simdjson, and arrays and objects record their
child records keyed by index and property name. InternalizeJSONProperty
threads the matching record down the tree, creates the context object,
and only attaches "source" when the record's stored value still equals
the live value (SameValue), which suppresses source for values a
reviver replaced or appended.

The record values live in heap storage the GC does not scan, and a
reviver can detach the originals from the object graph mid-walk, so
the snapshot's values are kept rooted for the duration of the walk.

Closes the six json-parse-with-source test262 failures and adds
test-js coverage for primitive source text and forward modification.
2026-06-17 21:24:33 +02:00
..
AsmIntGen LibJS: Sync AsmInt program counter before slow paths 2026-06-14 20:27:59 +02:00
Bytecode LibJS: Remove unused C++ local variable wrapper 2026-06-15 02:41:57 +02:00
BytecodeDef LibJS: Infer computed property function names 2026-05-22 01:56:57 +02:00
Contrib/Test262 LibJS: Remove gc from the global object 2026-04-24 18:36:23 +02:00
Heap LibJS: Eliminate GeneratorResult GC cell allocation on yield/await 2026-03-20 15:57:23 -05:00
Runtime LibJS: Support source text access in JSON.parse revivers 2026-06-17 21:24:33 +02:00
Rust LibJS: Move bytecode block counting to Rust 2026-06-15 02:41:57 +02:00
CMakeLists.txt LibJS: Remove unused C++ bytecode block classes 2026-06-14 20:27:59 +02:00
Console.cpp LibJS: Use conservative GC containers for unrooted property-key sets 2026-05-28 21:16:23 +02:00
Console.h LibJS+LibWeb: Make DOMException hold an [[ErrorData]] slot 2026-04-08 20:33:53 +02:00
CyclicModule.cpp LibJS: Allow cached module evaluation errors 2026-05-23 11:36:45 +02:00
CyclicModule.h LibJS: Track async module evaluation order 2026-05-22 01:56:57 +02:00
DecodedBytecodeCache.h LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
ExecutableBacking.h LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
Forward.h LibJS: Remove unused C++ bytecode block classes 2026-06-14 20:27:59 +02:00
Module.cpp LibGC: Default-construct RootHashTable from the global heap 2026-05-20 20:37:55 +02:00
Module.h LibJS: Adopt RootVector for module linking/evaluation stacks 2026-05-19 19:24:08 +02:00
ModuleEntry.h LibJS: Remove C++ AST 2026-03-19 21:55:10 -05:00
ModuleLoading.h LibGC+Everywhere: Factor out a LibGC from LibJS 2024-11-15 14:49:20 +01:00
ParserError.cpp LibJS: Port the JS lexer and parser to UTF-16 2025-08-13 09:56:13 -04:00
ParserError.h LibJS: Port the JS lexer and parser to UTF-16 2025-08-13 09:56:13 -04:00
Position.h LibJS: Drop source ranges from bytecode source maps 2026-05-14 09:41:03 +02:00
Print.cpp LibGC: Default-construct RootHashTable from the global heap 2026-05-20 20:37:55 +02:00
Print.h LibJS: Enable EXPLICIT_SYMBOL_EXPORT and annotate minimum symbol set 2025-07-22 11:51:29 -04:00
RustIntegration.cpp LibJS: Remove unused C++ local variable wrapper 2026-06-15 02:41:57 +02:00
RustIntegration.h LibJS: Move bytecode block counting to Rust 2026-06-15 02:41:57 +02:00
Script.cpp LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
Script.h LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
SourceCode.cpp LibJS: Lazily map UTF-8 source offsets 2026-05-19 17:58:08 +02:00
SourceCode.h LibJS: Lazily map UTF-8 source offsets 2026-05-19 17:58:08 +02:00
SourceRange.h LibJS: Drop source ranges from bytecode source maps 2026-05-14 09:41:03 +02:00
SourceTextModule.cpp LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
SourceTextModule.h LibWeb+LibJS: Cache decoded JS bytecode sidecars 2026-06-06 09:15:09 +02:00
SyntaxHighlighter.cpp LibSyntax+LibJS+LibWebView: Port the syntax highlighter to UTF-8 2026-06-06 18:42:18 +02:00
SyntaxHighlighter.h LibSyntax+LibJS+LibWeb+LibWebView: Remove unused syntax highlighter code 2026-06-06 18:42:18 +02:00
SyntheticModule.cpp LibJS+LibWeb: Adopt RootHashTable for unrooted GC-pointer storage 2026-05-19 19:24:08 +02:00
SyntheticModule.h LibJS+LibWeb: Adopt RootHashTable for unrooted GC-pointer storage 2026-05-19 19:24:08 +02:00
Token.h LibJS: Remove C++ lexer, use Rust tokenizer for syntax highlighting 2026-03-19 21:55:10 -05:00