5#include <private/qv4mm_p.h>
8#include "PageAllocation.h"
16 WTF::PageAllocation alloc;
24static const int kEntriesPerPage = int((WTF::pageSize() -
sizeof(
Header)) /
sizeof(
Value));
32 return reinterpret_cast<Page *
>(
reinterpret_cast<quintptr>(
val) & ~((
quintptr)(WTF::pageSize() - 1)));
37 p->header.next =
reinterpret_cast<Page *
>(
storage->firstPage);
38 p->header.prev =
reinterpret_cast<Page **
>(&
storage->firstPage);
40 p->header.next->header.prev = &
p->header.next;
47 *
p->header.prev =
p->header.next;
49 p->header.next->header.prev =
p->header.prev;
54 PageAllocation
page = WTF::PageAllocation::allocate(WTF::pageSize());
55 Page *
p =
reinterpret_cast<Page *
>(
page.base());
60 p->header.alloc =
page;
61 p->header.refCount = 0;
62 p->header.freeList = 0;
64 for (
int i = 0;
i < kEntriesPerPage - 1; ++
i) {
67 p->values[kEntriesPerPage - 1] =
Encode(-1);
79 Page *
page =
static_cast<Page *
>(
p);
81 ++
page->header.refCount;
87 Page *
page =
static_cast<Page *
>(
p);
89 ++
page->header.refCount;
94 Page *
page =
static_cast<Page *
>(
p);
95 if (
page && !--
page->header.refCount)
99 page =
static_cast<Page *
>(
p);
101 ++
page->header.refCount;
108 Page *
page =
static_cast<Page *
>(
p);
109 if (
page && !--
page->header.refCount)
115 while (
index < kEntriesPerPage - 1) {
122 if (!--
static_cast<Page *
>(
p)->
header.refCount)
126 ++
next->header.refCount;
148 for (
int i = 0;
i < kEntriesPerPage; ++
i) {
149 if (!
p->values[
i].isEmpty())
152 Page *
n =
p->header.next;
153 p->header.engine =
nullptr;
154 p->header.prev =
nullptr;
155 p->header.next =
nullptr;
164 if (
p &&
p->header.freeList == -1)
167 if (
p->header.freeList != -1)
172 p = allocatePage(
this);
174 Value *
v =
p->values +
p->header.freeList;
179 oldHint->header.refCount--;
185 p->header.refCount++;
188 ++
p->header.refCount;
195void PersistentValueStorage::freeUnchecked(
Value *
v)
198 Page *
p = getPage(
v);
201 p->header.freeList =
v -
p->values;
202 if (!--
p->header.refCount)
210 for (
int i = 0;
i < kEntriesPerPage; ++
i) {
224 if (!--
page->header.refCount)
232 return getPage(
v)->header.engine;
235void PersistentValueStorage::freePage(
void *
page)
237 Page *
p =
static_cast<Page *
>(
page);
239 p->header.alloc.deallocate();
273 val =
other.engine()->memoryManager->m_persistentValues->allocate();
288 if (!val && !
other.valueRef())
290 if (!
other.valueRef()) {
317 value.heapObject()->mark(stack);
331 val.heapObject()->mark(stack);
352 allocVal(
other.engine());
368 allocVal(
other.engine());
404 if (
auto *
h =
value.heapObject())
445 val->
mark(markStack);
448void WeakValue::free()
QVector< Value * > m_pendingFreedObjectWrapperValue
std::unique_ptr< GCStateMachine > gcStateMachine
PersistentValueStorage * m_persistentValues
PersistentValueStorage * m_weakValues
constexpr PersistentValue() noexcept=default
ExecutionEngine * engine() const
PersistentValue & operator=(const PersistentValue &other)
ReturnedValue value() const
void set(ExecutionEngine *engine, const Value &value)
void set(ExecutionEngine *engine, const Value &value)
ExecutionEngine * engine() const
ReturnedValue value() const
WeakValue & operator=(const WeakValue &other)
void markOnce(MarkStack *markStack)
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat GLfloat h
#define QML_NEARLY_ALWAYS_INLINE
QFuture< QSet< QChar > > set
[10]
static constexpr ReturnedValue undefined()
MemoryManager * memoryManager
Iterator & operator=(const Iterator &o)
Iterator(void *p, int idx)
static ExecutionEngine * getEngine(const Value *v)
~PersistentValueStorage()
static void free(Value *v)
void mark(MarkStack *markStack)
PersistentValueStorage(ExecutionEngine *engine)
QV4_NEARLY_ALWAYS_INLINE constexpr int int_32() const
void mark(MarkStack *markStack)
static constexpr Value fromReturnedValue(ReturnedValue val)
static void markCustom(Engine *engine, F &&markFunction)
static constexpr bool isInsertionBarrier