[webkit-dev] New marking model for GC collected objects

Oliver Hunt oliver at apple.com
Tue Aug 11 11:59:38 PDT 2009


Last night I landed a patch that replaces the old recursive marking  
functions with a new iterative model that uses an explicit mark  
stack.  This means that any custom mark methods that you need to write  
now need to be slightly different from what they were previously, i'll  
attempt to summarise here.

The most obvious change is that an object is no longer responsible for  
marking itself instead the recursive mark methods have been replaced  
by a new virtual markChildren(MarkStack&) which is responsible for  
appending an objects children to the stack.

The MarkStack is a very simple class, and the only method you really  
need to know about is MarkStack::append which adds a new object to the  
stack.

The changes to how your custom marking functions are implemented are  
trivial, but here's a simple example
void MyAwesomeObject::mark()
{
     Base::mark();
     if (!m_child.marked())
         m_child.mark();
}

Becomes
void MyAwesomeObject::markChildren(MarkStack& markStack)
{
     Base::markChildren(markStack);
     markStack.append(m_child);
}

And that's it, you're done.

It's important to note that you will never be in a position where you  
call markChildren yourself, if you are that is an error.

--Oliver



More information about the webkit-dev mailing list