source: webkit/trunk/JavaScriptCore/kjs/JSGlobalObject.cpp@ 36100

Last change on this file since 36100 was 36058, checked in by [email protected], 17 years ago

JavaScriptCore:

2008-09-02 Kevin McCullough <[email protected]>

Reviewed by Darin and Tim.

Remove most of the "zombie" mode from the profiler. Next we will need
to remove the client callback mechanism in profiles.

  • This simplifies the code, leverages the recent changes I've made in getting line numbers from SquirrelFish, and is a slight speed improvement on SunSpider.
  • Also the "zombie" mode was a constant source of odd edge cases and obscure bugs so it's good to remove since all of its issues may not have been found.
  • API/JSProfilerPrivate.cpp: No need to call didFinishAllExecution() any more. (JSEndProfiling):
  • JavaScriptCore.exp: Export the new signature of retrieveLastCaller()
  • VM/Machine.cpp: (KJS::Machine::execute): No need to call didFinishAllExecution() any more. (KJS::Machine::retrieveCaller): Now operates on InternalFunctions now since the RegisterFile is no longer guaranteeded to store only JSFunctions (KJS::Machine::retrieveLastCaller): Now also retrieve the function's name (KJS::Machine::callFrame): A result of changing retrieveCaller()
  • VM/Machine.h:
  • VM/Register.h:
  • kjs/JSGlobalObject.cpp: (KJS::JSGlobalObject::~JSGlobalObject):
  • kjs/nodes.h:
  • profiler/ProfileGenerator.cpp: (KJS::ProfileGenerator::create): Now pass the original exec and get the global exec and client when necessary. We need the original exec so we can have the stack frame where profiling started. (KJS::ProfileGenerator::ProfileGenerator): ditto. (KJS::ProfileGenerator::addParentForConsoleStart): This is where the parent to star of the profile is added, if there is one. (KJS::ProfileGenerator::willExecute): Remove uglyness! (KJS::ProfileGenerator::didExecute): Ditto! (KJS::ProfileGenerator::stopProfiling): (KJS::ProfileGenerator::removeProfileStart): Use a better way to find and remove the function we are looking for. (KJS::ProfileGenerator::removeProfileEnd): Ditto.
  • profiler/ProfileGenerator.h: (KJS::ProfileGenerator::client):
  • profiler/ProfileNode.cpp: (KJS::ProfileNode::removeChild): Add a better way to remove a child from a ProfileNode. (KJS::ProfileNode::stopProfiling): (KJS::ProfileNode::debugPrintData): Modified a debug-only diagnostic function to be sane.
  • profiler/ProfileNode.h:
  • profiler/Profiler.cpp: Change to pass the original exec state. (KJS::Profiler::startProfiling): (KJS::Profiler::stopProfiling): (KJS::Profiler::willExecute): (KJS::Profiler::didExecute): (KJS::Profiler::createCallIdentifier):
  • profiler/Profiler.h:

WebCore:

2008-09-03 Kevin McCullough <[email protected]>

Reviewed by Darin and Tim.

Remove most of the "zombie" mode from the profiler. Next we will need
to remove the client callback mechanism in profiles.

  • These changes are a result of changes to JSCore.
  • manual-tests/inspector/profiler-test-nested-start-and-stop-profiler.html:
  • page/Console.cpp: (WebCore::retrieveLastCaller): (WebCore::Console::profileEnd):
  • page/InspectorController.cpp: (WebCore::InspectorController::stopUserInitiatedProfiling):
  • Property svn:eol-style set to native
File size: 19.3 KB
Line 
1/*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Cameron Zwarich ([email protected])
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 "ArrayConstructor.h"
34#include "ArrayPrototype.h"
35#include "BooleanConstructor.h"
36#include "BooleanPrototype.h"
37#include "CodeBlock.h"
38#include "DateConstructor.h"
39#include "DatePrototype.h"
40#include "ErrorConstructor.h"
41#include "ErrorPrototype.h"
42#include "FunctionConstructor.h"
43#include "FunctionPrototype.h"
44#include "GlobalEvalFunction.h"
45#include "JSGlobalObjectFunctions.h"
46#include "JSLock.h"
47#include "Machine.h"
48#include "MathObject.h"
49#include "NativeErrorConstructor.h"
50#include "NativeErrorPrototype.h"
51#include "NumberConstructor.h"
52#include "NumberPrototype.h"
53#include "ObjectConstructor.h"
54#include "ObjectPrototype.h"
55#include "Profiler.h"
56#include "PrototypeFunction.h"
57#include "RegExpConstructor.h"
58#include "RegExpPrototype.h"
59#include "ScopeChainMark.h"
60#include "StringConstructor.h"
61#include "StringPrototype.h"
62#include "debugger.h"
63
64namespace KJS {
65
66ASSERT_CLASS_FITS_IN_CELL(JSGlobalObject);
67
68// Default number of ticks before a timeout check should be done.
69static const int initialTickCountThreshold = 255;
70
71// Preferred number of milliseconds between each timeout check
72static const int preferredScriptCheckTimeInterval = 1000;
73
74static inline void markIfNeeded(JSValue* v)
75{
76 if (v && !v->marked())
77 v->mark();
78}
79
80JSGlobalObject::~JSGlobalObject()
81{
82 ASSERT(JSLock::currentThreadIsHoldingLock());
83
84 if (d()->debugger)
85 d()->debugger->detach(this);
86
87 Profiler** profiler = Profiler::enabledProfilerReference();
88 if (UNLIKELY(*profiler != 0)) {
89 (*profiler)->stopProfiling(globalExec(), UString());
90 }
91
92 d()->next->d()->prev = d()->prev;
93 d()->prev->d()->next = d()->next;
94 JSGlobalObject*& headObject = head();
95 if (headObject == this)
96 headObject = d()->next;
97 if (headObject == this)
98 headObject = 0;
99
100 HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end();
101 for (HashSet<ProgramCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it)
102 (*it)->globalObject = 0;
103
104 RegisterFile& registerFile = globalData()->machine->registerFile();
105 if (registerFile.globalObject() == this) {
106 registerFile.setGlobalObject(0);
107 registerFile.setNumGlobals(0);
108 }
109 delete d();
110}
111
112void JSGlobalObject::init(JSObject* thisValue)
113{
114 ASSERT(JSLock::currentThreadIsHoldingLock());
115
116 d()->globalData = Heap::heap(this)->globalData();
117
118 if (JSGlobalObject*& headObject = head()) {
119 d()->prev = headObject;
120 d()->next = headObject->d()->next;
121 headObject->d()->next->d()->prev = this;
122 headObject->d()->next = this;
123 } else
124 headObject = d()->next = d()->prev = this;
125
126 d()->recursion = 0;
127 d()->debugger = 0;
128 globalData()->machine->initTimeout();
129
130 d()->globalExec.set(new ExecState(this, thisValue, d()->globalScopeChain.node()));
131
132 d()->profileGroup = 0;
133
134 reset(prototype());
135}
136
137void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot)
138{
139 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
140
141 if (symbolTablePut(propertyName, value))
142 return;
143 JSVariableObject::put(exec, propertyName, value, slot);
144}
145
146void JSGlobalObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue* value, unsigned attributes)
147{
148 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
149
150 if (symbolTablePutWithAttributes(propertyName, value, attributes))
151 return;
152
153 JSValue* valueBefore = getDirect(propertyName);
154 PutPropertySlot slot;
155 JSVariableObject::put(exec, propertyName, value, slot);
156 if (!valueBefore) {
157 if (JSValue* valueAfter = getDirect(propertyName))
158 putDirect(propertyName, valueAfter, attributes);
159 }
160}
161
162void JSGlobalObject::defineGetter(ExecState* exec, const Identifier& propertyName, JSObject* getterFunc)
163{
164 PropertySlot slot;
165 if (!symbolTableGet(propertyName, slot))
166 JSVariableObject::defineGetter(exec, propertyName, getterFunc);
167}
168
169void JSGlobalObject::defineSetter(ExecState* exec, const Identifier& propertyName, JSObject* setterFunc)
170{
171 PropertySlot slot;
172 if (!symbolTableGet(propertyName, slot))
173 JSVariableObject::defineSetter(exec, propertyName, setterFunc);
174}
175
176static inline JSObject* lastInPrototypeChain(JSObject* object)
177{
178 JSObject* o = object;
179 while (o->prototype()->isObject())
180 o = static_cast<JSObject*>(o->prototype());
181 return o;
182}
183
184void JSGlobalObject::reset(JSValue* prototype)
185{
186 // Clear before inititalizing, to avoid calling mark() on stale pointers --
187 // which would be wasteful -- or uninitialized pointers -- which would be
188 // dangerous. (The allocations below may cause a GC.)
189
190 ASSERT(!hasCustomProperties());
191 symbolTable().clear();
192 setRegisterArray(0, 0);
193
194 // Prototypes
195 d()->functionPrototype = 0;
196 d()->objectPrototype = 0;
197
198 d()->arrayPrototype = 0;
199 d()->stringPrototype = 0;
200 d()->booleanPrototype = 0;
201 d()->numberPrototype = 0;
202 d()->datePrototype = 0;
203 d()->regExpPrototype = 0;
204 d()->errorPrototype = 0;
205
206 d()->evalErrorPrototype = 0;
207 d()->rangeErrorPrototype = 0;
208 d()->referenceErrorPrototype = 0;
209 d()->syntaxErrorPrototype = 0;
210 d()->typeErrorPrototype = 0;
211 d()->URIErrorPrototype = 0;
212
213 // Constructors
214 d()->regExpConstructor = 0;
215 d()->errorConstructor = 0;
216
217 d()->evalErrorConstructor = 0;
218 d()->rangeErrorConstructor = 0;
219 d()->referenceErrorConstructor = 0;
220 d()->syntaxErrorConstructor = 0;
221 d()->typeErrorConstructor = 0;
222 d()->URIErrorConstructor = 0;
223
224 d()->evalFunction = 0;
225
226 ExecState* exec = d()->globalExec.get();
227
228 // Prototypes
229
230 d()->functionPrototype = new (exec) FunctionPrototype(exec);
231 d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->functionPrototype);
232 d()->functionPrototype->setPrototype(d()->objectPrototype);
233
234 d()->arrayPrototype = new (exec) ArrayPrototype(exec, d()->objectPrototype);
235 d()->stringPrototype = new (exec) StringPrototype(exec, d()->objectPrototype);
236 d()->booleanPrototype = new (exec) BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);
237 d()->numberPrototype = new (exec) NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);
238 d()->datePrototype = new (exec) DatePrototype(exec, d()->objectPrototype);
239 d()->regExpPrototype = new (exec) RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);
240 d()->errorPrototype = new (exec) ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);
241
242 d()->evalErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "EvalError", "EvalError");
243 d()->rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "RangeError", "RangeError");
244 d()->referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "ReferenceError", "ReferenceError");
245 d()->syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "SyntaxError", "SyntaxError");
246 d()->typeErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "TypeError", "TypeError");
247 d()->URIErrorPrototype = new (exec) NativeErrorPrototype(exec, d()->errorPrototype, "URIError", "URIError");
248
249 // Constructors
250
251 JSValue* objectConstructor = new (exec) ObjectConstructor(exec, d()->objectPrototype, d()->functionPrototype);
252 JSValue* functionConstructor = new (exec) FunctionConstructor(exec, d()->functionPrototype);
253 JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, d()->functionPrototype, d()->arrayPrototype);
254 JSValue* stringConstructor = new (exec) StringConstructor(exec, d()->functionPrototype, d()->stringPrototype);
255 JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, d()->functionPrototype, d()->booleanPrototype);
256 JSValue* numberConstructor = new (exec) NumberConstructor(exec, d()->functionPrototype, d()->numberPrototype);
257 JSValue* dateConstructor = new (exec) DateConstructor(exec, d()->functionPrototype, d()->datePrototype);
258
259 d()->regExpConstructor = new (exec) RegExpConstructor(exec, d()->functionPrototype, d()->regExpPrototype);
260
261 d()->errorConstructor = new (exec) ErrorConstructor(exec, d()->functionPrototype, d()->errorPrototype);
262
263 d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->evalErrorPrototype);
264 d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->rangeErrorPrototype);
265 d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->referenceErrorPrototype);
266 d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->syntaxErrorPrototype);
267 d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->typeErrorPrototype);
268 d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, d()->functionPrototype, d()->URIErrorPrototype);
269
270 d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
271
272 d()->objectPrototype->putDirect(exec->propertyNames().constructor, objectConstructor, DontEnum);
273 d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum);
274 d()->arrayPrototype->putDirect(exec->propertyNames().constructor, arrayConstructor, DontEnum);
275 d()->booleanPrototype->putDirect(exec->propertyNames().constructor, booleanConstructor, DontEnum);
276 d()->stringPrototype->putDirect(exec->propertyNames().constructor, stringConstructor, DontEnum);
277 d()->numberPrototype->putDirect(exec->propertyNames().constructor, numberConstructor, DontEnum);
278 d()->datePrototype->putDirect(exec->propertyNames().constructor, dateConstructor, DontEnum);
279 d()->regExpPrototype->putDirect(exec->propertyNames().constructor, d()->regExpConstructor, DontEnum);
280 d()->errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum);
281 d()->evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum);
282 d()->rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum);
283 d()->referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum);
284 d()->syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum);
285 d()->typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum);
286 d()->URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum);
287
288 // Set global constructors
289
290 // FIXME: These properties could be handled by a static hash table.
291
292 putDirect(Identifier(exec, "Object"), objectConstructor, DontEnum);
293 putDirect(Identifier(exec, "Function"), functionConstructor, DontEnum);
294 putDirect(Identifier(exec, "Array"), arrayConstructor, DontEnum);
295 putDirect(Identifier(exec, "Boolean"), booleanConstructor, DontEnum);
296 putDirect(Identifier(exec, "String"), stringConstructor, DontEnum);
297 putDirect(Identifier(exec, "Number"), numberConstructor, DontEnum);
298 putDirect(Identifier(exec, "Date"), dateConstructor, DontEnum);
299 putDirect(Identifier(exec, "RegExp"), d()->regExpConstructor, DontEnum);
300 putDirect(Identifier(exec, "Error"), d()->errorConstructor, DontEnum);
301 putDirect(Identifier(exec, "EvalError"), d()->evalErrorConstructor);
302 putDirect(Identifier(exec, "RangeError"), d()->rangeErrorConstructor);
303 putDirect(Identifier(exec, "ReferenceError"), d()->referenceErrorConstructor);
304 putDirect(Identifier(exec, "SyntaxError"), d()->syntaxErrorConstructor);
305 putDirect(Identifier(exec, "TypeError"), d()->typeErrorConstructor);
306 putDirect(Identifier(exec, "URIError"), d()->URIErrorConstructor);
307
308 // Set global values.
309 GlobalPropertyInfo staticGlobals[] = {
310 GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, d()->objectPrototype), DontEnum | DontDelete),
311 GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete),
312 GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete),
313 GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete)
314 };
315
316 addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
317
318 // Set global functions.
319
320 d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);
321 putDirectFunction(exec, d()->evalFunction, DontEnum);
322 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
323 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
324 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
325 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
326 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
327 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
328 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
329 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
330 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
331 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
332#ifndef NDEBUG
333 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);
334#endif
335
336 resetPrototype(prototype);
337}
338
339// Set prototype, and also insert the object prototype at the end of the chain.
340void JSGlobalObject::resetPrototype(JSValue* prototype)
341{
342 setPrototype(prototype);
343 lastInPrototypeChain(this)->setPrototype(d()->objectPrototype);
344}
345
346void JSGlobalObject::setTimeoutTime(unsigned timeoutTime)
347{
348 globalData()->machine->setTimeoutTime(timeoutTime);
349}
350
351void JSGlobalObject::startTimeoutCheck()
352{
353 globalData()->machine->startTimeoutCheck();
354}
355
356void JSGlobalObject::stopTimeoutCheck()
357{
358 globalData()->machine->stopTimeoutCheck();
359}
360
361void JSGlobalObject::mark()
362{
363 JSVariableObject::mark();
364
365 HashSet<ProgramCodeBlock*>::const_iterator end = codeBlocks().end();
366 for (HashSet<ProgramCodeBlock*>::const_iterator it = codeBlocks().begin(); it != end; ++it)
367 (*it)->mark();
368
369 RegisterFile& registerFile = globalData()->machine->registerFile();
370 if (registerFile.globalObject() == this)
371 registerFile.markGlobals(globalData()->heap);
372
373 markIfNeeded(d()->globalExec->exception());
374
375 markIfNeeded(d()->regExpConstructor);
376 markIfNeeded(d()->errorConstructor);
377 markIfNeeded(d()->evalErrorConstructor);
378 markIfNeeded(d()->rangeErrorConstructor);
379 markIfNeeded(d()->referenceErrorConstructor);
380 markIfNeeded(d()->syntaxErrorConstructor);
381 markIfNeeded(d()->typeErrorConstructor);
382 markIfNeeded(d()->URIErrorConstructor);
383
384 markIfNeeded(d()->evalFunction);
385
386 markIfNeeded(d()->objectPrototype);
387 markIfNeeded(d()->functionPrototype);
388 markIfNeeded(d()->arrayPrototype);
389 markIfNeeded(d()->booleanPrototype);
390 markIfNeeded(d()->stringPrototype);
391 markIfNeeded(d()->numberPrototype);
392 markIfNeeded(d()->datePrototype);
393 markIfNeeded(d()->regExpPrototype);
394 markIfNeeded(d()->errorPrototype);
395 markIfNeeded(d()->evalErrorPrototype);
396 markIfNeeded(d()->rangeErrorPrototype);
397 markIfNeeded(d()->referenceErrorPrototype);
398 markIfNeeded(d()->syntaxErrorPrototype);
399 markIfNeeded(d()->typeErrorPrototype);
400 markIfNeeded(d()->URIErrorPrototype);
401}
402
403JSGlobalObject* JSGlobalObject::toGlobalObject(ExecState*) const
404{
405 return const_cast<JSGlobalObject*>(this);
406}
407
408ExecState* JSGlobalObject::globalExec()
409{
410 return d()->globalExec.get();
411}
412
413bool JSGlobalObject::isDynamicScope() const
414{
415 return true;
416}
417
418void JSGlobalObject::copyGlobalsFrom(RegisterFile& registerFile)
419{
420 ASSERT(!d()->registerArray);
421 ASSERT(!d()->registerArraySize);
422
423 int numGlobals = registerFile.numGlobals();
424 if (!numGlobals) {
425 d()->registers = 0;
426 return;
427 }
428 copyRegisterArray(registerFile.lastGlobal(), numGlobals);
429}
430
431void JSGlobalObject::copyGlobalsTo(RegisterFile& registerFile)
432{
433 JSGlobalObject* lastGlobalObject = registerFile.globalObject();
434 if (lastGlobalObject && lastGlobalObject != this)
435 lastGlobalObject->copyGlobalsFrom(registerFile);
436
437 registerFile.setGlobalObject(this);
438 registerFile.setNumGlobals(symbolTable().size());
439
440 if (d()->registerArray) {
441 memcpy(registerFile.base() - d()->registerArraySize, d()->registerArray.get(), d()->registerArraySize * sizeof(Register));
442 setRegisterArray(0, 0);
443 }
444
445 d()->registers = registerFile.base();
446}
447
448void* JSGlobalObject::operator new(size_t size, JSGlobalData* globalData)
449{
450#ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE
451 return globalData->heap->inlineAllocate(size);
452#else
453 return globalData->heap->allocate(size);
454#endif
455}
456
457} // namespace KJS
Note: See TracBrowser for help on using the repository browser.