Browse Source

LibJS: Make Cell::Visitor::visit_impl() take a Cell&

Passing a null cell pointer is not supported.
Andreas Kling 4 years ago
parent
commit
0de954e86b

+ 2 - 2
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;
     };
 

+ 4 - 4
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);
     }
 };
 

+ 1 - 1
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);