2009-01-15 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jan 2009 23:49:55 +0000 (23:49 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jan 2009 23:49:55 +0000 (23:49 +0000)
        Reviewed by Gavin Barraclough.

        Fix crash seen running fast/canvas.

        Make sure to mark the ScopeNode and CodeBlock being created
        in the re-parse for exception information.

        * bytecode/CodeBlock.cpp:
        (JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
        * parser/Nodes.h:
        (JSC::ScopeNode::mark):
        * runtime/Collector.cpp:
        (JSC::Heap::collect):
        * runtime/JSGlobalData.cpp:
        (JSC::JSGlobalData::JSGlobalData):
        * runtime/JSGlobalData.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39951 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/bytecode/CodeBlock.cpp
JavaScriptCore/parser/Nodes.h
JavaScriptCore/runtime/Collector.cpp
JavaScriptCore/runtime/JSGlobalData.cpp
JavaScriptCore/runtime/JSGlobalData.h

index afc8ec9..d665648 100644 (file)
@@ -1,3 +1,22 @@
+2009-01-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Gavin Barraclough.
+
+        Fix crash seen running fast/canvas.
+
+        Make sure to mark the ScopeNode and CodeBlock being created
+        in the re-parse for exception information.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::reparseForExceptionInfoIfNecessary):
+        * parser/Nodes.h:
+        (JSC::ScopeNode::mark):
+        * runtime/Collector.cpp:
+        (JSC::Heap::collect):
+        * runtime/JSGlobalData.cpp:
+        (JSC::JSGlobalData::JSGlobalData):
+        * runtime/JSGlobalData.h:
+
 2009-01-15  Craig Schlenter  <craig.schlenter@gmail.com>
 
         Reviewed by Darin Adler.
index 257130d..c0bece9 100644 (file)
@@ -1409,6 +1409,9 @@ void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
             FunctionBodyNode* ownerFunctionBodyNode = static_cast<FunctionBodyNode*>(m_ownerNode);
             RefPtr<FunctionBodyNode> newFunctionBody = m_globalData->parser->reparse<FunctionBodyNode>(m_globalData, ownerFunctionBodyNode);
             newFunctionBody->finishParsing(ownerFunctionBodyNode->copyParameters(), ownerFunctionBodyNode->parameterCount());
+
+            m_globalData->scopeNodeBeingReparsed = newFunctionBody.get();
+
             CodeBlock& newCodeBlock = newFunctionBody->bytecodeForExceptionInfoReparse(scopeChain, this);
             ASSERT(newCodeBlock.m_exceptionInfo);
             ASSERT(newCodeBlock.m_instructionCount == m_instructionCount);
@@ -1419,11 +1422,17 @@ void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
 #endif
 
             m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release());
+
+            m_globalData->scopeNodeBeingReparsed = 0;
+
             break;
         }
         case EvalCode: {
             EvalNode* ownerEvalNode = static_cast<EvalNode*>(m_ownerNode);
             RefPtr<EvalNode> newEvalBody = m_globalData->parser->reparse<EvalNode>(m_globalData, ownerEvalNode);
+
+            m_globalData->scopeNodeBeingReparsed = newEvalBody.get();
+
             EvalCodeBlock& newCodeBlock = newEvalBody->bytecodeForExceptionInfoReparse(scopeChain, this);
             ASSERT(newCodeBlock.m_exceptionInfo);
             ASSERT(newCodeBlock.m_instructionCount == m_instructionCount);
@@ -1434,6 +1443,9 @@ void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
 #endif
 
             m_exceptionInfo.set(newCodeBlock.m_exceptionInfo.release());
+
+            m_globalData->scopeNodeBeingReparsed = 0;
+
             break;
         }
         default:
index b497f34..645aa65 100644 (file)
@@ -2118,6 +2118,8 @@ namespace JSC {
             return m_data->m_numConstants + 2;
         }
 
+        virtual void mark() { }
+
     protected:
         void setSource(const SourceCode& source) { m_source = source; }
 
@@ -2160,7 +2162,8 @@ namespace JSC {
 
         EvalCodeBlock& bytecodeForExceptionInfoReparse(ScopeChainNode*, CodeBlock*) JSC_FAST_CALL;
 
-        void mark();
+        virtual void mark();
+
     private:
         EvalNode(JSGlobalData*, SourceElements*, VarStack*, FunctionStack*, const SourceCode&, CodeFeatures, int numConstants) JSC_FAST_CALL;
 
@@ -2203,7 +2206,7 @@ namespace JSC {
             return m_code;
         }
 
-        void mark();
+        virtual void mark();
 
         void finishParsing(const SourceCode&, ParameterNode*);
         void finishParsing(Identifier* parameters, size_t parameterCount);
index 9399035..8d75c4c 100644 (file)
@@ -986,6 +986,8 @@ bool Heap::collect()
         m_globalData->exception->mark();
     m_globalData->interpreter->registerFile().markCallFrames(this);
     m_globalData->smallStrings.mark();
+    if (m_globalData->scopeNodeBeingReparsed)
+        m_globalData->scopeNodeBeingReparsed->mark();
 
     JAVASCRIPTCORE_GC_MARKED();
 
index e1ba4bd..f3271bb 100644 (file)
@@ -91,6 +91,7 @@ JSGlobalData::JSGlobalData(bool isShared)
     , dynamicGlobalObject(0)
     , isSharedInstance(isShared)
     , clientData(0)
+    , scopeNodeBeingReparsed(0)
     , heap(this)
 {
 #if PLATFORM(MAC)
index 67f4178..3449758 100644 (file)
@@ -46,12 +46,13 @@ namespace JSC {
     class CommonIdentifiers;
     class Heap;
     class IdentifierTable;
+    class Interpreter;
     class JSGlobalObject;
     class JSObject;
     class Lexer;
-    class Interpreter;
     class Parser;
     class ParserRefCounted;
+    class ScopeNode;
     class Structure;
     class UString;
     struct HashTable;
@@ -120,6 +121,8 @@ namespace JSC {
 
         HashSet<JSObject*> arrayVisitedElements;
 
+        ScopeNode* scopeNodeBeingReparsed;
+
         Heap heap;
 #if ENABLE(ASSEMBLER)
         PassRefPtr<ExecutablePool> poolForSize(size_t n) { return m_executableAllocator.poolForSize(n); }