mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJSGCVerifier: Support marking GCPtr members as raw references
This lets us avoid false positives when a GCPtr-wrapped member is only a weak reference which is automatically updated by the GC when the member's gc state is updated.
This commit is contained in:
parent
c3217754f1
commit
c84cd1d668
Notes:
sideshowbarker
2024-07-17 03:30:41 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/c84cd1d668 Pull-request: https://github.com/SerenityOS/serenity/pull/23854 Issue: https://github.com/SerenityOS/serenity/issues/23848 Reviewed-by: https://github.com/mattco98 ✅ Reviewed-by: https://github.com/trflynn89
4 changed files with 9 additions and 5 deletions
|
@ -87,7 +87,7 @@ std::vector<clang::QualType> get_all_qualified_types(clang::QualType const& type
|
|||
if (auto const* template_specialization = type->getAs<clang::TemplateSpecializationType>()) {
|
||||
auto specialization_name = template_specialization->getTemplateName().getAsTemplateDecl()->getQualifiedNameAsString();
|
||||
// Do not unwrap GCPtr/NonnullGCPtr
|
||||
if (specialization_name == "JS::GCPtr" || specialization_name == "JS::NonnullGCPtr") {
|
||||
if (specialization_name == "JS::GCPtr" || specialization_name == "JS::NonnullGCPtr" || specialization_name == "JS::RawGCPtr") {
|
||||
qualified_types.push_back(type);
|
||||
} else {
|
||||
auto const template_arguments = template_specialization->template_arguments();
|
||||
|
@ -141,7 +141,7 @@ FieldValidationResult validate_field(clang::FieldDecl const* field_decl)
|
|||
}
|
||||
} else if (auto const* specialization = qualified_type->getAs<clang::TemplateSpecializationType>()) {
|
||||
auto template_type_name = specialization->getTemplateName().getAsTemplateDecl()->getName();
|
||||
if (template_type_name != "GCPtr" && template_type_name != "NonnullGCPtr")
|
||||
if (template_type_name != "GCPtr" && template_type_name != "NonnullGCPtr" && template_type_name != "RawGCPtr")
|
||||
return result;
|
||||
|
||||
auto const template_args = specialization->template_arguments();
|
||||
|
@ -159,7 +159,7 @@ FieldValidationResult validate_field(clang::FieldDecl const* field_decl)
|
|||
|
||||
result.is_wrapped_in_gcptr = true;
|
||||
result.is_valid = record_inherits_from_cell(*record_decl);
|
||||
result.needs_visiting = true;
|
||||
result.needs_visiting = template_type_name != "RawGCPtr";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,6 +186,10 @@ private:
|
|||
T* m_ptr { nullptr };
|
||||
};
|
||||
|
||||
// Non-Owning GCPtr
|
||||
template<typename T>
|
||||
using RawGCPtr = GCPtr<T>;
|
||||
|
||||
template<typename T, typename U>
|
||||
inline bool operator==(GCPtr<T> const& a, GCPtr<U> const& b)
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ private:
|
|||
struct FreelistEntry final : public Cell {
|
||||
JS_CELL(FreelistEntry, Cell);
|
||||
|
||||
GCPtr<FreelistEntry> next;
|
||||
RawGCPtr<FreelistEntry> next;
|
||||
};
|
||||
|
||||
Cell* cell(size_t index)
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
private:
|
||||
explicit WeakSet(Object& prototype);
|
||||
|
||||
HashTable<GCPtr<Cell>> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
|
||||
HashTable<RawGCPtr<Cell>> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue