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