mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 00:13:02 +00:00
Instead of returning internal generator results as ordinary JS::Objects with properties, we now use GeneratorResult and CompletionCell which both inherit from Cell directly and allow efficient access to state. 1.59x speedup on JetStream3/lazy-collections.js :^)
36 lines
782 B
C++
36 lines
782 B
C++
/*
|
|
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/CellAllocator.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
#include <LibJS/Runtime/Completion.h>
|
|
|
|
namespace JS {
|
|
|
|
class CompletionCell final : public Cell {
|
|
GC_CELL(CompletionCell, Cell);
|
|
GC_DECLARE_ALLOCATOR(CompletionCell);
|
|
|
|
public:
|
|
CompletionCell(Completion completion)
|
|
: m_completion(move(completion))
|
|
{
|
|
}
|
|
|
|
virtual ~CompletionCell() override;
|
|
|
|
[[nodiscard]] Completion const& completion() const { return m_completion; }
|
|
void set_completion(Completion completion) { m_completion = move(completion); }
|
|
|
|
private:
|
|
virtual void visit_edges(Cell::Visitor& visitor) override;
|
|
|
|
Completion m_completion;
|
|
};
|
|
|
|
}
|