mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 05:17:34 +00:00
LibJS: Make it possible to go from a Cell* to its Heap&
This patch makes all HeapBlock allocations aligned to their block size, enabling us to find the HeapBlock* for a given Cell* by simply masking bits off of the cell address. Use this to make a simple Heap& getter for Cell, which lets us avoid plumbing the Heap& everywhere.
This commit is contained in:
parent
d9c7009604
commit
6089d6566b
5 changed files with 44 additions and 7 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <AK/LogStream.h>
|
||||
#include <LibJS/Cell.h>
|
||||
#include <LibJS/HeapBlock.h>
|
||||
#include <LibJS/Object.h>
|
||||
#include <LibJS/PrimitiveString.h>
|
||||
#include <LibJS/Value.h>
|
||||
|
@ -38,6 +39,11 @@ void Cell::Visitor::visit(Value value)
|
|||
visit(value.as_cell());
|
||||
}
|
||||
|
||||
Heap& Cell::heap()
|
||||
{
|
||||
return HeapBlock::from_cell(this)->heap();
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Cell* cell)
|
||||
{
|
||||
if (!cell)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue