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