Commit graph

22 commits

Author SHA1 Message Date
Andreas Kling
b81269e78b Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.

Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-22 19:51:25 +02:00
Andreas Kling
804bf2532b LibJS: Allow cached module evaluation errors
A second root module in a failed cycle can call Evaluate after the
cycle root has already cached an evaluation error. In that case
InnerModuleEvaluation returns the cached error immediately and Evaluate
must reject the new top-level capability with that same error.

Remove the extra assertion that the module evaluation error is empty in
the abrupt completion path. Add text coverage for evaluating both roots
of a module cycle whose dependency throws during evaluation.
2026-05-23 11:36:45 +02:00
Andreas Kling
fb5b78bfea LibJS: Track async module evaluation order
Store the spec's [[AsyncEvaluationOrder]] value instead of a boolean for
pending async module evaluation. This lets AsyncModuleExecutionFulfilled
sort available parent modules by the order assigned during module graph
evaluation before executing them.

This matches ECMA-262 module graph ordering and fixes TLA parent
completion order, including graphs where a dynamic import later reuses a
TLA dependency.
2026-05-22 01:56:57 +02:00
Shannon Booth
de6aec04e8 LibGC: Default-construct ConservativeVector from the global heap 2026-05-20 20:37:55 +02:00
Shannon Booth
387cd6e2e2 LibGC: Default-construct RootVector from the global heap
Similar to GC::Root<T>, make GC::RootVector<T> constructible without
explicitly passing a Heap.

This is implemented by having RootVectorBase use GC::Heap::the() for
heap-free construction.
2026-05-20 20:37:55 +02:00
Luke Wilde
32da124c6c LibJS: Adopt ConservativeVector for module setup vectors 2026-05-19 19:24:08 +02:00
Luke Wilde
c8a68f9a4f LibJS: Adopt RootVector for module linking/evaluation stacks 2026-05-19 19:24:08 +02:00
Andreas Kling
745f73bbaa LibJS: Account module storage as external memory
Report module record vectors, loaded module request attributes, graph
loading visited sets, and module filename storage through the GC
external memory hook.
2026-05-07 10:03:09 +02:00
Glenn Skrzypczak
e5dab9e1c7 LibWeb: Support WASM modules
This adds support for importing WASM modules in JavaScript and vice
versa.
2026-04-03 21:21:09 +02:00
Timothy Flynn
941336505c LibJS: Align async module rejection order with fulfillment order
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/4752038
2025-12-17 15:33:26 +01:00
Timothy Flynn
a8514a2c29 LibJS: Do not assume cyclic modules have a cycle root
This is a normative change in the ECMA-262 spec. See:
https://github.com/tc39/ecma262/commit/939b993
2025-11-13 14:05:18 +01:00
caztanj
e93f44112d LibJS: Do not verify cycle root's status is linked in CyclicModule
This VERIFY is both incorrect and redundant. The VERIFY at step 2
verifies the status when evaluate is called on m_cycle_root.
2025-10-22 11:54:56 +02:00
Feng Yu
61c36e2865 LibJS: Sync additional Import Attributes spec changes
Some steps were not updated with tc39/ecma262#3057. This patch
syncs the remaining changes.
2025-10-22 10:58:19 +02:00
Timothy Flynn
3867a192a1 LibJS: Update spec steps / links for the import-assertions proposal
This proposal has reached stage 4 and been merged into the main ECMA-262
spec. See:

https://github.com/tc39/ecma262/commit/4e3450e
2025-04-29 07:33:08 -04:00
Andreas Kling
c5a239b8c4 LibJS: Add missing visit for CyclicModule::m_evaluation_error 2025-04-05 21:34:13 +02:00
Andreas Kling
de424d6879 LibJS: Make Completion.[[Value]] non-optional
Instead, just use js_undefined() whenever the [[Value]] field is unused.
This avoids a whole bunch of presence checks.
2025-04-05 11:20:26 +02:00
Andreas Kling
53da8893ac LibJS: Replace PropertyKey(char[]) with PropertyKey(FlyString)
...and deal with the fallout.
2025-03-24 22:27:17 +00:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Timothy Flynn
2c3077d929 LibJS: Implement InnerModuleLoading as a free function
It is currently implemented as a member of CyclicModule. However, as the
spec indicates, this must be invokable with non-CyclicModule modules. In
several of the call sites, we are blindly casting to a CyclicModule;
this will fail for e.g. JSON modules.
2025-01-21 14:58:32 +01:00
Shannon Booth
f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00
Shannon Booth
1e54003cb1 LibJS+LibWeb: Rename Heap::allocate_without_realm to Heap::allocate
Now that the heap has no knowledge about a JavaScript realm and is
purely for managing the memory of the heap, it does not make sense
to name this function to say that it is a non-realm variant.
2024-11-13 16:51:44 -05:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibJS/CyclicModule.cpp (Browse further)