[webkit-dev] Integrating WebKit GC with other runtimes.

Antony Blakey antony.blakey at gmail.com
Mon Apr 21 06:00:03 PDT 2008


Hi,
    I'm working on embedding WebKit in Smalltalk (initially  
VisualWorks, probably also GST). I'm not aiming at the common embedded- 
browser use-cases. Instead the aim is to use WebKit as a UI toolkit in  
the same way that you would use Cocoa/Win32/GTK e.g. rather than your  
code having a reference to a text editing field, you have a reference  
to an 'INPUT' DOM node. I've got a few blog posts that go into more  
detail if anyone is interested: (there is a question at the end of  
this email, after the explanation of what I'm trying to do)

http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=WebInspector_for_WebKit_in_VW,_and_some_points_about_using_WebKit_as_a_replacement_GUI.&entry=3375921297

http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=Integrating_Gecko/Webkit_into_VisualWorks&entry=3374769328

This work relies on a seamless integration of the Smalltalk garbage  
collection, which uses an generational tracing collector, with the  
WebKit reference counting system. It is theoretically possible to do  
this without requiring the programmer to handle the WebKit reference  
counting to avoid cycles, using a mechanism I outline here:

http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=A_seamless_integration_of_VWs_tracing_collector_with_WebKits_reference_counting.&entry=3377387320

My question is how to best do the tracing within WebKit. Considering  
first a purely DOM-based solution i.e. ignoring javascript - if I have  
a WebKit object reference, what is the best way to trace the tree and  
find all reachable objects? Specifically I need to get to all my  
Smalltalk proxies. For efficiency purposes I need to keep track of  
what objects have already been visited in a given gc pass. Ideally  
every WebKit object would have a 2 bit colour (3 colours are needed to  
avoid a flag-reset pass, and 4 colors make the new-node code easier)  
but I could handle this using a per-pass identity set. The API  
abstraction I'm looking for is something like:

   <...>.visit(<color>, <callback>)

Which needs to be defined for every object that can be referenced from  
Smalltalk.

Does anyone have any suggestions about the best way to do this? A  
principal concern is that if I have to add a tracing method to every  
class that introduces reference members then merging with new WebKit  
releases will be a real PITA.

A related question is about threading - I've noticed with the  
integration I have so far that events are all handled on the primary  
thread (as I would have expected), but does any GC-significant  
mutation occur on secondary threads? Can I assume a single threaded  
mutator abstraction?

IMO this facility would not only be generally useful for other  
language integration e.g. I'm considering Gambit or Chicken (Scheme)  
integration, but would also enable a tracing collector for WebKit  
itself.

Antony Blakey
--------------------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

What can be done with fewer [assumptions] is done in vain with more
   -- William of Ockham (ca. 1285-1349)





More information about the webkit-dev mailing list