Use LIKELY() / UNLIKELY() hints when suitable in the JavaScript bindings
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestNondeterministic.cpp
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 "JSTestNondeterministic.h"
23
24 #include "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include "URL.h"
28 #include <runtime/Error.h>
29 #include <runtime/FunctionPrototype.h>
30 #include <runtime/JSString.h>
31 #include <wtf/GetPtr.h>
32
33 #if ENABLE(WEB_REPLAY)
34 #include "MemoizedDOMResult.h"
35 #include <replay/InputCursor.h>
36 #include <wtf/NeverDestroyed.h>
37 #endif
38
39 using namespace JSC;
40
41 namespace WebCore {
42
43 // Functions
44
45 JSC::EncodedJSValue JSC_HOST_CALL jsTestNondeterministicPrototypeFunctionNondeterministicZeroArgFunction(JSC::ExecState*);
46
47 // Attributes
48
49 JSC::EncodedJSValue jsTestNondeterministicNondeterministicReadonlyAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50 JSC::EncodedJSValue jsTestNondeterministicNondeterministicWriteableAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51 bool setJSTestNondeterministicNondeterministicWriteableAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
52 JSC::EncodedJSValue jsTestNondeterministicNondeterministicExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53 bool setJSTestNondeterministicNondeterministicExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
54 JSC::EncodedJSValue jsTestNondeterministicNondeterministicGetterExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55 bool setJSTestNondeterministicNondeterministicGetterExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
56 JSC::EncodedJSValue jsTestNondeterministicNondeterministicSetterExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57 bool setJSTestNondeterministicNondeterministicSetterExceptionAttr(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
58 JSC::EncodedJSValue jsTestNondeterministicConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59 bool setJSTestNondeterministicConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60
61 class JSTestNondeterministicPrototype : public JSC::JSNonFinalObject {
62 public:
63     typedef JSC::JSNonFinalObject Base;
64     static JSTestNondeterministicPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
65     {
66         JSTestNondeterministicPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNondeterministicPrototype>(vm.heap)) JSTestNondeterministicPrototype(vm, globalObject, structure);
67         ptr->finishCreation(vm);
68         return ptr;
69     }
70
71     DECLARE_INFO;
72     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
73     {
74         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
75     }
76
77 private:
78     JSTestNondeterministicPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
79         : JSC::JSNonFinalObject(vm, structure)
80     {
81     }
82
83     void finishCreation(JSC::VM&);
84 };
85
86 typedef JSDOMConstructorNotConstructable<JSTestNondeterministic> JSTestNondeterministicConstructor;
87
88 template<> JSValue JSTestNondeterministicConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
89 {
90     UNUSED_PARAM(vm);
91     return globalObject.functionPrototype();
92 }
93
94 template<> void JSTestNondeterministicConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
95 {
96     putDirect(vm, vm.propertyNames->prototype, JSTestNondeterministic::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
97     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestNondeterministic"))), ReadOnly | DontEnum);
98     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
99 }
100
101 template<> const ClassInfo JSTestNondeterministicConstructor::s_info = { "TestNondeterministic", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNondeterministicConstructor) };
102
103 /* Hash table for prototype */
104
105 static const HashTableValue JSTestNondeterministicPrototypeTableValues[] =
106 {
107     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNondeterministicConstructor) } },
108     { "nondeterministicReadonlyAttr", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicNondeterministicReadonlyAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
109     { "nondeterministicWriteableAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicNondeterministicWriteableAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNondeterministicNondeterministicWriteableAttr) } },
110     { "nondeterministicExceptionAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicNondeterministicExceptionAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNondeterministicNondeterministicExceptionAttr) } },
111     { "nondeterministicGetterExceptionAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicNondeterministicGetterExceptionAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNondeterministicNondeterministicGetterExceptionAttr) } },
112     { "nondeterministicSetterExceptionAttr", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNondeterministicNondeterministicSetterExceptionAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNondeterministicNondeterministicSetterExceptionAttr) } },
113     { "nondeterministicZeroArgFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestNondeterministicPrototypeFunctionNondeterministicZeroArgFunction), (intptr_t) (0) } },
114 };
115
116 const ClassInfo JSTestNondeterministicPrototype::s_info = { "TestNondeterministicPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNondeterministicPrototype) };
117
118 void JSTestNondeterministicPrototype::finishCreation(VM& vm)
119 {
120     Base::finishCreation(vm);
121     reifyStaticProperties(vm, JSTestNondeterministicPrototypeTableValues, *this);
122 }
123
124 const ClassInfo JSTestNondeterministic::s_info = { "TestNondeterministic", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestNondeterministic) };
125
126 JSTestNondeterministic::JSTestNondeterministic(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestNondeterministic>&& impl)
127     : JSDOMWrapper<TestNondeterministic>(structure, globalObject, WTFMove(impl))
128 {
129 }
130
131 JSObject* JSTestNondeterministic::createPrototype(VM& vm, JSGlobalObject* globalObject)
132 {
133     return JSTestNondeterministicPrototype::create(vm, globalObject, JSTestNondeterministicPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
134 }
135
136 JSObject* JSTestNondeterministic::prototype(VM& vm, JSGlobalObject* globalObject)
137 {
138     return getDOMPrototype<JSTestNondeterministic>(vm, globalObject);
139 }
140
141 void JSTestNondeterministic::destroy(JSC::JSCell* cell)
142 {
143     JSTestNondeterministic* thisObject = static_cast<JSTestNondeterministic*>(cell);
144     thisObject->JSTestNondeterministic::~JSTestNondeterministic();
145 }
146
147 EncodedJSValue jsTestNondeterministicNondeterministicReadonlyAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
148 {
149     UNUSED_PARAM(state);
150     UNUSED_PARAM(thisValue);
151     JSValue decodedThisValue = JSValue::decode(thisValue);
152     auto* castedThis = jsDynamicCast<JSTestNondeterministic*>(decodedThisValue);
153     if (UNLIKELY(!castedThis)) {
154         return throwGetterTypeError(*state, "TestNondeterministic", "nondeterministicReadonlyAttr");
155     }
156 #if ENABLE(WEB_REPLAY)
157     JSGlobalObject* globalObject = state->lexicalGlobalObject();
158     InputCursor& cursor = globalObject->inputCursor();
159     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicReadonlyAttr", AtomicString::ConstructFromLiteral);
160     if (cursor.isCapturing()) {
161         int memoizedResult = castedThis->wrapped().nondeterministicReadonlyAttr();
162         cursor.appendInput<MemoizedDOMResult<int>>(bindingName.get().string(), memoizedResult, 0);
163         JSValue result = jsNumber(memoizedResult);
164         return JSValue::encode(result);
165     }
166
167     if (cursor.isReplaying()) {
168         int memoizedResult;
169         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
170         if (input && input->convertTo<int>(memoizedResult)) {
171             JSValue result = jsNumber(memoizedResult);
172             return JSValue::encode(result);
173         }
174     }
175 #endif
176     auto& impl = castedThis->wrapped();
177     JSValue result = jsNumber(impl.nondeterministicReadonlyAttr());
178     return JSValue::encode(result);
179 }
180
181
182 EncodedJSValue jsTestNondeterministicNondeterministicWriteableAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
183 {
184     UNUSED_PARAM(state);
185     UNUSED_PARAM(thisValue);
186     JSValue decodedThisValue = JSValue::decode(thisValue);
187     auto* castedThis = jsDynamicCast<JSTestNondeterministic*>(decodedThisValue);
188     if (UNLIKELY(!castedThis)) {
189         return throwGetterTypeError(*state, "TestNondeterministic", "nondeterministicWriteableAttr");
190     }
191 #if ENABLE(WEB_REPLAY)
192     JSGlobalObject* globalObject = state->lexicalGlobalObject();
193     InputCursor& cursor = globalObject->inputCursor();
194     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicWriteableAttr", AtomicString::ConstructFromLiteral);
195     if (cursor.isCapturing()) {
196         String memoizedResult = castedThis->wrapped().nondeterministicWriteableAttr();
197         cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
198         JSValue result = jsStringWithCache(state, memoizedResult);
199         return JSValue::encode(result);
200     }
201
202     if (cursor.isReplaying()) {
203         String memoizedResult;
204         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
205         if (input && input->convertTo<String>(memoizedResult)) {
206             JSValue result = jsStringWithCache(state, memoizedResult);
207             return JSValue::encode(result);
208         }
209     }
210 #endif
211     auto& impl = castedThis->wrapped();
212     JSValue result = jsStringWithCache(state, impl.nondeterministicWriteableAttr());
213     return JSValue::encode(result);
214 }
215
216
217 EncodedJSValue jsTestNondeterministicNondeterministicExceptionAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
218 {
219     UNUSED_PARAM(state);
220     UNUSED_PARAM(thisValue);
221     JSValue decodedThisValue = JSValue::decode(thisValue);
222     auto* castedThis = jsDynamicCast<JSTestNondeterministic*>(decodedThisValue);
223     if (UNLIKELY(!castedThis)) {
224         return throwGetterTypeError(*state, "TestNondeterministic", "nondeterministicExceptionAttr");
225     }
226 #if ENABLE(WEB_REPLAY)
227     JSGlobalObject* globalObject = state->lexicalGlobalObject();
228     InputCursor& cursor = globalObject->inputCursor();
229     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicExceptionAttr", AtomicString::ConstructFromLiteral);
230     if (cursor.isCapturing()) {
231         String memoizedResult = castedThis->wrapped().nondeterministicExceptionAttr();
232         cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
233         JSValue result = jsStringWithCache(state, memoizedResult);
234         return JSValue::encode(result);
235     }
236
237     if (cursor.isReplaying()) {
238         String memoizedResult;
239         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
240         if (input && input->convertTo<String>(memoizedResult)) {
241             JSValue result = jsStringWithCache(state, memoizedResult);
242             return JSValue::encode(result);
243         }
244     }
245 #endif
246     auto& impl = castedThis->wrapped();
247     JSValue result = jsStringWithCache(state, impl.nondeterministicExceptionAttr());
248     return JSValue::encode(result);
249 }
250
251
252 EncodedJSValue jsTestNondeterministicNondeterministicGetterExceptionAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
253 {
254     UNUSED_PARAM(state);
255     UNUSED_PARAM(thisValue);
256     JSValue decodedThisValue = JSValue::decode(thisValue);
257     auto* castedThis = jsDynamicCast<JSTestNondeterministic*>(decodedThisValue);
258     if (UNLIKELY(!castedThis)) {
259         return throwGetterTypeError(*state, "TestNondeterministic", "nondeterministicGetterExceptionAttr");
260     }
261     ExceptionCode ec = 0;
262 #if ENABLE(WEB_REPLAY)
263     JSGlobalObject* globalObject = state->lexicalGlobalObject();
264     InputCursor& cursor = globalObject->inputCursor();
265     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicGetterExceptionAttr", AtomicString::ConstructFromLiteral);
266     if (cursor.isCapturing()) {
267         String memoizedResult = castedThis->wrapped().nondeterministicGetterExceptionAttr(ec);
268         cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, ec);
269         JSValue result = jsStringWithCache(state, memoizedResult);
270         setDOMException(state, ec);
271         return JSValue::encode(result);
272     }
273
274     if (cursor.isReplaying()) {
275         String memoizedResult;
276         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
277         if (input && input->convertTo<String>(memoizedResult)) {
278             JSValue result = jsStringWithCache(state, memoizedResult);
279             setDOMException(state, input->exceptionCode());
280             return JSValue::encode(result);
281         }
282     }
283 #endif
284     auto& impl = castedThis->wrapped();
285     JSValue result = jsStringWithCache(state, impl.nondeterministicGetterExceptionAttr(ec));
286     setDOMException(state, ec);
287     return JSValue::encode(result);
288 }
289
290
291 EncodedJSValue jsTestNondeterministicNondeterministicSetterExceptionAttr(ExecState* state, EncodedJSValue thisValue, PropertyName)
292 {
293     UNUSED_PARAM(state);
294     UNUSED_PARAM(thisValue);
295     JSValue decodedThisValue = JSValue::decode(thisValue);
296     auto* castedThis = jsDynamicCast<JSTestNondeterministic*>(decodedThisValue);
297     if (UNLIKELY(!castedThis)) {
298         return throwGetterTypeError(*state, "TestNondeterministic", "nondeterministicSetterExceptionAttr");
299     }
300 #if ENABLE(WEB_REPLAY)
301     JSGlobalObject* globalObject = state->lexicalGlobalObject();
302     InputCursor& cursor = globalObject->inputCursor();
303     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicSetterExceptionAttr", AtomicString::ConstructFromLiteral);
304     if (cursor.isCapturing()) {
305         String memoizedResult = castedThis->wrapped().nondeterministicSetterExceptionAttr();
306         cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
307         JSValue result = jsStringWithCache(state, memoizedResult);
308         return JSValue::encode(result);
309     }
310
311     if (cursor.isReplaying()) {
312         String memoizedResult;
313         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
314         if (input && input->convertTo<String>(memoizedResult)) {
315             JSValue result = jsStringWithCache(state, memoizedResult);
316             return JSValue::encode(result);
317         }
318     }
319 #endif
320     auto& impl = castedThis->wrapped();
321     JSValue result = jsStringWithCache(state, impl.nondeterministicSetterExceptionAttr());
322     return JSValue::encode(result);
323 }
324
325
326 EncodedJSValue jsTestNondeterministicConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
327 {
328     JSTestNondeterministicPrototype* domObject = jsDynamicCast<JSTestNondeterministicPrototype*>(JSValue::decode(thisValue));
329     if (UNLIKELY(!domObject))
330         return throwVMTypeError(state);
331     return JSValue::encode(JSTestNondeterministic::getConstructor(state->vm(), domObject->globalObject()));
332 }
333
334 bool setJSTestNondeterministicConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
335 {
336     JSValue value = JSValue::decode(encodedValue);
337     JSTestNondeterministicPrototype* domObject = jsDynamicCast<JSTestNondeterministicPrototype*>(JSValue::decode(thisValue));
338     if (UNLIKELY(!domObject)) {
339         throwVMTypeError(state);
340         return false;
341     }
342     // Shadowing a built-in constructor
343     return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
344 }
345
346 bool setJSTestNondeterministicNondeterministicWriteableAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
347 {
348     JSValue value = JSValue::decode(encodedValue);
349     UNUSED_PARAM(thisValue);
350     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
351     if (UNLIKELY(!castedThis)) {
352         return throwSetterTypeError(*state, "TestNondeterministic", "nondeterministicWriteableAttr");
353     }
354     auto& impl = castedThis->wrapped();
355     String nativeValue = value.toString(state)->value(state);
356     if (UNLIKELY(state->hadException()))
357         return false;
358     impl.setNondeterministicWriteableAttr(nativeValue);
359     return true;
360 }
361
362
363 bool setJSTestNondeterministicNondeterministicExceptionAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
364 {
365     JSValue value = JSValue::decode(encodedValue);
366     UNUSED_PARAM(thisValue);
367     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
368     if (UNLIKELY(!castedThis)) {
369         return throwSetterTypeError(*state, "TestNondeterministic", "nondeterministicExceptionAttr");
370     }
371     auto& impl = castedThis->wrapped();
372     String nativeValue = value.toString(state)->value(state);
373     if (UNLIKELY(state->hadException()))
374         return false;
375     impl.setNondeterministicExceptionAttr(nativeValue);
376     return true;
377 }
378
379
380 bool setJSTestNondeterministicNondeterministicGetterExceptionAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
381 {
382     JSValue value = JSValue::decode(encodedValue);
383     UNUSED_PARAM(thisValue);
384     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
385     if (UNLIKELY(!castedThis)) {
386         return throwSetterTypeError(*state, "TestNondeterministic", "nondeterministicGetterExceptionAttr");
387     }
388     auto& impl = castedThis->wrapped();
389     String nativeValue = value.toString(state)->value(state);
390     if (UNLIKELY(state->hadException()))
391         return false;
392     impl.setNondeterministicGetterExceptionAttr(nativeValue);
393     return true;
394 }
395
396
397 bool setJSTestNondeterministicNondeterministicSetterExceptionAttr(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
398 {
399     JSValue value = JSValue::decode(encodedValue);
400     UNUSED_PARAM(thisValue);
401     JSTestNondeterministic* castedThis = jsDynamicCast<JSTestNondeterministic*>(JSValue::decode(thisValue));
402     if (UNLIKELY(!castedThis)) {
403         return throwSetterTypeError(*state, "TestNondeterministic", "nondeterministicSetterExceptionAttr");
404     }
405     auto& impl = castedThis->wrapped();
406     ExceptionCode ec = 0;
407     String nativeValue = value.toString(state)->value(state);
408     if (UNLIKELY(state->hadException()))
409         return false;
410     impl.setNondeterministicSetterExceptionAttr(nativeValue, ec);
411     setDOMException(state, ec);
412     return true;
413 }
414
415
416 JSValue JSTestNondeterministic::getConstructor(VM& vm, const JSGlobalObject* globalObject)
417 {
418     return getDOMConstructor<JSTestNondeterministicConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
419 }
420
421 EncodedJSValue JSC_HOST_CALL jsTestNondeterministicPrototypeFunctionNondeterministicZeroArgFunction(ExecState* state)
422 {
423     JSValue thisValue = state->thisValue();
424     auto castedThis = jsDynamicCast<JSTestNondeterministic*>(thisValue);
425     if (UNLIKELY(!castedThis))
426         return throwThisTypeError(*state, "TestNondeterministic", "nondeterministicZeroArgFunction");
427     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNondeterministic::info());
428     auto& impl = castedThis->wrapped();
429     JSValue result;
430 #if ENABLE(WEB_REPLAY)
431     InputCursor& cursor = state->lexicalGlobalObject()->inputCursor();
432     static NeverDestroyed<const AtomicString> bindingName("TestNondeterministic.nondeterministicZeroArgFunction", AtomicString::ConstructFromLiteral);
433     if (cursor.isCapturing()) {
434         bool memoizedResult = impl.nondeterministicZeroArgFunction();
435         cursor.appendInput<MemoizedDOMResult<bool>>(bindingName.get().string(), memoizedResult, 0);
436         result = jsBoolean(memoizedResult);
437     } else if (cursor.isReplaying()) {
438         MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
439         bool memoizedResult;
440         if (input && input->convertTo<bool>(memoizedResult)) {
441             result = jsBoolean(memoizedResult);
442         } else
443             result = jsBoolean(impl.nondeterministicZeroArgFunction());
444     } else
445         result = jsBoolean(impl.nondeterministicZeroArgFunction());
446 #else
447     result = jsBoolean(impl.nondeterministicZeroArgFunction());
448 #endif
449     return JSValue::encode(result);
450 }
451
452 bool JSTestNondeterministicOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
453 {
454     UNUSED_PARAM(handle);
455     UNUSED_PARAM(visitor);
456     return false;
457 }
458
459 void JSTestNondeterministicOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
460 {
461     auto* jsTestNondeterministic = jsCast<JSTestNondeterministic*>(handle.slot()->asCell());
462     auto& world = *static_cast<DOMWrapperWorld*>(context);
463     uncacheWrapper(world, &jsTestNondeterministic->wrapped(), jsTestNondeterministic);
464 }
465
466 #if ENABLE(BINDING_INTEGRITY)
467 #if PLATFORM(WIN)
468 #pragma warning(disable: 4483)
469 extern "C" { extern void (*const __identifier("??_7TestNondeterministic@WebCore@@6B@")[])(); }
470 #else
471 extern "C" { extern void* _ZTVN7WebCore20TestNondeterministicE[]; }
472 #endif
473 #endif
474
475 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestNondeterministic* impl)
476 {
477     if (!impl)
478         return jsNull();
479     return createNewWrapper<JSTestNondeterministic>(globalObject, impl);
480 }
481
482 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestNondeterministic* impl)
483 {
484     if (!impl)
485         return jsNull();
486     if (JSValue result = getExistingWrapper<JSTestNondeterministic>(globalObject, impl))
487         return result;
488
489 #if ENABLE(BINDING_INTEGRITY)
490     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
491 #if PLATFORM(WIN)
492     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestNondeterministic@WebCore@@6B@"));
493 #else
494     void* expectedVTablePointer = &_ZTVN7WebCore20TestNondeterministicE[2];
495 #if COMPILER(CLANG)
496     // If this fails TestNondeterministic does not have a vtable, so you need to add the
497     // ImplementationLacksVTable attribute to the interface definition
498     COMPILE_ASSERT(__is_polymorphic(TestNondeterministic), TestNondeterministic_is_not_polymorphic);
499 #endif
500 #endif
501     // If you hit this assertion you either have a use after free bug, or
502     // TestNondeterministic has subclasses. If TestNondeterministic has subclasses that get passed
503     // to toJS() we currently require TestNondeterministic you to opt out of binding hardening
504     // by adding the SkipVTableValidation attribute to the interface IDL definition
505     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
506 #endif
507     return createNewWrapper<JSTestNondeterministic>(globalObject, impl);
508 }
509
510 TestNondeterministic* JSTestNondeterministic::toWrapped(JSC::JSValue value)
511 {
512     if (auto* wrapper = jsDynamicCast<JSTestNondeterministic*>(value))
513         return &wrapper->wrapped();
514     return nullptr;
515 }
516
517 }