Fix for 128110
[WebKit-https.git] / Source / JavaScriptCore / runtime / JSGlobalObject.cpp
1 /*
2  * Copyright (C) 2007, 2008, 2009 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 Computer, 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 "Arguments.h"
34 #include "ArgumentsIteratorConstructor.h"
35 #include "ArgumentsIteratorPrototype.h"
36 #include "ArrayConstructor.h"
37 #include "ArrayIteratorConstructor.h"
38 #include "ArrayIteratorPrototype.h"
39 #include "ArrayPrototype.h"
40 #include "BooleanConstructor.h"
41 #include "BooleanPrototype.h"
42 #include "CodeBlock.h"
43 #include "CodeCache.h"
44 #include "DateConstructor.h"
45 #include "DatePrototype.h"
46 #include "Debugger.h"
47 #include "Error.h"
48 #include "ErrorConstructor.h"
49 #include "ErrorPrototype.h"
50 #include "FunctionConstructor.h"
51 #include "FunctionPrototype.h"
52 #include "GetterSetter.h"
53 #include "HeapIterationScope.h"
54 #include "Interpreter.h"
55 #include "JSAPIWrapperObject.h"
56 #include "JSActivation.h"
57 #include "JSArgumentsIterator.h"
58 #include "JSArrayBuffer.h"
59 #include "JSArrayBufferConstructor.h"
60 #include "JSArrayBufferPrototype.h"
61 #include "JSArrayIterator.h"
62 #include "JSBoundFunction.h"
63 #include "JSCallbackConstructor.h"
64 #include "JSCallbackFunction.h"
65 #include "JSCallbackObject.h"
66 #include "JSDataView.h"
67 #include "JSDataViewPrototype.h"
68 #include "JSFunction.h"
69 #include "JSGenericTypedArrayViewConstructorInlines.h"
70 #include "JSGenericTypedArrayViewInlines.h"
71 #include "JSGenericTypedArrayViewPrototypeInlines.h"
72 #include "JSGlobalObjectFunctions.h"
73 #include "JSLock.h"
74 #include "JSMap.h"
75 #include "JSMapIterator.h"
76 #include "JSNameScope.h"
77 #include "JSONObject.h"
78 #include "JSSet.h"
79 #include "JSSetIterator.h"
80 #include "JSTypedArrayConstructors.h"
81 #include "JSTypedArrayPrototypes.h"
82 #include "JSTypedArrays.h"
83 #include "JSWeakMap.h"
84 #include "JSWithScope.h"
85 #include "LegacyProfiler.h"
86 #include "Lookup.h"
87 #include "MapConstructor.h"
88 #include "MapIteratorConstructor.h"
89 #include "MapIteratorPrototype.h"
90 #include "MapPrototype.h"
91 #include "MathObject.h"
92 #include "Microtask.h"
93 #include "NameConstructor.h"
94 #include "NameInstance.h"
95 #include "NamePrototype.h"
96 #include "NativeErrorConstructor.h"
97 #include "NativeErrorPrototype.h"
98 #include "NumberConstructor.h"
99 #include "NumberPrototype.h"
100 #include "ObjCCallbackFunction.h"
101 #include "ObjectConstructor.h"
102 #include "ObjectPrototype.h"
103 #include "Operations.h"
104 #include "ParserError.h"
105 #include "RegExpConstructor.h"
106 #include "RegExpMatchesArray.h"
107 #include "RegExpObject.h"
108 #include "RegExpPrototype.h"
109 #include "SetConstructor.h"
110 #include "SetIteratorConstructor.h"
111 #include "SetIteratorPrototype.h"
112 #include "SetPrototype.h"
113 #include "StrictEvalActivation.h"
114 #include "StringConstructor.h"
115 #include "StringPrototype.h"
116 #include "WeakMapConstructor.h"
117 #include "WeakMapPrototype.h"
118
119 #if ENABLE(PROMISES)
120 #include "JSPromise.h"
121 #include "JSPromiseConstructor.h"
122 #include "JSPromisePrototype.h"
123 #endif // ENABLE(PROMISES)
124
125 #if ENABLE(REMOTE_INSPECTOR)
126 #include "JSGlobalObjectDebuggable.h"
127 #include "RemoteInspector.h"
128 #endif
129
130 #if ENABLE(WEB_REPLAY)
131 #include "EmptyInputCursor.h"
132 #endif
133
134 #include "JSGlobalObject.lut.h"
135
136 namespace JSC {
137
138 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, 0, ExecState::globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
139
140 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptExperimentsEnabled, 0, &shouldInterruptScriptBeforeTimeout };
141
142 /* Source for JSGlobalObject.lut.h
143 @begin globalObjectTable
144   parseInt              globalFuncParseInt              DontEnum|Function 2
145   parseFloat            globalFuncParseFloat            DontEnum|Function 1
146   isNaN                 globalFuncIsNaN                 DontEnum|Function 1
147   isFinite              globalFuncIsFinite              DontEnum|Function 1
148   escape                globalFuncEscape                DontEnum|Function 1
149   unescape              globalFuncUnescape              DontEnum|Function 1
150   decodeURI             globalFuncDecodeURI             DontEnum|Function 1
151   decodeURIComponent    globalFuncDecodeURIComponent    DontEnum|Function 1
152   encodeURI             globalFuncEncodeURI             DontEnum|Function 1
153   encodeURIComponent    globalFuncEncodeURIComponent    DontEnum|Function 1
154 @end
155 */
156
157 JSGlobalObject::JSGlobalObject(VM& vm, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable)
158     : Base(vm, structure, 0)
159 #if ENABLE(WEB_REPLAY)
160     , m_inputCursor(EmptyInputCursor::create())
161 #endif
162     , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
163     , m_havingABadTimeWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
164     , m_varInjectionWatchpoint(adoptRef(new WatchpointSet(IsWatched)))
165     , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)))
166     , m_evalEnabled(true)
167     , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable)
168 {
169 }
170
171 JSGlobalObject::~JSGlobalObject()
172 {
173     if (m_debugger)
174         m_debugger->detach(this, Debugger::GlobalObjectIsDestructing);
175
176     if (LegacyProfiler* profiler = vm().enabledProfiler())
177         profiler->stopProfiling(this);
178 }
179
180 void JSGlobalObject::destroy(JSCell* cell)
181 {
182     static_cast<JSGlobalObject*>(cell)->JSGlobalObject::~JSGlobalObject();
183 }
184
185 void JSGlobalObject::setGlobalThis(VM& vm, JSObject* globalThis)
186
187     m_globalThis.set(vm, this, globalThis);
188 }
189
190 void JSGlobalObject::init(JSObject* thisValue)
191 {
192     ASSERT(vm().currentThreadIsHoldingAPILock());
193
194     setGlobalThis(vm(), thisValue);
195     JSGlobalObject::globalExec()->init(0, 0, this, CallFrame::noCaller(), 0, 0);
196
197     m_debugger = 0;
198
199 #if ENABLE(REMOTE_INSPECTOR)
200     m_inspectorDebuggable = std::make_unique<JSGlobalObjectDebuggable>(*this);
201     m_inspectorDebuggable->init();
202     m_inspectorDebuggable->setRemoteDebuggingAllowed(true);
203 #endif
204
205     reset(prototype());
206 }
207
208 void JSGlobalObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
209 {
210     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
211     ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
212
213     if (symbolTablePut(thisObject, exec, propertyName, value, slot.isStrictMode()))
214         return;
215     Base::put(thisObject, exec, propertyName, value, slot);
216 }
217
218 bool JSGlobalObject::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow)
219 {
220     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
221     PropertySlot slot(thisObject);
222     // silently ignore attempts to add accessors aliasing vars.
223     if (descriptor.isAccessorDescriptor() && symbolTableGet(thisObject, propertyName, slot))
224         return false;
225     return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
226 }
227
228 JSGlobalObject::NewGlobalVar JSGlobalObject::addGlobalVar(const Identifier& ident, ConstantMode constantMode)
229 {
230     ConcurrentJITLocker locker(symbolTable()->m_lock);
231     int index = symbolTable()->size(locker);
232     SymbolTableEntry newEntry(index, (constantMode == IsConstant) ? ReadOnly : 0);
233     if (constantMode == IsVariable)
234         newEntry.prepareToWatch();
235     SymbolTable::Map::AddResult result = symbolTable()->add(locker, ident.impl(), newEntry);
236     if (result.isNewEntry)
237         addRegisters(1);
238     else
239         index = result.iterator->value.getIndex();
240     NewGlobalVar var;
241     var.registerNumber = index;
242     var.set = result.iterator->value.watchpointSet();
243     return var;
244 }
245
246 void JSGlobalObject::addFunction(ExecState* exec, const Identifier& propertyName, JSValue value)
247 {
248     removeDirect(exec->vm(), propertyName); // Newly declared functions overwrite existing properties.
249     NewGlobalVar var = addGlobalVar(propertyName, IsVariable);
250     registerAt(var.registerNumber).set(exec->vm(), this, value);
251     if (var.set)
252         var.set->notifyWrite(value);
253 }
254
255 static inline JSObject* lastInPrototypeChain(JSObject* object)
256 {
257     JSObject* o = object;
258     while (o->prototype().isObject())
259         o = asObject(o->prototype());
260     return o;
261 }
262
263 void JSGlobalObject::reset(JSValue prototype)
264 {
265     ExecState* exec = JSGlobalObject::globalExec();
266     VM& vm = exec->vm();
267
268     m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
269     m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
270     m_boundFunctionStructure.set(vm, this, JSBoundFunction::createStructure(vm, this, m_functionPrototype.get()));
271     m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, 0, m_functionNameOffset));
272     m_internalFunctionStructure.set(vm, this, InternalFunction::createStructure(vm, this, m_functionPrototype.get()));
273     JSFunction* callFunction = 0;
274     JSFunction* applyFunction = 0;
275     m_functionPrototype->addFunctionProperties(exec, this, &callFunction, &applyFunction);
276     m_callFunction.set(vm, this, callFunction);
277     m_applyFunction.set(vm, this, applyFunction);
278     m_objectPrototype.set(vm, this, ObjectPrototype::create(vm, this, ObjectPrototype::createStructure(vm, this, jsNull())));
279     GetterSetter* protoAccessor = GetterSetter::create(vm);
280     protoAccessor->setGetter(vm, JSFunction::create(vm, this, 0, String(), globalFuncProtoGetter));
281     protoAccessor->setSetter(vm, JSFunction::create(vm, this, 0, String(), globalFuncProtoSetter));
282     m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
283     m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
284     
285     m_typedArrays[toIndex(TypeInt8)].prototype.set(vm, this, JSInt8ArrayPrototype::create(vm, this, JSInt8ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
286     m_typedArrays[toIndex(TypeInt16)].prototype.set(vm, this, JSInt16ArrayPrototype::create(vm, this, JSInt16ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
287     m_typedArrays[toIndex(TypeInt32)].prototype.set(vm, this, JSInt32ArrayPrototype::create(vm, this, JSInt32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
288     m_typedArrays[toIndex(TypeUint8)].prototype.set(vm, this, JSUint8ArrayPrototype::create(vm, this, JSUint8ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
289     m_typedArrays[toIndex(TypeUint8Clamped)].prototype.set(vm, this, JSUint8ClampedArrayPrototype::create(vm, this, JSUint8ClampedArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
290     m_typedArrays[toIndex(TypeUint16)].prototype.set(vm, this, JSUint16ArrayPrototype::create(vm, this, JSUint16ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
291     m_typedArrays[toIndex(TypeUint32)].prototype.set(vm, this, JSUint32ArrayPrototype::create(vm, this, JSUint32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
292     m_typedArrays[toIndex(TypeFloat32)].prototype.set(vm, this, JSFloat32ArrayPrototype::create(vm, this, JSFloat32ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
293     m_typedArrays[toIndex(TypeFloat64)].prototype.set(vm, this, JSFloat64ArrayPrototype::create(vm, this, JSFloat64ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
294     m_typedArrays[toIndex(TypeDataView)].prototype.set(vm, this, JSDataViewPrototype::create(vm, JSDataViewPrototype::createStructure(vm, this, m_objectPrototype.get())));
295     
296     m_typedArrays[toIndex(TypeInt8)].structure.set(vm, this, JSInt8Array::createStructure(vm, this, m_typedArrays[toIndex(TypeInt8)].prototype.get()));
297     m_typedArrays[toIndex(TypeInt16)].structure.set(vm, this, JSInt16Array::createStructure(vm, this, m_typedArrays[toIndex(TypeInt16)].prototype.get()));
298     m_typedArrays[toIndex(TypeInt32)].structure.set(vm, this, JSInt32Array::createStructure(vm, this, m_typedArrays[toIndex(TypeInt32)].prototype.get()));
299     m_typedArrays[toIndex(TypeUint8)].structure.set(vm, this, JSUint8Array::createStructure(vm, this, m_typedArrays[toIndex(TypeUint8)].prototype.get()));
300     m_typedArrays[toIndex(TypeUint8Clamped)].structure.set(vm, this, JSUint8ClampedArray::createStructure(vm, this, m_typedArrays[toIndex(TypeUint8Clamped)].prototype.get()));
301     m_typedArrays[toIndex(TypeUint16)].structure.set(vm, this, JSUint16Array::createStructure(vm, this, m_typedArrays[toIndex(TypeUint16)].prototype.get()));
302     m_typedArrays[toIndex(TypeUint32)].structure.set(vm, this, JSUint32Array::createStructure(vm, this, m_typedArrays[toIndex(TypeUint32)].prototype.get()));
303     m_typedArrays[toIndex(TypeFloat32)].structure.set(vm, this, JSFloat32Array::createStructure(vm, this, m_typedArrays[toIndex(TypeFloat32)].prototype.get()));
304     m_typedArrays[toIndex(TypeFloat64)].structure.set(vm, this, JSFloat64Array::createStructure(vm, this, m_typedArrays[toIndex(TypeFloat64)].prototype.get()));
305     m_typedArrays[toIndex(TypeDataView)].structure.set(vm, this, JSDataView::createStructure(vm, this, m_typedArrays[toIndex(TypeDataView)].prototype.get()));
306
307     m_nameScopeStructure.set(vm, this, JSNameScope::createStructure(vm, this, jsNull()));
308     m_activationStructure.set(vm, this, JSActivation::createStructure(vm, this, jsNull()));
309     m_strictEvalActivationStructure.set(vm, this, StrictEvalActivation::createStructure(vm, this, jsNull()));
310     m_withScopeStructure.set(vm, this, JSWithScope::createStructure(vm, this, jsNull()));
311
312     m_nullPrototypeObjectStructure.set(vm, this, JSFinalObject::createStructure(vm, this, jsNull(), JSFinalObject::defaultInlineCapacity()));
313
314     m_callbackFunctionStructure.set(vm, this, JSCallbackFunction::createStructure(vm, this, m_functionPrototype.get()));
315     m_argumentsStructure.set(vm, this, Arguments::createStructure(vm, this, m_objectPrototype.get()));
316     m_callbackConstructorStructure.set(vm, this, JSCallbackConstructor::createStructure(vm, this, m_objectPrototype.get()));
317     m_callbackObjectStructure.set(vm, this, JSCallbackObject<JSDestructibleObject>::createStructure(vm, this, m_objectPrototype.get()));
318 #if JSC_OBJC_API_ENABLED
319     m_objcCallbackFunctionStructure.set(vm, this, ObjCCallbackFunction::createStructure(vm, this, m_functionPrototype.get()));
320     m_objcWrapperObjectStructure.set(vm, this, JSCallbackObject<JSAPIWrapperObject>::createStructure(vm, this, m_objectPrototype.get()));
321 #endif
322
323     m_arrayPrototype.set(vm, this, ArrayPrototype::create(vm, this, ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
324     
325     m_originalArrayStructureForIndexingShape[UndecidedShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithUndecided));
326     m_originalArrayStructureForIndexingShape[Int32Shape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithInt32));
327     m_originalArrayStructureForIndexingShape[DoubleShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithDouble));
328     m_originalArrayStructureForIndexingShape[ContiguousShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithContiguous));
329     m_originalArrayStructureForIndexingShape[ArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithArrayStorage));
330     m_originalArrayStructureForIndexingShape[SlowPutArrayStorageShape >> IndexingShapeShift].set(vm, this, JSArray::createStructure(vm, this, m_arrayPrototype.get(), ArrayWithSlowPutArrayStorage));
331     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
332         m_arrayStructureForIndexingShapeDuringAllocation[i] = m_originalArrayStructureForIndexingShape[i];
333     
334     m_regExpMatchesArrayStructure.set(vm, this, RegExpMatchesArray::createStructure(vm, this, m_arrayPrototype.get()));
335
336     RegExp* emptyRegex = RegExp::create(vm, "", NoFlags);
337     
338     m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex));
339     m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
340
341 #if ENABLE(PROMISES)
342     m_promisePrototype.set(vm, this, JSPromisePrototype::create(exec, this, JSPromisePrototype::createStructure(vm, this, m_objectPrototype.get())));
343     m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get()));
344 #endif // ENABLE(PROMISES)
345
346 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
347     m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_objectPrototype.get()))); \
348     m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
349
350     FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
351
352 #undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
353
354     // Constructors
355
356     JSCell* objectConstructor = ObjectConstructor::create(vm, ObjectConstructor::createStructure(vm, this, m_functionPrototype.get()), m_objectPrototype.get());
357     JSCell* functionConstructor = FunctionConstructor::create(vm, FunctionConstructor::createStructure(vm, this, m_functionPrototype.get()), m_functionPrototype.get());
358     JSCell* arrayConstructor = ArrayConstructor::create(vm, ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_arrayPrototype.get());
359
360     m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get()));
361
362 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
363     capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get()); \
364     m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, DontEnum); \
365
366     FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE)
367
368 #undef CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE
369
370     m_errorConstructor.set(vm, this, errorConstructor);
371
372     Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(vm, this, m_errorPrototype.get());
373     Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(vm, this, m_functionPrototype.get());
374     m_evalErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("EvalError")));
375     m_rangeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("RangeError")));
376     m_referenceErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("ReferenceError")));
377     m_syntaxErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("SyntaxError")));
378     m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("TypeError")));
379     m_URIErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("URIError")));
380     m_promiseConstructor.set(vm, this, JSPromiseConstructor::create(vm, JSPromiseConstructor::createStructure(vm, this, m_functionPrototype.get()), m_promisePrototype.get()));
381
382     m_objectPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, objectConstructor, DontEnum);
383     m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, DontEnum);
384     m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, DontEnum);
385     m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_regExpConstructor.get(), DontEnum);
386 #if ENABLE(PROMISES)
387     m_promisePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_promiseConstructor.get(), DontEnum);
388 #endif
389
390     putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum);
391     putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, DontEnum);
392     putDirectWithoutTransition(vm, vm.propertyNames->Array, arrayConstructor, DontEnum);
393     putDirectWithoutTransition(vm, vm.propertyNames->RegExp, m_regExpConstructor.get(), DontEnum);
394     putDirectWithoutTransition(vm, vm.propertyNames->EvalError, m_evalErrorConstructor.get(), DontEnum);
395     putDirectWithoutTransition(vm, vm.propertyNames->RangeError, m_rangeErrorConstructor.get(), DontEnum);
396     putDirectWithoutTransition(vm, vm.propertyNames->ReferenceError, m_referenceErrorConstructor.get(), DontEnum);
397     putDirectWithoutTransition(vm, vm.propertyNames->SyntaxError, m_syntaxErrorConstructor.get(), DontEnum);
398     putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum);
399     putDirectWithoutTransition(vm, vm.propertyNames->URIError, m_URIErrorConstructor.get(), DontEnum);
400     putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum);
401
402
403 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
404     putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, DontEnum); \
405
406     FOR_EACH_SIMPLE_BUILTIN_TYPE(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
407
408 #undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
409     PrototypeMap& prototypeMap = vm.prototypeMap;
410     Structure* iteratorResultStructure = prototypeMap.emptyObjectStructureForPrototype(m_objectPrototype.get(), JSFinalObject::defaultInlineCapacity());
411     PropertyOffset offset;
412     iteratorResultStructure = Structure::addPropertyTransition(vm, iteratorResultStructure, vm.propertyNames->done, 0, 0, offset);
413     iteratorResultStructure = Structure::addPropertyTransition(vm, iteratorResultStructure, vm.propertyNames->value, 0, 0, offset);
414     m_iteratorResultStructure.set(vm, this, iteratorResultStructure);
415
416     m_evalFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->eval.string(), globalFuncEval));
417     putDirectWithoutTransition(vm, vm.propertyNames->eval, m_evalFunction.get(), DontEnum);
418
419     putDirectWithoutTransition(vm, vm.propertyNames->JSON, JSONObject::create(vm, JSONObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
420     putDirectWithoutTransition(vm, vm.propertyNames->Math, MathObject::create(vm, this, MathObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
421     
422     std::array<InternalFunction*, NUMBER_OF_TYPED_ARRAY_TYPES> typedArrayConstructors;
423     typedArrayConstructors[toIndex(TypeInt8)] = JSInt8ArrayConstructor::create(vm, JSInt8ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt8)].prototype.get(), "Int8Array");
424     typedArrayConstructors[toIndex(TypeInt16)] = JSInt16ArrayConstructor::create(vm, JSInt16ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt16)].prototype.get(), "Int16Array");
425     typedArrayConstructors[toIndex(TypeInt32)] = JSInt32ArrayConstructor::create(vm, JSInt32ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt32)].prototype.get(), "Int32Array");
426     typedArrayConstructors[toIndex(TypeUint8)] = JSUint8ArrayConstructor::create(vm, JSUint8ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeUint8)].prototype.get(), "Uint8Array");
427     typedArrayConstructors[toIndex(TypeUint8Clamped)] = JSUint8ClampedArrayConstructor::create(vm, JSUint8ClampedArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeUint8Clamped)].prototype.get(), "Uint8ClampedArray");
428     typedArrayConstructors[toIndex(TypeUint16)] = JSUint16ArrayConstructor::create(vm, JSUint16ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeUint16)].prototype.get(), "Uint16Array");
429     typedArrayConstructors[toIndex(TypeUint32)] = JSUint32ArrayConstructor::create(vm, JSUint32ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeUint32)].prototype.get(), "Uint32Array");
430     typedArrayConstructors[toIndex(TypeFloat32)] = JSFloat32ArrayConstructor::create(vm, JSFloat32ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeFloat32)].prototype.get(), "Float32Array");
431     typedArrayConstructors[toIndex(TypeFloat64)] = JSFloat64ArrayConstructor::create(vm, JSFloat64ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeFloat64)].prototype.get(), "Float64Array");
432     typedArrayConstructors[toIndex(TypeDataView)] = JSDataViewConstructor::create(vm, JSDataViewConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeDataView)].prototype.get(), "DataView");
433
434     for (unsigned typedArrayIndex = NUMBER_OF_TYPED_ARRAY_TYPES; typedArrayIndex--;) {
435         m_typedArrays[typedArrayIndex].prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, typedArrayConstructors[typedArrayIndex], DontEnum);
436         putDirectWithoutTransition(vm, Identifier(exec, typedArrayConstructors[typedArrayIndex]->name(exec)), typedArrayConstructors[typedArrayIndex], DontEnum);
437     }
438
439     GlobalPropertyInfo staticGlobals[] = {
440         GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
441         GlobalPropertyInfo(vm.propertyNames->Infinity, jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
442         GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly)
443     };
444     addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
445     
446     m_specialPointers[Special::CallFunction] = m_callFunction.get();
447     m_specialPointers[Special::ApplyFunction] = m_applyFunction.get();
448     m_specialPointers[Special::ObjectConstructor] = objectConstructor;
449     m_specialPointers[Special::ArrayConstructor] = arrayConstructor;
450
451     if (m_experimentsEnabled) {
452         NamePrototype* privateNamePrototype = NamePrototype::create(exec, NamePrototype::createStructure(vm, this, m_objectPrototype.get()));
453         m_privateNameStructure.set(vm, this, NameInstance::createStructure(vm, this, privateNamePrototype));
454
455         JSCell* privateNameConstructor = NameConstructor::create(vm, NameConstructor::createStructure(vm, this, m_functionPrototype.get()), privateNamePrototype);
456         privateNamePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, privateNameConstructor, DontEnum);
457         putDirectWithoutTransition(vm, Identifier(exec, "Name"), privateNameConstructor, DontEnum);
458     }
459
460     resetPrototype(vm, prototype);
461 }
462
463 // Private namespace for helpers for JSGlobalObject::haveABadTime()
464 namespace {
465
466 class ObjectsWithBrokenIndexingFinder : public MarkedBlock::VoidFunctor {
467 public:
468     ObjectsWithBrokenIndexingFinder(MarkedArgumentBuffer&, JSGlobalObject*);
469     void operator()(JSCell*);
470
471 private:
472     MarkedArgumentBuffer& m_foundObjects;
473     JSGlobalObject* m_globalObject;
474 };
475
476 ObjectsWithBrokenIndexingFinder::ObjectsWithBrokenIndexingFinder(
477     MarkedArgumentBuffer& foundObjects, JSGlobalObject* globalObject)
478     : m_foundObjects(foundObjects)
479     , m_globalObject(globalObject)
480 {
481 }
482
483 inline bool hasBrokenIndexing(JSObject* object)
484 {
485     // This will change if we have more indexing types.
486     IndexingType type = object->structure()->indexingType();
487     // This could be made obviously more efficient, but isn't made so right now, because
488     // we expect this to be an unlikely slow path anyway.
489     return hasUndecided(type) || hasInt32(type) || hasDouble(type) || hasContiguous(type) || hasFastArrayStorage(type);
490 }
491
492 void ObjectsWithBrokenIndexingFinder::operator()(JSCell* cell)
493 {
494     if (!cell->isObject())
495         return;
496     
497     JSObject* object = asObject(cell);
498
499     // Run this filter first, since it's cheap, and ought to filter out a lot of objects.
500     if (!hasBrokenIndexing(object))
501         return;
502     
503     // We only want to have a bad time in the affected global object, not in the entire
504     // VM. But we have to be careful, since there may be objects that claim to belong to
505     // a different global object that have prototypes from our global object.
506     bool foundGlobalObject = false;
507     for (JSObject* current = object; ;) {
508         if (current->globalObject() == m_globalObject) {
509             foundGlobalObject = true;
510             break;
511         }
512         
513         JSValue prototypeValue = current->prototype();
514         if (prototypeValue.isNull())
515             break;
516         current = asObject(prototypeValue);
517     }
518     if (!foundGlobalObject)
519         return;
520     
521     m_foundObjects.append(object);
522 }
523
524 } // end private namespace for helpers for JSGlobalObject::haveABadTime()
525
526 void JSGlobalObject::haveABadTime(VM& vm)
527 {
528     ASSERT(&vm == &this->vm());
529     
530     if (isHavingABadTime())
531         return;
532     
533     // Make sure that all allocations or indexed storage transitions that are inlining
534     // the assumption that it's safe to transition to a non-SlowPut array storage don't
535     // do so anymore.
536     m_havingABadTimeWatchpoint->fireAll();
537     ASSERT(isHavingABadTime()); // The watchpoint is what tells us that we're having a bad time.
538     
539     // Make sure that all JSArray allocations that load the appropriate structure from
540     // this object now load a structure that uses SlowPut.
541     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
542         m_arrayStructureForIndexingShapeDuringAllocation[i].set(vm, this, originalArrayStructureForIndexingType(ArrayWithSlowPutArrayStorage));
543     
544     // Make sure that all objects that have indexed storage switch to the slow kind of
545     // indexed storage.
546     MarkedArgumentBuffer foundObjects; // Use MarkedArgumentBuffer because switchToSlowPutArrayStorage() may GC.
547     ObjectsWithBrokenIndexingFinder finder(foundObjects, this);
548     {
549         HeapIterationScope iterationScope(vm.heap);
550         vm.heap.objectSpace().forEachLiveCell(iterationScope, finder);
551     }
552     while (!foundObjects.isEmpty()) {
553         JSObject* object = asObject(foundObjects.last());
554         foundObjects.removeLast();
555         ASSERT(hasBrokenIndexing(object));
556         object->switchToSlowPutArrayStorage(vm);
557     }
558 }
559
560 bool JSGlobalObject::objectPrototypeIsSane()
561 {
562     return !hasIndexedProperties(m_objectPrototype->structure()->indexingType())
563         && m_objectPrototype->prototype().isNull();
564 }
565
566 bool JSGlobalObject::arrayPrototypeChainIsSane()
567 {
568     return !hasIndexedProperties(m_arrayPrototype->structure()->indexingType())
569         && m_arrayPrototype->prototype() == m_objectPrototype.get()
570         && objectPrototypeIsSane();
571 }
572
573 bool JSGlobalObject::stringPrototypeChainIsSane()
574 {
575     return !hasIndexedProperties(m_stringPrototype->structure()->indexingType())
576         && m_stringPrototype->prototype() == m_objectPrototype.get()
577         && objectPrototypeIsSane();
578 }
579
580 void JSGlobalObject::createThrowTypeError(VM& vm)
581 {
582     JSFunction* thrower = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeError);
583     GetterSetter* getterSetter = GetterSetter::create(vm);
584     getterSetter->setGetter(vm, thrower);
585     getterSetter->setSetter(vm, thrower);
586     m_throwTypeErrorGetterSetter.set(vm, this, getterSetter);
587 }
588
589 // Set prototype, and also insert the object prototype at the end of the chain.
590 void JSGlobalObject::resetPrototype(VM& vm, JSValue prototype)
591 {
592     setPrototype(vm, prototype);
593
594     JSObject* oldLastInPrototypeChain = lastInPrototypeChain(this);
595     JSObject* objectPrototype = m_objectPrototype.get();
596     if (oldLastInPrototypeChain != objectPrototype)
597         oldLastInPrototypeChain->setPrototype(vm, objectPrototype);
598 }
599
600 void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
601
602     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(cell);
603     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
604     COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
605     ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
606     Base::visitChildren(thisObject, visitor);
607
608     visitor.append(&thisObject->m_globalThis);
609
610     visitor.append(&thisObject->m_regExpConstructor);
611     visitor.append(&thisObject->m_errorConstructor);
612     visitor.append(&thisObject->m_evalErrorConstructor);
613     visitor.append(&thisObject->m_rangeErrorConstructor);
614     visitor.append(&thisObject->m_referenceErrorConstructor);
615     visitor.append(&thisObject->m_syntaxErrorConstructor);
616     visitor.append(&thisObject->m_typeErrorConstructor);
617     visitor.append(&thisObject->m_URIErrorConstructor);
618     visitor.append(&thisObject->m_promiseConstructor);
619
620     visitor.append(&thisObject->m_evalFunction);
621     visitor.append(&thisObject->m_callFunction);
622     visitor.append(&thisObject->m_applyFunction);
623     visitor.append(&thisObject->m_throwTypeErrorGetterSetter);
624
625     visitor.append(&thisObject->m_objectPrototype);
626     visitor.append(&thisObject->m_functionPrototype);
627     visitor.append(&thisObject->m_arrayPrototype);
628     visitor.append(&thisObject->m_errorPrototype);
629 #if ENABLE(PROMISES)
630     visitor.append(&thisObject->m_promisePrototype);
631 #endif
632
633     visitor.append(&thisObject->m_withScopeStructure);
634     visitor.append(&thisObject->m_strictEvalActivationStructure);
635     visitor.append(&thisObject->m_activationStructure);
636     visitor.append(&thisObject->m_nameScopeStructure);
637     visitor.append(&thisObject->m_argumentsStructure);
638     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
639         visitor.append(&thisObject->m_originalArrayStructureForIndexingShape[i]);
640     for (unsigned i = 0; i < NumberOfIndexingShapes; ++i)
641         visitor.append(&thisObject->m_arrayStructureForIndexingShapeDuringAllocation[i]);
642     visitor.append(&thisObject->m_booleanObjectStructure);
643     visitor.append(&thisObject->m_callbackConstructorStructure);
644     visitor.append(&thisObject->m_callbackFunctionStructure);
645     visitor.append(&thisObject->m_callbackObjectStructure);
646 #if JSC_OBJC_API_ENABLED
647     visitor.append(&thisObject->m_objcCallbackFunctionStructure);
648     visitor.append(&thisObject->m_objcWrapperObjectStructure);
649 #endif
650     visitor.append(&thisObject->m_nullPrototypeObjectStructure);
651     visitor.append(&thisObject->m_errorStructure);
652     visitor.append(&thisObject->m_functionStructure);
653     visitor.append(&thisObject->m_boundFunctionStructure);
654     visitor.append(&thisObject->m_namedFunctionStructure);
655     visitor.append(&thisObject->m_privateNameStructure);
656     visitor.append(&thisObject->m_regExpMatchesArrayStructure);
657     visitor.append(&thisObject->m_regExpStructure);
658     visitor.append(&thisObject->m_internalFunctionStructure);
659
660 #if ENABLE(PROMISES)
661     visitor.append(&thisObject->m_promiseStructure);
662 #endif // ENABLE(PROMISES)
663
664 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
665     visitor.append(&thisObject->m_ ## lowerName ## Prototype); \
666     visitor.append(&thisObject->m_ ## properName ## Structure); \
667
668     FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
669
670 #undef VISIT_SIMPLE_TYPE
671
672     for (unsigned i = NUMBER_OF_TYPED_ARRAY_TYPES; i--;) {
673         visitor.append(&thisObject->m_typedArrays[i].prototype);
674         visitor.append(&thisObject->m_typedArrays[i].structure);
675     }
676 }
677
678 JSValue JSGlobalObject::toThis(JSCell*, ExecState* exec, ECMAMode ecmaMode)
679 {
680     if (ecmaMode == StrictMode)
681         return jsUndefined();
682     return exec->globalThisValue();
683 }
684
685 ExecState* JSGlobalObject::globalExec()
686 {
687     return CallFrame::create(m_globalCallFrame);
688 }
689
690 void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
691 {
692     addRegisters(count);
693
694     for (int i = 0; i < count; ++i) {
695         GlobalPropertyInfo& global = globals[i];
696         ASSERT(global.attributes & DontDelete);
697         
698         int index = symbolTable()->size();
699         SymbolTableEntry newEntry(index, global.attributes);
700         symbolTable()->add(global.identifier.impl(), newEntry);
701         registerAt(index).set(vm(), this, global.value);
702     }
703 }
704
705 bool JSGlobalObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
706 {
707     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
708     if (getStaticFunctionSlot<Base>(exec, ExecState::globalObjectTable(exec->vm()), thisObject, propertyName, slot))
709         return true;
710     return symbolTableGet(thisObject, propertyName, slot);
711 }
712
713 void JSGlobalObject::clearRareData(JSCell* cell)
714 {
715     jsCast<JSGlobalObject*>(cell)->m_rareData.clear();
716 }
717
718 void slowValidateCell(JSGlobalObject* globalObject)
719 {
720     RELEASE_ASSERT(globalObject->isGlobalObject());
721     ASSERT_GC_OBJECT_INHERITS(globalObject, JSGlobalObject::info());
722 }
723
724 UnlinkedProgramCodeBlock* JSGlobalObject::createProgramCodeBlock(CallFrame* callFrame, ProgramExecutable* executable, JSObject** exception)
725 {
726     ParserError error;
727     JSParserStrictness strictness = executable->isStrictMode() ? JSParseStrict : JSParseNormal;
728     DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff;
729     ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff;
730     UnlinkedProgramCodeBlock* unlinkedCodeBlock = vm().codeCache()->getProgramCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error);
731
732     if (hasDebugger())
733         debugger()->sourceParsed(callFrame, executable->source().provider(), error.m_line, error.m_message);
734
735     if (error.m_type != ParserError::ErrorNone) {
736         *exception = error.toErrorObject(this, executable->source());
737         return 0;
738     }
739     
740     return unlinkedCodeBlock;
741 }
742
743 UnlinkedEvalCodeBlock* JSGlobalObject::createEvalCodeBlock(CallFrame* callFrame, EvalExecutable* executable)
744 {
745     ParserError error;
746     JSParserStrictness strictness = executable->isStrictMode() ? JSParseStrict : JSParseNormal;
747     DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff;
748     ProfilerMode profilerMode = hasProfiler() ? ProfilerOn : ProfilerOff;
749     UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock(vm(), executable, executable->source(), strictness, debuggerMode, profilerMode, error);
750
751     if (hasDebugger())
752         debugger()->sourceParsed(callFrame, executable->source().provider(), error.m_line, error.m_message);
753
754     if (error.m_type != ParserError::ErrorNone) {
755         throwVMError(callFrame, error.toErrorObject(this, executable->source()));
756         return 0;
757     }
758
759     return unlinkedCodeBlock;
760 }
761
762 void JSGlobalObject::setRemoteDebuggingEnabled(bool enabled)
763 {
764 #if ENABLE(REMOTE_INSPECTOR)
765     m_inspectorDebuggable->setRemoteDebuggingAllowed(enabled);
766 #else
767     UNUSED_PARAM(enabled);
768 #endif
769 }
770
771 bool JSGlobalObject::remoteDebuggingEnabled() const
772 {
773 #if ENABLE(REMOTE_INSPECTOR)
774     return m_inspectorDebuggable->remoteDebuggingAllowed();
775 #else
776     return false;
777 #endif
778 }
779
780 #if ENABLE(WEB_REPLAY)
781 void JSGlobalObject::setInputCursor(PassRefPtr<InputCursor> prpCursor)
782 {
783     m_inputCursor = prpCursor;
784 }
785 #endif
786
787 void JSGlobalObject::setName(const String& name)
788 {
789     m_name = name;
790
791 #if ENABLE(REMOTE_INSPECTOR)
792     m_inspectorDebuggable->update();
793 #endif
794 }
795
796 void JSGlobalObject::queueMicrotask(PassRefPtr<Microtask> task)
797 {
798     if (globalObjectMethodTable()->queueTaskToEventLoop)
799         globalObjectMethodTable()->queueTaskToEventLoop(this, task);
800     else
801         WTFLogAlways("ERROR: Event loop not supported.");
802 }
803
804 } // namespace JSC