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