Changeset 39571 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 2, 2009, 8:36:40 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r39563 r39571 1 2009-01-02 Oliver Hunt <[email protected]> 2 3 Reviewed by Gavin Barraclough. 4 5 [jsfunfuzz] unwind logic for exceptions in eval fails to account for dynamic scope external to the eval 6 https://bugs.webkit.org/show_bug.cgi?id=23078 7 8 This bug was caused by eval codeblocks being generated without accounting 9 for the depth of the scope chain they inherited. This meant that exception 10 handlers would understate their expected scope chain depth, which in turn 11 led to incorrectly removing nodes from the scope chain. 12 13 * bytecompiler/BytecodeGenerator.cpp: 14 (JSC::BytecodeGenerator::BytecodeGenerator): 15 (JSC::BytecodeGenerator::emitCatch): 16 * bytecompiler/BytecodeGenerator.h: 17 * interpreter/Interpreter.cpp: 18 (JSC::depth): 19 * runtime/ScopeChain.cpp: 20 (JSC::ScopeChain::localDepth): 21 * runtime/ScopeChain.h: 22 (JSC::ScopeChainNode::deref): 23 (JSC::ScopeChainNode::ref): 24 1 25 2009-01-02 David Smith <[email protected]> 2 26 -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r39524 r39571 213 213 , m_finallyDepth(0) 214 214 , m_dynamicScopeDepth(0) 215 , m_baseScopeDepth(0) 215 216 , m_codeType(GlobalCode) 216 217 , m_nextGlobalIndex(-1) … … 293 294 , m_finallyDepth(0) 294 295 , m_dynamicScopeDepth(0) 296 , m_baseScopeDepth(0) 295 297 , m_codeType(FunctionCode) 296 298 , m_globalData(&scopeChain.globalObject()->globalExec()->globalData()) … … 364 366 , m_finallyDepth(0) 365 367 , m_dynamicScopeDepth(0) 368 , m_baseScopeDepth(scopeChain.localDepth()) 366 369 , m_codeType(EvalCode) 367 370 , m_globalData(&scopeChain.globalObject()->globalExec()->globalData()) … … 369 372 , m_emitNodeDepth(0) 370 373 { 371 if (m_shouldEmitDebugHooks )374 if (m_shouldEmitDebugHooks || m_baseScopeDepth) 372 375 m_codeBlock->setNeedsFullScopeChain(true); 373 376 … … 1589 1592 { 1590 1593 #if ENABLE(JIT) 1591 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth , 0 };1594 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth, 0 }; 1592 1595 #else 1593 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth };1596 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth }; 1594 1597 #endif 1595 1598 -
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r39366 r39571 441 441 int m_finallyDepth; 442 442 int m_dynamicScopeDepth; 443 int m_baseScopeDepth; 443 444 CodeType m_codeType; 444 445 -
trunk/JavaScriptCore/interpreter/Interpreter.cpp
r39525 r39571 103 103 if (!codeBlock->needsFullScopeChain()) 104 104 return 0; 105 int scopeDepth = 0; 106 ScopeChainIterator iter = sc.begin(); 107 ScopeChainIterator end = sc.end(); 108 while (!(*iter)->isObject(&JSActivation::info)) { 109 ++iter; 110 if (iter == end) 111 break; 112 ++scopeDepth; 113 } 114 return scopeDepth; 105 return sc.localDepth(); 115 106 } 116 107 -
trunk/JavaScriptCore/runtime/ScopeChain.cpp
r38087 r39571 51 51 #endif 52 52 53 int ScopeChain::localDepth() const 54 { 55 int scopeDepth = 0; 56 ScopeChainIterator iter = this->begin(); 57 ScopeChainIterator end = this->end(); 58 while (!(*iter)->isObject(&JSActivation::info)) { 59 ++iter; 60 if (iter == end) 61 break; 62 ++scopeDepth; 63 } 64 return scopeDepth; 65 } 66 53 67 } // namespace JSC -
trunk/JavaScriptCore/runtime/ScopeChain.h
r38473 r39571 49 49 int refCount; 50 50 51 void deref() { if (--refCount == 0) release();}52 void ref() { ++refCount; }51 void deref() { ASSERT(refCount); if (--refCount == 0) { release();} } 52 void ref() { ASSERT(refCount); ++refCount; } 53 53 void release(); 54 54 … … 192 192 void mark() const; 193 193 194 // Caution: this should only be used if the codeblock this is being used 195 // with needs a full scope chain, otherwise this returns the depth of 196 // the preceeding call frame 197 // 198 // Returns the depth of the current call frame's scope chain 199 int localDepth() const; 200 194 201 #ifndef NDEBUG 195 202 void print() const { m_node->print(); }
Note:
See TracChangeset
for help on using the changeset viewer.