Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStack.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef MarkStack_h
27 #define MarkStack_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStack.h:27:9`!
28
29 #include "JSValue.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h`/
30 #include <wtf/Noncopyable.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Noncopyable.h`/
31
32 namespace JSCcxx . . $ QTJSC/ {
33
34 class JSGlobalDatacxx . . $ QTJSC/JSGlobalData#;
35 class Registercxx . . $ QTJSC/Register#;
36
37 enum MarkSetPropertiescxx . . $ QTJSC/MarkSetProperties# { MayContainNullValuescxx . . $ QTJSC/MayContainNullValues., NoNullValuescxx . . $ QTJSC/NoNullValues. };
38
39 class MarkStackcxx . . $ QTJSC/MarkStack# : Noncopyablecxx . . $ Noncopyable# {
40 public:
41 MarkStackcxx . . $ QTJSC/MarkStack#MarkStack(5d22bdacc48458e8).(void* jsArrayVPtr)
42 : m_jsArrayVPtrcxx . . $ QTJSC/MarkStack#m_jsArrayVPtr.(jsArrayVPtr)
43 #ifndef NDEBUGcxx . . $ `<built-in>:472:9`!
44 , m_isCheckingForDefaultMarkViolation(false)
45 #endif
46 {
47 }
48
49 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void appendcxx . . $ QTJSC/MarkStack#append(5c2ac18db087b3e6).(JSValuecxx . . $ QTJSC/JSValue#);
50 void appendcxx . . $ QTJSC/MarkStack#append(c6d88d3bdacccd64).(JSCellcxx . . $ QTJSC/JSCell#*);
51
52 ALWAYS_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void appendValuescxx . . $ QTJSC/MarkStack#appendValues(43883644a1fa3f52).(Registercxx . . $ QTJSC/Register#* values, size_t count, MarkSetPropertiescxx . . $ QTJSC/MarkSetProperties# properties = NoNullValuescxx . . $ QTJSC/NoNullValues.)
53 {
54 appendValuescxx . . $ QTJSC/MarkStack#appendValues(5ce9403f1fe638b8).(reinterpret_cast<JSValuecxx . . $ QTJSC/JSValue#*>(values), count, properties);
55 }
56
57 ALWAYS_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void appendValuescxx . . $ QTJSC/MarkStack#appendValues(5ce9403f1fe638b8).(JSValuecxx . . $ QTJSC/JSValue#* values, size_t count, MarkSetPropertiescxx . . $ QTJSC/MarkSetProperties# properties = NoNullValuescxx . . $ QTJSC/NoNullValues.)
58 {
59 if (count)
60 m_markSets.append(MarkSet(values, values + count, properties));
61 }
62
63 inline void draincxx . . $ QTJSC/MarkStack#drain(49f6e7a06ebc5aa8).();
64 void compactcxx . . $ QTJSC/MarkStack#compact(49f6e7a06ebc5aa8).();
65
66 ~cxx . . $ QTJSC/MarkStack#`~MarkStack`(49f6e7a06ebc5aa8).MarkStackcxx . . $ QTJSC/MarkStack#()
67 {
68 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_markSets.isEmpty());
69 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_values.isEmpty());
70 }
71
72 private:
73 void markChildrencxx . . $ QTJSC/MarkStack#markChildren(c6d88d3bdacccd64).(JSCellcxx . . $ QTJSC/JSCell#*);
74
75 struct MarkSetcxx . . $ QTJSC/MarkStack#MarkSet# {
76 MarkSetcxx . . $ QTJSC/MarkStack#MarkSet#MarkSet(3594f603934a3c29).(JSValuecxx . . $ QTJSC/JSValue#* values, JSValuecxx . . $ QTJSC/JSValue#* end, MarkSetPropertiescxx . . $ QTJSC/MarkSetProperties# properties)
77 : m_valuescxx . . $ QTJSC/MarkStack#MarkSet#m_values.(values)
78 , m_endcxx . . $ QTJSC/MarkStack#MarkSet#m_end.(end)
79 , m_propertiescxx . . $ QTJSC/MarkStack#MarkSet#m_properties.(properties)
80 {
81 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(values);
82 }
83 JSValuecxx . . $ QTJSC/JSValue#* m_valuescxx . . $ QTJSC/MarkStack#MarkSet#m_values.;
84 JSValuecxx . . $ QTJSC/JSValue#* m_endcxx . . $ QTJSC/MarkStack#MarkSet#m_end.;
85 MarkSetPropertiescxx . . $ QTJSC/MarkSetProperties# m_propertiescxx . . $ QTJSC/MarkStack#MarkSet#m_properties.;
86 };
87
88 static void* allocateStackcxx . . $ QTJSC/MarkStack#allocateStack(bfcfa4d6b7f7ef64).(size_t size);
89 static void releaseStackcxx . . $ QTJSC/MarkStack#releaseStack(5500c4293b1bbef0).(void* addr, size_t size);
90
91 static void initializePagesizecxx . . $ QTJSC/MarkStack#initializePagesize(49f6e7a06ebc5aa8).();
92 static size_t pageSizecxx . . $ QTJSC/MarkStack#pageSize(f708dce9a8856c70).()
93 {
94 if (!s_pageSizecxx . . $ QTJSC/MarkStack#s_pageSize.)
95 initializePagesizecxx . . $ QTJSC/MarkStack#initializePagesize(49f6e7a06ebc5aa8).();
96 return s_pageSizecxx . . $ QTJSC/MarkStack#s_pageSize.;
97 }
98
99 template <typename T> struct MarkStackArraycxx . . $ QTJSC/MarkStack#MarkStackArray# {
100 MarkStackArraycxx . . $ QTJSC/MarkStack#MarkStackArray#`MarkStackArray<T>`(49f6e7a06ebc5aa8).()
101 : m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top.(0)
102 , m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.(MarkStackcxx . . $ QTJSC/MarkStack#::pageSizecxx . . $ QTJSC/MarkStack#pageSize(f708dce9a8856c70).())
103 , m_capacitycxx . . $ QTJSC/MarkStack#MarkStackArray#m_capacity.(m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. / sizeof(T))
104 {
105 m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data. = reinterpret_cast<T*>(allocateStackcxx . . $ QTJSC/MarkStack#allocateStack(bfcfa4d6b7f7ef64).(m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.));
106 }
107
108 ~cxx . . $ QTJSC/MarkStack#MarkStackArray#`~MarkStackArray<T>`(49f6e7a06ebc5aa8).MarkStackArray()
109 {
110 releaseStackcxx . . $ QTJSC/MarkStack#releaseStack(5500c4293b1bbef0).(m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data., m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.);
111 }
112
113 void expandcxx . . $ QTJSC/MarkStack#MarkStackArray#expand(49f6e7a06ebc5aa8).()
114 {
115 size_t oldAllocation = m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.;
116 m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. *= 2;
117 m_capacitycxx . . $ QTJSC/MarkStack#MarkStackArray#m_capacity. = m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. / sizeof(T);
118 void* newData = allocateStackcxx . . $ QTJSC/MarkStack#allocateStack(bfcfa4d6b7f7ef64).(m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.);
119 memcpy(newData, m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data., oldAllocation);
120 releaseStackcxx . . $ QTJSC/MarkStack#releaseStack(5500c4293b1bbef0).(m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data., oldAllocation);
121 m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data. = reinterpret_cast<T*>(newData);
122 }
123
124 inline void appendcxx . . $ QTJSC/MarkStack#MarkStackArray#append(77d9f17553126ecb).(const T& v)
125 {
126 if (m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top. == m_capacitycxx . . $ QTJSC/MarkStack#MarkStackArray#m_capacity.)
127 expandcxx . . $ QTJSC/MarkStack#MarkStackArray#expand(49f6e7a06ebc5aa8).();
128 m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data.[m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top.++] = v;
129 }
130
131 inline T removeLastcxx . . $ QTJSC/MarkStack#MarkStackArray#removeLast(5f357b03ed472e5e).()
132 {
133 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_top);
134 return m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data.[--m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top.];
135 }
136
137 inline T& lastcxx . . $ QTJSC/MarkStack#MarkStackArray#last(19b2b6f17af048b).()
138 {
139 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(m_top);
140 return m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data.[m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top. - 1];
141 }
142
143 inline bool isEmptycxx . . $ QTJSC/MarkStack#MarkStackArray#isEmpty(c9857a73d68e59ba).()
144 {
145 return m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top. == 0;
146 }
147
148 inline size_t sizecxx . . $ QTJSC/MarkStack#MarkStackArray#size(f708dce9a8856c70).() { return m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top.; }
149
150 inline void shrinkAllocationcxx . . $ QTJSC/MarkStack#MarkStackArray#shrinkAllocation(2c44cd906ae4e829).(size_t size)
151 {
152 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(size <= m_allocated);
153 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(0 == (size % MarkStack::pageSize()));
154 if (size == m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.)
155 return;
156 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINDOWS) || OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SYMBIAN) || PLATFORMcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:33:9`!(BREWMP)
157 // We cannot release a part of a region with VirtualFree. To get around this,
158 // we'll release the entire region and reallocate the size that we want.
159 releaseStack(m_data, m_allocated);
160 m_data = reinterpret_cast<T*>(allocateStack(size));
161 #else
162 releaseStackcxx . . $ QTJSC/MarkStack#releaseStack(5500c4293b1bbef0).(reinterpret_cast<char*>(m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data.) + size, m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. - size);
163 #endif
164 m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. = size;
165 m_capacitycxx . . $ QTJSC/MarkStack#MarkStackArray#m_capacity. = m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated. / sizeof(T);
166 }
167
168 private:
169 size_t m_topcxx . . $ QTJSC/MarkStack#MarkStackArray#m_top.;
170 size_t m_allocatedcxx . . $ QTJSC/MarkStack#MarkStackArray#m_allocated.;
171 size_t m_capacitycxx . . $ QTJSC/MarkStack#MarkStackArray#m_capacity.;
172 T* m_datacxx . . $ QTJSC/MarkStack#MarkStackArray#m_data.;
173 };
174
175 void* m_jsArrayVPtrcxx . . $ QTJSC/MarkStack#m_jsArrayVPtr.;
176 MarkStackArraycxx . . $ QTJSC/MarkStack#MarkStackArray#<MarkSetcxx . . $ QTJSC/MarkStack#MarkSet#> m_markSetscxx . . $ QTJSC/MarkStack#m_markSets.;
177 MarkStackArraycxx . . $ QTJSC/MarkStack#MarkStackArray#<JSCellcxx . . $ QTJSC/JSCell#*> m_valuescxx . . $ QTJSC/MarkStack#m_values.;
178 static size_t s_pageSizecxx . . $ QTJSC/MarkStack#s_pageSize.;
179
180 #ifndef NDEBUGcxx . . $ `<built-in>:472:9`!
181 public:
182 bool m_isCheckingForDefaultMarkViolation;
183 #endif
184 };
185 }
186
187 #endif