1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

LibJS: Add source location for Handle nodes in GC graph dumper output

With this change JS::Handle root nodes will contain source location
where they were constructed like:
```
    "94675029575744": {
        "root": "Handle activate_event_handler \
           serenity/Userland/Libraries/LibWeb/DOM/EventTarget.cpp:564",
        "class_name": "HTMLButtonElement",
        "edges": [
            "94675025955904",
            "94675026899520",
            "94675030831168",
```
This commit is contained in:
Aliaksandr Kalenik 2023-09-22 02:04:16 +02:00 committed by Andreas Kling
parent 4b06cef93a
commit 719a00df3a
9 changed files with 129 additions and 121 deletions

View file

@ -12,13 +12,13 @@
#include <AK/Vector.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/HeapRootTypeOrLocation.h>
#include <LibJS/Heap/HeapRoot.h>
namespace JS {
class MarkedVectorBase {
public:
virtual void gather_roots(HashMap<Cell*, JS::HeapRootTypeOrLocation>&) const = 0;
virtual void gather_roots(HashMap<Cell*, JS::HeapRoot>&) const = 0;
protected:
explicit MarkedVectorBase(Heap&);
@ -65,14 +65,14 @@ public:
return *this;
}
virtual void gather_roots(HashMap<Cell*, JS::HeapRootTypeOrLocation>& roots) const override
virtual void gather_roots(HashMap<Cell*, JS::HeapRoot>& roots) const override
{
for (auto& value : *this) {
if constexpr (IsSame<Value, T>) {
if (value.is_cell())
roots.set(&const_cast<T&>(value).as_cell(), HeapRootType::MarkedVector);
roots.set(&const_cast<T&>(value).as_cell(), HeapRoot { .type = HeapRoot::Type::MarkedVector });
} else {
roots.set(value, HeapRootType::MarkedVector);
roots.set(value, HeapRoot { .type = HeapRoot::Type::MarkedVector });
}
}
}