1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | #include "JSMallocStatistics.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConvertNumbers.h" |
27 | #include "JSDOMExceptionHandling.h" |
28 | #include "JSDOMWrapperCache.h" |
29 | #include "ScriptExecutionContext.h" |
30 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
31 | #include <JavaScriptCore/JSCInlines.h> |
32 | #include <wtf/GetPtr.h> |
33 | #include <wtf/PointerPreparations.h> |
34 | #include <wtf/URL.h> |
35 | |
36 | |
37 | namespace WebCore { |
38 | using namespace JSC; |
39 | |
40 | // Attributes |
41 | |
42 | JSC::EncodedJSValue jsMallocStatisticsReservedVMBytes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
43 | JSC::EncodedJSValue jsMallocStatisticsCommittedVMBytes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
44 | JSC::EncodedJSValue jsMallocStatisticsFreeListBytes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
45 | |
46 | class JSMallocStatisticsPrototype : public JSC::JSNonFinalObject { |
47 | public: |
48 | using Base = JSC::JSNonFinalObject; |
49 | static JSMallocStatisticsPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
50 | { |
51 | JSMallocStatisticsPrototype* ptr = new (NotNull, JSC::allocateCell<JSMallocStatisticsPrototype>(vm.heap)) JSMallocStatisticsPrototype(vm, globalObject, structure); |
52 | ptr->finishCreation(vm); |
53 | return ptr; |
54 | } |
55 | |
56 | DECLARE_INFO; |
57 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
58 | { |
59 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
60 | } |
61 | |
62 | private: |
63 | JSMallocStatisticsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
64 | : JSC::JSNonFinalObject(vm, structure) |
65 | { |
66 | } |
67 | |
68 | void finishCreation(JSC::VM&); |
69 | }; |
70 | |
71 | /* Hash table for prototype */ |
72 | |
73 | static const HashTableValue JSMallocStatisticsPrototypeTableValues[] = |
74 | { |
75 | { "reservedVMBytes" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMallocStatisticsReservedVMBytes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
76 | { "committedVMBytes" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMallocStatisticsCommittedVMBytes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
77 | { "freeListBytes" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMallocStatisticsFreeListBytes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
78 | }; |
79 | |
80 | const ClassInfo JSMallocStatisticsPrototype::s_info = { "MallocStatisticsPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMallocStatisticsPrototype) }; |
81 | |
82 | void JSMallocStatisticsPrototype::finishCreation(VM& vm) |
83 | { |
84 | Base::finishCreation(vm); |
85 | reifyStaticProperties(vm, JSMallocStatistics::info(), JSMallocStatisticsPrototypeTableValues, *this); |
86 | } |
87 | |
88 | const ClassInfo JSMallocStatistics::s_info = { "MallocStatistics" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMallocStatistics) }; |
89 | |
90 | JSMallocStatistics::JSMallocStatistics(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MallocStatistics>&& impl) |
91 | : JSDOMWrapper<MallocStatistics>(structure, globalObject, WTFMove(impl)) |
92 | { |
93 | } |
94 | |
95 | void JSMallocStatistics::finishCreation(VM& vm) |
96 | { |
97 | Base::finishCreation(vm); |
98 | ASSERT(inherits(vm, info())); |
99 | |
100 | } |
101 | |
102 | JSObject* JSMallocStatistics::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
103 | { |
104 | return JSMallocStatisticsPrototype::create(vm, &globalObject, JSMallocStatisticsPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
105 | } |
106 | |
107 | JSObject* JSMallocStatistics::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
108 | { |
109 | return getDOMPrototype<JSMallocStatistics>(vm, globalObject); |
110 | } |
111 | |
112 | void JSMallocStatistics::destroy(JSC::JSCell* cell) |
113 | { |
114 | JSMallocStatistics* thisObject = static_cast<JSMallocStatistics*>(cell); |
115 | thisObject->JSMallocStatistics::~JSMallocStatistics(); |
116 | } |
117 | |
118 | template<> inline JSMallocStatistics* IDLAttribute<JSMallocStatistics>::cast(ExecState& state, EncodedJSValue thisValue) |
119 | { |
120 | return jsDynamicCast<JSMallocStatistics*>(state.vm(), JSValue::decode(thisValue)); |
121 | } |
122 | |
123 | static inline JSValue jsMallocStatisticsReservedVMBytesGetter(ExecState& state, JSMallocStatistics& thisObject, ThrowScope& throwScope) |
124 | { |
125 | UNUSED_PARAM(throwScope); |
126 | UNUSED_PARAM(state); |
127 | auto& impl = thisObject.wrapped(); |
128 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.reservedVMBytes()); |
129 | return result; |
130 | } |
131 | |
132 | EncodedJSValue jsMallocStatisticsReservedVMBytes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
133 | { |
134 | return IDLAttribute<JSMallocStatistics>::get<jsMallocStatisticsReservedVMBytesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "reservedVMBytes" ); |
135 | } |
136 | |
137 | static inline JSValue jsMallocStatisticsCommittedVMBytesGetter(ExecState& state, JSMallocStatistics& thisObject, ThrowScope& throwScope) |
138 | { |
139 | UNUSED_PARAM(throwScope); |
140 | UNUSED_PARAM(state); |
141 | auto& impl = thisObject.wrapped(); |
142 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.committedVMBytes()); |
143 | return result; |
144 | } |
145 | |
146 | EncodedJSValue jsMallocStatisticsCommittedVMBytes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
147 | { |
148 | return IDLAttribute<JSMallocStatistics>::get<jsMallocStatisticsCommittedVMBytesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "committedVMBytes" ); |
149 | } |
150 | |
151 | static inline JSValue jsMallocStatisticsFreeListBytesGetter(ExecState& state, JSMallocStatistics& thisObject, ThrowScope& throwScope) |
152 | { |
153 | UNUSED_PARAM(throwScope); |
154 | UNUSED_PARAM(state); |
155 | auto& impl = thisObject.wrapped(); |
156 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.freeListBytes()); |
157 | return result; |
158 | } |
159 | |
160 | EncodedJSValue jsMallocStatisticsFreeListBytes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
161 | { |
162 | return IDLAttribute<JSMallocStatistics>::get<jsMallocStatisticsFreeListBytesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "freeListBytes" ); |
163 | } |
164 | |
165 | void JSMallocStatistics::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
166 | { |
167 | auto* thisObject = jsCast<JSMallocStatistics*>(cell); |
168 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
169 | if (thisObject->scriptExecutionContext()) |
170 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
171 | Base::heapSnapshot(cell, builder); |
172 | } |
173 | |
174 | bool JSMallocStatisticsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
175 | { |
176 | UNUSED_PARAM(handle); |
177 | UNUSED_PARAM(visitor); |
178 | UNUSED_PARAM(reason); |
179 | return false; |
180 | } |
181 | |
182 | void JSMallocStatisticsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
183 | { |
184 | auto* jsMallocStatistics = static_cast<JSMallocStatistics*>(handle.slot()->asCell()); |
185 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
186 | uncacheWrapper(world, &jsMallocStatistics->wrapped(), jsMallocStatistics); |
187 | } |
188 | |
189 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MallocStatistics>&& impl) |
190 | { |
191 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
192 | // attribute. You should remove that attribute. If the class has subclasses |
193 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
194 | // attribute to MallocStatistics. |
195 | static_assert(!std::is_polymorphic<MallocStatistics>::value, "MallocStatistics is polymorphic but the IDL claims it is not" ); |
196 | return createWrapper<MallocStatistics>(globalObject, WTFMove(impl)); |
197 | } |
198 | |
199 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MallocStatistics& impl) |
200 | { |
201 | return wrap(state, globalObject, impl); |
202 | } |
203 | |
204 | MallocStatistics* JSMallocStatistics::toWrapped(JSC::VM& vm, JSC::JSValue value) |
205 | { |
206 | if (auto* wrapper = jsDynamicCast<JSMallocStatistics*>(vm, value)) |
207 | return &wrapper->wrapped(); |
208 | return nullptr; |
209 | } |
210 | |
211 | } |
212 | |