Remove excessive headers from JavaScriptCore
[WebKit-https.git] / Source / JavaScriptCore / runtime / JSGlobalObject.cpp
1 /*
2  * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca)
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "config.h"
31 #include "JSGlobalObject.h"
32
33 #include "ArrayConstructor.h"
34 #include "ArrayIteratorPrototype.h"
35 #include "ArrayPrototype.h"
36 #include "AtomicsObject.h"
37 #include "AsyncFunctionConstructor.h"
38 #include "AsyncFunctionPrototype.h"
39 #include "BooleanConstructor.h"
40 #include "BooleanPrototype.h"
41 #include "BuiltinNames.h"
42 #include "CatchScope.h"
43 #include "ClonedArguments.h"
44 #include "CodeBlock.h"
45 #include "CodeCache.h"
46 #include "ConsoleObject.h"
47 #include "DateConstructor.h"
48 #include "DatePrototype.h"
49 #include "Debugger.h"
50 #include "DebuggerScope.h"
51 #include "DirectArguments.h"
52 #include "DirectEvalExecutable.h"
53 #include "ECMAScriptSpecInternalFunctions.h"
54 #include "Error.h"
55 #include "ErrorConstructor.h"
56 #include "ErrorPrototype.h"
57 #include "FunctionConstructor.h"
58 #include "FunctionPrototype.h"
59 #include "GeneratorFunctionConstructor.h"
60 #include "GeneratorFunctionPrototype.h"
61 #include "GeneratorPrototype.h"
62 #include "GetterSetter.h"
63 #include "HeapIterationScope.h"
64 #include "IndirectEvalExecutable.h"
65 #include "InspectorInstrumentationObject.h"
66 #include "Interpreter.h"
67 #include "IteratorPrototype.h"
68 #include "JSAPIWrapperObject.h"
69 #include "JSArrayBuffer.h"
70 #include "JSArrayBufferConstructor.h"
71 #include "JSArrayBufferPrototype.h"
72 #include "JSAsyncFunction.h"
73 #include "JSBoundFunction.h"
74 #include "JSCInlines.h"
75 #include "JSCallbackConstructor.h"
76 #include "JSCallbackFunction.h"
77 #include "JSCallbackObject.h"
78 #include "JSCustomGetterSetterFunction.h"
79 #include "JSDataView.h"
80 #include "JSDataViewPrototype.h"
81 #include "JSDollarVM.h"
82 #include "JSDollarVMPrototype.h"
83 #include "JSFunction.h"
84 #include "JSGeneratorFunction.h"
85 #include "JSGenericTypedArrayViewConstructorInlines.h"
86 #include "JSGenericTypedArrayViewInlines.h"
87 #include "JSGenericTypedArrayViewPrototypeInlines.h"
88 #include "JSGlobalObjectFunctions.h"
89 #include "JSInternalPromise.h"
90 #include "JSInternalPromiseConstructor.h"
91 #include "JSInternalPromisePrototype.h"
92 #include "JSJob.h"
93 #include "JSLexicalEnvironment.h"
94 #include "JSLock.h"
95 #include "JSMap.h"
96 #include "JSMapIterator.h"
97 #include "JSModuleEnvironment.h"
98 #include "JSModuleLoader.h"
99 #include "JSModuleNamespaceObject.h"
100 #include "JSModuleRecord.h"
101 #include "JSNativeStdFunction.h"
102 #include "JSONObject.h"
103 #include "JSPromise.h"
104 #include "JSPromiseConstructor.h"
105 #include "JSPromisePrototype.h"
106 #include "JSSet.h"
107 #include "JSSetIterator.h"
108 #include "JSStringIterator.h"
109 #include "JSTemplateRegistryKey.h"
110 #include "JSTypedArrayConstructors.h"
111 #include "JSTypedArrayPrototypes.h"
112 #include "JSTypedArrayViewConstructor.h"
113 #include "JSTypedArrayViewPrototype.h"
114 #include "JSTypedArrays.h"
115 #include "JSWeakMap.h"
116 #include "JSWeakSet.h"
117 #include "JSWebAssembly.h"
118 #include "JSWithScope.h"
119 #include "LazyClassStructureInlines.h"
120 #include "LazyPropertyInlines.h"
121 #include "Lookup.h"
122 #include "MapConstructor.h"
123 #include "MapIteratorPrototype.h"
124 #include "MapPrototype.h"
125 #include "MarkedSpaceInlines.h"
126 #include "MathObject.h"
127 #include "Microtask.h"
128 #include "ModuleLoaderPrototype.h"
129 #include "NativeErrorConstructor.h"
130 #include "NativeErrorPrototype.h"
131 #include "NullGetterFunction.h"
132 #include "NullSetterFunction.h"
133 #include "NumberConstructor.h"
134 #include "NumberPrototype.h"
135 #include "ObjCCallbackFunction.h"
136 #include "ObjectConstructor.h"
137 #include "ObjectPropertyChangeAdaptiveWatchpoint.h"
138 #include "ObjectPropertyConditionSet.h"
139 #include "ObjectPrototype.h"
140 #include "ParserError.h"
141 #include "ProxyConstructor.h"
142 #include "ProxyObject.h"
143 #include "ProxyRevoke.h"
144 #include "ReflectObject.h"
145 #include "RegExpConstructor.h"
146 #include "RegExpMatchesArray.h"
147 #include "RegExpObject.h"
148 #include "RegExpPrototype.h"
149 #include "ScopedArguments.h"
150 #include "SetConstructor.h"
151 #include "SetIteratorPrototype.h"
152 #include "SetPrototype.h"
153 #include "StrictEvalActivation.h"
154 #include "StringConstructor.h"
155 #include "StringIteratorPrototype.h"
156 #include "StringPrototype.h"
157 #include "Symbol.h"
158 #include "SymbolConstructor.h"
159 #include "SymbolObject.h"
160 #include "SymbolPrototype.h"
161 #include "VariableWriteFireDetail.h"
162 #include "WeakGCMapInlines.h"
163 #include "WeakMapConstructor.h"
164 #include "WeakMapPrototype.h"
165 #include "WeakSetConstructor.h"
166 #include "WeakSetPrototype.h"
167 #include "WebAssemblyToJSCallee.h"
168 #include <wtf/RandomNumber.h>
169
170 #if ENABLE(INTL)
171 #include "IntlObject.h"
172 #include <unicode/ucol.h>
173 #include <unicode/udat.h>
174 #include <unicode/unum.h>
175 #endif // ENABLE(INTL)
176
177 #if ENABLE(REMOTE_INSPECTOR)
178 #include "JSGlobalObjectDebuggable.h"
179 #include "JSGlobalObjectInspectorController.h"
180 #endif
181
182 #if ENABLE(WEB_REPLAY)
183 #include "EmptyInputCursor.h"
184 #include "JSReplayInputs.h"
185 #endif
186
187 namespace JSC {
188
189 static JSValue createProxyProperty(VM& vm, JSObject* object)
190 {
191     JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
192     return ProxyConstructor::create(vm, ProxyConstructor::createStructure(vm, global, global->functionPrototype()));
193 }
194
195 static JSValue createJSONProperty(VM& vm, JSObject* object)
196 {
197     JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
198     return JSONObject::create(vm, JSONObject::createStructure(vm, global, global->objectPrototype()));
199 }
200
201 static JSValue createMathProperty(VM& vm, JSObject* object)
202 {
203     JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
204     return MathObject::create(vm, global, MathObject::createStructure(vm, global, global->objectPrototype()));
205 }
206
207 static JSValue createConsoleProperty(VM& vm, JSObject* object)
208 {
209     JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
210     return ConsoleObject::create(vm, global, ConsoleObject::createStructure(vm, global, constructEmptyObject(global->globalExec())));
211 }
212
213 static JSValue createAtomicsProperty(VM& vm, JSObject* object)
214 {
215     JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
216     return AtomicsObject::create(vm, global, AtomicsObject::createStructure(vm, global, global->objectPrototype()));
217 }
218
219 static EncodedJSValue JSC_HOST_CALL makeBoundFunction(ExecState* exec)
220 {
221     VM& vm = exec->vm();
222     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
223
224     JSObject* target = asObject(exec->uncheckedArgument(0));
225     JSValue boundThis = exec->uncheckedArgument(1);
226     JSValue boundArgs = exec->uncheckedArgument(2);
227     JSValue length = exec->uncheckedArgument(3);
228     JSString* name = asString(exec->uncheckedArgument(4));
229
230     return JSValue::encode(JSBoundFunction::create(
231         vm, exec, globalObject, target, boundThis, boundArgs.isCell() ? jsCast<JSArray*>(boundArgs) : nullptr, length.asInt32(), name->value(exec)));
232 }
233
234 static EncodedJSValue JSC_HOST_CALL hasOwnLengthProperty(ExecState* exec)
235 {
236     VM& vm = exec->vm();
237     JSObject* target = asObject(exec->uncheckedArgument(0));
238     return JSValue::encode(jsBoolean(target->hasOwnProperty(exec, vm.propertyNames->length)));
239 }
240
241 } // namespace JSC
242
243 #include "JSGlobalObject.lut.h"
244
245 namespace JSC {
246
247 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, nullptr, CREATE_METHOD_TABLE(JSGlobalObject) };
248
249 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = {
250     &supportsRichSourceInfo,
251     &shouldInterruptScript,
252     &javaScriptRuntimeFlags,
253     nullptr, // queueTaskToEventLoop
254     &shouldInterruptScriptBeforeTimeout,
255     nullptr, // moduleLoaderImportModule
256     nullptr, // moduleLoaderResolve
257     nullptr, // moduleLoaderFetch
258     nullptr, // moduleLoaderInstantiate
259     nullptr, // moduleLoaderEvaluate
260     nullptr, // promiseRejectionTracker
261     nullptr, // defaultLanguage
262 };
263
264 /* Source for JSGlobalObject.lut.h
265 @begin globalObjectTable
266   isNaN                 JSBuiltin                                    DontEnum|Function 1
267   isFinite              JSBuiltin                                    DontEnum|Function 1
268   escape                globalFuncEscape                             DontEnum|Function 1
269   unescape              globalFuncUnescape                           DontEnum|Function 1
270   decodeURI             globalFuncDecodeURI                          DontEnum|Function 1
271   decodeURIComponent    globalFuncDecodeURIComponent                 DontEnum|Function 1
272   encodeURI             globalFuncEncodeURI                          DontEnum|Function 1
273   encodeURIComponent    globalFuncEncodeURIComponent                 DontEnum|Function 1
274   EvalError             JSGlobalObject::m_evalErrorConstructor       DontEnum|CellProperty
275   ReferenceError        JSGlobalObject::m_referenceErrorConstructor  DontEnum|CellProperty
276   SyntaxError           JSGlobalObject::m_syntaxErrorConstructor     DontEnum|CellProperty
277   URIError              JSGlobalObject::m_URIErrorConstructor        DontEnum|CellProperty
278   Proxy                 createProxyProperty                          DontEnum|PropertyCallback
279   JSON                  createJSONProperty                           DontEnum|PropertyCallback
280   Math                  createMathProperty                           DontEnum|PropertyCallback
281   Atomics               createAtomicsProperty                        DontEnum|PropertyCallback
282   console               createConsoleProperty                        DontEnum|PropertyCallback
283   Int8Array             JSGlobalObject::m_typedArrayInt8             DontEnum|ClassStructure
284   Int16Array            JSGlobalObject::m_typedArrayInt16            DontEnum|ClassStructure
285   Int32Array            JSGlobalObject::m_typedArrayInt32            DontEnum|ClassStructure
286   Uint8Array            JSGlobalObject::m_typedArrayUint8            DontEnum|ClassStructure
287   Uint8ClampedArray     JSGlobalObject::m_typedArrayUint8Clamped     DontEnum|ClassStructure
288   Uint16Array           JSGlobalObject::m_typedArrayUint16           DontEnum|ClassStructure
289   Uint32Array           JSGlobalObject::m_typedArrayUint32           DontEnum|ClassStructure
290   Float32Array          JSGlobalObject::m_typedArrayFloat32          DontEnum|ClassStructure
291   Float64Array          JSGlobalObject::m_typedArrayFloat64          DontEnum|ClassStructure
292   DataView              JSGlobalObject::m_typedArrayDataView         DontEnum|ClassStructure
293   Set                   JSGlobalObject::m_setStructure               DontEnum|ClassStructure
294   Date                  JSGlobalObject::m_dateStructure              DontEnum|ClassStructure
295   Boolean               JSGlobalObject::m_booleanObjectStructure     DontEnum|ClassStructure
296   Number                JSGlobalObject::m_numberObjectStructure      DontEnum|ClassStructure
297   WeakMap               JSGlobalObject::m_weakMapStructure           DontEnum|ClassStructure
298   WeakSet               JSGlobalObject::m_weakSetStructure           DontEnum|ClassStructure
299 @end
300 */
301
302 static EncodedJSValue JSC_HOST_CALL enqueueJob(ExecState* exec)
303 {
304     VM& vm = exec->vm();
305     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
306
307     JSValue job = exec->argument(0);
308     JSValue arguments = exec->argument(1);
309     ASSERT(arguments.inherits(vm, JSArray::info()));
310
311     globalObject->queueMicrotask(createJSJob(vm, job, jsCast<JSArray*>(arguments)));
312
313     return JSValue::encode(jsUndefined());
314 }
315
316 JSGlobalObject::JSGlobalObject(VM& vm, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
317     : Base(vm, structure, 0)
318     , m_vm(vm)
319 #if ENABLE(WEB_REPLAY)
320     , m_inputCursor(EmptyInputCursor::create())
321 #endif
322     , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
323     , m_havingABadTimeWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
324     , m_varInjectionWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
325     , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
326     , m_arrayIteratorProtocolWatchpoint(IsWatched)
327     , m_mapIteratorProtocolWatchpoint(IsWatched)
328     , m_setIteratorProtocolWatchpoint(IsWatched)
329     , m_mapSetWatchpoint(IsWatched)
330     , m_setAddWatchpoint(IsWatched)
331     , m_arraySpeciesWatchpoint(ClearWatchpoint)
332     , m_templateRegistry(vm)
333     , m_evalEnabled(true)
334     , m_runtimeFlags()
335     , m_consoleClient(nullptr)
336     , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable)
337 {
338 }
339
340 JSGlobalObject::~JSGlobalObject()
341 {
342 #if ENABLE(REMOTE_INSPECTOR)
343     m_inspectorController->globalObjectDestroyed();
344 #endif
345
346     if (m_debugger)
347         m_debugger->detach(this, Debugger::GlobalObjectIsDestructing);
348 }
349
350 void JSGlobalObject::destroy(JSCell* cell)
351 {
352     static_cast<JSGlobalObject*>(cell)->JSGlobalObject::~JSGlobalObject();
353 }
354
355 void JSGlobalObject::setGlobalThis(VM& vm, JSObject* globalThis)
356 {
357     m_globalThis.set(vm, this, globalThis);
358 }
359
360 static JSObject* getGetterById(ExecState* exec, JSObject* base, const Identifier& ident)
361 {
362     JSValue baseValue = JSValue(base);
363     PropertySlot slot(baseValue, PropertySlot::InternalMethodType::VMInquiry);
364     baseValue.getPropertySlot(exec, ident, slot);
365     return slot.getPureResult().toObject(exec);
366 }
367
368 void JSGlobalObject::init(VM& vm)
369 {
370     ASSERT(vm.currentThreadIsHoldingAPILock());
371     auto catchScope = DECLARE_CATCH_SCOPE(vm);
372
373     Base::setStructure(vm, Structure::toCacheableDictionaryTransition(vm, structure()));
374
375     m_debugger = 0;
376
377 #if ENABLE(REMOTE_INSPECTOR)
378     m_inspectorController = std::make_unique<Inspector::JSGlobalObjectInspectorController>(*this);
379     m_inspectorDebuggable = std::make_unique<JSGlobalObjectDebuggable>(*this);
380     m_inspectorDebuggable->init();
381     m_consoleClient = m_inspectorController->consoleClient();
382 #endif
383
384     m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
385     m_calleeStructure.set(vm, this, JSCallee::createStructure(vm, this, jsNull()));
386
387     m_globalLexicalEnvironment.set(vm, this, JSGlobalLexicalEnvironment::create(vm, JSGlobalLexicalEnvironment::createStructure(vm, this), this));
388     // Need to create the callee structure (above) before creating the callee.
389     JSCallee* globalCallee = JSCallee::create(vm, this, globalScope());
390     m_globalCallee.set(vm, this, globalCallee);
391
392     ExecState::initGlobalExec(JSGlobalObject::globalExec(), globalCallee);
393     ExecState* exec = JSGlobalObject::globalExec();
394
395     m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
396     m_customGetterSetterFunctionStructure.initLater(
397         [] (const Initializer<Structure>& init) {
398             init.set(JSCustomGetterSetterFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
399         });
400     m_boundFunctionStructure.initLater(
401         [] (const Initializer<Structure>& init) {
402             init.set(JSBoundFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
403         });
404     m_getterSetterStructure.set(vm, this, GetterSetter::createStructure(vm, this, jsNull()));
405     m_nativeStdFunctionStructure.initLater(
406         [] (const Initializer<Structure>& init) {
407             init.set(JSNativeStdFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
408         });
409     m_namedFunctionStructure.initLater(
410         [] (const Initializer<Structure>& init) {
411             init.set(Structure::addPropertyTransition(init.vm, init.owner->m_functionStructure.get(), init.vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, init.owner->m_functionNameOffset));
412         });
413     JSFunction* callFunction = nullptr;
414     JSFunction* applyFunction = nullptr;
415     JSFunction* hasInstanceSymbolFunction = nullptr;
416     m_functionPrototype->addFunctionProperties(exec, this, &callFunction, &applyFunction, &hasInstanceSymbolFunction);
417     m_callFunction.set(vm, this, callFunction);
418     m_applyFunction.set(vm, this, applyFunction);
419     m_arrayProtoToStringFunction.initLater(
420         [] (const Initializer<JSFunction>& init) {
421             init.set(JSFunction::create(init.vm, init.owner, 0, init.vm.propertyNames->toString.string(), arrayProtoFuncToString, NoIntrinsic));
422         });
423     m_arrayProtoValuesFunction.initLater(
424         [] (const Initializer<JSFunction>& init) {
425             init.set(JSFunction::createBuiltinFunction(init.vm, arrayPrototypeValuesCodeGenerator(init.vm), init.owner));
426         });
427     m_initializePromiseFunction.initLater(
428         [] (const Initializer<JSFunction>& init) {
429             init.set(JSFunction::createBuiltinFunction(init.vm, promiseOperationsInitializePromiseCodeGenerator(init.vm), init.owner));
430         });
431
432     m_iteratorProtocolFunction.initLater(
433         [] (const Initializer<JSFunction>& init) {
434             init.set(JSFunction::createBuiltinFunction(init.vm, iteratorHelpersPerformIterationCodeGenerator(init.vm), init.owner));
435         });
436
437     m_promiseResolveFunction.initLater(
438         [] (const Initializer<JSFunction>& init) {
439             init.set(JSFunction::createBuiltinFunction(init.vm, promiseConstructorResolveCodeGenerator(init.vm), init.owner));
440         });
441
442     m_newPromiseCapabilityFunction.set(vm, this, JSFunction::createBuiltinFunction(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
443     m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
444     m_throwTypeErrorGetterSetter.initLater(
445         [] (const Initializer<GetterSetter>& init) {
446             JSFunction* thrower = init.owner->throwTypeErrorFunction();
447             GetterSetter* getterSetter = GetterSetter::create(init.vm, init.owner);
448             getterSetter->setGetter(init.vm, init.owner, thrower);
449             getterSetter->setSetter(init.vm, init.owner, thrower);
450             init.set(getterSetter);
451         });
452
453     m_nullGetterFunction.set(vm, this, NullGetterFunction::create(vm, NullGetterFunction::createStructure(vm, this, m_functionPrototype.get())));
454     m_nullSetterFunction.set(vm, this, NullSetterFunction::create(vm, NullSetterFunction::createStructure(vm, this, m_functionPrototype.get())));
455     m_objectPrototype.set(vm, this, ObjectPrototype::create(vm, this, ObjectPrototype::createStructure(vm, this, jsNull())));
456     GetterSetter* protoAccessor = GetterSetter::create(vm, this);
457     protoAccessor->setGetter(vm, this, JSFunction::create(vm, this, 0, makeString("get ", vm.propertyNames->underscoreProto.string()), globalFuncProtoGetter));
458     protoAccessor->setSetter(vm, this, JSFunction::create(vm, this, 0, makeString("set ", vm.propertyNames->underscoreProto.string()), globalFuncProtoSetter));
459     m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
460     m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
461     m_objectStructureForObjectConstructor.set(vm, this, vm.prototypeMap.emptyObjectStructureForPrototype(this, m_objectPrototype.get(), JSFinalObject::defaultInlineCapacity()));
462     m_objectProtoValueOfFunction.set(vm, this, jsCast<JSFunction*>(objectPrototype()->getDirect(vm, vm.propertyNames->valueOf)));
463     
464     JSFunction* thrower = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeErrorArgumentsCalleeAndCaller);
465     GetterSetter* getterSetter = GetterSetter::create(vm, this);
466     getterSetter->setGetter(vm, this, thrower);
467     getterSetter->setSetter(vm, this, thrower);
468     m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter.set(vm, this, getterSetter);
469     
470     m_functionPrototype->initRestrictedProperties(exec, this);
471
472     m_speciesGetterSetter.set(vm, this, GetterSetter::create(vm, this));
473     m_speciesGetterSetter->setGetter(vm, this, JSFunction::createBuiltinFunction(vm, globalOperationsSpeciesGetterCodeGenerator(vm), this, "get [Symbol.species]"));
474
475     m_typedArrayProto.initLater(
476         [] (const Initializer<JSTypedArrayViewPrototype>& init) {
477             init.set(JSTypedArrayViewPrototype::create(init.vm, init.owner, JSTypedArrayViewPrototype::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get())));
478             
479             // Make sure that the constructor gets initialized, too.
480             init.owner->m_typedArraySuperConstructor.get(init.owner);
481         });
482     m_typedArraySuperConstructor.initLater(
483         [] (const Initializer<JSTypedArrayViewConstructor>& init) {
484             JSTypedArrayViewPrototype* prototype = init.owner->m_typedArrayProto.get(init.owner);
485             JSTypedArrayViewConstructor* constructor = JSTypedArrayViewConstructor::create(init.vm, init.owner, JSTypedArrayViewConstructor::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()), prototype, init.owner->m_speciesGetterSetter.get());
486             prototype->putDirectWithoutTransition(init.vm, init.vm.propertyNames->constructor, constructor, DontEnum);
487             init.set(constructor);
488         });
489     
490 #define INIT_TYPED_ARRAY_LATER(type) \
491     m_typedArray ## type.initLater( \
492         [] (LazyClassStructure::Initializer& init) { \
493             init.setPrototype(JS ## type ## ArrayPrototype::create(init.vm, init.global, JS ## type ## ArrayPrototype::createStructure(init.vm, init.global, init.global->m_typedArrayProto.get(init.global)))); \
494             init.setStructure(JS ## type ## Array::createStructure(init.vm, init.global, init.prototype)); \
495             init.setConstructor(JS ## type ## ArrayConstructor::create(init.vm, init.global, JS ## type ## ArrayConstructor::createStructure(init.vm, init.global, init.global->m_typedArraySuperConstructor.get(init.global)), init.prototype, ASCIILiteral(#type "Array"), typedArrayConstructorAllocate ## type ## ArrayCodeGenerator(init.vm))); \
496             init.global->putDirectWithoutTransition(init.vm, init.vm.propertyNames->builtinNames().type ## ArrayPrivateName(), init.constructor, DontEnum); \
497         });
498     FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(INIT_TYPED_ARRAY_LATER)
499 #undef INIT_TYPED_ARRAY_LATER
500     
501     m_typedArrayDataView.initLater(
502         [] (LazyClassStructure::Initializer& init) {
503             init.setPrototype(JSDataViewPrototype::create(init.vm, JSDataViewPrototype::createStructure(init.vm, init.global, init.global->m_objectPrototype.get())));
504             init.setStructure(JSDataView::createStructure(init.vm, init.global, init.prototype));
505             init.setConstructor(JSDataViewConstructor::create(init.vm, init.global, JSDataViewConstructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), init.prototype, ASCIILiteral("DataView"), nullptr));
506         });
507     
508     m_lexicalEnvironmentStructure.set(vm, this, JSLexicalEnvironment::createStructure(vm, this));
509     m_moduleEnvironmentStructure.initLater(
510         [] (const Initializer<Structure>& init) {
511             init.set(JSModuleEnvironment::createStructure(init.vm, init.owner));
512         });
513     m_strictEvalActivationStructure.set(vm, this, StrictEvalActivation::createStructure(vm, this, jsNull()));
514     m_debuggerScopeStructure.initLater(
515         [] (const Initializer<Structure>& init) {
516             init.set(DebuggerScope::createStructure(init.vm, init.owner));
517         });
518     m_withScopeStructure.initLater(
519         [] (const Initializer<Structure>& init) {
520             init.set(JSWithScope::createStructure(init.vm, init.owner, jsNull()));
521         });
522     
523     m_nullPrototypeObjectStructure.initLater(
524         [] (const Initializer<Structure>& init) {
525             init.set(JSFinalObject::createStructure(init.vm, init.owner, jsNull(), JSFinalObject::defaultInlineCapacity()));
526         });
527     
528     m_callbackFunctionStructure.initLater(
529         [] (const Initializer<Structure>& init) {
530             init.set(JSCallbackFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
531         });
532     m_directArgumentsStructure.set(vm, this, DirectArguments::createStructure(vm, this, m_objectPrototype.get()));
533     m_scopedArgumentsStructure.set(vm, this, ScopedArguments::createStructure(vm, this, m_objectPrototype.get()));
534     m_clonedArgumentsStructure.set(vm, this, ClonedArguments::createStructure(vm, this, m_objectPrototype.get()));
535     m_callbackConstructorStructure.initLater(
536         [] (const Initializer<Structure>& init) {
537             init.set(JSCallbackConstructor::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
538         });
539     m_callbackObjectStructure.initLater(
540         [] (const Initializer<Structure>& init) {
541             init.set(JSCallbackObject<JSDestructibleObject>::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
542         });
543
544 #if JSC_OBJC_API_ENABLED
545     m_objcCallbackFunctionStructure.initLater(
546         [] (const Initializer<Structure>& init) {
547             init.set(ObjCCallbackFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
548         });
549     m_objcWrapperObjectStructure.initLater(
550         [] (const Initializer<Structure>& init) {
551             init.set(JSCallbackObject<JSAPIWrapperObject>::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
552         });
553 #endif
554     
555     m_arrayPrototype.set(vm, this, ArrayPrototype::create(vm, this, ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
556     
557     m_originalArrayStructureForIndexingShape[UndecidedShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithUndecided));
558     m_originalArrayStructureForIndexingShape[Int32Shape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithInt32));
559     m_originalArrayStructureForIndexingShape[DoubleShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithDouble));
560     m_originalArrayStructureForIndexingShape[ContiguousShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithContiguous));
561     m_originalArrayStructureForIndexingShape[ArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithArrayStorage));
562     m_originalArrayStructureForIndexingShape[SlowPutArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithSlowPutArrayStorage));
563     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
564         m_arrayStructureForIndexingShapeDuringAllocation[i] = m_originalArrayStructureForIndexingShape[i];
565
566     m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get())));
567     m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
568     m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, this));
569
570     m_moduleRecordStructure.set(vm, this, JSModuleRecord::createStructure(vm, this, m_objectPrototype.get()));
571     m_moduleNamespaceObjectStructure.set(vm, this, JSModuleNamespaceObject::createStructure(vm, this, jsNull()));
572     {
573         bool isCallable = false;
574         m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
575         isCallable = true;
576         m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
577     }
578     m_proxyRevokeStructure.set(vm, this, ProxyRevoke::createStructure(vm, this, m_functionPrototype.get()));
579
580     m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, ParseIntIntrinsic));
581     putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum);
582     m_parseFloatFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->parseFloat.string(), globalFuncParseFloat, NoIntrinsic));
583     putDirectWithoutTransition(vm, vm.propertyNames->parseFloat, m_parseFloatFunction.get(), DontEnum);
584     
585     m_arrayBufferPrototype.set(vm, this, JSArrayBufferPrototype::create(vm, this, JSArrayBufferPrototype::createStructure(vm, this, m_objectPrototype.get()), ArrayBufferSharingMode::Default));
586     m_arrayBufferStructure.set(vm, this, JSArrayBuffer::createStructure(vm, this, m_arrayBufferPrototype.get()));
587     m_sharedArrayBufferPrototype.set(vm, this, JSArrayBufferPrototype::create(vm, this, JSArrayBufferPrototype::createStructure(vm, this, m_objectPrototype.get()), ArrayBufferSharingMode::Shared));
588     m_sharedArrayBufferStructure.set(vm, this, JSArrayBuffer::createStructure(vm, this, m_sharedArrayBufferPrototype.get()));
589
590     m_iteratorPrototype.set(vm, this, IteratorPrototype::create(vm, this, IteratorPrototype::createStructure(vm, this, m_objectPrototype.get())));
591     m_generatorPrototype.set(vm, this, GeneratorPrototype::create(vm, this, GeneratorPrototype::createStructure(vm, this, m_iteratorPrototype.get())));
592
593 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
594 m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
595 m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
596     
597     FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
598     FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
599     
600 #undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
601
602 #define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
603     m_ ## properName ## Structure.initLater(\
604         [] (LazyClassStructure::Initializer& init) { \
605             init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_ ## prototypeBase ## Prototype.get()))); \
606             init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
607             init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), jsCast<capitalName ## Prototype*>(init.prototype), init.global->m_speciesGetterSetter.get())); \
608         });
609     
610     FOR_EACH_LAZY_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_LAZY_TYPE)
611     
612 #undef CREATE_PROTOTYPE_FOR_LAZY_TYPE
613     
614     m_moduleLoaderPrototype.set(vm, this, ModuleLoaderPrototype::create(vm, this, ModuleLoaderPrototype::createStructure(vm, this, m_objectPrototype.get())));
615     
616     // Constructors
617
618     ObjectConstructor* objectConstructor = ObjectConstructor::create(vm, this, ObjectConstructor::createStructure(vm, this, m_functionPrototype.get()), m_objectPrototype.get());
619     m_objectConstructor.set(vm, this, objectConstructor);
620
621     JSFunction* throwTypeErrorFunction = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeError);
622     m_throwTypeErrorFunction.set(vm, this, throwTypeErrorFunction);
623
624     JSCell* functionConstructor = FunctionConstructor::create(vm, FunctionConstructor::createStructure(vm, this, m_functionPrototype.get()), m_functionPrototype.get());
625
626     ArrayConstructor* arrayConstructor = ArrayConstructor::create(vm, this, ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayPrototype.get(), m_speciesGetterSetter.get());
627     m_arrayConstructor.set(vm, this, arrayConstructor);
628     
629     m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get(), m_speciesGetterSetter.get()));
630     
631     JSArrayBufferConstructor* arrayBufferConstructor = JSArrayBufferConstructor::create(vm, JSArrayBufferConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayBufferPrototype.get(), m_speciesGetterSetter.get(), ArrayBufferSharingMode::Default);
632     m_arrayBufferPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayBufferConstructor, DontEnum);
633     JSArrayBufferConstructor* sharedArrayBufferConstructor = nullptr;
634     sharedArrayBufferConstructor = JSArrayBufferConstructor::create(vm, JSArrayBufferConstructor::createStructure(vm, this, m_functionPrototype.get()), m_sharedArrayBufferPrototype.get(), m_speciesGetterSetter.get(), ArrayBufferSharingMode::Shared);
635     m_sharedArrayBufferPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, sharedArrayBufferConstructor, DontEnum);
636     
637 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
638 capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
639 m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, DontEnum); \
640
641     FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE)
642     
643 #undef CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE
644
645     m_errorConstructor.set(vm, this, errorConstructor);
646     m_promiseConstructor.set(vm, this, promiseConstructor);
647     m_internalPromiseConstructor.set(vm, this, internalPromiseConstructor);
648     
649     m_nativeErrorPrototypeStructure.set(vm, this, NativeErrorPrototype::createStructure(vm, this, m_errorPrototype.get()));
650     m_nativeErrorStructure.set(vm, this, NativeErrorConstructor::createStructure(vm, this, errorConstructor));
651     m_evalErrorConstructor.initLater(
652         [] (const Initializer<NativeErrorConstructor>& init) {
653             init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("EvalError")));
654         });
655     m_rangeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), ASCIILiteral("RangeError")));
656     m_referenceErrorConstructor.initLater(
657         [] (const Initializer<NativeErrorConstructor>& init) {
658             init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("ReferenceError")));
659         });
660     m_syntaxErrorConstructor.initLater(
661         [] (const Initializer<NativeErrorConstructor>& init) {
662             init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("SyntaxError")));
663         });
664     m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), ASCIILiteral("TypeError")));
665     m_URIErrorConstructor.initLater(
666         [] (const Initializer<NativeErrorConstructor>& init) {
667             init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("URIError")));
668         });
669
670     m_generatorFunctionPrototype.set(vm, this, GeneratorFunctionPrototype::create(vm, GeneratorFunctionPrototype::createStructure(vm, this, m_functionPrototype.get())));
671     GeneratorFunctionConstructor* generatorFunctionConstructor = GeneratorFunctionConstructor::create(vm, GeneratorFunctionConstructor::createStructure(vm, this, functionConstructor), m_generatorFunctionPrototype.get());
672     m_generatorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, generatorFunctionConstructor, DontEnum | ReadOnly);
673     m_generatorFunctionStructure.set(vm, this, JSGeneratorFunction::createStructure(vm, this, m_generatorFunctionPrototype.get()));
674
675     m_generatorPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_generatorFunctionPrototype.get(), DontEnum | ReadOnly);
676     m_generatorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->prototype, m_generatorPrototype.get(), DontEnum | ReadOnly);
677
678     m_asyncFunctionPrototype.set(vm, this, AsyncFunctionPrototype::create(vm, AsyncFunctionPrototype::createStructure(vm, this, m_functionPrototype.get())));
679     AsyncFunctionConstructor* asyncFunctionConstructor = AsyncFunctionConstructor::create(vm, AsyncFunctionConstructor::createStructure(vm, this, functionConstructor), m_asyncFunctionPrototype.get());
680     m_asyncFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, asyncFunctionConstructor, DontEnum | ReadOnly);
681     m_asyncFunctionStructure.set(vm, this, JSAsyncFunction::createStructure(vm, this, m_asyncFunctionPrototype.get()));
682
683     m_objectPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, objectConstructor, DontEnum);
684     m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, DontEnum);
685     m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, DontEnum);
686     m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_regExpConstructor.get(), DontEnum);
687     
688     putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum);
689     putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, DontEnum);
690     putDirectWithoutTransition(vm, vm.propertyNames->Array, arrayConstructor, DontEnum);
691     putDirectWithoutTransition(vm, vm.propertyNames->RegExp, m_regExpConstructor.get(), DontEnum);
692     putDirectWithoutTransition(vm, vm.propertyNames->RangeError, m_rangeErrorConstructor.get(), DontEnum);
693     putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum);
694
695     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ObjectPrivateName(), objectConstructor, DontEnum | DontDelete | ReadOnly);
696     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ArrayPrivateName(), arrayConstructor, DontEnum | DontDelete | ReadOnly);
697
698     putDirectWithoutTransition(vm, vm.propertyNames->ArrayBuffer, arrayBufferConstructor, DontEnum);
699     putDirectWithoutTransition(vm, vm.propertyNames->SharedArrayBuffer, sharedArrayBufferConstructor, DontEnum);
700
701 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
702 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, DontEnum); \
703
704     FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
705
706 #undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
707     m_iteratorResultObjectStructure.set(vm, this, createIteratorResultObjectStructure(vm, *this));
708     
709     m_evalFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->eval.string(), globalFuncEval));
710     putDirectWithoutTransition(vm, vm.propertyNames->eval, m_evalFunction.get(), DontEnum);
711     
712 #if ENABLE(INTL)
713     IntlObject* intl = IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
714     putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, DontEnum);
715 #endif // ENABLE(INTL)
716     ReflectObject* reflectObject = ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get()));
717     putDirectWithoutTransition(vm, vm.propertyNames->Reflect, reflectObject, DontEnum);
718
719     m_moduleLoaderStructure.set(vm, this, JSModuleLoader::createStructure(vm, this, m_moduleLoaderPrototype.get()));
720     m_moduleLoader.set(vm, this, JSModuleLoader::create(globalExec(), vm, this, m_moduleLoaderStructure.get()));
721     if (Options::exposeInternalModuleLoader())
722         putDirectWithoutTransition(vm, vm.propertyNames->Loader, m_moduleLoader.get(), DontEnum);
723
724     JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
725
726     JSFunction* privateFuncAbs = JSFunction::create(vm, this, 0, String(), mathProtoFuncAbs, AbsIntrinsic);
727     JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
728     JSFunction* privateFuncTrunc = JSFunction::create(vm, this, 0, String(), mathProtoFuncTrunc, TruncIntrinsic);
729
730     JSFunction* privateFuncGetOwnPropertyNames = JSFunction::create(vm, this, 0, String(), objectConstructorGetOwnPropertyNames);
731     JSFunction* privateFuncPropertyIsEnumerable = JSFunction::create(vm, this, 0, String(), globalFuncPropertyIsEnumerable);
732     JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
733     JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
734     JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
735     JSFunction* privateFuncTypedArraySort = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSort);
736     JSFunction* privateFuncIsTypedArrayView = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncIsTypedArrayView, IsTypedArrayViewIntrinsic);
737     JSFunction* privateFuncTypedArraySubarrayCreate = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSubarrayCreate);
738     JSFunction* privateFuncIsBoundFunction = JSFunction::create(vm, this, 0, String(), isBoundFunction);
739     JSFunction* privateFuncHasInstanceBoundFunction = JSFunction::create(vm, this, 0, String(), hasInstanceBoundFunction);
740     JSFunction* privateFuncInstanceOf = JSFunction::create(vm, this, 0, String(), objectPrivateFuncInstanceOf);
741     JSFunction* privateFuncThisTimeValue = JSFunction::create(vm, this, 0, String(), dateProtoFuncGetTime);
742     JSFunction* privateFuncThisNumberValue = JSFunction::create(vm, this, 0, String(), numberProtoFuncValueOf);
743     JSFunction* privateFuncIsArrayConstructor = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArrayConstructor);
744     JSFunction* privateFuncIsArraySlow = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArraySlow);
745     JSFunction* privateFuncConcatMemcpy = JSFunction::create(vm, this, 0, String(), arrayProtoPrivateFuncConcatMemcpy);
746     JSFunction* privateFuncAppendMemcpy = JSFunction::create(vm, this, 0, String(), arrayProtoPrivateFuncAppendMemcpy);
747
748     JSObject* regExpProtoFlagsGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->flags);
749     catchScope.assertNoException();
750     JSObject* regExpProtoGlobalGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->global);
751     catchScope.assertNoException();
752     m_regExpProtoGlobalGetter.set(vm, this, regExpProtoGlobalGetterObject);
753     JSObject* regExpProtoIgnoreCaseGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->ignoreCase);
754     catchScope.assertNoException();
755     JSObject* regExpProtoMultilineGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->multiline);
756     catchScope.assertNoException();
757     JSObject* regExpProtoSourceGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->source);
758     catchScope.assertNoException();
759     JSObject* regExpProtoStickyGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->sticky);
760     catchScope.assertNoException();
761     JSObject* regExpProtoUnicodeGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->unicode);
762     catchScope.assertNoException();
763     m_regExpProtoUnicodeGetter.set(vm, this, regExpProtoUnicodeGetterObject);
764     JSObject* builtinRegExpExec = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->exec).asCell());
765     m_regExpProtoExec.set(vm, this, builtinRegExpExec);
766     JSObject* regExpSymbolReplace = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol).asCell());
767     m_regExpProtoSymbolReplace.set(vm, this, regExpSymbolReplace);
768
769 #define CREATE_PRIVATE_GLOBAL_FUNCTION(name, code) JSFunction* name ## PrivateFunction = JSFunction::createBuiltinFunction(vm, code ## CodeGenerator(vm), this);
770     JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(CREATE_PRIVATE_GLOBAL_FUNCTION)
771 #undef CREATE_PRIVATE_GLOBAL_FUNCTION
772
773     JSObject* arrayIteratorPrototype = ArrayIteratorPrototype::create(vm, this, ArrayIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
774     createArrayIteratorPrivateFunction->putDirect(vm, vm.propertyNames->prototype, arrayIteratorPrototype);
775
776     GlobalPropertyInfo staticGlobals[] = {
777 #define INIT_PRIVATE_GLOBAL(name, code) GlobalPropertyInfo(vm.propertyNames->builtinNames().name ## PrivateName(), name ## PrivateFunction, DontEnum | DontDelete | ReadOnly),
778         JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(INIT_PRIVATE_GLOBAL)
779 #undef INIT_PRIVATE_GLOBAL
780         GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
781         GlobalPropertyInfo(vm.propertyNames->Infinity, jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
782         GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
783         GlobalPropertyInfo(vm.propertyNames->builtinNames().getOwnPropertyNamesPrivateName(), privateFuncGetOwnPropertyNames, DontEnum | DontDelete | ReadOnly),
784         GlobalPropertyInfo(vm.propertyNames->builtinNames().propertyIsEnumerablePrivateName(), privateFuncPropertyIsEnumerable, DontEnum | DontDelete | ReadOnly),
785         GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, DontEnum | DontDelete | ReadOnly),
786         GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
787         GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), m_errorConstructor.get(), DontEnum | DontDelete | ReadOnly),
788         GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
789         GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
790         GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayLengthPrivateName(), privateFuncTypedArrayLength, DontEnum | DontDelete | ReadOnly),
791         GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayGetOriginalConstructorPrivateName(), privateFuncTypedArrayGetOriginalConstructor, DontEnum | DontDelete | ReadOnly),
792         GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArraySortPrivateName(), privateFuncTypedArraySort, DontEnum | DontDelete | ReadOnly),
793         GlobalPropertyInfo(vm.propertyNames->builtinNames().isTypedArrayViewPrivateName(), privateFuncIsTypedArrayView, DontEnum | DontDelete | ReadOnly),
794         GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArraySubarrayCreatePrivateName(), privateFuncTypedArraySubarrayCreate, DontEnum | DontDelete | ReadOnly),
795         GlobalPropertyInfo(vm.propertyNames->builtinNames().isBoundFunctionPrivateName(), privateFuncIsBoundFunction, DontEnum | DontDelete | ReadOnly),
796         GlobalPropertyInfo(vm.propertyNames->builtinNames().hasInstanceBoundFunctionPrivateName(), privateFuncHasInstanceBoundFunction, DontEnum | DontDelete | ReadOnly),
797         GlobalPropertyInfo(vm.propertyNames->builtinNames().instanceOfPrivateName(), privateFuncInstanceOf, DontEnum | DontDelete | ReadOnly),
798         GlobalPropertyInfo(vm.propertyNames->builtinNames().BuiltinLogPrivateName(), builtinLog, DontEnum | DontDelete | ReadOnly),
799         GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberPrivateName(), numberConstructor, DontEnum | DontDelete | ReadOnly),
800         GlobalPropertyInfo(vm.propertyNames->builtinNames().RegExpPrivateName(), m_regExpConstructor.get(), DontEnum | DontDelete | ReadOnly),
801         GlobalPropertyInfo(vm.propertyNames->builtinNames().StringPrivateName(), stringConstructor, DontEnum | DontDelete | ReadOnly),
802         GlobalPropertyInfo(vm.propertyNames->builtinNames().absPrivateName(), privateFuncAbs, DontEnum | DontDelete | ReadOnly),
803         GlobalPropertyInfo(vm.propertyNames->builtinNames().floorPrivateName(), privateFuncFloor, DontEnum | DontDelete | ReadOnly),
804         GlobalPropertyInfo(vm.propertyNames->builtinNames().truncPrivateName(), privateFuncTrunc, DontEnum | DontDelete | ReadOnly),
805         GlobalPropertyInfo(vm.propertyNames->builtinNames().PromisePrivateName(), promiseConstructor, DontEnum | DontDelete | ReadOnly),
806         GlobalPropertyInfo(vm.propertyNames->builtinNames().ReflectPrivateName(), reflectObject, DontEnum | DontDelete | ReadOnly),
807         GlobalPropertyInfo(vm.propertyNames->builtinNames().InternalPromisePrivateName(), internalPromiseConstructor, DontEnum | DontDelete | ReadOnly),
808
809         GlobalPropertyInfo(vm.propertyNames->builtinNames().repeatCharacterPrivateName(), JSFunction::create(vm, this, 2, String(), stringProtoFuncRepeatCharacter), DontEnum | DontDelete | ReadOnly),
810         GlobalPropertyInfo(vm.propertyNames->builtinNames().SetIteratorPrivateName(), JSFunction::create(vm, this, 1, String(), privateFuncSetIterator), DontEnum | DontDelete | ReadOnly),
811         GlobalPropertyInfo(vm.propertyNames->builtinNames().setIteratorNextPrivateName(), JSFunction::create(vm, this, 0, String(), privateFuncSetIteratorNext), DontEnum | DontDelete | ReadOnly),
812         GlobalPropertyInfo(vm.propertyNames->builtinNames().isArrayPrivateName(), arrayConstructor->getDirect(vm, vm.propertyNames->isArray), DontEnum | DontDelete | ReadOnly),
813         GlobalPropertyInfo(vm.propertyNames->builtinNames().isArraySlowPrivateName(), privateFuncIsArraySlow, DontEnum | DontDelete | ReadOnly),
814         GlobalPropertyInfo(vm.propertyNames->builtinNames().isArrayConstructorPrivateName(), privateFuncIsArrayConstructor, DontEnum | DontDelete | ReadOnly),
815         GlobalPropertyInfo(vm.propertyNames->builtinNames().concatMemcpyPrivateName(), privateFuncConcatMemcpy, DontEnum | DontDelete | ReadOnly),
816         GlobalPropertyInfo(vm.propertyNames->builtinNames().appendMemcpyPrivateName(), privateFuncAppendMemcpy, DontEnum | DontDelete | ReadOnly),
817         GlobalPropertyInfo(vm.propertyNames->builtinNames().MapIteratorPrivateName(), JSFunction::create(vm, this, 1, String(), privateFuncMapIterator), DontEnum | DontDelete | ReadOnly),
818         GlobalPropertyInfo(vm.propertyNames->builtinNames().mapIteratorNextPrivateName(), JSFunction::create(vm, this, 0, String(), privateFuncMapIteratorNext), DontEnum | DontDelete | ReadOnly),
819
820         GlobalPropertyInfo(vm.propertyNames->builtinNames().hostPromiseRejectionTrackerPrivateName(), JSFunction::create(vm, this, 2, String(), globalFuncHostPromiseRejectionTracker), DontEnum | DontDelete | ReadOnly),
821         GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly),
822         GlobalPropertyInfo(vm.propertyNames->builtinNames().MapPrivateName(), mapConstructor, DontEnum | DontDelete | ReadOnly),
823         GlobalPropertyInfo(vm.propertyNames->builtinNames().thisTimeValuePrivateName(), privateFuncThisTimeValue, DontEnum | DontDelete | ReadOnly),
824         GlobalPropertyInfo(vm.propertyNames->builtinNames().thisNumberValuePrivateName(), privateFuncThisNumberValue, DontEnum | DontDelete | ReadOnly),
825 #if ENABLE(INTL)
826         GlobalPropertyInfo(vm.propertyNames->builtinNames().CollatorPrivateName(), intl->getDirect(vm, vm.propertyNames->Collator), DontEnum | DontDelete | ReadOnly),
827         GlobalPropertyInfo(vm.propertyNames->builtinNames().DateTimeFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->DateTimeFormat), DontEnum | DontDelete | ReadOnly),
828         GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->NumberFormat), DontEnum | DontDelete | ReadOnly),
829 #endif // ENABLE(INTL)
830
831         GlobalPropertyInfo(vm.propertyNames->builtinNames().isConstructorPrivateName(), JSFunction::create(vm, this, 1, String(), esSpecIsConstructor, NoIntrinsic), DontEnum | DontDelete | ReadOnly),
832
833         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoFlagsGetterPrivateName(), regExpProtoFlagsGetterObject, DontEnum | DontDelete | ReadOnly),
834         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoGlobalGetterPrivateName(), regExpProtoGlobalGetterObject, DontEnum | DontDelete | ReadOnly),
835         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoIgnoreCaseGetterPrivateName(), regExpProtoIgnoreCaseGetterObject, DontEnum | DontDelete | ReadOnly),
836         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoMultilineGetterPrivateName(), regExpProtoMultilineGetterObject, DontEnum | DontDelete | ReadOnly),
837         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoSourceGetterPrivateName(), regExpProtoSourceGetterObject, DontEnum | DontDelete | ReadOnly),
838         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoStickyGetterPrivateName(), regExpProtoStickyGetterObject, DontEnum | DontDelete | ReadOnly),
839         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoUnicodeGetterPrivateName(), regExpProtoUnicodeGetterObject, DontEnum | DontDelete | ReadOnly),
840
841         // RegExp.prototype helpers.
842         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpBuiltinExecPrivateName(), builtinRegExpExec, DontEnum | DontDelete | ReadOnly),
843         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpCreatePrivateName(), JSFunction::create(vm, this, 2, String(), esSpecRegExpCreate, NoIntrinsic), DontEnum | DontDelete | ReadOnly),
844         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpMatchFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncMatchFast), DontEnum | DontDelete | ReadOnly),
845         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpSearchFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncSearchFast), DontEnum | DontDelete | ReadOnly),
846         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpSplitFastPrivateName(), JSFunction::create(vm, this, 2, String(), regExpProtoFuncSplitFast), DontEnum | DontDelete | ReadOnly),
847         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpPrototypeSymbolReplacePrivateName(), m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol), DontEnum | DontDelete | ReadOnly),
848         GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpTestFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncTestFast, RegExpTestFastIntrinsic), DontEnum | DontDelete | ReadOnly),
849
850         // String.prototype helpers.
851         GlobalPropertyInfo(vm.propertyNames->builtinNames().stringIncludesInternalPrivateName(), JSFunction::create(vm, this, 1, String(), builtinStringIncludesInternal), DontEnum | DontDelete | ReadOnly),
852         GlobalPropertyInfo(vm.propertyNames->builtinNames().stringSplitFastPrivateName(), JSFunction::create(vm, this, 2, String(), stringProtoFuncSplitFast), DontEnum | DontDelete | ReadOnly),
853         GlobalPropertyInfo(vm.propertyNames->builtinNames().stringSubstrInternalPrivateName(), JSFunction::create(vm, this, 2, String(), builtinStringSubstrInternal), DontEnum | DontDelete | ReadOnly),
854
855         // Function prototype helpers.
856         GlobalPropertyInfo(vm.propertyNames->builtinNames().makeBoundFunctionPrivateName(), JSFunction::create(vm, this, 5, String(), makeBoundFunction), DontEnum | DontDelete | ReadOnly),
857         GlobalPropertyInfo(vm.propertyNames->builtinNames().hasOwnLengthPropertyPrivateName(), JSFunction::create(vm, this, 1, String(), hasOwnLengthProperty), DontEnum | DontDelete | ReadOnly),
858     };
859     addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
860     
861     m_specialPointers[Special::CallFunction] = m_callFunction.get();
862     m_specialPointers[Special::ApplyFunction] = m_applyFunction.get();
863     m_specialPointers[Special::ObjectConstructor] = objectConstructor;
864     m_specialPointers[Special::ArrayConstructor] = arrayConstructor;
865
866     m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::ThrowTypeErrorFunction)] = m_throwTypeErrorFunction.get();
867
868     if (UNLIKELY(Options::useDollarVM())) {
869         JSDollarVMPrototype* dollarVMPrototype = JSDollarVMPrototype::create(vm, this, JSDollarVMPrototype::createStructure(vm, this, m_objectPrototype.get()));
870         m_dollarVMStructure.set(vm, this, JSDollarVM::createStructure(vm, this, dollarVMPrototype));
871         JSDollarVM* dollarVM = JSDollarVM::create(vm, m_dollarVMStructure.get());
872
873         GlobalPropertyInfo extraStaticGlobals[] = {
874             GlobalPropertyInfo(vm.propertyNames->builtinNames().dollarVMPrivateName(), dollarVM, DontEnum | DontDelete | ReadOnly),
875         };
876         addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
877
878         putDirectWithoutTransition(vm, Identifier::fromString(exec, "$vm"), dollarVM, DontEnum);
879     }
880
881 #if ENABLE(WEBASSEMBLY)
882     if (Options::useWebAssembly()) {
883         auto* webAssemblyPrototype = WebAssemblyPrototype::create(vm, this, WebAssemblyPrototype::createStructure(vm, this, m_objectPrototype.get()));
884         m_webAssemblyStructure.set(vm, this, JSWebAssembly::createStructure(vm, this, webAssemblyPrototype));
885         m_webAssemblyModuleRecordStructure.set(vm, this, WebAssemblyModuleRecord::createStructure(vm, this, m_objectPrototype.get()));
886         m_webAssemblyFunctionStructure.set(vm, this, WebAssemblyFunction::createStructure(vm, this, m_functionPrototype.get()));
887         m_webAssemblyWrapperFunctionStructure.set(vm, this, WebAssemblyWrapperFunction::createStructure(vm, this, m_functionPrototype.get()));
888         m_webAssemblyToJSCalleeStructure.set(vm, this, WebAssemblyToJSCallee::createStructure(vm, this, jsNull()));
889         auto* webAssembly = JSWebAssembly::create(vm, this, m_webAssemblyStructure.get());
890         putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, DontEnum);
891
892 #define CREATE_WEBASSEMBLY_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
893         typedef capitalName ## Prototype Prototype; \
894         typedef capitalName ## Constructor Constructor; \
895         typedef JS ## capitalName JSObj; \
896         auto* base = m_ ## prototypeBase ## Prototype.get(); \
897         auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
898         auto* structure = JSObj::createStructure(vm, this, prototype); \
899         auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype); \
900         prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum); \
901         m_ ## lowerName ## Prototype.set(vm, this, prototype); \
902         m_ ## properName ## Structure.set(vm, this, structure); \
903         webAssembly->putDirectWithoutTransition(vm, Identifier::fromString(this->globalExec(), #jsName), constructor, DontEnum); \
904     } while (0);
905
906         FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_CONSTRUCTOR)
907
908 #undef CREATE_WEBASSEMBLY_CONSTRUCTOR
909     }
910 #endif // ENABLE(WEBASSEMBLY)
911
912     {
913         ExecState* exec = globalExec();
914
915         auto setupAdaptiveWatchpoint = [&] (JSObject* base, const Identifier& ident) -> ObjectPropertyCondition {
916             // Performing these gets should not throw.
917             PropertySlot slot(base, PropertySlot::InternalMethodType::Get);
918             bool result = base->getOwnPropertySlot(base, exec, ident, slot);
919             ASSERT_UNUSED(result, result);
920             catchScope.assertNoException();
921             RELEASE_ASSERT(slot.isCacheableValue());
922             JSValue functionValue = slot.getValue(exec, ident);
923             catchScope.assertNoException();
924             ASSERT(jsDynamicCast<JSFunction*>(vm, functionValue));
925
926             ObjectPropertyCondition condition = generateConditionForSelfEquivalence(m_vm, nullptr, base, ident.impl());
927             RELEASE_ASSERT(condition.requiredValue() == functionValue);
928
929             bool isWatchable = condition.isWatchable(PropertyCondition::EnsureWatchability);
930             RELEASE_ASSERT(isWatchable); // We allow this to install the necessary watchpoints.
931
932             return condition;
933         };
934
935         {
936             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(arrayIteratorPrototype, m_vm.propertyNames->next);
937             m_arrayIteratorPrototypeNext = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
938             m_arrayIteratorPrototypeNext->install();
939         }
940
941         {
942             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this->arrayPrototype(), m_vm.propertyNames->iteratorSymbol);
943             m_arrayPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
944             m_arrayPrototypeSymbolIteratorWatchpoint->install();
945         }
946
947         {
948             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapIteratorPrototype.get(), m_vm.propertyNames->next);
949             m_mapIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
950             m_mapIteratorPrototypeNextWatchpoint->install();
951         }
952
953         {
954             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->iteratorSymbol);
955             m_mapPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
956             m_mapPrototypeSymbolIteratorWatchpoint->install();
957         }
958
959         {
960             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setIteratorPrototype.get(), m_vm.propertyNames->next);
961             m_setIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
962             m_setIteratorPrototypeNextWatchpoint->install();
963         }
964
965         {
966             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->iteratorSymbol);
967             m_setPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
968             m_setPrototypeSymbolIteratorWatchpoint->install();
969         }
970
971         {
972             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->set);
973             m_mapPrototypeSetWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapSetWatchpoint);
974             m_mapPrototypeSetWatchpoint->install();
975         }
976
977         {
978             ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->add);
979             m_setPrototypeAddWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setAddWatchpoint);
980             m_setPrototypeAddWatchpoint->install();
981         }
982     }
983
984     resetPrototype(vm, getPrototypeDirect());
985 }
986
987 bool JSGlobalObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
988 {
989     VM& vm = exec->vm();
990     auto scope = DECLARE_THROW_SCOPE(vm);
991     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
992     ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
993
994     if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
995         scope.release();
996         return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
997     }
998
999     bool shouldThrowReadOnlyError = slot.isStrictMode();
1000     bool ignoreReadOnlyErrors = false;
1001     bool putResult = false;
1002     bool done = symbolTablePutTouchWatchpointSet(thisObject, exec, propertyName, value, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);
1003     ASSERT((!!scope.exception() == (done && !putResult)) || !shouldThrowReadOnlyError);
1004     if (done)
1005         return putResult;
1006     scope.release();
1007     return Base::put(thisObject, exec, propertyName, value, slot);
1008 }
1009
1010 bool JSGlobalObject::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow)
1011 {
1012     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
1013     PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
1014     // silently ignore attempts to add accessors aliasing vars.
1015     if (descriptor.isAccessorDescriptor() && symbolTableGet(thisObject, propertyName, slot))
1016         return false;
1017     return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
1018 }
1019
1020 void JSGlobalObject::addGlobalVar(const Identifier& ident)
1021 {
1022     ConcurrentJSLocker locker(symbolTable()->m_lock);
1023     SymbolTableEntry entry = symbolTable()->get(locker, ident.impl());
1024     if (!entry.isNull())
1025         return;
1026     
1027     ScopeOffset offset = symbolTable()->takeNextScopeOffset(locker);
1028     SymbolTableEntry newEntry(VarOffset(offset), 0);
1029     newEntry.prepareToWatch();
1030     symbolTable()->add(locker, ident.impl(), WTFMove(newEntry));
1031     
1032     ScopeOffset offsetForAssert = addVariables(1, jsUndefined());
1033     RELEASE_ASSERT(offsetForAssert == offset);
1034 }
1035
1036 void JSGlobalObject::addFunction(ExecState* exec, const Identifier& propertyName)
1037 {
1038     VM& vm = exec->vm();
1039     VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
1040     methodTable(vm)->deleteProperty(this, exec, propertyName);
1041     addGlobalVar(propertyName);
1042 }
1043
1044 void JSGlobalObject::setGlobalScopeExtension(JSScope* scope)
1045 {
1046     m_globalScopeExtension.set(vm(), this, scope);
1047 }
1048
1049 void JSGlobalObject::clearGlobalScopeExtension()
1050 {
1051     m_globalScopeExtension.clear();
1052 }
1053
1054 static inline JSObject* lastInPrototypeChain(JSObject* object)
1055 {
1056     JSObject* o = object;
1057     while (o->getPrototypeDirect().isObject())
1058         o = asObject(o->getPrototypeDirect());
1059     return o;
1060 }
1061
1062 // Private namespace for helpers for JSGlobalObject::haveABadTime()
1063 namespace {
1064
1065 class ObjectsWithBrokenIndexingFinder : public MarkedBlock::VoidFunctor {
1066 public:
1067     ObjectsWithBrokenIndexingFinder(MarkedArgumentBuffer&, JSGlobalObject*);
1068     IterationStatus operator()(HeapCell*, HeapCell::Kind) const;
1069
1070 private:
1071     void visit(JSCell*);
1072
1073     MarkedArgumentBuffer& m_foundObjects;
1074     JSGlobalObject* m_globalObject;
1075 };
1076
1077 ObjectsWithBrokenIndexingFinder::ObjectsWithBrokenIndexingFinder(
1078     MarkedArgumentBuffer& foundObjects, JSGlobalObject* globalObject)
1079     : m_foundObjects(foundObjects)
1080     , m_globalObject(globalObject)
1081 {
1082 }
1083
1084 inline bool hasBrokenIndexing(JSObject* object)
1085 {
1086     // This will change if we have more indexing types.
1087     IndexingType type = object->indexingType();
1088     // This could be made obviously more efficient, but isn't made so right now, because
1089     // we expect this to be an unlikely slow path anyway.
1090     return hasUndecided(type) || hasInt32(type) || hasDouble(type) || hasContiguous(type) || hasArrayStorage(type);
1091 }
1092
1093 inline void ObjectsWithBrokenIndexingFinder::visit(JSCell* cell)
1094 {
1095     if (!cell->isObject())
1096         return;
1097     
1098     JSObject* object = asObject(cell);
1099
1100     // Run this filter first, since it's cheap, and ought to filter out a lot of objects.
1101     if (!hasBrokenIndexing(object))
1102         return;
1103     
1104     // We only want to have a bad time in the affected global object, not in the entire
1105     // VM. But we have to be careful, since there may be objects that claim to belong to
1106     // a different global object that have prototypes from our global object.
1107     bool foundGlobalObject = false;
1108     for (JSObject* current = object; ;) {
1109         if (current->globalObject() == m_globalObject) {
1110             foundGlobalObject = true;
1111             break;
1112         }
1113         
1114         JSValue prototypeValue = current->getPrototypeDirect();
1115         if (prototypeValue.isNull())
1116             break;
1117         current = asObject(prototypeValue);
1118     }
1119     if (!foundGlobalObject)
1120         return;
1121     
1122     m_foundObjects.append(object);
1123 }
1124
1125 IterationStatus ObjectsWithBrokenIndexingFinder::operator()(HeapCell* cell, HeapCell::Kind kind) const
1126 {
1127     if (kind == HeapCell::JSCell) {
1128         // FIXME: This const_cast exists because this isn't a C++ lambda.
1129         // https://bugs.webkit.org/show_bug.cgi?id=159644
1130         const_cast<ObjectsWithBrokenIndexingFinder*>(this)->visit(static_cast<JSCell*>(cell));
1131     }
1132     return IterationStatus::Continue;
1133 }
1134
1135 } // end private namespace for helpers for JSGlobalObject::haveABadTime()
1136
1137 void JSGlobalObject::haveABadTime(VM& vm)
1138 {
1139     ASSERT(&vm == &this->vm());
1140     
1141     if (isHavingABadTime())
1142         return;
1143     
1144     // Make sure that all allocations or indexed storage transitions that are inlining
1145     // the assumption that it's safe to transition to a non-SlowPut array storage don't
1146     // do so anymore.
1147     m_havingABadTimeWatchpoint->fireAll(vm, "Having a bad time");
1148     ASSERT(isHavingABadTime()); // The watchpoint is what tells us that we're having a bad time.
1149     
1150     // Make sure that all JSArray allocations that load the appropriate structure from
1151     // this object now load a structure that uses SlowPut.
1152     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1153         m_arrayStructureForIndexingShapeDuringAllocation[i].set(vm, this, originalArrayStructureForIndexingType(ArrayWithSlowPutArrayStorage));
1154
1155     // Same for any special array structures.
1156     Structure* slowPutStructure;
1157     slowPutStructure = createRegExpMatchesArraySlowPutStructure(vm, this);
1158     m_regExpMatchesArrayStructure.set(vm, this, slowPutStructure);
1159     slowPutStructure = ClonedArguments::createSlowPutStructure(vm, this, m_objectPrototype.get());
1160     m_clonedArgumentsStructure.set(vm, this, slowPutStructure);
1161
1162     // Make sure that all objects that have indexed storage switch to the slow kind of
1163     // indexed storage.
1164     MarkedArgumentBuffer foundObjects; // Use MarkedArgumentBuffer because switchToSlowPutArrayStorage() may GC.
1165     ObjectsWithBrokenIndexingFinder finder(foundObjects, this);
1166     {
1167         HeapIterationScope iterationScope(vm.heap);
1168         vm.heap.objectSpace().forEachLiveCell(iterationScope, finder);
1169     }
1170     while (!foundObjects.isEmpty()) {
1171         JSObject* object = asObject(foundObjects.last());
1172         foundObjects.removeLast();
1173         ASSERT(hasBrokenIndexing(object));
1174         object->switchToSlowPutArrayStorage(vm);
1175     }
1176 }
1177
1178 // Set prototype, and also insert the object prototype at the end of the chain.
1179 void JSGlobalObject::resetPrototype(VM& vm, JSValue prototype)
1180 {
1181     setPrototypeDirect(vm, prototype);
1182
1183     JSObject* oldLastInPrototypeChain = lastInPrototypeChain(this);
1184     JSObject* objectPrototype = m_objectPrototype.get();
1185     if (oldLastInPrototypeChain != objectPrototype)
1186         oldLastInPrototypeChain->setPrototypeDirect(vm, objectPrototype);
1187
1188     // Whenever we change the prototype of the global object, we need to create a new JSProxy with the correct prototype.
1189     setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, prototype, PureForwardingProxyType), this));
1190 }
1191
1192 void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
1193
1194     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
1195     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
1196     Base::visitChildren(thisObject, visitor);
1197
1198     visitor.append(thisObject->m_globalThis);
1199
1200     visitor.append(thisObject->m_globalLexicalEnvironment);
1201     visitor.append(thisObject->m_globalScopeExtension);
1202     visitor.append(thisObject->m_globalCallee);
1203     visitor.append(thisObject->m_regExpConstructor);
1204     visitor.append(thisObject->m_errorConstructor);
1205     visitor.append(thisObject->m_nativeErrorPrototypeStructure);
1206     visitor.append(thisObject->m_nativeErrorStructure);
1207     thisObject->m_evalErrorConstructor.visit(visitor);
1208     visitor.append(thisObject->m_rangeErrorConstructor);
1209     thisObject->m_referenceErrorConstructor.visit(visitor);
1210     thisObject->m_syntaxErrorConstructor.visit(visitor);
1211     visitor.append(thisObject->m_typeErrorConstructor);
1212     thisObject->m_URIErrorConstructor.visit(visitor);
1213     visitor.append(thisObject->m_objectConstructor);
1214     visitor.append(thisObject->m_promiseConstructor);
1215
1216     visitor.append(thisObject->m_nullGetterFunction);
1217     visitor.append(thisObject->m_nullSetterFunction);
1218
1219     visitor.append(thisObject->m_parseIntFunction);
1220     visitor.append(thisObject->m_parseFloatFunction);
1221     visitor.append(thisObject->m_evalFunction);
1222     visitor.append(thisObject->m_callFunction);
1223     visitor.append(thisObject->m_applyFunction);
1224     visitor.append(thisObject->m_throwTypeErrorFunction);
1225     thisObject->m_arrayProtoToStringFunction.visit(visitor);
1226     thisObject->m_arrayProtoValuesFunction.visit(visitor);
1227     thisObject->m_initializePromiseFunction.visit(visitor);
1228     thisObject->m_iteratorProtocolFunction.visit(visitor);
1229     thisObject->m_promiseResolveFunction.visit(visitor);
1230     visitor.append(thisObject->m_objectProtoValueOfFunction);
1231     visitor.append(thisObject->m_newPromiseCapabilityFunction);
1232     visitor.append(thisObject->m_functionProtoHasInstanceSymbolFunction);
1233     thisObject->m_throwTypeErrorGetterSetter.visit(visitor);
1234     visitor.append(thisObject->m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter);
1235     visitor.append(thisObject->m_moduleLoader);
1236
1237     visitor.append(thisObject->m_objectPrototype);
1238     visitor.append(thisObject->m_functionPrototype);
1239     visitor.append(thisObject->m_arrayPrototype);
1240     visitor.append(thisObject->m_errorPrototype);
1241     visitor.append(thisObject->m_iteratorPrototype);
1242     visitor.append(thisObject->m_generatorFunctionPrototype);
1243     visitor.append(thisObject->m_generatorPrototype);
1244     visitor.append(thisObject->m_asyncFunctionPrototype);
1245     visitor.append(thisObject->m_moduleLoaderPrototype);
1246
1247     thisObject->m_debuggerScopeStructure.visit(visitor);
1248     thisObject->m_withScopeStructure.visit(visitor);
1249     visitor.append(thisObject->m_strictEvalActivationStructure);
1250     visitor.append(thisObject->m_lexicalEnvironmentStructure);
1251     thisObject->m_moduleEnvironmentStructure.visit(visitor);
1252     visitor.append(thisObject->m_directArgumentsStructure);
1253     visitor.append(thisObject->m_scopedArgumentsStructure);
1254     visitor.append(thisObject->m_clonedArgumentsStructure);
1255     visitor.append(thisObject->m_objectStructureForObjectConstructor);
1256     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1257         visitor.append(thisObject->m_originalArrayStructureForIndexingShape[i]);
1258     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1259         visitor.append(thisObject->m_arrayStructureForIndexingShapeDuringAllocation[i]);
1260     thisObject->m_callbackConstructorStructure.visit(visitor);
1261     thisObject->m_callbackFunctionStructure.visit(visitor);
1262     thisObject->m_callbackObjectStructure.visit(visitor);
1263 #if JSC_OBJC_API_ENABLED
1264     thisObject->m_objcCallbackFunctionStructure.visit(visitor);
1265     thisObject->m_objcWrapperObjectStructure.visit(visitor);
1266 #endif
1267     thisObject->m_nullPrototypeObjectStructure.visit(visitor);
1268     visitor.append(thisObject->m_errorStructure);
1269     visitor.append(thisObject->m_calleeStructure);
1270     visitor.append(thisObject->m_functionStructure);
1271     thisObject->m_customGetterSetterFunctionStructure.visit(visitor);
1272     thisObject->m_boundFunctionStructure.visit(visitor);
1273     visitor.append(thisObject->m_getterSetterStructure);
1274     thisObject->m_nativeStdFunctionStructure.visit(visitor);
1275     thisObject->m_namedFunctionStructure.visit(visitor);
1276     visitor.append(thisObject->m_symbolObjectStructure);
1277     visitor.append(thisObject->m_regExpStructure);
1278     visitor.append(thisObject->m_generatorFunctionStructure);
1279     visitor.append(thisObject->m_asyncFunctionStructure);
1280     visitor.append(thisObject->m_iteratorResultObjectStructure);
1281     visitor.append(thisObject->m_regExpMatchesArrayStructure);
1282     visitor.append(thisObject->m_moduleRecordStructure);
1283     visitor.append(thisObject->m_moduleNamespaceObjectStructure);
1284     visitor.append(thisObject->m_dollarVMStructure);
1285     visitor.append(thisObject->m_proxyObjectStructure);
1286     visitor.append(thisObject->m_callableProxyObjectStructure);
1287     visitor.append(thisObject->m_proxyRevokeStructure);
1288     visitor.append(thisObject->m_moduleLoaderStructure);
1289     
1290     visitor.append(thisObject->m_arrayBufferPrototype);
1291     visitor.append(thisObject->m_arrayBufferStructure);
1292     visitor.append(thisObject->m_sharedArrayBufferPrototype);
1293     visitor.append(thisObject->m_sharedArrayBufferStructure);
1294
1295 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
1296     visitor.append(thisObject->m_ ## lowerName ## Prototype); \
1297     visitor.append(thisObject->m_ ## properName ## Structure); \
1298
1299     FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
1300     FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(VISIT_SIMPLE_TYPE)
1301     
1302 #if ENABLE(WEBASSEMBLY)
1303     visitor.append(thisObject->m_webAssemblyStructure);
1304     visitor.append(thisObject->m_webAssemblyModuleRecordStructure);
1305     visitor.append(thisObject->m_webAssemblyFunctionStructure);
1306     visitor.append(thisObject->m_webAssemblyWrapperFunctionStructure);
1307     visitor.append(thisObject->m_webAssemblyToJSCalleeStructure);
1308     FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(VISIT_SIMPLE_TYPE)
1309 #endif // ENABLE(WEBASSEMBLY)
1310
1311 #undef VISIT_SIMPLE_TYPE
1312
1313 #define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
1314     thisObject->m_ ## properName ## Structure.visit(visitor);
1315     
1316     FOR_EACH_LAZY_BUILTIN_TYPE(VISIT_LAZY_TYPE)
1317
1318 #undef VISIT_LAZY_TYPE
1319
1320     for (unsigned i = NUMBER_OF_TYPED_ARRAY_TYPES; i--;)
1321         thisObject->lazyTypedArrayStructure(indexToTypedArrayType(i)).visit(visitor);
1322     
1323     visitor.append(thisObject->m_speciesGetterSetter);
1324     thisObject->m_typedArrayProto.visit(visitor);
1325     thisObject->m_typedArraySuperConstructor.visit(visitor);
1326 }
1327
1328 JSValue JSGlobalObject::toThis(JSCell*, ExecState* exec, ECMAMode ecmaMode)
1329 {
1330     if (ecmaMode == StrictMode)
1331         return jsUndefined();
1332     return exec->globalThisValue();
1333 }
1334
1335 ExecState* JSGlobalObject::globalExec()
1336 {
1337     return CallFrame::create(m_globalCallFrame);
1338 }
1339
1340 void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
1341 {
1342     ScopeOffset startOffset = addVariables(count, jsUndefined());
1343
1344     for (int i = 0; i < count; ++i) {
1345         GlobalPropertyInfo& global = globals[i];
1346         ASSERT(global.attributes & DontDelete);
1347         
1348         WatchpointSet* watchpointSet = nullptr;
1349         WriteBarrierBase<Unknown>* variable = nullptr;
1350         {
1351             ConcurrentJSLocker locker(symbolTable()->m_lock);
1352             ScopeOffset offset = symbolTable()->takeNextScopeOffset(locker);
1353             RELEASE_ASSERT(offset == startOffset + i);
1354             SymbolTableEntry newEntry(VarOffset(offset), global.attributes);
1355             newEntry.prepareToWatch();
1356             watchpointSet = newEntry.watchpointSet();
1357             symbolTable()->add(locker, global.identifier.impl(), WTFMove(newEntry));
1358             variable = &variableAt(offset);
1359         }
1360         symbolTablePutTouchWatchpointSet(vm(), this, global.identifier, global.value, variable, watchpointSet);
1361     }
1362 }
1363
1364 bool JSGlobalObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
1365 {
1366     if (Base::getOwnPropertySlot(object, exec, propertyName, slot))
1367         return true;
1368     return symbolTableGet(jsCast<JSGlobalObject*>(object), propertyName, slot);
1369 }
1370
1371 void JSGlobalObject::clearRareData(JSCell* cell)
1372 {
1373     jsCast<JSGlobalObject*>(cell)->m_rareData = nullptr;
1374 }
1375
1376 void slowValidateCell(JSGlobalObject* globalObject)
1377 {
1378     RELEASE_ASSERT(globalObject->isGlobalObject());
1379     ASSERT_GC_OBJECT_INHERITS(globalObject, JSGlobalObject::info());
1380 }
1381
1382 void JSGlobalObject::setRemoteDebuggingEnabled(bool enabled)
1383 {
1384 #if ENABLE(REMOTE_INSPECTOR)
1385     m_inspectorDebuggable->setRemoteDebuggingAllowed(enabled);
1386 #else
1387     UNUSED_PARAM(enabled);
1388 #endif
1389 }
1390
1391 bool JSGlobalObject::remoteDebuggingEnabled() const
1392 {
1393 #if ENABLE(REMOTE_INSPECTOR)
1394     return m_inspectorDebuggable->remoteDebuggingAllowed();
1395 #else
1396     return false;
1397 #endif
1398 }
1399
1400 #if ENABLE(WEB_REPLAY)
1401 void JSGlobalObject::setInputCursor(Ref<InputCursor>&& cursor)
1402 {
1403     m_inputCursor = WTFMove(cursor);
1404     // Save or set the random seed. This performed here rather than the constructor
1405     // to avoid threading the input cursor through all the abstraction layers.
1406     if (m_inputCursor->isCapturing())
1407         m_inputCursor->appendInput<SetRandomSeed>(m_weakRandom.seed());
1408     else if (m_inputCursor->isReplaying()) {
1409         if (SetRandomSeed* input = m_inputCursor->fetchInput<SetRandomSeed>())
1410             m_weakRandom.setSeed(static_cast<unsigned>(input->randomSeed()));
1411     }
1412 }
1413 #endif
1414
1415 void JSGlobalObject::setName(const String& name)
1416 {
1417     m_name = name;
1418
1419 #if ENABLE(REMOTE_INSPECTOR)
1420     m_inspectorDebuggable->update();
1421 #endif
1422 }
1423
1424 # if ENABLE(INTL)
1425 const HashSet<String>& JSGlobalObject::intlCollatorAvailableLocales()
1426 {
1427     if (m_intlCollatorAvailableLocales.isEmpty()) {
1428         int32_t count = ucol_countAvailable();
1429         for (int32_t i = 0; i < count; ++i) {
1430             String locale(ucol_getAvailable(i));
1431             convertICULocaleToBCP47LanguageTag(locale);
1432             m_intlCollatorAvailableLocales.add(locale);
1433         }
1434     }
1435     return m_intlCollatorAvailableLocales;
1436 }
1437
1438 const HashSet<String>& JSGlobalObject::intlDateTimeFormatAvailableLocales()
1439 {
1440     if (m_intlDateTimeFormatAvailableLocales.isEmpty()) {
1441         int32_t count = udat_countAvailable();
1442         for (int32_t i = 0; i < count; ++i) {
1443             String locale(udat_getAvailable(i));
1444             convertICULocaleToBCP47LanguageTag(locale);
1445             m_intlDateTimeFormatAvailableLocales.add(locale);
1446         }
1447     }
1448     return m_intlDateTimeFormatAvailableLocales;
1449 }
1450
1451 const HashSet<String>& JSGlobalObject::intlNumberFormatAvailableLocales()
1452 {
1453     if (m_intlNumberFormatAvailableLocales.isEmpty()) {
1454         int32_t count = unum_countAvailable();
1455         for (int32_t i = 0; i < count; ++i) {
1456             String locale(unum_getAvailable(i));
1457             convertICULocaleToBCP47LanguageTag(locale);
1458             m_intlNumberFormatAvailableLocales.add(locale);
1459         }
1460     }
1461     return m_intlNumberFormatAvailableLocales;
1462 }
1463 #endif // ENABLE(INTL)
1464
1465 void JSGlobalObject::queueMicrotask(Ref<Microtask>&& task)
1466 {
1467     if (globalObjectMethodTable()->queueTaskToEventLoop) {
1468         globalObjectMethodTable()->queueTaskToEventLoop(*this, WTFMove(task));
1469         return;
1470     }
1471
1472     vm().queueMicrotask(*this, WTFMove(task));
1473 }
1474
1475 bool JSGlobalObject::hasDebugger() const
1476
1477     return m_debugger;
1478 }
1479
1480 bool JSGlobalObject::hasInteractiveDebugger() const 
1481
1482     return m_debugger && m_debugger->isInteractivelyDebugging();
1483 }
1484
1485 JSGlobalObject* JSGlobalObject::create(VM& vm, Structure* structure)
1486 {
1487     JSGlobalObject* globalObject = new (NotNull, allocateCell<JSGlobalObject>(vm.heap)) JSGlobalObject(vm, structure);
1488     globalObject->finishCreation(vm);
1489     return globalObject;
1490 }
1491
1492 void JSGlobalObject::finishCreation(VM& vm)
1493 {
1494     Base::finishCreation(vm);
1495     structure()->setGlobalObject(vm, this);
1496     m_runtimeFlags = m_globalObjectMethodTable->javaScriptRuntimeFlags(this);
1497     init(vm);
1498     setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, getPrototypeDirect(), PureForwardingProxyType), this));
1499 }
1500
1501 void JSGlobalObject::finishCreation(VM& vm, JSObject* thisValue)
1502 {
1503     Base::finishCreation(vm);
1504     structure()->setGlobalObject(vm, this);
1505     m_runtimeFlags = m_globalObjectMethodTable->javaScriptRuntimeFlags(this);
1506     init(vm);
1507     setGlobalThis(vm, thisValue);
1508 }
1509
1510 } // namespace JSC