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