From 0de954e86b64ff3e36c737d8e19cc6957de098c9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 25 May 2021 18:39:01 +0200 Subject: [PATCH] LibJS: Make Cell::Visitor::visit_impl() take a Cell& Passing a null cell pointer is not supported. --- Userland/Libraries/LibJS/Heap/Cell.h | 4 ++-- Userland/Libraries/LibJS/Heap/Heap.cpp | 8 ++++---- Userland/Libraries/LibJS/Runtime/Value.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Userland/Libraries/LibJS/Heap/Cell.h b/Userland/Libraries/LibJS/Heap/Cell.h index 3074562fac..16d72c24de 100644 --- a/Userland/Libraries/LibJS/Heap/Cell.h +++ b/Userland/Libraries/LibJS/Heap/Cell.h @@ -41,12 +41,12 @@ public: void visit(Cell* cell) { if (cell) - visit_impl(cell); + visit_impl(*cell); } void visit(Value); protected: - virtual void visit_impl(Cell*) = 0; + virtual void visit_impl(Cell&) = 0; virtual ~Visitor() = default; }; diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index 669d5d7b02..8d0e3be1d0 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -155,13 +155,13 @@ class MarkingVisitor final : public Cell::Visitor { public: MarkingVisitor() { } - virtual void visit_impl(Cell* cell) + virtual void visit_impl(Cell& cell) { - if (cell->is_marked()) + if (cell.is_marked()) return; dbgln_if(HEAP_DEBUG, " ! {}", cell); - cell->set_marked(true); - cell->visit_edges(*this); + cell.set_marked(true); + cell.visit_edges(*this); } }; diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index f4ca977faa..22b7b49282 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -330,7 +330,7 @@ inline Value js_negative_infinity() inline void Cell::Visitor::visit(Value value) { if (value.is_cell()) - visit_impl(value.as_cell()); + visit_impl(*value.as_cell()); } Value greater_than(GlobalObject&, Value lhs, Value rhs);