Truly independent web browser
LibGC+LibJS: Make the default heap and VM per thread
Andreas Kling65f9018ebcce
diff --git a/Libraries/LibGC/BlockAllocator.cpp b/Libraries/LibGC/BlockAllocator.cppindex 9cb4ed4d709..03d40f4000a 100644--- a/Libraries/LibGC/BlockAllocator.cpp+++ b/Libraries/LibGC/BlockAllocator.cpp@@ -95,7 +95,7 @@ public:*registration.m_copy = js_heap_region_base;}- // This process-global region is shared by every Heap. GC block allocation is single-threaded per process, but the+ // This process-global region is shared by every Heap, and heaps allocate blocks on their own threads while the// decommit worker prepares the next chunk ahead of time, so the chunk bookkeeping is under a lock.void* allocate_chunk(){diff --git a/Libraries/LibGC/CAPI.cpp b/Libraries/LibGC/CAPI.cppindex 01d6cd22938..f7f52f6afe7 100644--- a/Libraries/LibGC/CAPI.cpp+++ b/Libraries/LibGC/CAPI.cpp@@ -229,14 +229,14 @@ uintptr_t gc_primitive_storage_cage_base(void)return js_primitive_storage_cage_base;}-GCHeap* gc_heap_create(GCGatherRootsCallback gather_roots, void* context, bool become_process_default)+GCHeap* gc_heap_create(GCGatherRootsCallback gather_roots, void* context, bool become_thread_default){auto* heap = new Heap([gather_roots, context](HashMap<Cell*, HeapRoot>& roots) {RootGatheringVisitor visitor { roots };gather_roots(context, reinterpret_cast<GCVisitor*>(static_cast<Cell::Visitor*>(&visitor)));},- become_process_default ? Heap::BecomeProcessDefault::Yes : Heap::BecomeProcessDefault::No);+ become_thread_default ? Heap::BecomeThreadDefault::Yes : Heap::BecomeThreadDefault::No);CAPI::set_foreign_context(*heap, context);return reinterpret_cast<GCHeap*>(heap);}diff --git a/Libraries/LibGC/CAPI.h b/Libraries/LibGC/CAPI.hindex 1908870c883..e9f1c7c3a3d 100644--- a/Libraries/LibGC/CAPI.h+++ b/Libraries/LibGC/CAPI.h@@ -108,7 +108,7 @@ GC_API void gc_get_layout(GCLayout*);GC_API uintptr_t gc_heap_region_base(void);GC_API uintptr_t gc_primitive_storage_cage_base(void);-GC_API GCHeap* gc_heap_create(GCGatherRootsCallback, void* context, bool become_process_default);+GC_API GCHeap* gc_heap_create(GCGatherRootsCallback, void* context, bool become_thread_default);// Finalizes and destroys every remaining cell. Roots created with gc_root_create() must be destroyed first. The final// collection also runs every sweep callback and pending post-GC task, with gc_heap_is_collecting_everything() true,// so their contexts must stay valid until this returns; nothing they allocate then is destroyed.diff --git a/Libraries/LibGC/Heap.cpp b/Libraries/LibGC/Heap.cppindex b7133d71ae5..47a1cf50e2c 100644--- a/Libraries/LibGC/Heap.cpp+++ b/Libraries/LibGC/Heap.cpp@@ -77,7 +77,8 @@ static constexpr int GC_INCREMENTAL_SWEEP_SLICE_MS = 5;// whether to proactively collect. See idle_gc_on_timer().static constexpr int GC_IDLE_GC_INTERVAL_MS = 4000;-static Heap* s_the;+// Every thread that runs a VM has a heap of its own, and all but the main thread may come and go.+AK_TLS_INITIAL_EXEC static thread_local constinit Heap* s_the = nullptr;namespace {@@ -321,10 +322,10 @@ CellAllocator& Heap::create_cell_allocator(CellAllocatorDescriptorBase& descriptreturn *allocator;}-Heap::Heap(AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots, BecomeProcessDefault become_process_default)+Heap::Heap(AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots, BecomeThreadDefault become_thread_default): m_gather_embedder_roots(move(gather_embedder_roots)){- if (become_process_default == BecomeProcessDefault::Yes)+ if (become_thread_default == BecomeThreadDefault::Yes)s_the = this;m_gc_bytes_threshold = GC_MIN_BYTES_THRESHOLD;m_last_collection_end_ns = MonotonicTime::now().nanoseconds();@@ -347,6 +348,9 @@ Heap::~Heap()for (auto* member : m_incoming_cross_heap_members)member->detach_from_heap({});m_incoming_cross_heap_members.clear();++ if (s_the == this)+ s_the = nullptr;}void Heap::free_weak_blocks()diff --git a/Libraries/LibGC/Heap.h b/Libraries/LibGC/Heap.hindex 5bd3cafc732..50093dd2324 100644--- a/Libraries/LibGC/Heap.h+++ b/Libraries/LibGC/Heap.h@@ -52,12 +52,12 @@ class GC_API Heap {public:AK_ALLOC_WITH_KMALLOC;- enum class BecomeProcessDefault {+ enum class BecomeThreadDefault {No,Yes,};- explicit Heap(AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots, BecomeProcessDefault = BecomeProcessDefault::Yes);+ explicit Heap(AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots, BecomeThreadDefault = BecomeThreadDefault::Yes);~Heap();static Heap& the();diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cppindex ed72677acd4..1fcb87c09ea 100644--- a/Libraries/LibJS/Runtime/VM.cpp+++ b/Libraries/LibJS/Runtime/VM.cpp@@ -49,8 +49,16 @@ static_assert(to_underlying(Promise::RejectionOperation::Handle) == JS_PROMISE_Rstatic_assert(sizeof(Value) == sizeof(JSValue));static_assert(sizeof(JSScriptOrModule) == sizeof(ScriptOrModule));-VM* VM::s_the = nullptr;-static size_t s_vm_count = 0;+#if defined(AK_OS_WINDOWS)+static thread_local VM* s_the = nullptr;++VM& VM::the()+{+ return *s_the;+}+#else+constinit thread_local VM* VM::s_the = nullptr;+#endifstatic JSVM* vm_abi(VM const& vm){@@ -279,11 +287,10 @@ static constexpr JSVmHostHooks s_host_hook_thunks {NonnullRefPtr<VM> VM::create(){- // NOTE: We only allow a single VM instance per process.+ // NOTE: We only allow a single VM instance per thread.// However, test runners need to create and destroy VMs repeatedly,// so we allow recreating the VM as long as the previous one was destroyed.- VERIFY(s_vm_count == 0);- ++s_vm_count;+ VERIFY(!s_the);ErrorMessages error_messages {};error_messages[to_underlying(ErrorMessage::OutOfMemory)] = Utf16String::from_utf16(ErrorType::OutOfMemory.message());@@ -299,7 +306,7 @@ VM::VM(ErrorMessages error_messages)// The embedder's C++ cells live in the VM's heap, and a SharedArrayBuffer of a fixed length lives in memory that// other processes can map.JSVmOptions options {- .become_process_default_heap = true,+ .become_thread_default_heap = true,.shared_memory_shared_array_buffers = true,};VERIFY(js_vm_construct_at(m_engine_storage, sizeof(m_engine_storage), alignof(VM), &options));@@ -313,6 +320,8 @@ VM::VM(ErrorMessages error_messages)VM::~VM(){+ VERIFY(s_the == this);+// The hooks and the agent may hold roots, which have to go before the heap does.js_vm_set_agent(vm_abi(*this), nullptr);js_vm_set_embedder(vm_abi(*this), nullptr, nullptr);@@ -322,10 +331,7 @@ VM::~VM()js_vm_destroy_at(vm_abi(*this));- if (s_the == this)- s_the = nullptr;- --s_vm_count;- VERIFY(s_vm_count == 0);+ s_the = nullptr;}void VM::unref() constdiff --git a/Libraries/LibJS/Runtime/VM.h b/Libraries/LibJS/Runtime/VM.hindex d8aa8d6a4a7..e36a5933fc0 100644--- a/Libraries/LibJS/Runtime/VM.h+++ b/Libraries/LibJS/Runtime/VM.h@@ -129,7 +129,17 @@ public:void ref() const { ++m_reference_count; }void unref() const;+ // The VM of the calling thread. A thread that runs a VM creates and destroys it, and has at most one at a time.+#if defined(AK_OS_WINDOWS)+ static VM& the();+#elseALWAYS_INLINE static VM& the() { return *s_the; }+#endif++ // A thread that runs a VM should have a stack of at least this size, which is what main threads usually get. The+ // default for other threads can be far less (512 KiB on macOS), where recursion that works on the main thread would+ // end in a RangeError.+ static constexpr size_t MINIMUM_THREAD_STACK_SIZE = 8 * MiB;GC::Heap& heap() const { return *m_heap; }@@ -487,7 +497,10 @@ private:void push_execution_context_growing_the_stack(ExecutionContext&);- static VM* s_the;+#if !defined(AK_OS_WINDOWS)+ // NB: Cell::vm() reads this all the time, so it stays inline where it can: a DLL cannot export a thread_local.+ AK_TLS_INITIAL_EXEC static constinit thread_local VM* s_the;+#endifmutable u32 m_reference_count { 1 };GC::Heap* m_heap { nullptr };diff --git a/Libraries/LibJS/Rust/src/embedding/vm.rs b/Libraries/LibJS/Rust/src/embedding/vm.rsindex d9354341fdd..cd81bf9a269 100644--- a/Libraries/LibJS/Rust/src/embedding/vm.rs+++ b/Libraries/LibJS/Rust/src/embedding/vm.rs@@ -47,8 +47,9 @@ const _: () = assert!(#[repr(C)]#[derive(Clone, Copy, Default)]pub struct JSVmOptions {- /// Makes the VM's heap the one GC::Heap::the() returns, so that C++ cells of the embedder are allocated from it.- pub become_process_default_heap: bool,+ /// Makes the VM's heap the one GC::Heap::the() returns on this thread, so that C++ cells of the embedder are+ /// allocated from it.+ pub become_thread_default_heap: bool,/// Backs SharedArrayBuffers with shared memory, which other processes can map.pub shared_memory_shared_array_buffers: bool,}@@ -56,7 +57,7 @@ pub struct JSVmOptions {impl From<JSVmOptions> for VmOptions {fn from(options: JSVmOptions) -> Self {Self {- become_process_default_heap: options.become_process_default_heap,+ become_thread_default_heap: options.become_thread_default_heap,shared_memory_shared_array_buffers: options.shared_memory_shared_array_buffers,}}diff --git a/Libraries/LibJS/Rust/src/gc/capi.rs b/Libraries/LibJS/Rust/src/gc/capi.rsindex ed8c7191bd7..78088469619 100644--- a/Libraries/LibJS/Rust/src/gc/capi.rs+++ b/Libraries/LibJS/Rust/src/gc/capi.rs@@ -95,7 +95,7 @@ unsafe extern "C" {pub fn gc_heap_create(gather_roots: GCGatherRootsCallback,context: *mut c_void,- become_process_default: bool,+ become_thread_default: bool,) -> *mut GCHeap;pub fn gc_heap_destroy(heap: *mut GCHeap);// NB: The functions that take a reference to the heap have no other preconditions.diff --git a/Libraries/LibJS/Rust/src/gc/heap.rs b/Libraries/LibJS/Rust/src/gc/heap.rsindex 2625b1a6150..4992cace5f7 100644--- a/Libraries/LibJS/Rust/src/gc/heap.rs+++ b/Libraries/LibJS/Rust/src/gc/heap.rs@@ -157,16 +157,16 @@ enum AllocationKind {impl Heap {/// Creates a heap that calls `gather_roots` with `context` whenever it gathers its roots. A heap that becomes the- /// process default is the one GC::Heap::the() returns to C++ code.+ /// default of its thread is the one GC::Heap::the() returns to C++ code on that thread.////// # Safety////// `context` must stay valid for as long as the heap exists, including while it is being destroyed.- pub unsafe fn new(gather_roots: GCGatherRootsCallback, context: *mut c_void, become_process_default: bool) -> Self {+ pub unsafe fn new(gather_roots: GCGatherRootsCallback, context: *mut c_void, become_thread_default: bool) -> Self {let layout = check_layout();crate::layout_forward::initialize_heap_region_base();// SAFETY: The caller keeps the context alive for the heap's lifetime.- let raw = unsafe { capi::gc_heap_create(gather_roots, context, become_process_default) };+ let raw = unsafe { capi::gc_heap_create(gather_roots, context, become_thread_default) };let raw = NonNull::new(raw).expect("LibGC creates the heap");// NB: LibGC reports offsets of fields of its heap.let counter = |offset: u32| {diff --git a/Libraries/LibJS/Rust/src/interpreter/vm.rs b/Libraries/LibJS/Rust/src/interpreter/vm.rsindex 27030b24fbd..02ceaeb9acc 100644--- a/Libraries/LibJS/Rust/src/interpreter/vm.rs+++ b/Libraries/LibJS/Rust/src/interpreter/vm.rs@@ -174,8 +174,9 @@ pub type OnUnimplementedPropertyAccess = fn(&Vm, &Object, &PropertyKey);/// How a VM is set up, which is fixed once it is created.#[derive(Clone, Copy, Debug, Default)]pub struct VmOptions {- /// Makes the VM's heap the one GC::Heap::the() returns, so that the embedder's C++ cells are allocated from it.- pub become_process_default_heap: bool,+ /// Makes the VM's heap the one GC::Heap::the() returns on this thread, so that the embedder's C++ cells are+ /// allocated from it.+ pub become_thread_default_heap: bool,/// Backs SharedArrayBuffers with shared memory, which other processes can map.pub shared_memory_shared_array_buffers: bool,}@@ -767,7 +768,7 @@ impl Vm {vm.update_dispatch_tables();let context = storage.cast();// SAFETY: The VM stays at this address until it is dropped, and it destroys the heap before anything else.- let heap = unsafe { Heap::new(gather_roots, context, options.become_process_default_heap) };+ let heap = unsafe { Heap::new(gather_roots, context, options.become_thread_default_heap) };// SAFETY: As above.unsafe { heap.register_sweep_callback(sweep, context) };vm.head.stack_base.set(heap.stack_bounds().0);diff --git a/Tests/LibGC/TestGCEphemeron.cpp b/Tests/LibGC/TestGCEphemeron.cppindex eaa79ecfa53..7af345c4378 100644--- a/Tests/LibGC/TestGCEphemeron.cpp+++ b/Tests/LibGC/TestGCEphemeron.cpp@@ -137,7 +137,7 @@ NEVER_INLINE void add_double_of_dead_key(GC::Heap& heap, EphemeronTable& table)static NEVER_INLINE void value_referring_to_its_key_dies_with_it(){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);auto table = GC::make_root(heap.allocate<EphemeronTable>());@@ -152,7 +152,7 @@ static NEVER_INLINE void value_referring_to_its_key_dies_with_it()static NEVER_INLINE void value_survives_when_its_key_is_marked_later(){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);auto table = GC::make_root(heap.allocate<EphemeronTable>());auto first_key = GC::make_root(heap.allocate<TestCell>());@@ -168,8 +168,8 @@ static NEVER_INLINE void value_survives_when_its_key_is_marked_later()static NEVER_INLINE void value_of_key_outside_domain_survives_local_collection(){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);- GC::Heap foreign_heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);+ GC::Heap foreign_heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);foreign_heap.set_incremental_sweep_enabled(false);auto table = GC::make_root(heap.allocate<EphemeronTable>());@@ -185,7 +185,7 @@ static NEVER_INLINE void value_of_key_outside_domain_survives_local_collection()static NEVER_INLINE void non_cell_value_is_ignored(){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);auto table = GC::make_root(heap.allocate<EphemeronTable>());auto key = GC::make_root(heap.allocate<TestCell>());diff --git a/Tests/LibGC/TestGCFreeList.cpp b/Tests/LibGC/TestGCFreeList.cppindex 32d695ed5a9..686d8a1b6e8 100644--- a/Tests/LibGC/TestGCFreeList.cpp+++ b/Tests/LibGC/TestGCFreeList.cpp@@ -36,7 +36,7 @@ NEVER_INLINE void allocate_unreachable_cells(GC::Heap& heap, size_t count)TEST_CASE(a_corrupted_free_cell_link_leads_to_a_cell_of_the_same_block){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);// NB: The cells of a new block come in address order.diff --git a/Tests/LibGC/TestGCHeapGroup.cpp b/Tests/LibGC/TestGCHeapGroup.cppindex 3282d99835a..49f867e33ea 100644--- a/Tests/LibGC/TestGCHeapGroup.cpp+++ b/Tests/LibGC/TestGCHeapGroup.cpp@@ -109,7 +109,7 @@ NEVER_INLINE void allocate_garbage(GC::Heap& heap)static NEVER_INLINE void sanity_single_heap_frees_garbage(){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.set_incremental_sweep_enabled(false);allocate_garbage(heap);@@ -121,8 +121,8 @@ static NEVER_INLINE void sanity_single_heap_frees_garbage()static NEVER_INLINE void incoming_cross_heap_member_roots_local_collection(){- GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeProcessDefault::No);- GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeThreadDefault::No);+ GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeThreadDefault::No);// No event loop runs during this test; sweep synchronously so frees are observable.heap_a.set_incremental_sweep_enabled(false);heap_b.set_incremental_sweep_enabled(false);@@ -155,8 +155,8 @@ static NEVER_INLINE void incoming_cross_heap_member_roots_local_collection()static NEVER_INLINE void group_collection_breaks_cross_heap_cycles(){- GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeProcessDefault::No);- GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeThreadDefault::No);+ GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap_a.set_incremental_sweep_enabled(false);heap_b.set_incremental_sweep_enabled(false);@@ -184,8 +184,8 @@ static NEVER_INLINE void group_collection_breaks_cross_heap_cycles()static NEVER_INLINE void group_collection_traces_live_cross_heap_chains(){- GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeProcessDefault::No);- GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeThreadDefault::No);+ GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap_a.set_incremental_sweep_enabled(false);heap_b.set_incremental_sweep_enabled(false);@@ -212,8 +212,8 @@ static NEVER_INLINE void group_collection_traces_live_cross_heap_chains()static NEVER_INLINE void group_collection_finalizer_creates_null_weak_to_dead_foreign_cell(){- GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeProcessDefault::No);- GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap_a([](auto&) { }, GC::Heap::BecomeThreadDefault::No);+ GC::Heap heap_b([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap_a.set_incremental_sweep_enabled(false);heap_b.set_incremental_sweep_enabled(false);diff --git a/Tests/LibGC/TestGCIncrementalSweep.cpp b/Tests/LibGC/TestGCIncrementalSweep.cppindex 27f6641c086..07b5fccd952 100644--- a/Tests/LibGC/TestGCIncrementalSweep.cpp+++ b/Tests/LibGC/TestGCIncrementalSweep.cpp@@ -94,7 +94,7 @@ NEVER_INLINE GC::Root<CellOfAnotherType> allocate_reachable_cell_of_another_typeTEST_CASE(allocating_from_a_destructor_during_a_sweep_does_not_free_reachable_cells_of_the_block){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);auto reachable_cell = allocate_unreachable_then_reachable_cell(heap);GC::scrub_stack_for_testing();@@ -115,7 +115,7 @@ TEST_CASE(allocating_from_a_destructor_during_a_sweep_does_not_free_reachable_ceTEST_CASE(ending_a_deferral_from_a_destructor_during_a_sweep_does_not_start_a_collection){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.enable_stats();s_cell_that_allocates_when_destroyed_was_destroyed = false;s_reachable_cell_was_destroyed = false;@@ -145,7 +145,7 @@ TEST_CASE(ending_a_deferral_from_a_destructor_during_a_sweep_does_not_start_a_coTEST_CASE(free_cells_that_a_destructor_takes_while_a_collection_finishes_the_sweep_go_back_to_their_block){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);auto reachable_cell = allocate_reachable_cell_of_another_type_then_unreachable_cell(heap);GC::scrub_stack_for_testing();@@ -172,7 +172,7 @@ TEST_CASE(free_cells_that_a_destructor_takes_while_a_collection_finishes_the_sweTEST_CASE(cells_allocated_into_blocks_pending_sweep_do_not_count_as_live){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.enable_stats();auto reachable_cell = GC::make_root(heap.allocate<CellOfAnotherType>());@@ -201,7 +201,7 @@ TEST_CASE(cells_allocated_into_blocks_pending_sweep_do_not_count_as_live)TEST_CASE(collect_everything_leaves_no_live_cell_bytes){- GC::Heap heap([](auto&) { }, GC::Heap::BecomeProcessDefault::No);+ GC::Heap heap([](auto&) { }, GC::Heap::BecomeThreadDefault::No);heap.enable_stats();{diff --git a/Tests/LibGfx/CMakeLists.txt b/Tests/LibGfx/CMakeLists.txtindex 9416c4c0a16..928ddf15f4d 100644--- a/Tests/LibGfx/CMakeLists.txt+++ b/Tests/LibGfx/CMakeLists.txt@@ -19,6 +19,12 @@ list(APPEND TEST_SOURCES TestBitmapSequence.cpp TestShareableBitmap.cpp)if (BUILD_SHARED_LIBS AND (APPLE OR LINUX))list(APPEND TEST_SOURCES TestRustCrateCopies.cpp)target_link_libraries(TestLibGfx PRIVATE LibWeb)+ # LibWeb's initial-exec thread-locals need static TLS, which glibc has only a small surplus of for dlopen(). No symbol+ # here keeps LibWeb linked, so the linker would drop it and leave it to the dlopen() in the test. Opening a library+ # the program has loaded already gives the same handle.+ if (LINUX)+ target_link_options(TestLibGfx PRIVATE LINKER:--no-as-needed)+ endif()endif()target_sources(TestLibGfx PRIVATE ${TEST_SOURCES})