Files
ladybird/Libraries/LibJS/Heap/Cell.h
Shannon Booth c2988a7dd5 LibJS: Don't directly teach the heap about the javascript VM or Realm
Instead, smuggle it in as a `void*` private data and let Javascript
aware code cast out that pointer to a VM&.

In order to make this split, rename JS::Cell to JS::CellImpl. Once we
have a LibGC, this will become GC::Cell. CellImpl then has no specific
knowledge of the VM& and Realm&. That knowledge is instead put into
JS::Cell, which inherits from CellImpl. JS::Cell is responsible for
JavaScript's realm initialization, as well as converting of the void*
private data to what it knows should be the VM&.
2024-11-14 15:38:45 +01:00

23 lines
378 B
C++

/*
* Copyright (c) 2020-2024, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Heap/CellImpl.h>
namespace JS {
class Cell : public CellImpl {
JS_CELL(Cell, CellImpl);
public:
virtual void initialize(Realm&);
ALWAYS_INLINE VM& vm() const { return *reinterpret_cast<VM*>(private_data()); }
};
}