2 * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Cameron Zwarich (cwzwarich@uwaterloo.ca)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
31 #include "JSGlobalObject.h"
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 "BooleanConstructor.h"
45 #include "BooleanPrototype.h"
46 #include "BuiltinNames.h"
47 #include "CatchScope.h"
48 #include "ClonedArguments.h"
49 #include "CodeBlock.h"
50 #include "CodeCache.h"
51 #include "ConsoleObject.h"
52 #include "DateConstructor.h"
53 #include "DatePrototype.h"
55 #include "DebuggerScope.h"
56 #include "DirectArguments.h"
57 #include "DirectEvalExecutable.h"
58 #include "ECMAScriptSpecInternalFunctions.h"
60 #include "ErrorConstructor.h"
61 #include "ErrorPrototype.h"
62 #include "FunctionConstructor.h"
63 #include "FunctionPrototype.h"
64 #include "GeneratorFunctionConstructor.h"
65 #include "GeneratorFunctionPrototype.h"
66 #include "GeneratorPrototype.h"
67 #include "GetterSetter.h"
68 #include "HeapIterationScope.h"
69 #include "IndirectEvalExecutable.h"
70 #include "InspectorInstrumentationObject.h"
71 #include "Interpreter.h"
72 #include "IteratorPrototype.h"
73 #include "JSAPIWrapperObject.h"
74 #include "JSArrayBuffer.h"
75 #include "JSArrayBufferConstructor.h"
76 #include "JSArrayBufferPrototype.h"
77 #include "JSAsyncFunction.h"
78 #include "JSAsyncGeneratorFunction.h"
79 #include "JSBoundFunction.h"
80 #include "JSCInlines.h"
81 #include "JSCallbackConstructor.h"
82 #include "JSCallbackFunction.h"
83 #include "JSCallbackObject.h"
84 #include "JSCustomGetterSetterFunction.h"
85 #include "JSDataView.h"
86 #include "JSDataViewPrototype.h"
87 #include "JSDollarVM.h"
88 #include "JSDollarVMPrototype.h"
89 #include "JSFunction.h"
90 #include "JSGeneratorFunction.h"
91 #include "JSGenericTypedArrayViewConstructorInlines.h"
92 #include "JSGenericTypedArrayViewInlines.h"
93 #include "JSGenericTypedArrayViewPrototypeInlines.h"
94 #include "JSGlobalObjectFunctions.h"
95 #include "JSInternalPromise.h"
96 #include "JSInternalPromiseConstructor.h"
97 #include "JSInternalPromisePrototype.h"
99 #include "JSLexicalEnvironment.h"
102 #include "JSModuleEnvironment.h"
103 #include "JSModuleLoader.h"
104 #include "JSModuleNamespaceObject.h"
105 #include "JSModuleRecord.h"
106 #include "JSNativeStdFunction.h"
107 #include "JSONObject.h"
108 #include "JSPromise.h"
109 #include "JSPromiseConstructor.h"
110 #include "JSPromisePrototype.h"
112 #include "JSStringIterator.h"
113 #include "JSTemplateRegistryKey.h"
114 #include "JSTypedArrayConstructors.h"
115 #include "JSTypedArrayPrototypes.h"
116 #include "JSTypedArrayViewConstructor.h"
117 #include "JSTypedArrayViewPrototype.h"
118 #include "JSTypedArrays.h"
119 #include "JSWeakMap.h"
120 #include "JSWeakSet.h"
121 #include "JSWebAssembly.h"
122 #include "JSWithScope.h"
123 #include "LazyClassStructureInlines.h"
124 #include "LazyPropertyInlines.h"
126 #include "MapConstructor.h"
127 #include "MapIteratorPrototype.h"
128 #include "MapPrototype.h"
129 #include "MarkedSpaceInlines.h"
130 #include "MathObject.h"
131 #include "Microtask.h"
132 #include "ModuleLoaderPrototype.h"
133 #include "NativeErrorConstructor.h"
134 #include "NativeErrorPrototype.h"
135 #include "NullGetterFunction.h"
136 #include "NullSetterFunction.h"
137 #include "NumberConstructor.h"
138 #include "NumberPrototype.h"
139 #include "ObjCCallbackFunction.h"
140 #include "ObjectConstructor.h"
141 #include "ObjectPropertyChangeAdaptiveWatchpoint.h"
142 #include "ObjectPropertyConditionSet.h"
143 #include "ObjectPrototype.h"
144 #include "ParserError.h"
145 #include "ProxyConstructor.h"
146 #include "ProxyObject.h"
147 #include "ProxyRevoke.h"
148 #include "ReflectObject.h"
149 #include "RegExpConstructor.h"
150 #include "RegExpMatchesArray.h"
151 #include "RegExpObject.h"
152 #include "RegExpPrototype.h"
153 #include "ScopedArguments.h"
154 #include "SetConstructor.h"
155 #include "SetIteratorPrototype.h"
156 #include "SetPrototype.h"
157 #include "StrictEvalActivation.h"
158 #include "StringConstructor.h"
159 #include "StringIteratorPrototype.h"
160 #include "StringPrototype.h"
162 #include "SymbolConstructor.h"
163 #include "SymbolObject.h"
164 #include "SymbolPrototype.h"
165 #include "VariableWriteFireDetail.h"
166 #include "WeakGCMapInlines.h"
167 #include "WeakMapConstructor.h"
168 #include "WeakMapPrototype.h"
169 #include "WeakSetConstructor.h"
170 #include "WeakSetPrototype.h"
171 #include "WebAssemblyToJSCallee.h"
172 #include <wtf/RandomNumber.h>
175 #include "IntlObject.h"
176 #include <unicode/ucol.h>
177 #include <unicode/udat.h>
178 #include <unicode/unum.h>
179 #endif // ENABLE(INTL)
181 #if ENABLE(REMOTE_INSPECTOR)
182 #include "JSGlobalObjectDebuggable.h"
183 #include "JSGlobalObjectInspectorController.h"
188 static JSValue createProxyProperty(VM& vm, JSObject* object)
190 JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
191 return ProxyConstructor::create(vm, ProxyConstructor::createStructure(vm, global, global->functionPrototype()));
194 static JSValue createJSONProperty(VM& vm, JSObject* object)
196 JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
197 return JSONObject::create(vm, JSONObject::createStructure(vm, global, global->objectPrototype()));
200 static JSValue createMathProperty(VM& vm, JSObject* object)
202 JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
203 return MathObject::create(vm, global, MathObject::createStructure(vm, global, global->objectPrototype()));
206 static JSValue createConsoleProperty(VM& vm, JSObject* object)
208 JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
209 return ConsoleObject::create(vm, global, ConsoleObject::createStructure(vm, global, constructEmptyObject(global->globalExec())));
212 static JSValue createAtomicsProperty(VM& vm, JSObject* object)
214 JSGlobalObject* global = jsCast<JSGlobalObject*>(object);
215 return AtomicsObject::create(vm, global, AtomicsObject::createStructure(vm, global, global->objectPrototype()));
218 static EncodedJSValue JSC_HOST_CALL makeBoundFunction(ExecState* exec)
221 JSGlobalObject* globalObject = exec->lexicalGlobalObject();
223 JSObject* target = asObject(exec->uncheckedArgument(0));
224 JSValue boundThis = exec->uncheckedArgument(1);
225 JSValue boundArgs = exec->uncheckedArgument(2);
226 JSValue length = exec->uncheckedArgument(3);
227 JSString* name = asString(exec->uncheckedArgument(4));
229 return JSValue::encode(JSBoundFunction::create(
230 vm, exec, globalObject, target, boundThis, boundArgs.isCell() ? jsCast<JSArray*>(boundArgs) : nullptr, length.asInt32(), name->value(exec)));
233 static EncodedJSValue JSC_HOST_CALL hasOwnLengthProperty(ExecState* exec)
236 JSObject* target = asObject(exec->uncheckedArgument(0));
237 return JSValue::encode(jsBoolean(target->hasOwnProperty(exec, vm.propertyNames->length)));
242 #include "JSGlobalObject.lut.h"
246 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, nullptr, CREATE_METHOD_TABLE(JSGlobalObject) };
248 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = {
249 &supportsRichSourceInfo,
250 &shouldInterruptScript,
251 &javaScriptRuntimeFlags,
252 nullptr, // queueTaskToEventLoop
253 &shouldInterruptScriptBeforeTimeout,
254 nullptr, // moduleLoaderImportModule
255 nullptr, // moduleLoaderResolve
256 nullptr, // moduleLoaderFetch
257 nullptr, // moduleLoaderInstantiate
258 nullptr, // moduleLoaderEvaluate
259 nullptr, // promiseRejectionTracker
260 nullptr, // defaultLanguage
263 /* Source for JSGlobalObject.lut.h
264 @begin globalObjectTable
265 isNaN JSBuiltin DontEnum|Function 1
266 isFinite JSBuiltin DontEnum|Function 1
267 escape globalFuncEscape DontEnum|Function 1
268 unescape globalFuncUnescape DontEnum|Function 1
269 decodeURI globalFuncDecodeURI DontEnum|Function 1
270 decodeURIComponent globalFuncDecodeURIComponent DontEnum|Function 1
271 encodeURI globalFuncEncodeURI DontEnum|Function 1
272 encodeURIComponent globalFuncEncodeURIComponent DontEnum|Function 1
273 EvalError JSGlobalObject::m_evalErrorConstructor DontEnum|CellProperty
274 ReferenceError JSGlobalObject::m_referenceErrorConstructor DontEnum|CellProperty
275 SyntaxError JSGlobalObject::m_syntaxErrorConstructor DontEnum|CellProperty
276 URIError JSGlobalObject::m_URIErrorConstructor DontEnum|CellProperty
277 Proxy createProxyProperty DontEnum|PropertyCallback
278 JSON createJSONProperty DontEnum|PropertyCallback
279 Math createMathProperty DontEnum|PropertyCallback
280 Atomics createAtomicsProperty DontEnum|PropertyCallback
281 console createConsoleProperty DontEnum|PropertyCallback
282 Int8Array JSGlobalObject::m_typedArrayInt8 DontEnum|ClassStructure
283 Int16Array JSGlobalObject::m_typedArrayInt16 DontEnum|ClassStructure
284 Int32Array JSGlobalObject::m_typedArrayInt32 DontEnum|ClassStructure
285 Uint8Array JSGlobalObject::m_typedArrayUint8 DontEnum|ClassStructure
286 Uint8ClampedArray JSGlobalObject::m_typedArrayUint8Clamped DontEnum|ClassStructure
287 Uint16Array JSGlobalObject::m_typedArrayUint16 DontEnum|ClassStructure
288 Uint32Array JSGlobalObject::m_typedArrayUint32 DontEnum|ClassStructure
289 Float32Array JSGlobalObject::m_typedArrayFloat32 DontEnum|ClassStructure
290 Float64Array JSGlobalObject::m_typedArrayFloat64 DontEnum|ClassStructure
291 DataView JSGlobalObject::m_typedArrayDataView DontEnum|ClassStructure
292 Date JSGlobalObject::m_dateStructure DontEnum|ClassStructure
293 Boolean JSGlobalObject::m_booleanObjectStructure DontEnum|ClassStructure
294 Number JSGlobalObject::m_numberObjectStructure DontEnum|ClassStructure
295 WeakMap JSGlobalObject::m_weakMapStructure DontEnum|ClassStructure
296 WeakSet JSGlobalObject::m_weakSetStructure DontEnum|ClassStructure
300 static EncodedJSValue JSC_HOST_CALL enqueueJob(ExecState* exec)
303 JSGlobalObject* globalObject = exec->lexicalGlobalObject();
305 JSValue job = exec->argument(0);
306 JSValue arguments = exec->argument(1);
307 ASSERT(arguments.inherits(vm, JSArray::info()));
309 globalObject->queueMicrotask(createJSJob(vm, job, jsCast<JSArray*>(arguments)));
311 return JSValue::encode(jsUndefined());
314 JSGlobalObject::JSGlobalObject(VM& vm, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
315 : Base(vm, structure, 0)
317 , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
318 , m_havingABadTimeWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
319 , m_varInjectionWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
320 , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
321 , m_arrayIteratorProtocolWatchpoint(IsWatched)
322 , m_mapIteratorProtocolWatchpoint(IsWatched)
323 , m_setIteratorProtocolWatchpoint(IsWatched)
324 , m_stringIteratorProtocolWatchpoint(IsWatched)
325 , m_mapSetWatchpoint(IsWatched)
326 , m_setAddWatchpoint(IsWatched)
327 , m_arraySpeciesWatchpoint(ClearWatchpoint)
328 , m_templateRegistry(vm)
330 , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable)
334 JSGlobalObject::~JSGlobalObject()
336 #if ENABLE(REMOTE_INSPECTOR)
337 m_inspectorController->globalObjectDestroyed();
341 m_debugger->detach(this, Debugger::GlobalObjectIsDestructing);
344 void JSGlobalObject::destroy(JSCell* cell)
346 static_cast<JSGlobalObject*>(cell)->JSGlobalObject::~JSGlobalObject();
349 void JSGlobalObject::setGlobalThis(VM& vm, JSObject* globalThis)
351 m_globalThis.set(vm, this, globalThis);
354 static JSObject* getGetterById(ExecState* exec, JSObject* base, const Identifier& ident)
356 JSValue baseValue = JSValue(base);
357 PropertySlot slot(baseValue, PropertySlot::InternalMethodType::VMInquiry);
358 baseValue.getPropertySlot(exec, ident, slot);
359 return slot.getPureResult().toObject(exec);
362 void JSGlobalObject::init(VM& vm)
364 ASSERT(vm.currentThreadIsHoldingAPILock());
365 auto catchScope = DECLARE_CATCH_SCOPE(vm);
367 Base::setStructure(vm, Structure::toCacheableDictionaryTransition(vm, structure()));
371 #if ENABLE(REMOTE_INSPECTOR)
372 m_inspectorController = std::make_unique<Inspector::JSGlobalObjectInspectorController>(*this);
373 m_inspectorDebuggable = std::make_unique<JSGlobalObjectDebuggable>(*this);
374 m_inspectorDebuggable->init();
375 m_consoleClient = m_inspectorController->consoleClient();
378 m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
379 m_calleeStructure.set(vm, this, JSCallee::createStructure(vm, this, jsNull()));
381 m_globalLexicalEnvironment.set(vm, this, JSGlobalLexicalEnvironment::create(vm, JSGlobalLexicalEnvironment::createStructure(vm, this), this));
382 // Need to create the callee structure (above) before creating the callee.
383 JSCallee* globalCallee = JSCallee::create(vm, this, globalScope());
384 m_globalCallee.set(vm, this, globalCallee);
386 ExecState::initGlobalExec(JSGlobalObject::globalExec(), globalCallee);
387 ExecState* exec = JSGlobalObject::globalExec();
389 m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
390 m_customGetterSetterFunctionStructure.initLater(
391 [] (const Initializer<Structure>& init) {
392 init.set(JSCustomGetterSetterFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
394 m_boundFunctionStructure.initLater(
395 [] (const Initializer<Structure>& init) {
396 init.set(JSBoundFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
398 m_getterSetterStructure.set(vm, this, GetterSetter::createStructure(vm, this, jsNull()));
399 m_nativeStdFunctionStructure.initLater(
400 [] (const Initializer<Structure>& init) {
401 init.set(JSNativeStdFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
403 m_namedFunctionStructure.initLater(
404 [] (const Initializer<Structure>& init) {
405 init.set(Structure::addPropertyTransition(init.vm, init.owner->m_functionStructure.get(), init.vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, init.owner->m_functionNameOffset));
407 JSFunction* callFunction = nullptr;
408 JSFunction* applyFunction = nullptr;
409 JSFunction* hasInstanceSymbolFunction = nullptr;
410 m_functionPrototype->addFunctionProperties(exec, this, &callFunction, &applyFunction, &hasInstanceSymbolFunction);
411 m_callFunction.set(vm, this, callFunction);
412 m_applyFunction.set(vm, this, applyFunction);
413 m_arrayProtoToStringFunction.initLater(
414 [] (const Initializer<JSFunction>& init) {
415 init.set(JSFunction::create(init.vm, init.owner, 0, init.vm.propertyNames->toString.string(), arrayProtoFuncToString, NoIntrinsic));
417 m_arrayProtoValuesFunction.initLater(
418 [] (const Initializer<JSFunction>& init) {
419 init.set(JSFunction::create(init.vm, arrayPrototypeValuesCodeGenerator(init.vm), init.owner));
421 m_initializePromiseFunction.initLater(
422 [] (const Initializer<JSFunction>& init) {
423 init.set(JSFunction::create(init.vm, promiseOperationsInitializePromiseCodeGenerator(init.vm), init.owner));
426 m_iteratorProtocolFunction.initLater(
427 [] (const Initializer<JSFunction>& init) {
428 init.set(JSFunction::create(init.vm, iteratorHelpersPerformIterationCodeGenerator(init.vm), init.owner));
431 m_promiseResolveFunction.initLater(
432 [] (const Initializer<JSFunction>& init) {
433 init.set(JSFunction::create(init.vm, promiseConstructorResolveCodeGenerator(init.vm), init.owner));
436 m_newPromiseCapabilityFunction.set(vm, this, JSFunction::create(vm, promiseOperationsNewPromiseCapabilityCodeGenerator(vm), this));
437 m_functionProtoHasInstanceSymbolFunction.set(vm, this, hasInstanceSymbolFunction);
438 m_throwTypeErrorGetterSetter.initLater(
439 [] (const Initializer<GetterSetter>& init) {
440 JSFunction* thrower = init.owner->throwTypeErrorFunction();
441 GetterSetter* getterSetter = GetterSetter::create(init.vm, init.owner);
442 getterSetter->setGetter(init.vm, init.owner, thrower);
443 getterSetter->setSetter(init.vm, init.owner, thrower);
444 init.set(getterSetter);
447 m_nullGetterFunction.set(vm, this, NullGetterFunction::create(vm, NullGetterFunction::createStructure(vm, this, m_functionPrototype.get())));
448 m_nullSetterFunction.set(vm, this, NullSetterFunction::create(vm, NullSetterFunction::createStructure(vm, this, m_functionPrototype.get())));
449 m_objectPrototype.set(vm, this, ObjectPrototype::create(vm, this, ObjectPrototype::createStructure(vm, this, jsNull())));
450 GetterSetter* protoAccessor = GetterSetter::create(vm, this);
451 protoAccessor->setGetter(vm, this, JSFunction::create(vm, this, 0, makeString("get ", vm.propertyNames->underscoreProto.string()), globalFuncProtoGetter));
452 protoAccessor->setSetter(vm, this, JSFunction::create(vm, this, 0, makeString("set ", vm.propertyNames->underscoreProto.string()), globalFuncProtoSetter));
453 m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
454 m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
455 m_objectStructureForObjectConstructor.set(vm, this, vm.prototypeMap.emptyObjectStructureForPrototype(this, m_objectPrototype.get(), JSFinalObject::defaultInlineCapacity()));
456 m_objectProtoValueOfFunction.set(vm, this, jsCast<JSFunction*>(objectPrototype()->getDirect(vm, vm.propertyNames->valueOf)));
458 JSFunction* thrower = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeErrorArgumentsCalleeAndCaller);
459 GetterSetter* getterSetter = GetterSetter::create(vm, this);
460 getterSetter->setGetter(vm, this, thrower);
461 getterSetter->setSetter(vm, this, thrower);
462 m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter.set(vm, this, getterSetter);
464 m_functionPrototype->initRestrictedProperties(exec, this);
466 m_speciesGetterSetter.set(vm, this, GetterSetter::create(vm, this));
467 m_speciesGetterSetter->setGetter(vm, this, JSFunction::create(vm, globalOperationsSpeciesGetterCodeGenerator(vm), this));
469 m_typedArrayProto.initLater(
470 [] (const Initializer<JSTypedArrayViewPrototype>& init) {
471 init.set(JSTypedArrayViewPrototype::create(init.vm, init.owner, JSTypedArrayViewPrototype::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get())));
473 // Make sure that the constructor gets initialized, too.
474 init.owner->m_typedArraySuperConstructor.get(init.owner);
476 m_typedArraySuperConstructor.initLater(
477 [] (const Initializer<JSTypedArrayViewConstructor>& init) {
478 JSTypedArrayViewPrototype* prototype = init.owner->m_typedArrayProto.get(init.owner);
479 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());
480 prototype->putDirectWithoutTransition(init.vm, init.vm.propertyNames->constructor, constructor, DontEnum);
481 init.set(constructor);
484 #define INIT_TYPED_ARRAY_LATER(type) \
485 m_typedArray ## type.initLater( \
486 [] (LazyClassStructure::Initializer& init) { \
487 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)))); \
488 init.setStructure(JS ## type ## Array::createStructure(init.vm, init.global, init.prototype)); \
489 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))); \
490 init.global->putDirectWithoutTransition(init.vm, init.vm.propertyNames->builtinNames().type ## ArrayPrivateName(), init.constructor, DontEnum); \
492 FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(INIT_TYPED_ARRAY_LATER)
493 #undef INIT_TYPED_ARRAY_LATER
495 m_typedArrayDataView.initLater(
496 [] (LazyClassStructure::Initializer& init) {
497 init.setPrototype(JSDataViewPrototype::create(init.vm, JSDataViewPrototype::createStructure(init.vm, init.global, init.global->m_objectPrototype.get())));
498 init.setStructure(JSDataView::createStructure(init.vm, init.global, init.prototype));
499 init.setConstructor(JSDataViewConstructor::create(init.vm, init.global, JSDataViewConstructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), init.prototype, ASCIILiteral("DataView"), nullptr));
502 m_lexicalEnvironmentStructure.set(vm, this, JSLexicalEnvironment::createStructure(vm, this));
503 m_moduleEnvironmentStructure.initLater(
504 [] (const Initializer<Structure>& init) {
505 init.set(JSModuleEnvironment::createStructure(init.vm, init.owner));
507 m_strictEvalActivationStructure.set(vm, this, StrictEvalActivation::createStructure(vm, this, jsNull()));
508 m_debuggerScopeStructure.initLater(
509 [] (const Initializer<Structure>& init) {
510 init.set(DebuggerScope::createStructure(init.vm, init.owner));
512 m_withScopeStructure.initLater(
513 [] (const Initializer<Structure>& init) {
514 init.set(JSWithScope::createStructure(init.vm, init.owner, jsNull()));
517 m_nullPrototypeObjectStructure.initLater(
518 [] (const Initializer<Structure>& init) {
519 init.set(JSFinalObject::createStructure(init.vm, init.owner, jsNull(), JSFinalObject::defaultInlineCapacity()));
522 m_callbackFunctionStructure.initLater(
523 [] (const Initializer<Structure>& init) {
524 init.set(JSCallbackFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
526 m_directArgumentsStructure.set(vm, this, DirectArguments::createStructure(vm, this, m_objectPrototype.get()));
527 m_scopedArgumentsStructure.set(vm, this, ScopedArguments::createStructure(vm, this, m_objectPrototype.get()));
528 m_clonedArgumentsStructure.set(vm, this, ClonedArguments::createStructure(vm, this, m_objectPrototype.get()));
529 m_callbackConstructorStructure.initLater(
530 [] (const Initializer<Structure>& init) {
531 init.set(JSCallbackConstructor::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
533 m_callbackObjectStructure.initLater(
534 [] (const Initializer<Structure>& init) {
535 init.set(JSCallbackObject<JSDestructibleObject>::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
538 #if JSC_OBJC_API_ENABLED
539 m_objcCallbackFunctionStructure.initLater(
540 [] (const Initializer<Structure>& init) {
541 init.set(ObjCCallbackFunction::createStructure(init.vm, init.owner, init.owner->m_functionPrototype.get()));
543 m_objcWrapperObjectStructure.initLater(
544 [] (const Initializer<Structure>& init) {
545 init.set(JSCallbackObject<JSAPIWrapperObject>::createStructure(init.vm, init.owner, init.owner->m_objectPrototype.get()));
549 m_arrayPrototype.set(vm, this, ArrayPrototype::create(vm, this, ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
551 m_originalArrayStructureForIndexingShape[UndecidedShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithUndecided));
552 m_originalArrayStructureForIndexingShape[Int32Shape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithInt32));
553 m_originalArrayStructureForIndexingShape[DoubleShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithDouble));
554 m_originalArrayStructureForIndexingShape[ContiguousShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithContiguous));
555 m_originalArrayStructureForIndexingShape[ArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithArrayStorage));
556 m_originalArrayStructureForIndexingShape[SlowPutArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithSlowPutArrayStorage));
557 for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
558 m_arrayStructureForIndexingShapeDuringAllocation[i] = m_originalArrayStructureForIndexingShape[i];
560 m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get())));
561 m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
562 m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, this));
564 m_moduleRecordStructure.set(vm, this, JSModuleRecord::createStructure(vm, this, m_objectPrototype.get()));
565 m_moduleNamespaceObjectStructure.set(vm, this, JSModuleNamespaceObject::createStructure(vm, this, jsNull()));
567 bool isCallable = false;
568 m_proxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
570 m_callableProxyObjectStructure.set(vm, this, ProxyObject::createStructure(vm, this, jsNull(), isCallable));
572 m_proxyRevokeStructure.set(vm, this, ProxyRevoke::createStructure(vm, this, m_functionPrototype.get()));
574 m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, ParseIntIntrinsic));
575 putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum);
576 m_parseFloatFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->parseFloat.string(), globalFuncParseFloat, NoIntrinsic));
577 putDirectWithoutTransition(vm, vm.propertyNames->parseFloat, m_parseFloatFunction.get(), DontEnum);
579 m_arrayBufferPrototype.set(vm, this, JSArrayBufferPrototype::create(vm, this, JSArrayBufferPrototype::createStructure(vm, this, m_objectPrototype.get()), ArrayBufferSharingMode::Default));
580 m_arrayBufferStructure.set(vm, this, JSArrayBuffer::createStructure(vm, this, m_arrayBufferPrototype.get()));
581 m_sharedArrayBufferPrototype.set(vm, this, JSArrayBufferPrototype::create(vm, this, JSArrayBufferPrototype::createStructure(vm, this, m_objectPrototype.get()), ArrayBufferSharingMode::Shared));
582 m_sharedArrayBufferStructure.set(vm, this, JSArrayBuffer::createStructure(vm, this, m_sharedArrayBufferPrototype.get()));
584 m_iteratorPrototype.set(vm, this, IteratorPrototype::create(vm, this, IteratorPrototype::createStructure(vm, this, m_objectPrototype.get())));
585 m_asyncIteratorPrototype.set(vm, this, AsyncIteratorPrototype::create(vm, this, AsyncIteratorPrototype::createStructure(vm, this, m_objectPrototype.get())));
587 m_generatorPrototype.set(vm, this, GeneratorPrototype::create(vm, this, GeneratorPrototype::createStructure(vm, this, m_iteratorPrototype.get())));
588 m_asyncGeneratorPrototype.set(vm, this, AsyncGeneratorPrototype::create(vm, this, AsyncGeneratorPrototype::createStructure(vm, this, m_asyncIteratorPrototype.get())));
590 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
591 m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
592 m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
594 FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
595 FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
597 #undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
599 #define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
600 m_ ## properName ## Structure.initLater(\
601 [] (LazyClassStructure::Initializer& init) { \
602 init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_ ## prototypeBase ## Prototype.get()))); \
603 init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
604 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())); \
607 FOR_EACH_LAZY_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_LAZY_TYPE)
609 #undef CREATE_PROTOTYPE_FOR_LAZY_TYPE
611 m_moduleLoaderPrototype.set(vm, this, ModuleLoaderPrototype::create(vm, this, ModuleLoaderPrototype::createStructure(vm, this, m_objectPrototype.get())));
615 ObjectConstructor* objectConstructor = ObjectConstructor::create(vm, this, ObjectConstructor::createStructure(vm, this, m_functionPrototype.get()), m_objectPrototype.get());
616 m_objectConstructor.set(vm, this, objectConstructor);
618 JSFunction* throwTypeErrorFunction = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeError);
619 m_throwTypeErrorFunction.set(vm, this, throwTypeErrorFunction);
621 JSCell* functionConstructor = FunctionConstructor::create(vm, FunctionConstructor::createStructure(vm, this, m_functionPrototype.get()), m_functionPrototype.get());
623 ArrayConstructor* arrayConstructor = ArrayConstructor::create(vm, this, ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayPrototype.get(), m_speciesGetterSetter.get());
624 m_arrayConstructor.set(vm, this, arrayConstructor);
626 m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get(), m_speciesGetterSetter.get()));
628 JSArrayBufferConstructor* arrayBufferConstructor = JSArrayBufferConstructor::create(vm, JSArrayBufferConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayBufferPrototype.get(), m_speciesGetterSetter.get(), ArrayBufferSharingMode::Default);
629 m_arrayBufferPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayBufferConstructor, DontEnum);
630 JSArrayBufferConstructor* sharedArrayBufferConstructor = nullptr;
631 sharedArrayBufferConstructor = JSArrayBufferConstructor::create(vm, JSArrayBufferConstructor::createStructure(vm, this, m_functionPrototype.get()), m_sharedArrayBufferPrototype.get(), m_speciesGetterSetter.get(), ArrayBufferSharingMode::Shared);
632 m_sharedArrayBufferPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, sharedArrayBufferConstructor, DontEnum);
634 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
635 capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
636 m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, DontEnum); \
638 FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE)
640 #undef CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE
642 m_errorConstructor.set(vm, this, errorConstructor);
643 m_promiseConstructor.set(vm, this, promiseConstructor);
644 m_internalPromiseConstructor.set(vm, this, internalPromiseConstructor);
646 m_nativeErrorPrototypeStructure.set(vm, this, NativeErrorPrototype::createStructure(vm, this, m_errorPrototype.get()));
647 m_nativeErrorStructure.set(vm, this, NativeErrorConstructor::createStructure(vm, this, errorConstructor));
648 m_evalErrorConstructor.initLater(
649 [] (const Initializer<NativeErrorConstructor>& init) {
650 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("EvalError")));
652 m_rangeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), ASCIILiteral("RangeError")));
653 m_referenceErrorConstructor.initLater(
654 [] (const Initializer<NativeErrorConstructor>& init) {
655 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("ReferenceError")));
657 m_syntaxErrorConstructor.initLater(
658 [] (const Initializer<NativeErrorConstructor>& init) {
659 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("SyntaxError")));
661 m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), ASCIILiteral("TypeError")));
662 m_URIErrorConstructor.initLater(
663 [] (const Initializer<NativeErrorConstructor>& init) {
664 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), ASCIILiteral("URIError")));
667 m_generatorFunctionPrototype.set(vm, this, GeneratorFunctionPrototype::create(vm, GeneratorFunctionPrototype::createStructure(vm, this, m_functionPrototype.get())));
668 GeneratorFunctionConstructor* generatorFunctionConstructor = GeneratorFunctionConstructor::create(vm, GeneratorFunctionConstructor::createStructure(vm, this, functionConstructor), m_generatorFunctionPrototype.get());
669 m_generatorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, generatorFunctionConstructor, DontEnum | ReadOnly);
670 m_generatorFunctionStructure.set(vm, this, JSGeneratorFunction::createStructure(vm, this, m_generatorFunctionPrototype.get()));
672 m_generatorPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_generatorFunctionPrototype.get(), DontEnum | ReadOnly);
673 m_generatorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->prototype, m_generatorPrototype.get(), DontEnum | ReadOnly);
675 m_asyncFunctionPrototype.set(vm, this, AsyncFunctionPrototype::create(vm, AsyncFunctionPrototype::createStructure(vm, this, m_functionPrototype.get())));
676 AsyncFunctionConstructor* asyncFunctionConstructor = AsyncFunctionConstructor::create(vm, AsyncFunctionConstructor::createStructure(vm, this, functionConstructor), m_asyncFunctionPrototype.get());
677 m_asyncFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, asyncFunctionConstructor, DontEnum | ReadOnly);
678 m_asyncFunctionStructure.set(vm, this, JSAsyncFunction::createStructure(vm, this, m_asyncFunctionPrototype.get()));
680 m_asyncGeneratorFunctionPrototype.set(vm, this, AsyncGeneratorFunctionPrototype::create(vm, AsyncGeneratorFunctionPrototype::createStructure(vm, this, m_functionPrototype.get())));
681 AsyncGeneratorFunctionConstructor* asyncGeneratorFunctionConstructor = AsyncGeneratorFunctionConstructor::create(vm, AsyncGeneratorFunctionConstructor::createStructure(vm, this, functionConstructor), m_asyncGeneratorFunctionPrototype.get());
682 m_asyncGeneratorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, asyncGeneratorFunctionConstructor, DontEnum | ReadOnly);
683 m_asyncGeneratorFunctionStructure.set(vm, this, JSAsyncGeneratorFunction::createStructure(vm, this, m_asyncGeneratorFunctionPrototype.get()));
685 m_asyncGeneratorPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_asyncGeneratorFunctionPrototype.get(), DontEnum | ReadOnly);
686 m_asyncGeneratorFunctionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->prototype, m_asyncGeneratorPrototype.get(), DontEnum | ReadOnly);
689 m_objectPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, objectConstructor, DontEnum);
690 m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, DontEnum);
691 m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, DontEnum);
692 m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_regExpConstructor.get(), DontEnum);
694 putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum);
695 putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, DontEnum);
696 putDirectWithoutTransition(vm, vm.propertyNames->Array, arrayConstructor, DontEnum);
697 putDirectWithoutTransition(vm, vm.propertyNames->RegExp, m_regExpConstructor.get(), DontEnum);
698 putDirectWithoutTransition(vm, vm.propertyNames->RangeError, m_rangeErrorConstructor.get(), DontEnum);
699 putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum);
701 putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ObjectPrivateName(), objectConstructor, DontEnum | DontDelete | ReadOnly);
702 putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ArrayPrivateName(), arrayConstructor, DontEnum | DontDelete | ReadOnly);
704 putDirectWithoutTransition(vm, vm.propertyNames->ArrayBuffer, arrayBufferConstructor, DontEnum);
705 putDirectWithoutTransition(vm, vm.propertyNames->SharedArrayBuffer, sharedArrayBufferConstructor, DontEnum);
707 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
708 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, DontEnum); \
710 FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
712 #undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
713 m_iteratorResultObjectStructure.set(vm, this, createIteratorResultObjectStructure(vm, *this));
715 m_evalFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->eval.string(), globalFuncEval));
716 putDirectWithoutTransition(vm, vm.propertyNames->eval, m_evalFunction.get(), DontEnum);
719 IntlObject* intl = IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
720 putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, DontEnum);
721 #endif // ENABLE(INTL)
722 ReflectObject* reflectObject = ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get()));
723 putDirectWithoutTransition(vm, vm.propertyNames->Reflect, reflectObject, DontEnum);
725 m_moduleLoaderStructure.set(vm, this, JSModuleLoader::createStructure(vm, this, m_moduleLoaderPrototype.get()));
726 m_moduleLoader.set(vm, this, JSModuleLoader::create(globalExec(), vm, this, m_moduleLoaderStructure.get()));
727 if (Options::exposeInternalModuleLoader())
728 putDirectWithoutTransition(vm, vm.propertyNames->Loader, m_moduleLoader.get(), DontEnum);
730 JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
732 JSFunction* privateFuncAbs = JSFunction::create(vm, this, 0, String(), mathProtoFuncAbs, AbsIntrinsic);
733 JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
734 JSFunction* privateFuncTrunc = JSFunction::create(vm, this, 0, String(), mathProtoFuncTrunc, TruncIntrinsic);
736 JSFunction* privateFuncGetOwnPropertyNames = JSFunction::create(vm, this, 0, String(), objectConstructorGetOwnPropertyNames);
737 JSFunction* privateFuncPropertyIsEnumerable = JSFunction::create(vm, this, 0, String(), globalFuncPropertyIsEnumerable);
738 JSFunction* privateFuncImportModule = JSFunction::create(vm, this, 0, String(), globalFuncImportModule);
739 JSFunction* privateFuncTypedArrayLength = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncLength);
740 JSFunction* privateFuncTypedArrayGetOriginalConstructor = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncGetOriginalConstructor);
741 JSFunction* privateFuncTypedArraySort = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSort);
742 JSFunction* privateFuncIsTypedArrayView = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncIsTypedArrayView, IsTypedArrayViewIntrinsic);
743 JSFunction* privateFuncTypedArraySubarrayCreate = JSFunction::create(vm, this, 0, String(), typedArrayViewPrivateFuncSubarrayCreate);
744 JSFunction* privateFuncIsBoundFunction = JSFunction::create(vm, this, 0, String(), isBoundFunction);
745 JSFunction* privateFuncHasInstanceBoundFunction = JSFunction::create(vm, this, 0, String(), hasInstanceBoundFunction);
746 JSFunction* privateFuncInstanceOf = JSFunction::create(vm, this, 0, String(), objectPrivateFuncInstanceOf);
747 JSFunction* privateFuncThisTimeValue = JSFunction::create(vm, this, 0, String(), dateProtoFuncGetTime);
748 JSFunction* privateFuncThisNumberValue = JSFunction::create(vm, this, 0, String(), numberProtoFuncValueOf);
749 JSFunction* privateFuncIsArrayConstructor = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArrayConstructor);
750 JSFunction* privateFuncIsArraySlow = JSFunction::create(vm, this, 0, String(), arrayConstructorPrivateFuncIsArraySlow);
751 JSFunction* privateFuncConcatMemcpy = JSFunction::create(vm, this, 0, String(), arrayProtoPrivateFuncConcatMemcpy);
752 JSFunction* privateFuncAppendMemcpy = JSFunction::create(vm, this, 0, String(), arrayProtoPrivateFuncAppendMemcpy);
753 JSFunction* privateFuncMapBucketHead = JSFunction::create(vm, this, 0, String(), mapPrivateFuncMapBucketHead, JSMapBucketHeadIntrinsic);
754 JSFunction* privateFuncMapBucketNext = JSFunction::create(vm, this, 0, String(), mapPrivateFuncMapBucketNext, JSMapBucketNextIntrinsic);
755 JSFunction* privateFuncMapBucketKey = JSFunction::create(vm, this, 0, String(), mapPrivateFuncMapBucketKey, JSMapBucketKeyIntrinsic);
756 JSFunction* privateFuncMapBucketValue = JSFunction::create(vm, this, 0, String(), mapPrivateFuncMapBucketValue, JSMapBucketValueIntrinsic);
757 JSFunction* privateFuncSetBucketHead = JSFunction::create(vm, this, 0, String(), setPrivateFuncSetBucketHead, JSSetBucketHeadIntrinsic);
758 JSFunction* privateFuncSetBucketNext = JSFunction::create(vm, this, 0, String(), setPrivateFuncSetBucketNext, JSSetBucketNextIntrinsic);
759 JSFunction* privateFuncSetBucketKey = JSFunction::create(vm, this, 0, String(), setPrivateFuncSetBucketKey, JSSetBucketKeyIntrinsic);
761 JSObject* regExpProtoFlagsGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->flags);
762 catchScope.assertNoException();
763 JSObject* regExpProtoGlobalGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->global);
764 catchScope.assertNoException();
765 m_regExpProtoGlobalGetter.set(vm, this, regExpProtoGlobalGetterObject);
766 JSObject* regExpProtoIgnoreCaseGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->ignoreCase);
767 catchScope.assertNoException();
768 JSObject* regExpProtoMultilineGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->multiline);
769 catchScope.assertNoException();
770 JSObject* regExpProtoSourceGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->source);
771 catchScope.assertNoException();
772 JSObject* regExpProtoStickyGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->sticky);
773 catchScope.assertNoException();
774 JSObject* regExpProtoUnicodeGetterObject = getGetterById(exec, m_regExpPrototype.get(), vm.propertyNames->unicode);
775 catchScope.assertNoException();
776 m_regExpProtoUnicodeGetter.set(vm, this, regExpProtoUnicodeGetterObject);
777 JSObject* builtinRegExpExec = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->exec).asCell());
778 m_regExpProtoExec.set(vm, this, builtinRegExpExec);
779 JSObject* regExpSymbolReplace = asObject(m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol).asCell());
780 m_regExpProtoSymbolReplace.set(vm, this, regExpSymbolReplace);
782 #define CREATE_PRIVATE_GLOBAL_FUNCTION(name, code) JSFunction* name ## PrivateFunction = JSFunction::create(vm, code ## CodeGenerator(vm), this);
783 JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(CREATE_PRIVATE_GLOBAL_FUNCTION)
784 #undef CREATE_PRIVATE_GLOBAL_FUNCTION
786 JSObject* arrayIteratorPrototype = ArrayIteratorPrototype::create(vm, this, ArrayIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
787 createArrayIteratorPrivateFunction->putDirect(vm, vm.propertyNames->prototype, arrayIteratorPrototype);
789 JSObject* asyncFromSyncIteratorPrototype = AsyncFromSyncIteratorPrototype::create(vm, this, AsyncFromSyncIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
790 AsyncFromSyncIteratorConstructorPrivateFunction->putDirect(vm, vm.propertyNames->prototype, asyncFromSyncIteratorPrototype);
792 JSObject* mapIteratorPrototype = MapIteratorPrototype::create(vm, this, MapIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
793 createMapIteratorPrivateFunction->putDirect(vm, vm.propertyNames->prototype, mapIteratorPrototype);
795 JSObject* setIteratorPrototype = SetIteratorPrototype::create(vm, this, SetIteratorPrototype::createStructure(vm, this, m_iteratorPrototype.get()));
796 createSetIteratorPrivateFunction->putDirect(vm, vm.propertyNames->prototype, setIteratorPrototype);
798 GlobalPropertyInfo staticGlobals[] = {
799 #define INIT_PRIVATE_GLOBAL(name, code) GlobalPropertyInfo(vm.propertyNames->builtinNames().name ## PrivateName(), name ## PrivateFunction, DontEnum | DontDelete | ReadOnly),
800 JSC_FOREACH_BUILTIN_FUNCTION_PRIVATE_GLOBAL_NAME(INIT_PRIVATE_GLOBAL)
801 #undef INIT_PRIVATE_GLOBAL
802 GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
803 GlobalPropertyInfo(vm.propertyNames->Infinity, jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
804 GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
805 GlobalPropertyInfo(vm.propertyNames->builtinNames().getOwnPropertyNamesPrivateName(), privateFuncGetOwnPropertyNames, DontEnum | DontDelete | ReadOnly),
806 GlobalPropertyInfo(vm.propertyNames->builtinNames().propertyIsEnumerablePrivateName(), privateFuncPropertyIsEnumerable, DontEnum | DontDelete | ReadOnly),
807 GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, DontEnum | DontDelete | ReadOnly),
808 GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
809 GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), m_errorConstructor.get(), DontEnum | DontDelete | ReadOnly),
810 GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
811 GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
812 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayLengthPrivateName(), privateFuncTypedArrayLength, DontEnum | DontDelete | ReadOnly),
813 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayGetOriginalConstructorPrivateName(), privateFuncTypedArrayGetOriginalConstructor, DontEnum | DontDelete | ReadOnly),
814 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArraySortPrivateName(), privateFuncTypedArraySort, DontEnum | DontDelete | ReadOnly),
815 GlobalPropertyInfo(vm.propertyNames->builtinNames().isTypedArrayViewPrivateName(), privateFuncIsTypedArrayView, DontEnum | DontDelete | ReadOnly),
816 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArraySubarrayCreatePrivateName(), privateFuncTypedArraySubarrayCreate, DontEnum | DontDelete | ReadOnly),
817 GlobalPropertyInfo(vm.propertyNames->builtinNames().isBoundFunctionPrivateName(), privateFuncIsBoundFunction, DontEnum | DontDelete | ReadOnly),
818 GlobalPropertyInfo(vm.propertyNames->builtinNames().hasInstanceBoundFunctionPrivateName(), privateFuncHasInstanceBoundFunction, DontEnum | DontDelete | ReadOnly),
819 GlobalPropertyInfo(vm.propertyNames->builtinNames().instanceOfPrivateName(), privateFuncInstanceOf, DontEnum | DontDelete | ReadOnly),
820 GlobalPropertyInfo(vm.propertyNames->builtinNames().BuiltinLogPrivateName(), builtinLog, DontEnum | DontDelete | ReadOnly),
821 GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberPrivateName(), numberConstructor, DontEnum | DontDelete | ReadOnly),
822 GlobalPropertyInfo(vm.propertyNames->builtinNames().RegExpPrivateName(), m_regExpConstructor.get(), DontEnum | DontDelete | ReadOnly),
823 GlobalPropertyInfo(vm.propertyNames->builtinNames().StringPrivateName(), stringConstructor, DontEnum | DontDelete | ReadOnly),
824 GlobalPropertyInfo(vm.propertyNames->builtinNames().absPrivateName(), privateFuncAbs, DontEnum | DontDelete | ReadOnly),
825 GlobalPropertyInfo(vm.propertyNames->builtinNames().floorPrivateName(), privateFuncFloor, DontEnum | DontDelete | ReadOnly),
826 GlobalPropertyInfo(vm.propertyNames->builtinNames().truncPrivateName(), privateFuncTrunc, DontEnum | DontDelete | ReadOnly),
827 GlobalPropertyInfo(vm.propertyNames->builtinNames().PromisePrivateName(), promiseConstructor, DontEnum | DontDelete | ReadOnly),
828 GlobalPropertyInfo(vm.propertyNames->builtinNames().ReflectPrivateName(), reflectObject, DontEnum | DontDelete | ReadOnly),
829 GlobalPropertyInfo(vm.propertyNames->builtinNames().InternalPromisePrivateName(), internalPromiseConstructor, DontEnum | DontDelete | ReadOnly),
831 GlobalPropertyInfo(vm.propertyNames->builtinNames().repeatCharacterPrivateName(), JSFunction::create(vm, this, 2, String(), stringProtoFuncRepeatCharacter), DontEnum | DontDelete | ReadOnly),
832 GlobalPropertyInfo(vm.propertyNames->builtinNames().isArrayPrivateName(), arrayConstructor->getDirect(vm, vm.propertyNames->isArray), DontEnum | DontDelete | ReadOnly),
833 GlobalPropertyInfo(vm.propertyNames->builtinNames().isArraySlowPrivateName(), privateFuncIsArraySlow, DontEnum | DontDelete | ReadOnly),
834 GlobalPropertyInfo(vm.propertyNames->builtinNames().isArrayConstructorPrivateName(), privateFuncIsArrayConstructor, DontEnum | DontDelete | ReadOnly),
835 GlobalPropertyInfo(vm.propertyNames->builtinNames().concatMemcpyPrivateName(), privateFuncConcatMemcpy, DontEnum | DontDelete | ReadOnly),
836 GlobalPropertyInfo(vm.propertyNames->builtinNames().appendMemcpyPrivateName(), privateFuncAppendMemcpy, DontEnum | DontDelete | ReadOnly),
838 GlobalPropertyInfo(vm.propertyNames->builtinNames().hostPromiseRejectionTrackerPrivateName(), JSFunction::create(vm, this, 2, String(), globalFuncHostPromiseRejectionTracker), DontEnum | DontDelete | ReadOnly),
839 GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly),
840 GlobalPropertyInfo(vm.propertyNames->builtinNames().MapPrivateName(), mapConstructor, DontEnum | DontDelete | ReadOnly),
841 GlobalPropertyInfo(vm.propertyNames->builtinNames().SetPrivateName(), setConstructor, DontEnum | DontDelete | ReadOnly),
842 GlobalPropertyInfo(vm.propertyNames->builtinNames().thisTimeValuePrivateName(), privateFuncThisTimeValue, DontEnum | DontDelete | ReadOnly),
843 GlobalPropertyInfo(vm.propertyNames->builtinNames().thisNumberValuePrivateName(), privateFuncThisNumberValue, DontEnum | DontDelete | ReadOnly),
845 GlobalPropertyInfo(vm.propertyNames->builtinNames().CollatorPrivateName(), intl->getDirect(vm, vm.propertyNames->Collator), DontEnum | DontDelete | ReadOnly),
846 GlobalPropertyInfo(vm.propertyNames->builtinNames().DateTimeFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->DateTimeFormat), DontEnum | DontDelete | ReadOnly),
847 GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->NumberFormat), DontEnum | DontDelete | ReadOnly),
848 #endif // ENABLE(INTL)
850 GlobalPropertyInfo(vm.propertyNames->builtinNames().isConstructorPrivateName(), JSFunction::create(vm, this, 1, String(), esSpecIsConstructor, NoIntrinsic), DontEnum | DontDelete | ReadOnly),
852 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoFlagsGetterPrivateName(), regExpProtoFlagsGetterObject, DontEnum | DontDelete | ReadOnly),
853 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoGlobalGetterPrivateName(), regExpProtoGlobalGetterObject, DontEnum | DontDelete | ReadOnly),
854 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoIgnoreCaseGetterPrivateName(), regExpProtoIgnoreCaseGetterObject, DontEnum | DontDelete | ReadOnly),
855 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoMultilineGetterPrivateName(), regExpProtoMultilineGetterObject, DontEnum | DontDelete | ReadOnly),
856 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoSourceGetterPrivateName(), regExpProtoSourceGetterObject, DontEnum | DontDelete | ReadOnly),
857 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoStickyGetterPrivateName(), regExpProtoStickyGetterObject, DontEnum | DontDelete | ReadOnly),
858 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpProtoUnicodeGetterPrivateName(), regExpProtoUnicodeGetterObject, DontEnum | DontDelete | ReadOnly),
860 // RegExp.prototype helpers.
861 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpBuiltinExecPrivateName(), builtinRegExpExec, DontEnum | DontDelete | ReadOnly),
862 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpCreatePrivateName(), JSFunction::create(vm, this, 2, String(), esSpecRegExpCreate, NoIntrinsic), DontEnum | DontDelete | ReadOnly),
863 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpMatchFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncMatchFast), DontEnum | DontDelete | ReadOnly),
864 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpSearchFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncSearchFast), DontEnum | DontDelete | ReadOnly),
865 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpSplitFastPrivateName(), JSFunction::create(vm, this, 2, String(), regExpProtoFuncSplitFast), DontEnum | DontDelete | ReadOnly),
866 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpPrototypeSymbolReplacePrivateName(), m_regExpPrototype->getDirect(vm, vm.propertyNames->replaceSymbol), DontEnum | DontDelete | ReadOnly),
867 GlobalPropertyInfo(vm.propertyNames->builtinNames().regExpTestFastPrivateName(), JSFunction::create(vm, this, 1, String(), regExpProtoFuncTestFast, RegExpTestFastIntrinsic), DontEnum | DontDelete | ReadOnly),
869 // String.prototype helpers.
870 GlobalPropertyInfo(vm.propertyNames->builtinNames().stringIncludesInternalPrivateName(), JSFunction::create(vm, this, 1, String(), builtinStringIncludesInternal), DontEnum | DontDelete | ReadOnly),
871 GlobalPropertyInfo(vm.propertyNames->builtinNames().stringSplitFastPrivateName(), JSFunction::create(vm, this, 2, String(), stringProtoFuncSplitFast), DontEnum | DontDelete | ReadOnly),
872 GlobalPropertyInfo(vm.propertyNames->builtinNames().stringSubstrInternalPrivateName(), JSFunction::create(vm, this, 2, String(), builtinStringSubstrInternal), DontEnum | DontDelete | ReadOnly),
874 // Function prototype helpers.
875 GlobalPropertyInfo(vm.propertyNames->builtinNames().makeBoundFunctionPrivateName(), JSFunction::create(vm, this, 5, String(), makeBoundFunction), DontEnum | DontDelete | ReadOnly),
876 GlobalPropertyInfo(vm.propertyNames->builtinNames().hasOwnLengthPropertyPrivateName(), JSFunction::create(vm, this, 1, String(), hasOwnLengthProperty), DontEnum | DontDelete | ReadOnly),
878 // Map and Set helpers.
879 GlobalPropertyInfo(vm.propertyNames->builtinNames().mapBucketHeadPrivateName(), privateFuncMapBucketHead, DontEnum | DontDelete | ReadOnly),
880 GlobalPropertyInfo(vm.propertyNames->builtinNames().mapBucketNextPrivateName(), privateFuncMapBucketNext, DontEnum | DontDelete | ReadOnly),
881 GlobalPropertyInfo(vm.propertyNames->builtinNames().mapBucketKeyPrivateName(), privateFuncMapBucketKey, DontEnum | DontDelete | ReadOnly),
882 GlobalPropertyInfo(vm.propertyNames->builtinNames().mapBucketValuePrivateName(), privateFuncMapBucketValue, DontEnum | DontDelete | ReadOnly),
883 GlobalPropertyInfo(vm.propertyNames->builtinNames().setBucketHeadPrivateName(), privateFuncSetBucketHead, DontEnum | DontDelete | ReadOnly),
884 GlobalPropertyInfo(vm.propertyNames->builtinNames().setBucketNextPrivateName(), privateFuncSetBucketNext, DontEnum | DontDelete | ReadOnly),
885 GlobalPropertyInfo(vm.propertyNames->builtinNames().setBucketKeyPrivateName(), privateFuncSetBucketKey, DontEnum | DontDelete | ReadOnly),
887 addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
889 m_specialPointers[Special::CallFunction] = m_callFunction.get();
890 m_specialPointers[Special::ApplyFunction] = m_applyFunction.get();
891 m_specialPointers[Special::ObjectConstructor] = objectConstructor;
892 m_specialPointers[Special::ArrayConstructor] = arrayConstructor;
894 m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::ThrowTypeErrorFunction)] = m_throwTypeErrorFunction.get();
896 if (UNLIKELY(Options::useDollarVM())) {
897 JSDollarVMPrototype* dollarVMPrototype = JSDollarVMPrototype::create(vm, this, JSDollarVMPrototype::createStructure(vm, this, m_objectPrototype.get()));
898 m_dollarVMStructure.set(vm, this, JSDollarVM::createStructure(vm, this, dollarVMPrototype));
899 JSDollarVM* dollarVM = JSDollarVM::create(vm, m_dollarVMStructure.get());
901 GlobalPropertyInfo extraStaticGlobals[] = {
902 GlobalPropertyInfo(vm.propertyNames->builtinNames().dollarVMPrivateName(), dollarVM, DontEnum | DontDelete | ReadOnly),
904 addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
906 putDirectWithoutTransition(vm, Identifier::fromString(exec, "$vm"), dollarVM, DontEnum);
909 #if ENABLE(WEBASSEMBLY)
910 if (Options::useWebAssembly()) {
911 auto* webAssemblyPrototype = WebAssemblyPrototype::create(vm, this, WebAssemblyPrototype::createStructure(vm, this, m_objectPrototype.get()));
912 m_webAssemblyStructure.set(vm, this, JSWebAssembly::createStructure(vm, this, webAssemblyPrototype));
913 m_webAssemblyModuleRecordStructure.set(vm, this, WebAssemblyModuleRecord::createStructure(vm, this, m_objectPrototype.get()));
914 m_webAssemblyFunctionStructure.set(vm, this, WebAssemblyFunction::createStructure(vm, this, m_functionPrototype.get()));
915 m_webAssemblyWrapperFunctionStructure.set(vm, this, WebAssemblyWrapperFunction::createStructure(vm, this, m_functionPrototype.get()));
916 m_webAssemblyToJSCalleeStructure.set(vm, this, WebAssemblyToJSCallee::createStructure(vm, this, jsNull()));
917 auto* webAssembly = JSWebAssembly::create(vm, this, m_webAssemblyStructure.get());
918 putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, DontEnum);
920 #define CREATE_WEBASSEMBLY_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
921 typedef capitalName ## Prototype Prototype; \
922 typedef capitalName ## Constructor Constructor; \
923 typedef JS ## capitalName JSObj; \
924 auto* base = m_ ## prototypeBase ## Prototype.get(); \
925 auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
926 auto* structure = JSObj::createStructure(vm, this, prototype); \
927 auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype); \
928 prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum); \
929 m_ ## lowerName ## Prototype.set(vm, this, prototype); \
930 m_ ## properName ## Structure.set(vm, this, structure); \
931 webAssembly->putDirectWithoutTransition(vm, Identifier::fromString(this->globalExec(), #jsName), constructor, DontEnum); \
934 FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_CONSTRUCTOR)
936 #undef CREATE_WEBASSEMBLY_CONSTRUCTOR
938 #endif // ENABLE(WEBASSEMBLY)
941 ExecState* exec = globalExec();
943 auto setupAdaptiveWatchpoint = [&] (JSObject* base, const Identifier& ident) -> ObjectPropertyCondition {
944 // Performing these gets should not throw.
945 PropertySlot slot(base, PropertySlot::InternalMethodType::Get);
946 bool result = base->getOwnPropertySlot(base, exec, ident, slot);
947 ASSERT_UNUSED(result, result);
948 catchScope.assertNoException();
949 RELEASE_ASSERT(slot.isCacheableValue());
950 JSValue functionValue = slot.getValue(exec, ident);
951 catchScope.assertNoException();
952 ASSERT(jsDynamicCast<JSFunction*>(vm, functionValue));
954 ObjectPropertyCondition condition = generateConditionForSelfEquivalence(m_vm, nullptr, base, ident.impl());
955 RELEASE_ASSERT(condition.requiredValue() == functionValue);
957 bool isWatchable = condition.isWatchable(PropertyCondition::EnsureWatchability);
958 RELEASE_ASSERT(isWatchable); // We allow this to install the necessary watchpoints.
964 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(arrayIteratorPrototype, m_vm.propertyNames->next);
965 m_arrayIteratorPrototypeNext = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
966 m_arrayIteratorPrototypeNext->install();
969 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(this->arrayPrototype(), m_vm.propertyNames->iteratorSymbol);
970 m_arrayPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_arrayIteratorProtocolWatchpoint);
971 m_arrayPrototypeSymbolIteratorWatchpoint->install();
975 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(mapIteratorPrototype, m_vm.propertyNames->next);
976 m_mapIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
977 m_mapIteratorPrototypeNextWatchpoint->install();
980 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->iteratorSymbol);
981 m_mapPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapIteratorProtocolWatchpoint);
982 m_mapPrototypeSymbolIteratorWatchpoint->install();
986 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(setIteratorPrototype, m_vm.propertyNames->next);
987 m_setIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
988 m_setIteratorPrototypeNextWatchpoint->install();
991 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->iteratorSymbol);
992 m_setPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setIteratorProtocolWatchpoint);
993 m_setPrototypeSymbolIteratorWatchpoint->install();
997 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringIteratorPrototype.get(), m_vm.propertyNames->next);
998 m_stringIteratorPrototypeNextWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
999 m_stringIteratorPrototypeNextWatchpoint->install();
1002 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_stringPrototype.get(), m_vm.propertyNames->iteratorSymbol);
1003 m_stringPrototypeSymbolIteratorWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_stringIteratorProtocolWatchpoint);
1004 m_stringPrototypeSymbolIteratorWatchpoint->install();
1008 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_mapPrototype.get(), m_vm.propertyNames->set);
1009 m_mapPrototypeSetWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_mapSetWatchpoint);
1010 m_mapPrototypeSetWatchpoint->install();
1014 ObjectPropertyCondition condition = setupAdaptiveWatchpoint(m_setPrototype.get(), m_vm.propertyNames->add);
1015 m_setPrototypeAddWatchpoint = std::make_unique<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>>(vm, condition, m_setAddWatchpoint);
1016 m_setPrototypeAddWatchpoint->install();
1020 resetPrototype(vm, getPrototypeDirect());
1023 bool JSGlobalObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
1025 VM& vm = exec->vm();
1026 auto scope = DECLARE_THROW_SCOPE(vm);
1027 JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
1028 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
1030 if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
1032 return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
1035 bool shouldThrowReadOnlyError = slot.isStrictMode();
1036 bool ignoreReadOnlyErrors = false;
1037 bool putResult = false;
1038 bool done = symbolTablePutTouchWatchpointSet(thisObject, exec, propertyName, value, shouldThrowReadOnlyError, ignoreReadOnlyErrors, putResult);
1039 ASSERT((!!scope.exception() == (done && !putResult)) || !shouldThrowReadOnlyError);
1043 return Base::put(thisObject, exec, propertyName, value, slot);
1046 bool JSGlobalObject::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow)
1048 JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
1049 PropertySlot slot(thisObject, PropertySlot::InternalMethodType::VMInquiry);
1050 // silently ignore attempts to add accessors aliasing vars.
1051 if (descriptor.isAccessorDescriptor() && symbolTableGet(thisObject, propertyName, slot))
1053 return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
1056 void JSGlobalObject::addGlobalVar(const Identifier& ident)
1058 ConcurrentJSLocker locker(symbolTable()->m_lock);
1059 SymbolTableEntry entry = symbolTable()->get(locker, ident.impl());
1060 if (!entry.isNull())
1063 ScopeOffset offset = symbolTable()->takeNextScopeOffset(locker);
1064 SymbolTableEntry newEntry(VarOffset(offset), 0);
1065 newEntry.prepareToWatch();
1066 symbolTable()->add(locker, ident.impl(), WTFMove(newEntry));
1068 ScopeOffset offsetForAssert = addVariables(1, jsUndefined());
1069 RELEASE_ASSERT(offsetForAssert == offset);
1072 void JSGlobalObject::addFunction(ExecState* exec, const Identifier& propertyName)
1074 VM& vm = exec->vm();
1075 VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
1076 methodTable(vm)->deleteProperty(this, exec, propertyName);
1077 addGlobalVar(propertyName);
1080 void JSGlobalObject::setGlobalScopeExtension(JSScope* scope)
1082 m_globalScopeExtension.set(vm(), this, scope);
1085 void JSGlobalObject::clearGlobalScopeExtension()
1087 m_globalScopeExtension.clear();
1090 static inline JSObject* lastInPrototypeChain(JSObject* object)
1092 JSObject* o = object;
1093 while (o->getPrototypeDirect().isObject())
1094 o = asObject(o->getPrototypeDirect());
1098 // Private namespace for helpers for JSGlobalObject::haveABadTime()
1101 class ObjectsWithBrokenIndexingFinder : public MarkedBlock::VoidFunctor {
1103 ObjectsWithBrokenIndexingFinder(MarkedArgumentBuffer&, JSGlobalObject*);
1104 IterationStatus operator()(HeapCell*, HeapCell::Kind) const;
1107 void visit(JSCell*);
1109 MarkedArgumentBuffer& m_foundObjects;
1110 JSGlobalObject* m_globalObject;
1113 ObjectsWithBrokenIndexingFinder::ObjectsWithBrokenIndexingFinder(
1114 MarkedArgumentBuffer& foundObjects, JSGlobalObject* globalObject)
1115 : m_foundObjects(foundObjects)
1116 , m_globalObject(globalObject)
1120 inline bool hasBrokenIndexing(JSObject* object)
1122 // This will change if we have more indexing types.
1123 IndexingType type = object->indexingType();
1124 // This could be made obviously more efficient, but isn't made so right now, because
1125 // we expect this to be an unlikely slow path anyway.
1126 return hasUndecided(type) || hasInt32(type) || hasDouble(type) || hasContiguous(type) || hasArrayStorage(type);
1129 inline void ObjectsWithBrokenIndexingFinder::visit(JSCell* cell)
1131 if (!cell->isObject())
1134 JSObject* object = asObject(cell);
1136 // Run this filter first, since it's cheap, and ought to filter out a lot of objects.
1137 if (!hasBrokenIndexing(object))
1140 // We only want to have a bad time in the affected global object, not in the entire
1141 // VM. But we have to be careful, since there may be objects that claim to belong to
1142 // a different global object that have prototypes from our global object.
1143 bool foundGlobalObject = false;
1144 for (JSObject* current = object; ;) {
1145 if (current->globalObject() == m_globalObject) {
1146 foundGlobalObject = true;
1150 JSValue prototypeValue = current->getPrototypeDirect();
1151 if (prototypeValue.isNull())
1153 current = asObject(prototypeValue);
1155 if (!foundGlobalObject)
1158 m_foundObjects.append(object);
1161 IterationStatus ObjectsWithBrokenIndexingFinder::operator()(HeapCell* cell, HeapCell::Kind kind) const
1163 if (kind == HeapCell::JSCell) {
1164 // FIXME: This const_cast exists because this isn't a C++ lambda.
1165 // https://bugs.webkit.org/show_bug.cgi?id=159644
1166 const_cast<ObjectsWithBrokenIndexingFinder*>(this)->visit(static_cast<JSCell*>(cell));
1168 return IterationStatus::Continue;
1171 } // end private namespace for helpers for JSGlobalObject::haveABadTime()
1173 void JSGlobalObject::haveABadTime(VM& vm)
1175 ASSERT(&vm == &this->vm());
1177 if (isHavingABadTime())
1180 // Make sure that all allocations or indexed storage transitions that are inlining
1181 // the assumption that it's safe to transition to a non-SlowPut array storage don't
1183 m_havingABadTimeWatchpoint->fireAll(vm, "Having a bad time");
1184 ASSERT(isHavingABadTime()); // The watchpoint is what tells us that we're having a bad time.
1186 // Make sure that all JSArray allocations that load the appropriate structure from
1187 // this object now load a structure that uses SlowPut.
1188 for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1189 m_arrayStructureForIndexingShapeDuringAllocation[i].set(vm, this, originalArrayStructureForIndexingType(ArrayWithSlowPutArrayStorage));
1191 // Same for any special array structures.
1192 Structure* slowPutStructure;
1193 slowPutStructure = createRegExpMatchesArraySlowPutStructure(vm, this);
1194 m_regExpMatchesArrayStructure.set(vm, this, slowPutStructure);
1195 slowPutStructure = ClonedArguments::createSlowPutStructure(vm, this, m_objectPrototype.get());
1196 m_clonedArgumentsStructure.set(vm, this, slowPutStructure);
1198 // Make sure that all objects that have indexed storage switch to the slow kind of
1200 MarkedArgumentBuffer foundObjects; // Use MarkedArgumentBuffer because switchToSlowPutArrayStorage() may GC.
1201 ObjectsWithBrokenIndexingFinder finder(foundObjects, this);
1203 HeapIterationScope iterationScope(vm.heap);
1204 vm.heap.objectSpace().forEachLiveCell(iterationScope, finder);
1206 while (!foundObjects.isEmpty()) {
1207 JSObject* object = asObject(foundObjects.last());
1208 foundObjects.removeLast();
1209 ASSERT(hasBrokenIndexing(object));
1210 object->switchToSlowPutArrayStorage(vm);
1214 // Set prototype, and also insert the object prototype at the end of the chain.
1215 void JSGlobalObject::resetPrototype(VM& vm, JSValue prototype)
1217 setPrototypeDirect(vm, prototype);
1219 JSObject* oldLastInPrototypeChain = lastInPrototypeChain(this);
1220 JSObject* objectPrototype = m_objectPrototype.get();
1221 if (oldLastInPrototypeChain != objectPrototype)
1222 oldLastInPrototypeChain->setPrototypeDirect(vm, objectPrototype);
1224 // Whenever we change the prototype of the global object, we need to create a new JSProxy with the correct prototype.
1225 setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, prototype, PureForwardingProxyType), this));
1228 void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
1230 JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
1231 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
1232 Base::visitChildren(thisObject, visitor);
1234 visitor.append(thisObject->m_globalThis);
1236 visitor.append(thisObject->m_globalLexicalEnvironment);
1237 visitor.append(thisObject->m_globalScopeExtension);
1238 visitor.append(thisObject->m_globalCallee);
1239 visitor.append(thisObject->m_regExpConstructor);
1240 visitor.append(thisObject->m_errorConstructor);
1241 visitor.append(thisObject->m_nativeErrorPrototypeStructure);
1242 visitor.append(thisObject->m_nativeErrorStructure);
1243 thisObject->m_evalErrorConstructor.visit(visitor);
1244 visitor.append(thisObject->m_rangeErrorConstructor);
1245 thisObject->m_referenceErrorConstructor.visit(visitor);
1246 thisObject->m_syntaxErrorConstructor.visit(visitor);
1247 visitor.append(thisObject->m_typeErrorConstructor);
1248 thisObject->m_URIErrorConstructor.visit(visitor);
1249 visitor.append(thisObject->m_objectConstructor);
1250 visitor.append(thisObject->m_promiseConstructor);
1252 visitor.append(thisObject->m_nullGetterFunction);
1253 visitor.append(thisObject->m_nullSetterFunction);
1255 visitor.append(thisObject->m_parseIntFunction);
1256 visitor.append(thisObject->m_parseFloatFunction);
1257 visitor.append(thisObject->m_evalFunction);
1258 visitor.append(thisObject->m_callFunction);
1259 visitor.append(thisObject->m_applyFunction);
1260 visitor.append(thisObject->m_throwTypeErrorFunction);
1261 thisObject->m_arrayProtoToStringFunction.visit(visitor);
1262 thisObject->m_arrayProtoValuesFunction.visit(visitor);
1263 thisObject->m_initializePromiseFunction.visit(visitor);
1264 thisObject->m_iteratorProtocolFunction.visit(visitor);
1265 thisObject->m_promiseResolveFunction.visit(visitor);
1266 visitor.append(thisObject->m_objectProtoValueOfFunction);
1267 visitor.append(thisObject->m_newPromiseCapabilityFunction);
1268 visitor.append(thisObject->m_functionProtoHasInstanceSymbolFunction);
1269 thisObject->m_throwTypeErrorGetterSetter.visit(visitor);
1270 visitor.append(thisObject->m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter);
1271 visitor.append(thisObject->m_moduleLoader);
1273 visitor.append(thisObject->m_objectPrototype);
1274 visitor.append(thisObject->m_functionPrototype);
1275 visitor.append(thisObject->m_arrayPrototype);
1276 visitor.append(thisObject->m_errorPrototype);
1277 visitor.append(thisObject->m_iteratorPrototype);
1278 visitor.append(thisObject->m_generatorFunctionPrototype);
1279 visitor.append(thisObject->m_generatorPrototype);
1280 visitor.append(thisObject->m_asyncFunctionPrototype);
1281 visitor.append(thisObject->m_asyncGeneratorPrototype);
1282 visitor.append(thisObject->m_asyncIteratorPrototype);
1283 visitor.append(thisObject->m_asyncGeneratorFunctionPrototype);
1284 visitor.append(thisObject->m_moduleLoaderPrototype);
1286 thisObject->m_debuggerScopeStructure.visit(visitor);
1287 thisObject->m_withScopeStructure.visit(visitor);
1288 visitor.append(thisObject->m_strictEvalActivationStructure);
1289 visitor.append(thisObject->m_lexicalEnvironmentStructure);
1290 thisObject->m_moduleEnvironmentStructure.visit(visitor);
1291 visitor.append(thisObject->m_directArgumentsStructure);
1292 visitor.append(thisObject->m_scopedArgumentsStructure);
1293 visitor.append(thisObject->m_clonedArgumentsStructure);
1294 visitor.append(thisObject->m_objectStructureForObjectConstructor);
1295 for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1296 visitor.append(thisObject->m_originalArrayStructureForIndexingShape[i]);
1297 for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
1298 visitor.append(thisObject->m_arrayStructureForIndexingShapeDuringAllocation[i]);
1299 thisObject->m_callbackConstructorStructure.visit(visitor);
1300 thisObject->m_callbackFunctionStructure.visit(visitor);
1301 thisObject->m_callbackObjectStructure.visit(visitor);
1302 #if JSC_OBJC_API_ENABLED
1303 thisObject->m_objcCallbackFunctionStructure.visit(visitor);
1304 thisObject->m_objcWrapperObjectStructure.visit(visitor);
1306 thisObject->m_nullPrototypeObjectStructure.visit(visitor);
1307 visitor.append(thisObject->m_errorStructure);
1308 visitor.append(thisObject->m_calleeStructure);
1309 visitor.append(thisObject->m_functionStructure);
1310 thisObject->m_customGetterSetterFunctionStructure.visit(visitor);
1311 thisObject->m_boundFunctionStructure.visit(visitor);
1312 visitor.append(thisObject->m_getterSetterStructure);
1313 thisObject->m_nativeStdFunctionStructure.visit(visitor);
1314 thisObject->m_namedFunctionStructure.visit(visitor);
1315 visitor.append(thisObject->m_symbolObjectStructure);
1316 visitor.append(thisObject->m_regExpStructure);
1317 visitor.append(thisObject->m_generatorFunctionStructure);
1318 visitor.append(thisObject->m_asyncFunctionStructure);
1319 visitor.append(thisObject->m_asyncGeneratorFunctionStructure);
1320 visitor.append(thisObject->m_iteratorResultObjectStructure);
1321 visitor.append(thisObject->m_regExpMatchesArrayStructure);
1322 visitor.append(thisObject->m_moduleRecordStructure);
1323 visitor.append(thisObject->m_moduleNamespaceObjectStructure);
1324 visitor.append(thisObject->m_dollarVMStructure);
1325 visitor.append(thisObject->m_proxyObjectStructure);
1326 visitor.append(thisObject->m_callableProxyObjectStructure);
1327 visitor.append(thisObject->m_proxyRevokeStructure);
1328 visitor.append(thisObject->m_moduleLoaderStructure);
1330 visitor.append(thisObject->m_arrayBufferPrototype);
1331 visitor.append(thisObject->m_arrayBufferStructure);
1332 visitor.append(thisObject->m_sharedArrayBufferPrototype);
1333 visitor.append(thisObject->m_sharedArrayBufferStructure);
1335 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
1336 visitor.append(thisObject->m_ ## lowerName ## Prototype); \
1337 visitor.append(thisObject->m_ ## properName ## Structure); \
1339 FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
1340 FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(VISIT_SIMPLE_TYPE)
1342 #if ENABLE(WEBASSEMBLY)
1343 visitor.append(thisObject->m_webAssemblyStructure);
1344 visitor.append(thisObject->m_webAssemblyModuleRecordStructure);
1345 visitor.append(thisObject->m_webAssemblyFunctionStructure);
1346 visitor.append(thisObject->m_webAssemblyWrapperFunctionStructure);
1347 visitor.append(thisObject->m_webAssemblyToJSCalleeStructure);
1348 FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(VISIT_SIMPLE_TYPE)
1349 #endif // ENABLE(WEBASSEMBLY)
1351 #undef VISIT_SIMPLE_TYPE
1353 #define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
1354 thisObject->m_ ## properName ## Structure.visit(visitor);
1356 FOR_EACH_LAZY_BUILTIN_TYPE(VISIT_LAZY_TYPE)
1358 #undef VISIT_LAZY_TYPE
1360 for (unsigned i = NUMBER_OF_TYPED_ARRAY_TYPES; i--;)
1361 thisObject->lazyTypedArrayStructure(indexToTypedArrayType(i)).visit(visitor);
1363 visitor.append(thisObject->m_speciesGetterSetter);
1364 thisObject->m_typedArrayProto.visit(visitor);
1365 thisObject->m_typedArraySuperConstructor.visit(visitor);
1368 JSValue JSGlobalObject::toThis(JSCell*, ExecState* exec, ECMAMode ecmaMode)
1370 if (ecmaMode == StrictMode)
1371 return jsUndefined();
1372 return exec->globalThisValue();
1375 ExecState* JSGlobalObject::globalExec()
1377 return CallFrame::create(m_globalCallFrame);
1380 void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
1382 ScopeOffset startOffset = addVariables(count, jsUndefined());
1384 for (int i = 0; i < count; ++i) {
1385 GlobalPropertyInfo& global = globals[i];
1386 ASSERT(global.attributes & DontDelete);
1388 WatchpointSet* watchpointSet = nullptr;
1389 WriteBarrierBase<Unknown>* variable = nullptr;
1391 ConcurrentJSLocker locker(symbolTable()->m_lock);
1392 ScopeOffset offset = symbolTable()->takeNextScopeOffset(locker);
1393 RELEASE_ASSERT(offset == startOffset + i);
1394 SymbolTableEntry newEntry(VarOffset(offset), global.attributes);
1395 newEntry.prepareToWatch();
1396 watchpointSet = newEntry.watchpointSet();
1397 symbolTable()->add(locker, global.identifier.impl(), WTFMove(newEntry));
1398 variable = &variableAt(offset);
1400 symbolTablePutTouchWatchpointSet(vm(), this, global.identifier, global.value, variable, watchpointSet);
1404 bool JSGlobalObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
1406 if (Base::getOwnPropertySlot(object, exec, propertyName, slot))
1408 return symbolTableGet(jsCast<JSGlobalObject*>(object), propertyName, slot);
1411 void JSGlobalObject::clearRareData(JSCell* cell)
1413 jsCast<JSGlobalObject*>(cell)->m_rareData = nullptr;
1416 void slowValidateCell(JSGlobalObject* globalObject)
1418 RELEASE_ASSERT(globalObject->isGlobalObject());
1419 ASSERT_GC_OBJECT_INHERITS(globalObject, JSGlobalObject::info());
1422 void JSGlobalObject::setRemoteDebuggingEnabled(bool enabled)
1424 #if ENABLE(REMOTE_INSPECTOR)
1425 m_inspectorDebuggable->setRemoteDebuggingAllowed(enabled);
1427 UNUSED_PARAM(enabled);
1431 bool JSGlobalObject::remoteDebuggingEnabled() const
1433 #if ENABLE(REMOTE_INSPECTOR)
1434 return m_inspectorDebuggable->remoteDebuggingAllowed();
1440 void JSGlobalObject::setName(const String& name)
1444 #if ENABLE(REMOTE_INSPECTOR)
1445 m_inspectorDebuggable->update();
1450 const HashSet<String>& JSGlobalObject::intlCollatorAvailableLocales()
1452 if (m_intlCollatorAvailableLocales.isEmpty()) {
1453 int32_t count = ucol_countAvailable();
1454 for (int32_t i = 0; i < count; ++i) {
1455 String locale(ucol_getAvailable(i));
1456 convertICULocaleToBCP47LanguageTag(locale);
1457 m_intlCollatorAvailableLocales.add(locale);
1460 return m_intlCollatorAvailableLocales;
1463 const HashSet<String>& JSGlobalObject::intlDateTimeFormatAvailableLocales()
1465 if (m_intlDateTimeFormatAvailableLocales.isEmpty()) {
1466 int32_t count = udat_countAvailable();
1467 for (int32_t i = 0; i < count; ++i) {
1468 String locale(udat_getAvailable(i));
1469 convertICULocaleToBCP47LanguageTag(locale);
1470 m_intlDateTimeFormatAvailableLocales.add(locale);
1473 return m_intlDateTimeFormatAvailableLocales;
1476 const HashSet<String>& JSGlobalObject::intlNumberFormatAvailableLocales()
1478 if (m_intlNumberFormatAvailableLocales.isEmpty()) {
1479 int32_t count = unum_countAvailable();
1480 for (int32_t i = 0; i < count; ++i) {
1481 String locale(unum_getAvailable(i));
1482 convertICULocaleToBCP47LanguageTag(locale);
1483 m_intlNumberFormatAvailableLocales.add(locale);
1486 return m_intlNumberFormatAvailableLocales;
1488 #endif // ENABLE(INTL)
1490 void JSGlobalObject::queueMicrotask(Ref<Microtask>&& task)
1492 if (globalObjectMethodTable()->queueTaskToEventLoop) {
1493 globalObjectMethodTable()->queueTaskToEventLoop(*this, WTFMove(task));
1497 vm().queueMicrotask(*this, WTFMove(task));
1500 bool JSGlobalObject::hasDebugger() const
1505 bool JSGlobalObject::hasInteractiveDebugger() const
1507 return m_debugger && m_debugger->isInteractivelyDebugging();
1510 JSGlobalObject* JSGlobalObject::create(VM& vm, Structure* structure)
1512 JSGlobalObject* globalObject = new (NotNull, allocateCell<JSGlobalObject>(vm.heap)) JSGlobalObject(vm, structure);
1513 globalObject->finishCreation(vm);
1514 return globalObject;
1517 void JSGlobalObject::finishCreation(VM& vm)
1519 Base::finishCreation(vm);
1520 structure()->setGlobalObject(vm, this);
1521 m_runtimeFlags = m_globalObjectMethodTable->javaScriptRuntimeFlags(this);
1523 setGlobalThis(vm, JSProxy::create(vm, JSProxy::createStructure(vm, this, getPrototypeDirect(), PureForwardingProxyType), this));
1526 void JSGlobalObject::finishCreation(VM& vm, JSObject* thisValue)
1528 Base::finishCreation(vm);
1529 structure()->setGlobalObject(vm, this);
1530 m_runtimeFlags = m_globalObjectMethodTable->javaScriptRuntimeFlags(this);
1532 setGlobalThis(vm, thisValue);