Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4identifierhashdata_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4#ifndef QV4IDENTIFIERHASHDATA_H
5#define QV4IDENTIFIERHASHDATA_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qv4global_p.h>
19#include <private/qv4propertykey_p.h>
20#include <private/qv4identifiertable_p.h>
21#include <QtCore/qatomic.h>
22
23QT_BEGIN_NAMESPACE
24
25namespace QV4 {
26
31
33{
34 IdentifierHashData(IdentifierTable *table, int numBits)
35 : size(0)
36 , numBits(numBits)
38 {
39 refCount.storeRelaxed(1);
40 alloc = qPrimeForNumBits(numBits);
42 memset(entries, 0, alloc*sizeof(IdentifierHashEntry));
43 identifierTable->addIdentifierHash(this);
44 }
45
47 : size(other->size)
48 , numBits(other->numBits)
50 {
51 refCount.storeRelaxed(1);
52 alloc = other->alloc;
54 memcpy(entries, other->entries, alloc*sizeof(IdentifierHashEntry));
55 identifierTable->addIdentifierHash(this);
56 }
57
59 free(entries);
60 if (identifierTable)
61 identifierTable->removeIdentifierHash(this);
62 }
63
64 void markObjects(MarkStack *markStack) const
65 {
67 IdentifierHashEntry *end = e + alloc;
68 while (e < end) {
69 if (Heap::Base *o = e->identifier.asStringOrSymbol())
70 o->mark(markStack);
71 ++e;
72 }
73 }
74
76 int alloc;
77 int size;
81};
82
83} // namespace QV4
84
85QT_END_NAMESPACE
86
87#endif // QV4IDENTIFIERHASHDATA_P_H
Definition qjsvalue.h:23
void markObjects(MarkStack *markStack) const
IdentifierHashData(IdentifierHashData *other)
IdentifierHashData(IdentifierTable *table, int numBits)
IdentifierHashEntry * entries