Changeset 36726 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
- Timestamp:
- Sep 20, 2008, 7:29:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r36263 r36726 78 78 } 79 79 80 static inline void markIfNeeded(const RefPtr<StructureID>& s) 81 { 82 if (s) 83 s->mark(); 84 } 85 80 86 JSGlobalObject::~JSGlobalObject() 81 87 { … … 192 198 setRegisterArray(0, 0); 193 199 200 ExecState* exec = d()->globalExec.get(); 201 194 202 // 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; 203 204 d()->functionPrototype = new (exec) FunctionPrototype(exec); 205 d()->functionStructure = StructureID::create(d()->functionPrototype); 206 d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype); 207 d()->prototypeFunctionStructure = StructureID::create(d()->functionPrototype); 208 d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype); 209 d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get()); 210 d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->prototypeFunctionStructure.get()); 211 d()->emptyObjectStructure = d()->objectPrototype->inheritorID(); 212 d()->functionPrototype->setPrototype(d()->objectPrototype); 213 d()->argumentsStructure = StructureID::create(d()->objectPrototype); 214 d()->callbackConstructorStructure = StructureID::create(d()->objectPrototype); 215 d()->callbackObjectStructure = StructureID::create(d()->objectPrototype); 216 d()->arrayPrototype = new (exec) ArrayPrototype(StructureID::create(d()->objectPrototype)); 217 d()->arrayStructure = StructureID::create(d()->arrayPrototype); 218 d()->regExpMatchesArrayStructure = StructureID::create(d()->arrayPrototype); 219 d()->stringPrototype = new (exec) StringPrototype(exec, StructureID::create(d()->objectPrototype)); 220 d()->stringObjectStructure = StructureID::create(d()->stringPrototype); 221 d()->booleanPrototype = new (exec) BooleanPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get()); 222 d()->booleanObjectStructure = StructureID::create(d()->booleanPrototype); 223 d()->numberPrototype = new (exec) NumberPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get()); 224 d()->numberObjectStructure = StructureID::create(d()->numberPrototype); 225 d()->datePrototype = new (exec) DatePrototype(exec, StructureID::create(d()->objectPrototype)); 226 d()->dateStructure = StructureID::create(d()->datePrototype); 227 d()->regExpPrototype = new (exec) RegExpPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get()); 228 d()->regExpStructure = StructureID::create(d()->regExpPrototype); 229 ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get()); 230 d()->errorStructure = StructureID::create(errorPrototype); 231 232 RefPtr<StructureID> nativeErrorPrototypeStructure = StructureID::create(errorPrototype); 233 234 NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "EvalError", "EvalError"); 235 NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "RangeError", "RangeError"); 236 NativeErrorPrototype* referenceErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "ReferenceError", "ReferenceError"); 237 NativeErrorPrototype* syntaxErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "SyntaxError", "SyntaxError"); 238 NativeErrorPrototype* typeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "TypeError", "TypeError"); 239 NativeErrorPrototype* URIErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "URIError", "URIError"); 212 240 213 241 // 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); 242 243 JSValue* objectConstructor = new (exec) ObjectConstructor(exec, StructureID::create(d()->functionPrototype), d()->objectPrototype); 244 JSValue* functionConstructor = new (exec) FunctionConstructor(exec, StructureID::create(d()->functionPrototype), d()->functionPrototype); 245 JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, StructureID::create(d()->functionPrototype), d()->arrayPrototype); 246 JSValue* stringConstructor = new (exec) StringConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype); 247 JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, StructureID::create(d()->functionPrototype), d()->booleanPrototype); 248 JSValue* numberConstructor = new (exec) NumberConstructor(exec, StructureID::create(d()->functionPrototype), d()->numberPrototype); 249 JSValue* dateConstructor = new (exec) DateConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype); 250 251 d()->regExpConstructor = new (exec) RegExpConstructor(exec, StructureID::create(d()->functionPrototype), d()->regExpPrototype); 252 253 d()->errorConstructor = new (exec) ErrorConstructor(exec, StructureID::create(d()->functionPrototype), errorPrototype); 254 255 RefPtr<StructureID> nativeErrorStructure = StructureID::create(d()->functionPrototype); 256 257 d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype); 258 d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype); 259 d()->referenceErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, referenceErrorPrototype); 260 d()->syntaxErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, syntaxErrorPrototype); 261 d()->typeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, typeErrorPrototype); 262 d()->URIErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, URIErrorPrototype); 269 263 270 264 d()->functionPrototype->putDirect(exec->propertyNames().constructor, functionConstructor, DontEnum); … … 278 272 d()->datePrototype->putDirect(exec->propertyNames().constructor, dateConstructor, DontEnum); 279 273 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);274 errorPrototype->putDirect(exec->propertyNames().constructor, d()->errorConstructor, DontEnum); 275 evalErrorPrototype->putDirect(exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum); 276 rangeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum); 277 referenceErrorPrototype->putDirect(exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum); 278 syntaxErrorPrototype->putDirect(exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum); 279 typeErrorPrototype->putDirect(exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum); 280 URIErrorPrototype->putDirect(exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum); 287 281 288 282 // Set global constructors … … 308 302 // Set global values. 309 303 GlobalPropertyInfo staticGlobals[] = { 310 GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, d()->objectPrototype), DontEnum | DontDelete),304 GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, StructureID::create(d()->objectPrototype)), DontEnum | DontDelete), 311 305 GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete), 312 306 GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete), … … 318 312 // Set global functions. 319 313 320 d()->evalFunction = new (exec) GlobalEvalFunction(exec, d()->functionPrototype, 1, exec->propertyNames().eval, globalFuncEval, this);314 d()->evalFunction = new (exec) GlobalEvalFunction(exec, StructureID::create(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this); 321 315 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);316 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum); 317 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum); 318 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum); 319 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum); 320 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum); 321 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum); 322 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum); 323 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum); 324 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum); 325 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum); 332 326 #ifndef NDEBUG 333 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()-> functionPrototype, 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum);327 putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "kjsprint"), globalFuncKJSPrint), DontEnum); 334 328 #endif 335 329 … … 381 375 markIfNeeded(d()->typeErrorConstructor); 382 376 markIfNeeded(d()->URIErrorConstructor); 383 377 384 378 markIfNeeded(d()->evalFunction); 385 379 386 380 markIfNeeded(d()->objectPrototype); 387 381 markIfNeeded(d()->functionPrototype); 388 markIfNeeded(d()->arrayPrototype);389 382 markIfNeeded(d()->booleanPrototype); 390 383 markIfNeeded(d()->stringPrototype); … … 392 385 markIfNeeded(d()->datePrototype); 393 386 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); 387 388 markIfNeeded(d()->errorStructure); 389 390 // No need to mark the other structures, because their prototypes are all 391 // guaranteed to be referenced elsewhere. 401 392 } 402 393
Note:
See TracChangeset
for help on using the changeset viewer.