Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/JSGlobalObject.h
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r33038 r33979 2 2 /* 3 3 * Copyright (C) 2007 Eric Seidel <[email protected]> 4 * Copyright (C) 2007 Apple Inc. All rights reserved.4 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 25 25 26 26 #include "JSVariableObject.h" 27 #include "Activation.h" 27 #include "RegisterFile.h" 28 #include "RegisterFileStack.h" 29 #include <wtf/HashSet.h> 30 #include <wtf/OwnPtr.h> 28 31 29 32 namespace KJS { 30 33 31 class ActivationImp;32 34 class ArrayObjectImp; 33 35 class ArrayPrototype; … … 51 53 class ObjectObjectImp; 52 54 class ObjectPrototype; 55 class ProgramCodeBlock; 53 56 class PrototypeReflexiveFunction; 54 57 class RangeError; … … 78 81 79 82 struct JSGlobalObjectData : public JSVariableObjectData { 80 JSGlobalObjectData() 81 : JSVariableObjectData(&inlineSymbolTable) 83 JSGlobalObjectData(JSGlobalObject* globalObject, JSObject* thisValue) 84 : JSVariableObjectData(&symbolTable, registerFileStack.globalBasePointer(), 0) 85 , globalScopeChain(globalObject) 86 , globalExec(new ExecState(globalObject, thisValue, globalScopeChain.node())) 82 87 { 83 88 } … … 88 93 Debugger* debugger; 89 94 90 OwnPtr<GlobalExecState> globalExec; 95 RegisterFileStack registerFileStack; 96 ScopeChain globalScopeChain; 97 OwnPtr<ExecState> globalExec; 98 91 99 int recursion; 92 100 … … 132 140 NativeErrorPrototype* URIErrorPrototype; 133 141 134 SymbolTable inlineSymbolTable; 135 136 ExecStateStack activeExecStates; 137 138 ActivationStackNode* activations; 139 size_t activationCount; 140 142 SymbolTable symbolTable; 141 143 unsigned pageGroupIdentifier; 142 144 145 PerThreadData perThreadData; 146 147 HashSet<ProgramCodeBlock*> codeBlocks; 148 143 149 OwnPtr<HashSet<JSObject*> > arrayVisitedElements; // Global data shared by array prototype functions. 144 145 PerThreadData perThreadData;146 150 }; 147 151 148 152 public: 149 153 JSGlobalObject() 150 : JSVariableObject(new JSGlobalObjectData )154 : JSVariableObject(new JSGlobalObjectData(this, this)) 151 155 { 152 156 init(this); … … 155 159 protected: 156 160 JSGlobalObject(JSValue* proto, JSObject* globalThisValue) 157 : JSVariableObject(proto, new JSGlobalObjectData )161 : JSVariableObject(proto, new JSGlobalObjectData(this, globalThisValue)) 158 162 { 159 163 init(globalThisValue); … … 164 168 165 169 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 170 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable); 166 171 virtual void put(ExecState*, const Identifier&, JSValue*); 167 172 virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue* value, unsigned attributes); … … 228 233 void incRecursion() { ++d()->recursion; } 229 234 void decRecursion() { --d()->recursion; } 235 236 ScopeChain& globalScopeChain() { return d()->globalScopeChain; } 230 237 231 238 virtual void mark(); … … 240 247 virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; } 241 248 242 ActivationImp* pushActivation(ExecState*);243 void popActivation();244 void tearOffActivation(ExecState*, bool markAsRelic = false);245 246 249 virtual bool isDynamicScope() const; 247 250 248 ExecStateStack& activeExecStates() const { return d()->activeExecStates; }249 250 251 HashSet<JSObject*>& arrayVisitedElements() { if (!d()->arrayVisitedElements) d()->arrayVisitedElements.set(new HashSet<JSObject*>); return *d()->arrayVisitedElements; } 252 253 HashSet<ProgramCodeBlock*>& codeBlocks() { return d()->codeBlocks; } 254 255 RegisterFileStack& registerFileStack() { return d()->registerFileStack; } 251 256 252 257 // Per-thread hash tables, cached on the global object for faster access. … … 261 266 JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); } 262 267 268 struct GlobalPropertyInfo { 269 GlobalPropertyInfo(const Identifier& i, JSValue* v, unsigned a) 270 : identifier(i) 271 , value(v) 272 , attributes(a) 273 { 274 } 275 276 const Identifier& identifier; 277 JSValue* value; 278 unsigned attributes; 279 }; 280 void addStaticGlobals(GlobalPropertyInfo*, int count); 281 263 282 bool checkTimeout(); 264 283 void resetTimeoutCheck(); 265 284 266 void deleteActivationStack();267 void checkActivationCount();268 269 285 static JSGlobalObject* s_head; 270 286 }; 271 287 288 inline void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count) 289 { 290 RegisterFile* registerFile = registerFileStack().current(); 291 ASSERT(registerFile->safeForReentry() && registerFile->isGlobal() && !registerFile->size()); 292 int index = -registerFile->numGlobalSlots() - 1; 293 registerFile->addGlobalSlots(count); 294 for (int i = 0; i < count; ++i) { 295 ASSERT(globals[i].attributes & DontDelete); 296 SymbolTableEntry newEntry(index, globals[i].attributes); 297 symbolTable().add(globals[i].identifier.ustring().rep(), newEntry); 298 valueAt(index) = globals[i].value; 299 --index; 300 } 301 } 302 303 inline bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 304 { 305 if (JSVariableObject::getOwnPropertySlot(exec, propertyName, slot)) 306 return true; 307 return symbolTableGet(propertyName, slot); 308 } 309 310 inline bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable) 311 { 312 if (JSVariableObject::getOwnPropertySlotForWrite(exec, propertyName, slot, slotIsWriteable)) 313 return true; 314 return symbolTableGet(propertyName, slot, slotIsWriteable); 315 } 316 272 317 inline bool JSGlobalObject::timedOut() 273 318 { … … 280 325 } 281 326 282 inline ActivationImp* JSGlobalObject::pushActivation(ExecState* exec) 283 { 284 if (d()->activationCount == activationStackNodeSize) { 285 ActivationStackNode* newNode = new ActivationStackNode; 286 newNode->prev = d()->activations; 287 d()->activations = newNode; 288 d()->activationCount = 0; 289 } 290 291 StackActivation* stackEntry = &d()->activations->data[d()->activationCount++]; 292 stackEntry->activationStorage.init(exec); 293 return &stackEntry->activationStorage; 294 } 295 296 inline void JSGlobalObject::checkActivationCount() 297 { 298 if (!d()->activationCount) { 299 ActivationStackNode* prev = d()->activations->prev; 300 ASSERT(prev); 301 delete d()->activations; 302 d()->activations = prev; 303 d()->activationCount = activationStackNodeSize; 304 } 305 } 306 307 inline void JSGlobalObject::popActivation() 308 { 309 checkActivationCount(); 310 d()->activations->data[--d()->activationCount].activationDataStorage.localStorage.shrink(0); 327 inline JSGlobalObject* ScopeChainNode::globalObject() const 328 { 329 JSGlobalObject* globalObject = static_cast<JSGlobalObject*>(bottom()); 330 ASSERT(globalObject->isGlobalObject()); 331 return globalObject; 311 332 } 312 333
Note:
See TracChangeset
for help on using the changeset viewer.