Changeset 28527 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Dec 7, 2007, 2:05:55 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.cpp
r28468 r28527 51 51 if (type == FunctionCode) { 52 52 m_activation = new ActivationImp(this); 53 m_variable = m_activation;53 m_variableObject = m_activation; 54 54 } else { 55 55 m_activation = 0; 56 m_variable = globalObject;56 m_variableObject = globalObject; 57 57 } 58 58 … … 62 62 if (m_callingExec) { 63 63 m_scopeChain = m_callingExec->scopeChain(); 64 m_variable = m_callingExec->variableObject();64 m_variableObject = m_callingExec->variableObject(); 65 65 m_thisVal = m_callingExec->thisValue(); 66 66 break; … … 73 73 m_scopeChain = func->scope(); 74 74 m_scopeChain.push(m_activation); 75 m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3)75 m_variableObject = m_activation; 76 76 m_thisVal = thisV; 77 77 break; … … 107 107 void ExecState::updateLocalStorage() 108 108 { 109 m_localStorageBuffer = static_cast<ActivationImp*>(m_activation)->localStorage().data();109 m_localStorageBuffer = m_activation->localStorage().data(); 110 110 } 111 111 -
trunk/JavaScriptCore/kjs/ExecState.h
r28468 r28527 39 39 }; 40 40 41 class JSGlobalObject; 42 class ScopeChain; 43 class Interpreter; 41 class ActivationImp; 42 class FunctionBodyNode; 44 43 class FunctionImp; 45 44 class GlobalFuncImp; 46 class FunctionBodyNode; 45 class Interpreter; 46 class JSGlobalObject; 47 class JSVariableObject; 48 class ScopeChain; 47 49 struct LocalStorageEntry; 48 50 … … 74 76 const ScopeChain& scopeChain() const { return m_scopeChain; } 75 77 76 JS Object* variableObject() const { return m_variable; }77 void setVariableObject(JS Object* v) { m_variable= v; }78 JSVariableObject* variableObject() const { return m_variableObject; } 79 void setVariableObject(JSVariableObject* v) { m_variableObject = v; } 78 80 79 81 JSObject* thisValue() const { return m_thisVal; } … … 81 83 ExecState* callingExecState() { return m_callingExec; } 82 84 83 JSObject* activationObject() { return m_activation; }85 ActivationImp* activationObject() { return m_activation; } 84 86 CodeType codeType() { return m_codeType; } 85 87 FunctionBodyNode* currentBody() { return m_currentBody; } … … 129 131 FunctionImp* m_function; 130 132 const List* m_arguments; 131 JSObject* m_activation;133 ActivationImp* m_activation; 132 134 LocalStorageEntry* m_localStorageBuffer; 133 135 134 136 ScopeChain m_scopeChain; 135 JS Object* m_variable;137 JSVariableObject* m_variableObject; 136 138 JSObject* m_thisVal; 137 139 -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r28479 r28527 93 93 ASSERT(JSLock::currentThreadIsHoldingLock()); 94 94 95 if (d ->debugger)96 d ->debugger->detach(this);97 98 d ->next->d->prev = d->prev;99 d ->prev->d->next = d->next;100 s_head = d ->next;95 if (d()->debugger) 96 d()->debugger->detach(this); 97 98 d()->next->d()->prev = d()->prev; 99 d()->prev->d()->next = d()->next; 100 s_head = d()->next; 101 101 if (s_head == this) 102 102 s_head = 0; 103 104 delete d(); 103 105 } 104 106 … … 107 109 ASSERT(JSLock::currentThreadIsHoldingLock()); 108 110 109 d.reset(new JSGlobalObjectData(this));110 111 111 if (s_head) { 112 d ->prev = s_head;113 d ->next = s_head->d->next;114 s_head->d ->next->d->prev = this;115 s_head->d ->next = this;112 d()->prev = s_head; 113 d()->next = s_head->d()->next; 114 s_head->d()->next->d()->prev = this; 115 s_head->d()->next = this; 116 116 } else 117 s_head = d ->next = d->prev = this;118 119 d ->compatMode = NativeMode;117 s_head = d()->next = d()->prev = this; 118 119 d()->compatMode = NativeMode; 120 120 121 121 resetTimeoutCheck(); 122 d ->timeoutTime = 0;123 d ->timeoutCheckCount = 0;124 125 d ->currentExec = 0;126 d ->recursion = 0;127 d ->debugger = 0;122 d()->timeoutTime = 0; 123 d()->timeoutCheckCount = 0; 124 125 d()->currentExec = 0; 126 d()->recursion = 0; 127 d()->debugger = 0; 128 128 129 129 reset(prototype()); … … 144 144 // new objects below. 145 145 146 ExecState* exec = &d ->globalExec;146 ExecState* exec = &d()->globalExec; 147 147 148 148 // Prototypes 149 d ->functionPrototype = 0;150 d ->objectPrototype = 0;151 152 d ->arrayPrototype = 0;153 d ->stringPrototype = 0;154 d ->booleanPrototype = 0;155 d ->numberPrototype = 0;156 d ->datePrototype = 0;157 d ->regExpPrototype = 0;158 d ->errorPrototype = 0;159 160 d ->evalErrorPrototype = 0;161 d ->rangeErrorPrototype = 0;162 d ->referenceErrorPrototype = 0;163 d ->syntaxErrorPrototype = 0;164 d ->typeErrorPrototype = 0;165 d ->URIErrorPrototype = 0;149 d()->functionPrototype = 0; 150 d()->objectPrototype = 0; 151 152 d()->arrayPrototype = 0; 153 d()->stringPrototype = 0; 154 d()->booleanPrototype = 0; 155 d()->numberPrototype = 0; 156 d()->datePrototype = 0; 157 d()->regExpPrototype = 0; 158 d()->errorPrototype = 0; 159 160 d()->evalErrorPrototype = 0; 161 d()->rangeErrorPrototype = 0; 162 d()->referenceErrorPrototype = 0; 163 d()->syntaxErrorPrototype = 0; 164 d()->typeErrorPrototype = 0; 165 d()->URIErrorPrototype = 0; 166 166 167 167 // Constructors 168 d ->objectConstructor = 0;169 d ->functionConstructor = 0;170 d ->arrayConstructor = 0;171 d ->stringConstructor = 0;172 d ->booleanConstructor = 0;173 d ->numberConstructor = 0;174 d ->dateConstructor = 0;175 d ->regExpConstructor = 0;176 d ->errorConstructor = 0;177 178 d ->evalErrorConstructor = 0;179 d ->rangeErrorConstructor = 0;180 d ->referenceErrorConstructor = 0;181 d ->syntaxErrorConstructor = 0;182 d ->typeErrorConstructor = 0;183 d ->URIErrorConstructor = 0;168 d()->objectConstructor = 0; 169 d()->functionConstructor = 0; 170 d()->arrayConstructor = 0; 171 d()->stringConstructor = 0; 172 d()->booleanConstructor = 0; 173 d()->numberConstructor = 0; 174 d()->dateConstructor = 0; 175 d()->regExpConstructor = 0; 176 d()->errorConstructor = 0; 177 178 d()->evalErrorConstructor = 0; 179 d()->rangeErrorConstructor = 0; 180 d()->referenceErrorConstructor = 0; 181 d()->syntaxErrorConstructor = 0; 182 d()->typeErrorConstructor = 0; 183 d()->URIErrorConstructor = 0; 184 184 185 185 // Prototypes 186 d ->functionPrototype = new FunctionPrototype(exec);187 d ->objectPrototype = new ObjectPrototype(exec, d->functionPrototype);188 d ->functionPrototype->setPrototype(d->objectPrototype);189 190 d ->arrayPrototype = new ArrayPrototype(exec, d->objectPrototype);191 d ->stringPrototype = new StringPrototype(exec, d->objectPrototype);192 d ->booleanPrototype = new BooleanPrototype(exec, d->objectPrototype, d->functionPrototype);193 d ->numberPrototype = new NumberPrototype(exec, d->objectPrototype, d->functionPrototype);194 d ->datePrototype = new DatePrototype(exec, d->objectPrototype);195 d ->regExpPrototype = new RegExpPrototype(exec, d->objectPrototype, d->functionPrototype);;196 d ->errorPrototype = new ErrorPrototype(exec, d->objectPrototype, d->functionPrototype);197 198 d ->evalErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, EvalError, "EvalError", "EvalError");199 d ->rangeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, RangeError, "RangeError", "RangeError");200 d ->referenceErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");201 d ->syntaxErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");202 d ->typeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, TypeError, "TypeError", "TypeError");203 d ->URIErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, URIError, "URIError", "URIError");186 d()->functionPrototype = new FunctionPrototype(exec); 187 d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype); 188 d()->functionPrototype->setPrototype(d()->objectPrototype); 189 190 d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype); 191 d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype); 192 d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype); 193 d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype); 194 d()->datePrototype = new DatePrototype(exec, d()->objectPrototype); 195 d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);; 196 d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype); 197 198 d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, EvalError, "EvalError", "EvalError"); 199 d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, RangeError, "RangeError", "RangeError"); 200 d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError"); 201 d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError"); 202 d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, TypeError, "TypeError", "TypeError"); 203 d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, URIError, "URIError", "URIError"); 204 204 205 205 // Constructors 206 d ->objectConstructor = new ObjectObjectImp(exec, d->objectPrototype, d->functionPrototype);207 d ->functionConstructor = new FunctionObjectImp(exec, d->functionPrototype);208 d ->arrayConstructor = new ArrayObjectImp(exec, d->functionPrototype, d->arrayPrototype);209 d ->stringConstructor = new StringObjectImp(exec, d->functionPrototype, d->stringPrototype);210 d ->booleanConstructor = new BooleanObjectImp(exec, d->functionPrototype, d->booleanPrototype);211 d ->numberConstructor = new NumberObjectImp(exec, d->functionPrototype, d->numberPrototype);212 d ->dateConstructor = new DateObjectImp(exec, d->functionPrototype, d->datePrototype);213 d ->regExpConstructor = new RegExpObjectImp(exec, d->functionPrototype, d->regExpPrototype);214 d ->errorConstructor = new ErrorObjectImp(exec, d->functionPrototype, d->errorPrototype);215 216 d ->evalErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->evalErrorPrototype);217 d ->rangeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->rangeErrorPrototype);218 d ->referenceErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->referenceErrorPrototype);219 d ->syntaxErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->syntaxErrorPrototype);220 d ->typeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->typeErrorPrototype);221 d ->URIErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->URIErrorPrototype);222 223 d ->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum);224 225 d ->objectPrototype->put(exec, exec->propertyNames().constructor, d->objectConstructor, DontEnum | DontDelete | ReadOnly);226 d ->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum | DontDelete | ReadOnly);227 d ->arrayPrototype->put(exec, exec->propertyNames().constructor, d->arrayConstructor, DontEnum | DontDelete | ReadOnly);228 d ->booleanPrototype->put(exec, exec->propertyNames().constructor, d->booleanConstructor, DontEnum | DontDelete | ReadOnly);229 d ->stringPrototype->put(exec, exec->propertyNames().constructor, d->stringConstructor, DontEnum | DontDelete | ReadOnly);230 d ->numberPrototype->put(exec, exec->propertyNames().constructor, d->numberConstructor, DontEnum | DontDelete | ReadOnly);231 d ->datePrototype->put(exec, exec->propertyNames().constructor, d->dateConstructor, DontEnum | DontDelete | ReadOnly);232 d ->regExpPrototype->put(exec, exec->propertyNames().constructor, d->regExpConstructor, DontEnum | DontDelete | ReadOnly);233 d ->errorPrototype->put(exec, exec->propertyNames().constructor, d->errorConstructor, DontEnum | DontDelete | ReadOnly);234 d ->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);235 d ->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);236 d ->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);237 d ->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);238 d ->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);239 d ->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);206 d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype); 207 d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype); 208 d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype); 209 d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype); 210 d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype); 211 d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype); 212 d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype); 213 d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype); 214 d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype); 215 216 d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype); 217 d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype); 218 d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype); 219 d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype); 220 d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype); 221 d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype); 222 223 d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum); 224 225 d()->objectPrototype->put(exec, exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly); 226 d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly); 227 d()->arrayPrototype->put(exec, exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly); 228 d()->booleanPrototype->put(exec, exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly); 229 d()->stringPrototype->put(exec, exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly); 230 d()->numberPrototype->put(exec, exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly); 231 d()->datePrototype->put(exec, exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly); 232 d()->regExpPrototype->put(exec, exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly); 233 d()->errorPrototype->put(exec, exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly); 234 d()->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly); 235 d()->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly); 236 d()->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly); 237 d()->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly); 238 d()->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly); 239 d()->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly); 240 240 241 241 // Set global constructors … … 247 247 // FIXME: These properties should be handled by a static hash table. 248 248 249 putDirect("Object", d ->objectConstructor, DontEnum);250 putDirect("Function", d ->functionConstructor, DontEnum);251 putDirect("Array", d ->arrayConstructor, DontEnum);252 putDirect("Boolean", d ->booleanConstructor, DontEnum);253 putDirect("String", d ->stringConstructor, DontEnum);254 putDirect("Number", d ->numberConstructor, DontEnum);255 putDirect("Date", d ->dateConstructor, DontEnum);256 putDirect("RegExp", d ->regExpConstructor, DontEnum);257 putDirect("Error", d ->errorConstructor, DontEnum);258 putDirect("EvalError", d ->evalErrorConstructor, Internal);259 putDirect("RangeError", d ->rangeErrorConstructor, Internal);260 putDirect("ReferenceError", d ->referenceErrorConstructor, Internal);261 putDirect("SyntaxError", d ->syntaxErrorConstructor, Internal);262 putDirect("TypeError", d ->typeErrorConstructor, Internal);263 putDirect("URIError", d ->URIErrorConstructor, Internal);249 putDirect("Object", d()->objectConstructor, DontEnum); 250 putDirect("Function", d()->functionConstructor, DontEnum); 251 putDirect("Array", d()->arrayConstructor, DontEnum); 252 putDirect("Boolean", d()->booleanConstructor, DontEnum); 253 putDirect("String", d()->stringConstructor, DontEnum); 254 putDirect("Number", d()->numberConstructor, DontEnum); 255 putDirect("Date", d()->dateConstructor, DontEnum); 256 putDirect("RegExp", d()->regExpConstructor, DontEnum); 257 putDirect("Error", d()->errorConstructor, DontEnum); 258 putDirect("EvalError", d()->evalErrorConstructor, Internal); 259 putDirect("RangeError", d()->rangeErrorConstructor, Internal); 260 putDirect("ReferenceError", d()->referenceErrorConstructor, Internal); 261 putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal); 262 putDirect("TypeError", d()->typeErrorConstructor, Internal); 263 putDirect("URIError", d()->URIErrorConstructor, Internal); 264 264 265 265 // Set global values. 266 266 267 putDirect("Math", new MathObjectImp(exec, d ->objectPrototype), DontEnum);267 putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum); 268 268 269 269 putDirect("NaN", jsNaN(), DontEnum | DontDelete); … … 273 273 // Set global functions. 274 274 275 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);276 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);277 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);278 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);279 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);280 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);281 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);282 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);283 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);284 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);285 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);275 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum); 276 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum); 277 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum); 278 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum); 279 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum); 280 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum); 281 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum); 282 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum); 283 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum); 284 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum); 285 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum); 286 286 #ifndef NDEBUG 287 putDirectFunction(new GlobalFuncImp(exec, d ->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);287 putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum); 288 288 #endif 289 289 … … 291 291 292 292 setPrototype(prototype); 293 lastInPrototypeChain(this)->setPrototype(d ->objectPrototype);293 lastInPrototypeChain(this)->setPrototype(d()->objectPrototype); 294 294 } 295 295 296 296 void JSGlobalObject::startTimeoutCheck() 297 297 { 298 if (!d ->timeoutCheckCount)298 if (!d()->timeoutCheckCount) 299 299 resetTimeoutCheck(); 300 300 301 ++d ->timeoutCheckCount;301 ++d()->timeoutCheckCount; 302 302 } 303 303 304 304 void JSGlobalObject::stopTimeoutCheck() 305 305 { 306 --d ->timeoutCheckCount;306 --d()->timeoutCheckCount; 307 307 } 308 308 309 309 void JSGlobalObject::resetTimeoutCheck() 310 310 { 311 d ->tickCount = 0;312 d ->ticksUntilNextTimeoutCheck = initialTickCountThreshold;313 d ->timeAtLastCheckTimeout = 0;314 d ->timeExecuting = 0;311 d()->tickCount = 0; 312 d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; 313 d()->timeAtLastCheckTimeout = 0; 314 d()->timeExecuting = 0; 315 315 } 316 316 317 317 bool JSGlobalObject::checkTimeout() 318 318 { 319 d ->tickCount = 0;319 d()->tickCount = 0; 320 320 321 321 unsigned currentTime = getCurrentTime(); 322 322 323 if (!d ->timeAtLastCheckTimeout) {323 if (!d()->timeAtLastCheckTimeout) { 324 324 // Suspicious amount of looping in a script -- start timing it 325 d ->timeAtLastCheckTimeout = currentTime;325 d()->timeAtLastCheckTimeout = currentTime; 326 326 return false; 327 327 } 328 328 329 unsigned timeDiff = currentTime - d ->timeAtLastCheckTimeout;329 unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout; 330 330 331 331 if (timeDiff == 0) 332 332 timeDiff = 1; 333 333 334 d ->timeExecuting += timeDiff;335 d ->timeAtLastCheckTimeout = currentTime;334 d()->timeExecuting += timeDiff; 335 d()->timeAtLastCheckTimeout = currentTime; 336 336 337 337 // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in 338 338 // preferredScriptCheckTimeInterval 339 d ->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d->ticksUntilNextTimeoutCheck;339 d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck; 340 340 341 341 // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the 342 342 // preferred script check time interval. 343 if (d ->ticksUntilNextTimeoutCheck == 0)344 d ->ticksUntilNextTimeoutCheck = initialTickCountThreshold;345 346 if (d ->timeoutTime && d->timeExecuting > d->timeoutTime) {343 if (d()->ticksUntilNextTimeoutCheck == 0) 344 d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold; 345 346 if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) { 347 347 if (shouldInterruptScript()) 348 348 return true; … … 359 359 builtins._internal = new SavedBuiltinsInternal; 360 360 361 builtins._internal->objectConstructor = d ->objectConstructor;362 builtins._internal->functionConstructor = d ->functionConstructor;363 builtins._internal->arrayConstructor = d ->arrayConstructor;364 builtins._internal->booleanConstructor = d ->booleanConstructor;365 builtins._internal->stringConstructor = d ->stringConstructor;366 builtins._internal->numberConstructor = d ->numberConstructor;367 builtins._internal->dateConstructor = d ->dateConstructor;368 builtins._internal->regExpConstructor = d ->regExpConstructor;369 builtins._internal->errorConstructor = d ->errorConstructor;370 builtins._internal->evalErrorConstructor = d ->evalErrorConstructor;371 builtins._internal->rangeErrorConstructor = d ->rangeErrorConstructor;372 builtins._internal->referenceErrorConstructor = d ->referenceErrorConstructor;373 builtins._internal->syntaxErrorConstructor = d ->syntaxErrorConstructor;374 builtins._internal->typeErrorConstructor = d ->typeErrorConstructor;375 builtins._internal->URIErrorConstructor = d ->URIErrorConstructor;376 377 builtins._internal->objectPrototype = d ->objectPrototype;378 builtins._internal->functionPrototype = d ->functionPrototype;379 builtins._internal->arrayPrototype = d ->arrayPrototype;380 builtins._internal->booleanPrototype = d ->booleanPrototype;381 builtins._internal->stringPrototype = d ->stringPrototype;382 builtins._internal->numberPrototype = d ->numberPrototype;383 builtins._internal->datePrototype = d ->datePrototype;384 builtins._internal->regExpPrototype = d ->regExpPrototype;385 builtins._internal->errorPrototype = d ->errorPrototype;386 builtins._internal->evalErrorPrototype = d ->evalErrorPrototype;387 builtins._internal->rangeErrorPrototype = d ->rangeErrorPrototype;388 builtins._internal->referenceErrorPrototype = d ->referenceErrorPrototype;389 builtins._internal->syntaxErrorPrototype = d ->syntaxErrorPrototype;390 builtins._internal->typeErrorPrototype = d ->typeErrorPrototype;391 builtins._internal->URIErrorPrototype = d ->URIErrorPrototype;361 builtins._internal->objectConstructor = d()->objectConstructor; 362 builtins._internal->functionConstructor = d()->functionConstructor; 363 builtins._internal->arrayConstructor = d()->arrayConstructor; 364 builtins._internal->booleanConstructor = d()->booleanConstructor; 365 builtins._internal->stringConstructor = d()->stringConstructor; 366 builtins._internal->numberConstructor = d()->numberConstructor; 367 builtins._internal->dateConstructor = d()->dateConstructor; 368 builtins._internal->regExpConstructor = d()->regExpConstructor; 369 builtins._internal->errorConstructor = d()->errorConstructor; 370 builtins._internal->evalErrorConstructor = d()->evalErrorConstructor; 371 builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor; 372 builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor; 373 builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor; 374 builtins._internal->typeErrorConstructor = d()->typeErrorConstructor; 375 builtins._internal->URIErrorConstructor = d()->URIErrorConstructor; 376 377 builtins._internal->objectPrototype = d()->objectPrototype; 378 builtins._internal->functionPrototype = d()->functionPrototype; 379 builtins._internal->arrayPrototype = d()->arrayPrototype; 380 builtins._internal->booleanPrototype = d()->booleanPrototype; 381 builtins._internal->stringPrototype = d()->stringPrototype; 382 builtins._internal->numberPrototype = d()->numberPrototype; 383 builtins._internal->datePrototype = d()->datePrototype; 384 builtins._internal->regExpPrototype = d()->regExpPrototype; 385 builtins._internal->errorPrototype = d()->errorPrototype; 386 builtins._internal->evalErrorPrototype = d()->evalErrorPrototype; 387 builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype; 388 builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype; 389 builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype; 390 builtins._internal->typeErrorPrototype = d()->typeErrorPrototype; 391 builtins._internal->URIErrorPrototype = d()->URIErrorPrototype; 392 392 } 393 393 … … 397 397 return; 398 398 399 d ->objectConstructor = builtins._internal->objectConstructor;400 d ->functionConstructor = builtins._internal->functionConstructor;401 d ->arrayConstructor = builtins._internal->arrayConstructor;402 d ->booleanConstructor = builtins._internal->booleanConstructor;403 d ->stringConstructor = builtins._internal->stringConstructor;404 d ->numberConstructor = builtins._internal->numberConstructor;405 d ->dateConstructor = builtins._internal->dateConstructor;406 d ->regExpConstructor = builtins._internal->regExpConstructor;407 d ->errorConstructor = builtins._internal->errorConstructor;408 d ->evalErrorConstructor = builtins._internal->evalErrorConstructor;409 d ->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;410 d ->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;411 d ->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;412 d ->typeErrorConstructor = builtins._internal->typeErrorConstructor;413 d ->URIErrorConstructor = builtins._internal->URIErrorConstructor;414 415 d ->objectPrototype = builtins._internal->objectPrototype;416 d ->functionPrototype = builtins._internal->functionPrototype;417 d ->arrayPrototype = builtins._internal->arrayPrototype;418 d ->booleanPrototype = builtins._internal->booleanPrototype;419 d ->stringPrototype = builtins._internal->stringPrototype;420 d ->numberPrototype = builtins._internal->numberPrototype;421 d ->datePrototype = builtins._internal->datePrototype;422 d ->regExpPrototype = builtins._internal->regExpPrototype;423 d ->errorPrototype = builtins._internal->errorPrototype;424 d ->evalErrorPrototype = builtins._internal->evalErrorPrototype;425 d ->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;426 d ->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;427 d ->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;428 d ->typeErrorPrototype = builtins._internal->typeErrorPrototype;429 d ->URIErrorPrototype = builtins._internal->URIErrorPrototype;399 d()->objectConstructor = builtins._internal->objectConstructor; 400 d()->functionConstructor = builtins._internal->functionConstructor; 401 d()->arrayConstructor = builtins._internal->arrayConstructor; 402 d()->booleanConstructor = builtins._internal->booleanConstructor; 403 d()->stringConstructor = builtins._internal->stringConstructor; 404 d()->numberConstructor = builtins._internal->numberConstructor; 405 d()->dateConstructor = builtins._internal->dateConstructor; 406 d()->regExpConstructor = builtins._internal->regExpConstructor; 407 d()->errorConstructor = builtins._internal->errorConstructor; 408 d()->evalErrorConstructor = builtins._internal->evalErrorConstructor; 409 d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor; 410 d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor; 411 d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor; 412 d()->typeErrorConstructor = builtins._internal->typeErrorConstructor; 413 d()->URIErrorConstructor = builtins._internal->URIErrorConstructor; 414 415 d()->objectPrototype = builtins._internal->objectPrototype; 416 d()->functionPrototype = builtins._internal->functionPrototype; 417 d()->arrayPrototype = builtins._internal->arrayPrototype; 418 d()->booleanPrototype = builtins._internal->booleanPrototype; 419 d()->stringPrototype = builtins._internal->stringPrototype; 420 d()->numberPrototype = builtins._internal->numberPrototype; 421 d()->datePrototype = builtins._internal->datePrototype; 422 d()->regExpPrototype = builtins._internal->regExpPrototype; 423 d()->errorPrototype = builtins._internal->errorPrototype; 424 d()->evalErrorPrototype = builtins._internal->evalErrorPrototype; 425 d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype; 426 d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype; 427 d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype; 428 d()->typeErrorPrototype = builtins._internal->typeErrorPrototype; 429 d()->URIErrorPrototype = builtins._internal->URIErrorPrototype; 430 430 } 431 431 432 432 void JSGlobalObject::mark() 433 433 { 434 JS Object::mark();435 436 if (d ->currentExec)437 d ->currentExec->mark();438 439 markIfNeeded(d ->globalExec.exception());440 441 markIfNeeded(d ->objectConstructor);442 markIfNeeded(d ->functionConstructor);443 markIfNeeded(d ->arrayConstructor);444 markIfNeeded(d ->booleanConstructor);445 markIfNeeded(d ->stringConstructor);446 markIfNeeded(d ->numberConstructor);447 markIfNeeded(d ->dateConstructor);448 markIfNeeded(d ->regExpConstructor);449 markIfNeeded(d ->errorConstructor);450 markIfNeeded(d ->evalErrorConstructor);451 markIfNeeded(d ->rangeErrorConstructor);452 markIfNeeded(d ->referenceErrorConstructor);453 markIfNeeded(d ->syntaxErrorConstructor);454 markIfNeeded(d ->typeErrorConstructor);455 markIfNeeded(d ->URIErrorConstructor);456 457 markIfNeeded(d ->objectPrototype);458 markIfNeeded(d ->functionPrototype);459 markIfNeeded(d ->arrayPrototype);460 markIfNeeded(d ->booleanPrototype);461 markIfNeeded(d ->stringPrototype);462 markIfNeeded(d ->numberPrototype);463 markIfNeeded(d ->datePrototype);464 markIfNeeded(d ->regExpPrototype);465 markIfNeeded(d ->errorPrototype);466 markIfNeeded(d ->evalErrorPrototype);467 markIfNeeded(d ->rangeErrorPrototype);468 markIfNeeded(d ->referenceErrorPrototype);469 markIfNeeded(d ->syntaxErrorPrototype);470 markIfNeeded(d ->typeErrorPrototype);471 markIfNeeded(d ->URIErrorPrototype);434 JSVariableObject::mark(); 435 436 if (d()->currentExec) 437 d()->currentExec->mark(); 438 439 markIfNeeded(d()->globalExec.exception()); 440 441 markIfNeeded(d()->objectConstructor); 442 markIfNeeded(d()->functionConstructor); 443 markIfNeeded(d()->arrayConstructor); 444 markIfNeeded(d()->booleanConstructor); 445 markIfNeeded(d()->stringConstructor); 446 markIfNeeded(d()->numberConstructor); 447 markIfNeeded(d()->dateConstructor); 448 markIfNeeded(d()->regExpConstructor); 449 markIfNeeded(d()->errorConstructor); 450 markIfNeeded(d()->evalErrorConstructor); 451 markIfNeeded(d()->rangeErrorConstructor); 452 markIfNeeded(d()->referenceErrorConstructor); 453 markIfNeeded(d()->syntaxErrorConstructor); 454 markIfNeeded(d()->typeErrorConstructor); 455 markIfNeeded(d()->URIErrorConstructor); 456 457 markIfNeeded(d()->objectPrototype); 458 markIfNeeded(d()->functionPrototype); 459 markIfNeeded(d()->arrayPrototype); 460 markIfNeeded(d()->booleanPrototype); 461 markIfNeeded(d()->stringPrototype); 462 markIfNeeded(d()->numberPrototype); 463 markIfNeeded(d()->datePrototype); 464 markIfNeeded(d()->regExpPrototype); 465 markIfNeeded(d()->errorPrototype); 466 markIfNeeded(d()->evalErrorPrototype); 467 markIfNeeded(d()->rangeErrorPrototype); 468 markIfNeeded(d()->referenceErrorPrototype); 469 markIfNeeded(d()->syntaxErrorPrototype); 470 markIfNeeded(d()->typeErrorPrototype); 471 markIfNeeded(d()->URIErrorPrototype); 472 472 } 473 473 474 474 ExecState* JSGlobalObject::globalExec() 475 475 { 476 return &d ->globalExec;476 return &d()->globalExec; 477 477 } 478 478 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r28468 r28527 24 24 #define KJS_GlobalObject_h 25 25 26 #include " object.h"26 #include "JSVariableObject.h" 27 27 28 28 namespace KJS { … … 68 68 enum CompatMode { NativeMode, IECompat, NetscapeCompat }; 69 69 70 class JSGlobalObject : public JS Object {70 class JSGlobalObject : public JSVariableObject { 71 71 protected: 72 struct JSGlobalObjectData { 72 using JSVariableObject::JSVariableObjectData; 73 74 struct JSGlobalObjectData : public JSVariableObjectData { 73 75 JSGlobalObjectData(JSGlobalObject* globalObject) 74 : globalExec(globalObject, globalObject, 0) 76 : JSVariableObjectData(&inlineSymbolTable) 77 , globalExec(globalObject, globalObject, 0) 75 78 { 76 79 } … … 81 84 Debugger* debugger; 82 85 CompatMode compatMode; 83 86 84 87 ExecState globalExec; 85 88 ExecState* currentExec; … … 124 127 NativeErrorPrototype* typeErrorPrototype; 125 128 NativeErrorPrototype* URIErrorPrototype; 129 130 SymbolTable inlineSymbolTable; 126 131 }; 127 132 128 133 public: 129 134 JSGlobalObject() 135 : JSVariableObject(new JSGlobalObjectData(this)) 130 136 { 131 137 init(); … … 134 140 protected: 135 141 JSGlobalObject(JSValue* proto) 136 : JS Object(proto)142 : JSVariableObject(proto, new JSGlobalObjectData(this)) 137 143 { 138 144 init(); … … 144 150 // Linked list of all global objects. 145 151 static JSGlobalObject* head() { return s_head; } 146 JSGlobalObject* next() { return d ->next; }152 JSGlobalObject* next() { return d()->next; } 147 153 148 154 // Resets the global object to contain only built-in properties, sets … … 155 161 // replaces the global object's associated property. 156 162 157 ObjectObjectImp* objectConstructor() const { return d ->objectConstructor; }158 FunctionObjectImp* functionConstructor() const { return d ->functionConstructor; }159 ArrayObjectImp* arrayConstructor() const { return d ->arrayConstructor; }160 BooleanObjectImp* booleanConstructor() const { return d ->booleanConstructor; }161 StringObjectImp* stringConstructor() const{ return d ->stringConstructor; }162 NumberObjectImp* numberConstructor() const{ return d ->numberConstructor; }163 DateObjectImp* dateConstructor() const{ return d ->dateConstructor; }164 RegExpObjectImp* regExpConstructor() const { return d ->regExpConstructor; }165 ErrorObjectImp* errorConstructor() const { return d ->errorConstructor; }166 NativeErrorImp* evalErrorConstructor() const { return d ->evalErrorConstructor; }167 NativeErrorImp* rangeErrorConstructor() const { return d ->rangeErrorConstructor; }168 NativeErrorImp* referenceErrorConstructor() const { return d ->referenceErrorConstructor; }169 NativeErrorImp* syntaxErrorConstructor() const { return d ->syntaxErrorConstructor; }170 NativeErrorImp* typeErrorConstructor() const { return d ->typeErrorConstructor; }171 NativeErrorImp* URIErrorConstructor() const { return d ->URIErrorConstructor; }172 173 ObjectPrototype* objectPrototype() const { return d ->objectPrototype; }174 FunctionPrototype* functionPrototype() const { return d ->functionPrototype; }175 ArrayPrototype* arrayPrototype() const { return d ->arrayPrototype; }176 BooleanPrototype* booleanPrototype() const { return d ->booleanPrototype; }177 StringPrototype* stringPrototype() const { return d ->stringPrototype; }178 NumberPrototype* numberPrototype() const { return d ->numberPrototype; }179 DatePrototype* datePrototype() const { return d ->datePrototype; }180 RegExpPrototype* regExpPrototype() const { return d ->regExpPrototype; }181 ErrorPrototype* errorPrototype() const { return d ->errorPrototype; }182 NativeErrorPrototype* evalErrorPrototype() const { return d ->evalErrorPrototype; }183 NativeErrorPrototype* rangeErrorPrototype() const { return d ->rangeErrorPrototype; }184 NativeErrorPrototype* referenceErrorPrototype() const { return d ->referenceErrorPrototype; }185 NativeErrorPrototype* syntaxErrorPrototype() const { return d ->syntaxErrorPrototype; }186 NativeErrorPrototype* typeErrorPrototype() const { return d ->typeErrorPrototype; }187 NativeErrorPrototype* URIErrorPrototype() const { return d ->URIErrorPrototype; }163 ObjectObjectImp* objectConstructor() const { return d()->objectConstructor; } 164 FunctionObjectImp* functionConstructor() const { return d()->functionConstructor; } 165 ArrayObjectImp* arrayConstructor() const { return d()->arrayConstructor; } 166 BooleanObjectImp* booleanConstructor() const { return d()->booleanConstructor; } 167 StringObjectImp* stringConstructor() const{ return d()->stringConstructor; } 168 NumberObjectImp* numberConstructor() const{ return d()->numberConstructor; } 169 DateObjectImp* dateConstructor() const{ return d()->dateConstructor; } 170 RegExpObjectImp* regExpConstructor() const { return d()->regExpConstructor; } 171 ErrorObjectImp* errorConstructor() const { return d()->errorConstructor; } 172 NativeErrorImp* evalErrorConstructor() const { return d()->evalErrorConstructor; } 173 NativeErrorImp* rangeErrorConstructor() const { return d()->rangeErrorConstructor; } 174 NativeErrorImp* referenceErrorConstructor() const { return d()->referenceErrorConstructor; } 175 NativeErrorImp* syntaxErrorConstructor() const { return d()->syntaxErrorConstructor; } 176 NativeErrorImp* typeErrorConstructor() const { return d()->typeErrorConstructor; } 177 NativeErrorImp* URIErrorConstructor() const { return d()->URIErrorConstructor; } 178 179 ObjectPrototype* objectPrototype() const { return d()->objectPrototype; } 180 FunctionPrototype* functionPrototype() const { return d()->functionPrototype; } 181 ArrayPrototype* arrayPrototype() const { return d()->arrayPrototype; } 182 BooleanPrototype* booleanPrototype() const { return d()->booleanPrototype; } 183 StringPrototype* stringPrototype() const { return d()->stringPrototype; } 184 NumberPrototype* numberPrototype() const { return d()->numberPrototype; } 185 DatePrototype* datePrototype() const { return d()->datePrototype; } 186 RegExpPrototype* regExpPrototype() const { return d()->regExpPrototype; } 187 ErrorPrototype* errorPrototype() const { return d()->errorPrototype; } 188 NativeErrorPrototype* evalErrorPrototype() const { return d()->evalErrorPrototype; } 189 NativeErrorPrototype* rangeErrorPrototype() const { return d()->rangeErrorPrototype; } 190 NativeErrorPrototype* referenceErrorPrototype() const { return d()->referenceErrorPrototype; } 191 NativeErrorPrototype* syntaxErrorPrototype() const { return d()->syntaxErrorPrototype; } 192 NativeErrorPrototype* typeErrorPrototype() const { return d()->typeErrorPrototype; } 193 NativeErrorPrototype* URIErrorPrototype() const { return d()->URIErrorPrototype; } 188 194 189 195 void saveBuiltins(SavedBuiltins&) const; 190 196 void restoreBuiltins(const SavedBuiltins&); 191 197 192 void setTimeoutTime(unsigned timeoutTime) { d ->timeoutTime = timeoutTime; }198 void setTimeoutTime(unsigned timeoutTime) { d()->timeoutTime = timeoutTime; } 193 199 void startTimeoutCheck(); 194 200 void stopTimeoutCheck(); 195 201 bool timedOut(); 196 202 197 Debugger* debugger() const { return d ->debugger; }198 void setDebugger(Debugger* debugger) { d ->debugger = debugger; }199 200 void setCurrentExec(ExecState* exec) { d ->currentExec = exec; }201 ExecState* currentExec() const { return d ->currentExec; }203 Debugger* debugger() const { return d()->debugger; } 204 void setDebugger(Debugger* debugger) { d()->debugger = debugger; } 205 206 void setCurrentExec(ExecState* exec) { d()->currentExec = exec; } 207 ExecState* currentExec() const { return d()->currentExec; } 202 208 203 209 // FIXME: Let's just pick one compatible behavior and go with it. 204 void setCompatMode(CompatMode mode) { d ->compatMode = mode; }205 CompatMode compatMode() const { return d ->compatMode; }210 void setCompatMode(CompatMode mode) { d()->compatMode = mode; } 211 CompatMode compatMode() const { return d()->compatMode; } 206 212 207 int recursion() { return d ->recursion; }208 void incRecursion() { ++d ->recursion; }209 void decRecursion() { --d ->recursion; }213 int recursion() { return d()->recursion; } 214 void incRecursion() { ++d()->recursion; } 215 void decRecursion() { --d()->recursion; } 210 216 211 217 virtual void mark(); … … 218 224 219 225 virtual bool isSafeScript(const JSGlobalObject*) const { return true; } 220 221 protected:222 std::auto_ptr<JSGlobalObjectData> d;223 226 224 227 private: 225 228 void init(); 229 230 JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); } 226 231 227 232 bool checkTimeout(); … … 233 238 inline bool JSGlobalObject::timedOut() 234 239 { 235 d ->tickCount++;236 237 if (d ->tickCount != d->ticksUntilNextTimeoutCheck)240 d()->tickCount++; 241 242 if (d()->tickCount != d()->ticksUntilNextTimeoutCheck) 238 243 return false; 239 244 -
trunk/JavaScriptCore/kjs/function.cpp
r28468 r28527 97 97 while (e) { 98 98 if (e->function() == thisObj) 99 return static_cast<ActivationImp*>(e->activationObject())->get(exec, propertyName);99 return e->activationObject()->get(exec, propertyName); 100 100 e = e->callingExecState(); 101 101 } … … 359 359 const ClassInfo ActivationImp::info = { "Activation", 0, 0 }; 360 360 361 ActivationImp::ActivationImp(ExecState* exec)362 : d(new ActivationImpPrivate(exec))363 , m_symbolTable(&exec->function()->body->symbolTable())364 {365 }366 367 361 JSValue* ActivationImp::argumentsGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot) 368 362 { 369 363 ActivationImp* thisObj = static_cast<ActivationImp*>(slot.slotBase()); 370 ActivationImpPrivate* d = thisObj->d.get(); 371 372 if (!d->argumentsObject) 364 365 if (!thisObj->d()->argumentsObject) 373 366 thisObj->createArgumentsObject(exec); 374 367 375 return d->argumentsObject;368 return thisObj->d()->argumentsObject; 376 369 } 377 370 … … 383 376 bool ActivationImp::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 384 377 { 385 // We don't call through to JSObject because there's no way to give an 386 // activation object getter/setter properties, and __proto__ is a 387 // non-standard extension that other implementations do not expose in the 388 // activation object. 389 ASSERT(!_prop.hasGetterSetterProperties()); 390 391 // it's more efficient to just get and check for a special empty 392 // value than to do a separate contains check 393 size_t index = m_symbolTable->get(propertyName.ustring().rep()); 394 if (index != missingSymbolMarker()) { 395 slot.setValueSlot(this, &d->localStorage[index].value); 378 if (symbolTableGet(propertyName, slot)) 396 379 return true; 397 }398 380 399 381 if (JSValue** location = getDirectLocation(propertyName)) { … … 408 390 } 409 391 392 // We don't call through to JSObject because there's no way to give an 393 // activation object getter properties or a prototype. 394 ASSERT(!_prop.hasGetterSetterProperties()); 395 ASSERT(prototype() == jsNull()); 410 396 return false; 411 397 } … … 416 402 return false; 417 403 418 if (m_symbolTable->contains(propertyName.ustring().rep())) 419 return false; 420 421 return JSObject::deleteProperty(exec, propertyName); 422 } 423 424 void ActivationImp::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 425 { 426 SymbolTable::const_iterator::Keys end = m_symbolTable->end().keys(); 427 for (SymbolTable::const_iterator::Keys it = m_symbolTable->begin().keys(); it != end; ++it) 428 propertyNames.add(Identifier(*it)); 429 430 JSObject::getPropertyNames(exec, propertyNames); 404 return JSVariableObject::deleteProperty(exec, propertyName); 431 405 } 432 406 433 407 void ActivationImp::put(ExecState*, const Identifier& propertyName, JSValue* value, int attr) 434 408 { 435 // There's no way that an activation object can have a prototype or getter/setter properties. 436 ASSERT(!_prop.hasGetterSetterProperties()); 437 ASSERT(prototype() == jsNull()); 438 439 // it's more efficient to just get and check for a special empty 440 // value than to do a separate contains check 441 size_t index = m_symbolTable->get(propertyName.ustring().rep()); 442 if (index != missingSymbolMarker()) { 443 LocalStorageEntry& entry = d->localStorage[index]; 444 entry.value = value; 445 entry.attributes = attr; 446 return; 447 } 448 449 _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete)); 409 if (symbolTablePut(propertyName, value, attr)) 410 return; 411 412 // We don't call through to JSObject because __proto__ and getter/setter 413 // properties are non-standard extensions that other implementations do not 414 // expose in the activation object. 415 ASSERT(!_prop.hasGetterSetterProperties()); 416 _prop.put(propertyName, value, attr, (attr == None || attr == DontDelete)); 450 417 } 451 418 452 419 void ActivationImp::mark() 453 420 { 454 JSObject::mark(); 455 456 size_t size = d->localStorage.size(); 457 for (size_t i = 0; i < size; ++i) { 458 JSValue* value = d->localStorage[i].value; 459 if (!value->marked()) 460 value->mark(); 461 } 462 463 ASSERT(d->function); 464 if (!d->function->marked()) 465 d->function->mark(); 466 467 if (d->argumentsObject && !d->argumentsObject->marked()) 468 d->argumentsObject->mark(); 421 JSVariableObject::mark(); 422 423 if (d()->argumentsObject && !d()->argumentsObject->marked()) 424 d()->argumentsObject->mark(); 469 425 } 470 426 … … 474 430 // we can retrieve our argument list from the ExecState for our function 475 431 // call instead of storing the list ourselves. 476 d ->argumentsObject = new Arguments(exec, d->function, *d->exec->arguments(), this);432 d()->argumentsObject = new Arguments(exec, d()->exec->function(), *d()->exec->arguments(), this); 477 433 } 478 434 … … 764 720 if (switchGlobal) { 765 721 newExec.pushScope(thisObj); 766 newExec.setVariableObject( thisObj);722 newExec.setVariableObject(static_cast<JSGlobalObject*>(thisObj)); 767 723 } 768 724 -
trunk/JavaScriptCore/kjs/function.h
r28110 r28527 26 26 #define KJS_FUNCTION_H 27 27 28 #include "JSVariableObject.h" 28 29 #include "LocalStorage.h" 29 30 #include "SymbolTable.h" 31 #include "nodes.h" 30 32 #include "object.h" 31 #include <wtf/OwnPtr.h>32 33 33 34 namespace KJS { … … 138 139 }; 139 140 140 class ActivationImp : public JSObject { 141 private: 142 struct ActivationImpPrivate { 143 ActivationImpPrivate(ExecState* e) 144 : exec(e) 145 , function(e->function()) 141 class ActivationImp : public JSVariableObject { 142 private: 143 using JSVariableObject::JSVariableObjectData; 144 145 struct ActivationImpData : public JSVariableObjectData { 146 ActivationImpData(ExecState* e) 147 : JSVariableObjectData(&e->function()->body->symbolTable()) 148 , exec(e) 146 149 , argumentsObject(0) 147 150 { 148 151 } 149 150 LocalStorage localStorage; 152 151 153 ExecState* exec; 152 FunctionImp* function;153 154 Arguments* argumentsObject; 154 155 }; 155 156 156 157 public: 157 ActivationImp(ExecState*); 158 ActivationImp::ActivationImp(ExecState* exec) 159 : JSVariableObject(new ActivationImpData(exec)) 160 { 161 } 162 163 virtual ~ActivationImp() 164 { 165 delete d(); 166 } 158 167 159 168 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 160 169 virtual void put(ExecState*, const Identifier& propertyName, JSValue* value, int attr = None); 161 170 virtual bool deleteProperty(ExecState*, const Identifier& propertyName); 162 virtual void getPropertyNames(ExecState*, PropertyNameArray&);163 171 164 172 virtual const ClassInfo* classInfo() const { return &info; } … … 167 175 virtual void mark(); 168 176 169 bool isActivation() { return true; } 170 171 LocalStorage& localStorage() { return d->localStorage; } 172 SymbolTable& symbolTable() { return *m_symbolTable; } 177 virtual bool isActivationObject() { return true; } 173 178 174 179 private: … … 176 181 static JSValue* argumentsGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot); 177 182 void createArgumentsObject(ExecState*); 178 179 OwnPtr<ActivationImpPrivate> d; 180 SymbolTable* m_symbolTable; 183 ActivationImpData* d() { return static_cast<ActivationImpData*>(JSVariableObject::d); } 181 184 }; 182 185 -
trunk/JavaScriptCore/kjs/nodes.cpp
r28476 r28527 94 94 return false; 95 95 96 ASSERT(exec->variableObject()->isActivation()); // Because this is function code.97 98 96 // Static lookup is impossible if the symbol isn't statically declared. 99 if (! static_cast<ActivationImp*>(exec->variableObject())->symbolTable().contains(ident.ustring().rep()))97 if (!exec->variableObject()->symbolTable().contains(ident.ustring().rep())) 100 98 return false; 101 99 … … 573 571 JSValue* LocalVarAccessNode::inlineEvaluate(ExecState* exec) 574 572 { 575 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 576 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 573 ASSERT(exec->variableObject() == exec->scopeChain().top()); 577 574 return exec->localStorage()[index].value; 578 575 } … … 1001 998 // of implementation we use the global object anyway here. This guarantees 1002 999 // that in host objects you always get a valid object for this. 1003 if (thisObj->isActivation ())1000 if (thisObj->isActivationObject()) 1004 1001 thisObj = exec->dynamicGlobalObject(); 1005 1002 … … 1047 1044 JSValue* LocalVarFunctionCallNode::inlineEvaluate(ExecState* exec) 1048 1045 { 1049 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1050 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1046 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1051 1047 1052 1048 JSValue* v = exec->localStorage()[index].value; … … 1151 1147 ASSERT(thisObj); 1152 1148 ASSERT(thisObj->isObject()); 1153 ASSERT(!thisObj->isActivation ());1149 ASSERT(!thisObj->isActivationObject()); 1154 1150 1155 1151 return func->call(exec, thisObj, argList); … … 1200 1196 ASSERT(thisObj); 1201 1197 ASSERT(thisObj->isObject()); 1202 ASSERT(!thisObj->isActivation ());1198 ASSERT(!thisObj->isActivationObject()); 1203 1199 1204 1200 return func->call(exec, thisObj, argList); … … 1285 1281 JSValue* PostIncLocalVarNode::evaluate(ExecState* exec) 1286 1282 { 1287 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1288 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1283 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1289 1284 1290 1285 JSValue** slot = &exec->localStorage()[m_index].value; … … 1343 1338 JSValue* PostDecLocalVarNode::evaluate(ExecState* exec) 1344 1339 { 1345 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1346 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1340 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1347 1341 1348 1342 JSValue** slot = &exec->localStorage()[m_index].value; … … 1354 1348 double PostDecLocalVarNode::inlineEvaluateToNumber(ExecState* exec) 1355 1349 { 1356 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1357 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1350 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1358 1351 1359 1352 JSValue** slot = &exec->localStorage()[m_index].value; … … 1665 1658 JSValue* LocalVarTypeOfNode::evaluate(ExecState* exec) 1666 1659 { 1667 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1668 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1660 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1669 1661 1670 1662 return typeStringForValue(exec->localStorage()[m_index].value); … … 1718 1710 JSValue* PreIncLocalVarNode::evaluate(ExecState* exec) 1719 1711 { 1720 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1721 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1712 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1722 1713 JSValue** slot = &exec->localStorage()[m_index].value; 1723 1714 … … 1766 1757 JSValue* PreDecLocalVarNode::evaluate(ExecState* exec) 1767 1758 { 1768 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 1769 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 1759 ASSERT(exec->variableObject() == exec->scopeChain().top()); 1770 1760 JSValue** slot = &exec->localStorage()[m_index].value; 1771 1761 … … 3179 3169 JSValue* ReadModifyLocalVarNode::evaluate(ExecState* exec) 3180 3170 { 3181 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 3182 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 3171 ASSERT(exec->variableObject() == exec->scopeChain().top()); 3183 3172 JSValue** slot = &exec->localStorage()[m_index].value; 3184 3173 … … 3194 3183 JSValue* AssignLocalVarNode::evaluate(ExecState* exec) 3195 3184 { 3196 ASSERT(static_cast<ActivationImp*>(exec->variableObject())->isActivation()); 3197 ASSERT(static_cast<ActivationImp*>(exec->variableObject()) == exec->scopeChain().top()); 3185 ASSERT(exec->variableObject() == exec->scopeChain().top()); 3198 3186 JSValue* v = m_right->evaluate(exec); 3199 3187 … … 4504 4492 optimizeVariableAccess(); 4505 4493 4506 ASSERT(exec->variableObject()->isActivation()); 4507 LocalStorage& localStorage = static_cast<ActivationImp*>(exec->variableObject())->localStorage(); 4494 LocalStorage& localStorage = exec->variableObject()->localStorage(); 4508 4495 localStorage.reserveCapacity(m_varStack.size() + m_parameters.size() + m_functionStack.size()); 4509 4496 -
trunk/JavaScriptCore/kjs/object.h
r28468 r28527 454 454 void restoreProperties(const SavedProperties &p) { _prop.restore(p); } 455 455 456 virtual bool isActivation () { return false; }456 virtual bool isActivationObject() { return false; } 457 457 virtual bool isGlobalObject() const { return false; } 458 458 protected:
Note:
See TracChangeset
for help on using the changeset viewer.