mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
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.
This commit is contained in:
parent
6b65a5c8c4
commit
bfa1aa6904
8 changed files with 60 additions and 43 deletions
|
@ -17,8 +17,12 @@ target_link_libraries(LibGC PRIVATE LibCore)
|
|||
if (ENABLE_SWIFT)
|
||||
generate_clang_module_map(LibGC)
|
||||
target_sources(LibGC PRIVATE
|
||||
Heap+Swift.swift
|
||||
Heap+Swift.swift
|
||||
)
|
||||
target_link_libraries(LibGC PRIVATE AK)
|
||||
add_swift_target_properties(LibGC LAGOM_LIBRARIES AK)
|
||||
|
||||
# FIXME: https://github.com/swiftlang/swift/issues/80182
|
||||
target_compile_options(LibGC PUBLIC $<$<COMPILE_LANGUAGE:C,CXX>:-DLIBGC_WORKAROUND_BOOL_BITFIELD>
|
||||
SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xcc -DLIBGC_WORKAROUND_BOOL_BITFIELD>)
|
||||
add_swift_target_properties(LibGC LAGOM_LIBRARIES AK COMPILE_DEFINITIONS LIBGC_WORKAROUND_BOOL_BITFIELD)
|
||||
endif()
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Swift.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibGC/Forward.h>
|
||||
#include <LibGC/Internals.h>
|
||||
|
@ -27,6 +28,13 @@ namespace GC {
|
|||
# define IGNORE_GC
|
||||
#endif
|
||||
|
||||
// https://github.com/swiftlang/swift/issues/80182
|
||||
#if defined(LIBGC_WORKAROUND_BOOL_BITFIELD)
|
||||
# define BOOL_BITFIELD
|
||||
#else
|
||||
# define BOOL_BITFIELD : 1
|
||||
#endif
|
||||
|
||||
#define GC_CELL(class_, base_class) \
|
||||
public: \
|
||||
using Base = base_class; \
|
||||
|
@ -163,7 +171,7 @@ public:
|
|||
protected:
|
||||
virtual void visit_impl(Cell&) = 0;
|
||||
virtual ~Visitor() = default;
|
||||
};
|
||||
} SWIFT_UNSAFE_REFERENCE;
|
||||
|
||||
virtual void visit_edges(Visitor&) { }
|
||||
|
||||
|
@ -187,10 +195,10 @@ protected:
|
|||
void set_overrides_must_survive_garbage_collection(bool b) { m_overrides_must_survive_garbage_collection = b; }
|
||||
|
||||
private:
|
||||
bool m_mark { false };
|
||||
bool m_overrides_must_survive_garbage_collection { false };
|
||||
State m_state { State::Live };
|
||||
};
|
||||
bool m_mark BOOL_BITFIELD { false };
|
||||
bool m_overrides_must_survive_garbage_collection BOOL_BITFIELD { false };
|
||||
State m_state BOOL_BITFIELD { State::Live };
|
||||
} SWIFT_UNSAFE_REFERENCE;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -142,9 +142,9 @@ private:
|
|||
PropertyAttributes m_attributes { 0 };
|
||||
TransitionType m_transition_type { TransitionType::Invalid };
|
||||
|
||||
bool m_dictionary : 1 { false };
|
||||
bool m_cacheable : 1 { true };
|
||||
bool m_is_prototype_shape : 1 { false };
|
||||
bool m_dictionary BOOL_BITFIELD { false };
|
||||
bool m_cacheable BOOL_BITFIELD { true };
|
||||
bool m_is_prototype_shape BOOL_BITFIELD { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -49,17 +49,17 @@ protected:
|
|||
explicit PlatformObject(JS::Object& prototype, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||
|
||||
struct LegacyPlatformObjectFlags {
|
||||
u16 supports_indexed_properties : 1 = false;
|
||||
u16 supports_named_properties : 1 = false;
|
||||
u16 has_indexed_property_setter : 1 = false;
|
||||
u16 has_named_property_setter : 1 = false;
|
||||
u16 has_named_property_deleter : 1 = false;
|
||||
u16 has_legacy_unenumerable_named_properties_interface_extended_attribute : 1 = false;
|
||||
u16 has_legacy_override_built_ins_interface_extended_attribute : 1 = false;
|
||||
u16 has_global_interface_extended_attribute : 1 = false;
|
||||
u16 indexed_property_setter_has_identifier : 1 = false;
|
||||
u16 named_property_setter_has_identifier : 1 = false;
|
||||
u16 named_property_deleter_has_identifier : 1 = false;
|
||||
u16 supports_indexed_properties BOOL_BITFIELD = false;
|
||||
u16 supports_named_properties BOOL_BITFIELD = false;
|
||||
u16 has_indexed_property_setter BOOL_BITFIELD = false;
|
||||
u16 has_named_property_setter BOOL_BITFIELD = false;
|
||||
u16 has_named_property_deleter BOOL_BITFIELD = false;
|
||||
u16 has_legacy_unenumerable_named_properties_interface_extended_attribute BOOL_BITFIELD = false;
|
||||
u16 has_legacy_override_built_ins_interface_extended_attribute BOOL_BITFIELD = false;
|
||||
u16 has_global_interface_extended_attribute BOOL_BITFIELD = false;
|
||||
u16 indexed_property_setter_has_identifier BOOL_BITFIELD = false;
|
||||
u16 named_property_setter_has_identifier BOOL_BITFIELD = false;
|
||||
u16 named_property_deleter_has_identifier BOOL_BITFIELD = false;
|
||||
};
|
||||
Optional<LegacyPlatformObjectFlags> m_legacy_platform_object_flags = {};
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
namespace Web::CSS {
|
||||
|
||||
struct RequiredInvalidationAfterStyleChange {
|
||||
bool repaint : 1 { false };
|
||||
bool rebuild_stacking_context_tree : 1 { false };
|
||||
bool relayout : 1 { false };
|
||||
bool rebuild_layout_tree : 1 { false };
|
||||
bool repaint BOOL_BITFIELD { false };
|
||||
bool rebuild_stacking_context_tree BOOL_BITFIELD { false };
|
||||
bool relayout BOOL_BITFIELD { false };
|
||||
bool rebuild_layout_tree BOOL_BITFIELD { false };
|
||||
|
||||
void operator|=(RequiredInvalidationAfterStyleChange const& other)
|
||||
{
|
||||
|
|
|
@ -553,16 +553,16 @@ private:
|
|||
|
||||
Array<CSSPixelPoint, 3> m_scroll_offset;
|
||||
|
||||
bool m_in_top_layer : 1 { false };
|
||||
bool m_rendered_in_top_layer : 1 { false };
|
||||
bool m_style_uses_css_custom_properties { false };
|
||||
bool m_affected_by_has_pseudo_class_in_subject_position : 1 { false };
|
||||
bool m_affected_by_has_pseudo_class_in_non_subject_position : 1 { false };
|
||||
bool m_affected_by_direct_sibling_combinator : 1 { false };
|
||||
bool m_affected_by_indirect_sibling_combinator : 1 { false };
|
||||
bool m_affected_by_first_or_last_child_pseudo_class : 1 { false };
|
||||
bool m_affected_by_nth_child_pseudo_class : 1 { false };
|
||||
bool m_affected_by_has_pseudo_class_with_relative_selector_that_has_sibling_combinator : 1 { false };
|
||||
bool m_in_top_layer BOOL_BITFIELD { false };
|
||||
bool m_rendered_in_top_layer BOOL_BITFIELD { false };
|
||||
bool m_style_uses_css_custom_properties BOOL_BITFIELD { false };
|
||||
bool m_affected_by_has_pseudo_class_in_subject_position BOOL_BITFIELD { false };
|
||||
bool m_affected_by_has_pseudo_class_in_non_subject_position BOOL_BITFIELD { false };
|
||||
bool m_affected_by_direct_sibling_combinator BOOL_BITFIELD { false };
|
||||
bool m_affected_by_indirect_sibling_combinator BOOL_BITFIELD { false };
|
||||
bool m_affected_by_first_or_last_child_pseudo_class BOOL_BITFIELD { false };
|
||||
bool m_affected_by_nth_child_pseudo_class BOOL_BITFIELD { false };
|
||||
bool m_affected_by_has_pseudo_class_with_relative_selector_that_has_sibling_combinator BOOL_BITFIELD { false };
|
||||
|
||||
size_t m_sibling_invalidation_distance { 0 };
|
||||
|
||||
|
|
|
@ -168,12 +168,12 @@ private:
|
|||
|
||||
SelectionState m_selection_state { SelectionState::None };
|
||||
|
||||
bool m_positioned : 1 { false };
|
||||
bool m_fixed_position : 1 { false };
|
||||
bool m_sticky_position : 1 { false };
|
||||
bool m_absolutely_positioned : 1 { false };
|
||||
bool m_floating : 1 { false };
|
||||
bool m_inline : 1 { false };
|
||||
bool m_positioned BOOL_BITFIELD { false };
|
||||
bool m_fixed_position BOOL_BITFIELD { false };
|
||||
bool m_sticky_position BOOL_BITFIELD { false };
|
||||
bool m_absolutely_positioned BOOL_BITFIELD { false };
|
||||
bool m_floating BOOL_BITFIELD { false };
|
||||
bool m_inline BOOL_BITFIELD { false };
|
||||
};
|
||||
|
||||
inline DOM::Node* HitTestResult::dom_node()
|
||||
|
|
|
@ -40,7 +40,7 @@ function(swizzle_target_properties_for_swift target_name)
|
|||
endfunction()
|
||||
|
||||
function(add_swift_target_properties target_name)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 SWIFT_TARGET "" "" "LAGOM_LIBRARIES")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 SWIFT_TARGET "" "" "LAGOM_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS")
|
||||
|
||||
target_compile_features(${target_name} PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
|
||||
target_compile_options(${target_name} PUBLIC "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xcc -std=c++23 -cxx-interoperability-mode=default>")
|
||||
|
@ -60,8 +60,13 @@ function(add_swift_target_properties target_name)
|
|||
get_target_property(_NATIVE_DIRS ${target_name} INCLUDE_DIRECTORIES)
|
||||
list(APPEND _NATIVE_DIRS ${CMAKE_Swift_MODULE_DIRECTORY})
|
||||
|
||||
set(EXTRA_COMPILE_DEFINITIONS "")
|
||||
foreach (compile_definition IN LISTS SWIFT_TARGET_COMPILE_DEFINITIONS)
|
||||
list(APPEND EXTRA_COMPILE_DEFINITIONS "-Xcc" "-D${compile_definition}")
|
||||
endforeach()
|
||||
|
||||
_swift_generate_cxx_header(${target_name} "${target_name}-Swift.h"
|
||||
SEARCH_PATHS ${_NATIVE_DIRS}
|
||||
COMPILE_OPTIONS ${VFS_OVERLAY_OPTIONS}
|
||||
COMPILE_OPTIONS ${VFS_OVERLAY_OPTIONS} ${EXTRA_COMPILE_DEFINITIONS} ${SWIFT_TARGET_COMPILE_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
|
Loading…
Add table
Reference in a new issue