Changeset 29710 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Jan 21, 2008, 10:18:10 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ExecState.cpp
r29542 r29710 42 42 // ECMA 10.2 43 43 44 // The constructor for the globalExec pseudo-ExecState 45 ExecState::ExecState(JSGlobalObject* globalObject) 46 : m_globalObject(globalObject) 47 , m_exception(0) 48 , m_propertyNames(CommonIdentifiers::shared()) 49 , m_emptyList(globalEmptyList()) 50 , m_callingExec(0) 51 , m_scopeNode(0) 52 , m_function(0) 53 , m_arguments(0) 54 , m_activation(0) 55 , m_localStorage(&globalObject->localStorage()) 56 , m_variableObject(globalObject) 57 , m_thisVal(globalObject) 58 , m_iterationDepth(0) 59 , m_switchDepth(0) 60 , m_codeType(GlobalCode) 61 { 62 m_scopeChain.push(globalObject); 63 } 64 44 65 ExecState::ExecState(JSGlobalObject* globalObject, JSObject* /*thisObject*/, ProgramNode* programNode) 45 66 : m_globalObject(globalObject) … … 48 69 , m_emptyList(globalEmptyList()) 49 70 , m_callingExec(0) 50 , m_savedExec(0)51 71 , m_scopeNode(programNode) 52 72 , m_function(0) … … 63 83 // a script with a this object that's not the same as the global object is broken, and probably 64 84 // has been for some time. 85 ASSERT(m_scopeNode); 86 activeExecStates().append(this); 65 87 m_scopeChain.push(globalObject); 66 if (programNode)67 globalObject->setCurrentExec(this);68 88 } 69 89 … … 74 94 , m_emptyList(callingExec->m_emptyList) 75 95 , m_callingExec(callingExec) 76 , m_savedExec(globalObject->currentExec())77 96 , m_scopeNode(evalNode) 78 97 , m_function(0) … … 87 106 , m_codeType(EvalCode) 88 107 { 89 globalObject->setCurrentExec(this); 108 ASSERT(m_scopeNode); 109 activeExecStates().append(this); 90 110 } 91 111 … … 98 118 , m_emptyList(callingExec->m_emptyList) 99 119 , m_callingExec(callingExec) 100 , m_savedExec(globalObject->currentExec())101 120 , m_scopeNode(functionBodyNode) 102 121 , m_function(func) … … 108 127 , m_codeType(FunctionCode) 109 128 { 129 ASSERT(m_scopeNode); 130 activeExecStates().append(this); 131 110 132 ActivationImp* activation = globalObject->pushActivation(this); 111 133 m_activation = activation; … … 113 135 m_variableObject = activation; 114 136 m_scopeChain.push(activation); 115 globalObject->setCurrentExec(this);116 137 } 117 138 118 139 ExecState::~ExecState() 119 140 { 120 if (m_codeType == FunctionCode && m_activation->needsPop()) 141 ASSERT(m_scopeNode && activeExecStates().last() == this || !m_scopeNode); 142 if (m_scopeNode) 143 activeExecStates().removeLast(); 144 145 if (m_activation && m_activation->needsPop()) 121 146 m_globalObject->popActivation(); 122 123 m_globalObject->setCurrentExec(m_savedExec);124 }125 126 void ExecState::mark()127 {128 for (ExecState* exec = this; exec; exec = exec->m_callingExec) {129 exec->m_scopeChain.mark();130 131 if (exec->m_savedExec != exec->m_callingExec && exec->m_savedExec)132 exec->m_savedExec->mark();133 }134 147 } 135 148 … … 146 159 } 147 160 161 void ExecState::markActiveExecStates() 162 { 163 ExecStateStack::const_iterator end = activeExecStates().end(); 164 for (ExecStateStack::const_iterator it = activeExecStates().begin(); it != end; ++it) 165 (*it)->m_scopeChain.mark(); 166 } 167 168 ExecStateStack& ExecState::activeExecStates() 169 { 170 static ExecStateStack staticActiveExecStates; 171 return staticActiveExecStates; 172 } 173 148 174 } // namespace KJS -
trunk/JavaScriptCore/kjs/ExecState.h
r29425 r29710 52 52 struct LocalStorageEntry; 53 53 54 typedef Vector<ExecState*, 16> ExecStateStack; 55 54 56 /** 55 57 * Represents the current state of script execution. This is … … 86 88 87 89 ExecState* callingExecState() { return m_callingExec; } 88 ExecState* savedExec() { return m_savedExec; }89 90 90 91 ActivationImp* activationObject() { return m_activation; } … … 107 108 bool inSwitch() const { return (m_switchDepth > 0); } 108 109 109 void mark();110 111 110 // These pointers are used to avoid accessing global variables for these, 112 111 // to avoid taking PIC branches in Mach-O binaries. … … 179 178 } 180 179 180 ExecState(JSGlobalObject*); 181 181 ExecState(JSGlobalObject*, JSObject* thisObject, ProgramNode*); 182 182 ExecState(JSGlobalObject*, EvalNode*, ExecState* callingExecState); … … 185 185 ~ExecState(); 186 186 187 static void markActiveExecStates(); 188 static ExecStateStack& activeExecStates(); 189 187 190 private: 188 191 // ExecStates are always stack-allocated, and the garbage collector … … 195 198 196 199 ExecState* m_callingExec; 197 ExecState* m_savedExec; 200 198 201 ScopeNode* m_scopeNode; 199 202 -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r29663 r29710 136 136 d()->timeoutCheckCount = 0; 137 137 138 d()->currentExec = 0;139 138 d()->recursion = 0; 140 139 d()->debugger = 0; … … 472 471 { 473 472 JSVariableObject::mark(); 474 475 if (d()->currentExec)476 d()->currentExec->mark();477 473 478 474 markIfNeeded(d()->globalExec.exception()); -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r29663 r29710 77 77 JSGlobalObjectData(JSGlobalObject* globalObject) 78 78 : JSVariableObjectData(&inlineSymbolTable) 79 , globalExec(globalObject , globalObject, 0)79 , globalExec(globalObject) 80 80 { 81 81 } … … 88 88 89 89 ExecState globalExec; 90 ExecState* currentExec;91 90 int recursion; 92 91 … … 212 211 void setDebugger(Debugger* debugger) { d()->debugger = debugger; } 213 212 214 void setCurrentExec(ExecState* exec) { d()->currentExec = exec; }215 ExecState* currentExec() const { return d()->currentExec; }216 217 213 // FIXME: Let's just pick one compatible behavior and go with it. 218 214 void setCompatMode(CompatMode mode) { d()->compatMode = mode; } -
trunk/JavaScriptCore/kjs/collector.cpp
r29611 r29710 953 953 markStackObjectsConservatively(); 954 954 markProtectedObjects(); 955 ExecState::markActiveExecStates(); 955 956 List::markProtectedLists(); 956 957 #if USE(MULTIPLE_THREADS) … … 1067 1068 void Collector::reportOutOfMemoryToAllExecStates() 1068 1069 { 1069 JSGlobalObject* o = JSGlobalObject::head(); 1070 if (!o) 1071 return; 1072 1073 do { 1074 ExecState* exec = o->currentExec() ? o->currentExec() : o->globalExec(); 1075 exec->setException(Error::create(exec, GeneralError, "Out of memory")); 1076 o = o->next(); 1077 } while(o != JSGlobalObject::head()); 1070 ExecStateStack::const_iterator end = ExecState::activeExecStates().end(); 1071 for (ExecStateStack::const_iterator it = ExecState::activeExecStates().begin(); it != end; ++it) { 1072 (*it)->setException(Error::create(*it, GeneralError, "Out of memory")); 1073 } 1078 1074 } 1079 1075
Note:
See TracChangeset
for help on using the changeset viewer.