mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
This is a weak pointer that integrates with the garbage collector. It has a number of differences compared to AK::WeakPtr, including: - The "control block" is allocated from a well-packed WeakBlock owned by the GC heap, not just a generic malloc allocation. - Pointers to dead cells are nulled out by the garbage collector immediately before running destructors. - It works on any GC::Cell derived type, meaning you don't have to inherit from AK::Weakable for the ability to be weakly referenced. - The Weak always points to a control block, even when "null" (it then points to a null WeakImpl), which means one less null check when chasing pointers.
31 lines
764 B
CMake
31 lines
764 B
CMake
set(SOURCES
|
|
BlockAllocator.cpp
|
|
Cell.cpp
|
|
CellAllocator.cpp
|
|
ConservativeVector.cpp
|
|
ForeignCell.cpp
|
|
Root.cpp
|
|
RootHashMap.cpp
|
|
RootVector.cpp
|
|
Heap.cpp
|
|
HeapBlock.cpp
|
|
WeakBlock.cpp
|
|
WeakContainer.cpp
|
|
)
|
|
|
|
ladybird_lib(LibGC gc EXPLICIT_SYMBOL_EXPORT)
|
|
target_link_libraries(LibGC PRIVATE LibCore)
|
|
|
|
if (ENABLE_SWIFT)
|
|
generate_clang_module_map(LibGC)
|
|
target_sources(LibGC PRIVATE
|
|
Heap+Swift.swift
|
|
)
|
|
target_link_libraries(LibGC PRIVATE AK)
|
|
add_swift_target_properties(LibGC LAGOM_LIBRARIES AK)
|
|
endif()
|
|
|
|
# TODO: Use lagom_generate_export_header and annotate entire LibGC with export macros
|
|
include(GenerateExportHeader)
|
|
generate_export_header(LibGC EXPORT_MACRO_NAME GC_API EXPORT_FILE_NAME "Export.h")
|