Commit graph

27 commits

Author SHA1 Message Date
Timothy Flynn
8ec420bc28 LibGC: Allow move-assigning RootVector instances
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Rule of 5 - we were missing a move-assignment operator, thus all move
assignments resulted in a copy.
2025-04-19 02:03:43 +02:00
Timothy Flynn
cceb4321fc LibGC: Allow visiting vectors with inline capacity
This allows visiting e.g. Vector<Value, 1>.
2025-04-11 12:10:46 -04:00
Andreas Kling
be70f8d345 LibGC: Avoid excessive bitfield use in GC::Cell
We didn't actually save any space by making the Cell flags bitfields.
In fact, it just forced us to do bit twiddling when accessing them.
2025-04-08 12:09:42 +02:00
Andrew Kaster
8fd81c3338 LibGC+LibWeb+LibJS: Remove workaround for Swift boolean bitfield issue
We're using a main snapshot everywhere, so we can yeet the workaround.
2025-04-04 13:06:53 -06:00
Andrew Kaster
8554ee386e LibGC: Teach Swift bindings about Cell and Cell::Visitor
Add the proper annotations for the Cell and Cell::Visitor classes to be
visible in Swift. This lets us remove some OpaquePointer shinangians in
the Swift bindings.
2025-04-03 16:47:48 -06:00
Andrew Kaster
e4c88915ab LibGC+LibJS+LibWeb: Add workaround for Swift boolean bitfield issue
This patch adds a workaround for a Swift issue where boolean bitfields
with getters and setters in SWIFT_UNSAFE_REFERENCE types are improperly
imported, causing an ICE.
2025-04-03 16:47:48 -06:00
Andreas Kling
ab5d5d8b50 LibGC: Avoid excessive bitfield use in GC::Cell
We didn't actually save any space by making the Cell flags bitfields.
In fact, it just forced us to do bit twiddling when accessing them.
2025-04-03 13:56:39 +02:00
Tim Ledbetter
568531f06a Everywhere: Mark GC::Cell derived classes as Weakable explicitly
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Previously, all `GC::Cell` derived classes were Weakable. Marking only
those classes that require this functionality as Weakable allows us to
reduce the memory footprint of some frequently used classes.
2025-03-29 17:36:33 -05:00
Luke Wilde
5146bbe296 LibGC: Visit the edges of the cells that must survive garbage collection
Previously, we would only keep the cell that must survive alive, but
none of it's edges.

This cropped up with a GC UAF in must_survive_garbage_collection of
WebSocket in .NET's SignalR frontend implementation, where an
out-of-scope WebSocket had it's underlying EventTarget properties
garbage collected, and must_survive_garbage_collection read from the
destroyed EventTarget properties.

See: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/clients/ts/signalr/src/WebSocketTransport.ts#L81
Found on https://www.formula1.com/ during a live session.

Co-Authored-By: Tim Flynn <trflynn89@pm.me>
2025-02-27 14:35:28 -05:00
Timothy Flynn
bc54c0cdfb AK+Everywhere: Store JSON strings as String 2025-02-20 19:27:51 -05:00
Timothy Flynn
70eb0ba1cd AK+Everywhere: Remove the char const* JSON value constructor 2025-02-20 19:27:51 -05:00
Andreas Kling
51a91771b8 LibJS+LibGC: Run FinalizationRegistry cleanup host hook *after* GC
Before this change, it was possible for a second GC to get triggered
in the middle of a first GC, due to allocations happening in the
FinalizationRegistry cleanup host hook. To avoid this causing problems,
we add a "post-GC task" mechanism and use that to invoke the host hook
once all other GC activity is finished, and we've unset the "collecting
garbage" flag.

Note that the test included here only fails reliably when running with
the -g flag (collect garbage after each allocation).

Fixes #3051
2025-01-23 12:10:21 +01:00
Timothy Flynn
85b424464a AK+Everywhere: Rename verify_cast to as
Follow-up to fc20e61e72.
2025-01-21 11:34:06 -05:00
Andreas Kling
34a8f51eb8 LibGC: Add ability to construct RootVector<T> from a span of T 2025-01-21 17:02:51 +01:00
InvalidUsernameException
01f8ab35f1 LibGC: Rename remaining occurrence of marked vector
In 3bfb0534be `MarkedVector` was renamed to `RootVector`, but some
related symbols were missed. This commit corrects this.
2025-01-02 16:22:29 -07:00
Andreas Kling
3bfb0534be LibGC: Rename MarkedVector => RootVector
Let's try to make it a bit more clear that this is a Vector of GC roots.
2024-12-26 19:10:44 +01:00
stasoid
15a96e841b Meta: Make pthread and mman available for all libraries on Windows
by default
2024-12-18 05:55:58 +01:00
stasoid
27a654c739 LibGC: Port to Windows 2024-12-17 12:14:41 +01:00
Pavel Shliak
03ac6e6e87 LibGC: Preallocate space before dumping GC graph
Speeds up the append_gc_graph function by preallocating space.
This change reduces the time taken to dump the GC graph by 4%
on about:blank.
2024-12-14 09:06:58 +01:00
Andrew Kaster
2f38c83caf LibGC: Mark GC::Function and create_function as ESCAPING
Whenever we create a GC function, it should always be so that we can
pass it to a platform event loop spin, HTML event loop spin, or some
queued task on the HTML event loop. For every use case, any local
variables will be out of scope by the time the function executes.
2024-12-10 07:13:00 +01:00
Pavel Shliak
6f81b80114 Everywhere: Include HashMap only where it's actually used 2024-12-09 12:31:16 +01:00
Jonne Ransijn
cfb00ba494 LibJS: Stop lazily coercing numeric PropertyKeys
Lazily coercing might have made sense in the past, but since hashing
and comparing requires the `PropertyKey` to be coerced, and since a
`PropertyKey` will be used to index into a hashmap 99% of the time,
which will hash the `PropertyKey` and use it in comparisons, the
extra complexity and branching produced by lazily coercing has
become more trouble than it is worth.

Remove the lazy coercions, which then also neatly allows us to
switch to a `Variant`-based implementation.
2024-12-01 10:42:49 +01:00
Andrew Kaster
fca6fd0b85 LibGC: Add Swift bindings to the GC heap
This includes a protocol for creating LibGC Heap allocated Swift
objects. Pay no attention to the Unmanaged shenanigans, they are
all behind the curtain.
2024-11-19 14:32:11 -07:00
Andrew Kaster
829391e714 LibGC: Add a ForeignCell class for ownership of non-C++ objects
This will allow us to use the GC to manage the lifetime of objects
that are not C++ objects, such as Swift objects. In the future we
could expand this cursed FFI to other languages as well.
2024-11-19 14:32:11 -07:00
Andrew Kaster
726f2cfb11 LibGC: Expose deferred state publicly, annotate DeferGC for Swift
While we don't want arbitrary callers deferring GC, we do want
deferral to be available to the Swift. In order for Swift to
understand the RAII nature of DeferGC, we need to mark it as
non-copyable.
2024-11-19 14:32:11 -07:00
Andrew Kaster
d5fb48a6f5 LibGC: Add missing Types.h to forwarding header
The forwarding header was not including any other headers, but still
relied on a definition of size_t.
2024-11-19 14:32:11 -07: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