Re: [webkit-dev] about hashmap staticDOMObjects
Re-adding list (I assume it was omitted by mistake). On Apr 22, 2009, at 11:12 PM, ZHOU Xiao-bo wrote: thanks, but I have another question: Is every DOM wrapper that is inserted into the hashtable been protected, I mean whether they are added in the protectset? If yes, when are they inserted, if not, I think they may become wild pointer after Collector::collect is called. Objects in this hashtable are not protected from garbage collection. Instead, all DOM object wrappers that are eligible to be in this hash table will automatically remove themselves when collected. This ensures that the hashtable does not contain bad pointers after a GC. - Maciej 2009/4/23 Maciej Stachowiak m...@apple.com On Apr 22, 2009, at 12:27 AM, ZHOU Xiao-bo wrote: hi all: I still don't understand the purpose of the HashMap: static DOMObjectMap domObjects() { // Don't use malloc here. Calling malloc from a mark function can deadlock. static DOMObjectMap staticDOMObjects; return staticDOMObjects; } what kind of DOMObjects should be stored in it? And why? I searched the source codes and I found that these classes below will do that: Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, DOMCoreException, DOMImplementation, DOMParser, EventException, History, NamedNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker, XMLHttpRequestException, XMLSerializer, Clipboard but what's the reason? Is it because these classes are essentially simple and just acting as a tool? The hash map is to ensure that DOM wrappers are unique but created on demand, without consuming a pointer in the underlying C++ object. For DOM Nodes, we use a hash table in the Node's owner document, but in the case of non-Node objects and the Document itself (which has no owner document), we need this global hash table. Regards, Maciej ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
[webkit-dev] about hashmap staticDOMObjects
hi all: I still don't understand the purpose of the HashMap: static DOMObjectMap domObjects() { // Don't use malloc here. Calling malloc from a mark function can deadlock. static DOMObjectMap staticDOMObjects; return staticDOMObjects; } what kind of DOMObjects should be stored in it? And why? I searched the source codes and I found that these classes below will do that: Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, DOMCoreException, DOMImplementation, DOMParser, EventException, History, NamedNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker, XMLHttpRequestException, XMLSerializer, Clipboard but what's the reason? Is it because these classes are essentially simple and just acting as a tool? thanks a lot ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] about hashmap staticDOMObjects
oh, I got an idea: Is it because these domobjects doesn't belong to a Document, so they can't be stored in static NodePerDocMap domNodesPerDocument() { ASSERT(JSLock::lockCount()); static NodePerDocMap staticDOMNodesPerDocument; return staticDOMNodesPerDocument; } 2009/4/22 ZHOU Xiao-bo zhxb.u...@gmail.com hi all: I still don't understand the purpose of the HashMap: static DOMObjectMap domObjects() { // Don't use malloc here. Calling malloc from a mark function can deadlock. static DOMObjectMap staticDOMObjects; return staticDOMObjects; } what kind of DOMObjects should be stored in it? And why? I searched the source codes and I found that these classes below will do that: Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, DOMCoreException, DOMImplementation, DOMParser, EventException, History, NamedNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker, XMLHttpRequestException, XMLSerializer, Clipboard but what's the reason? Is it because these classes are essentially simple and just acting as a tool? thanks a lot ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] about hashmap staticDOMObjects
On Apr 22, 2009, at 12:27 AM, ZHOU Xiao-bo wrote: hi all: I still don't understand the purpose of the HashMap: static DOMObjectMap domObjects() { // Don't use malloc here. Calling malloc from a mark function can deadlock. static DOMObjectMap staticDOMObjects; return staticDOMObjects; } what kind of DOMObjects should be stored in it? And why? I searched the source codes and I found that these classes below will do that: Document, Event, HTMLCollection, XMLHttpRequest, CanvasGradient, CanvasPattern, CanvasRenderingContext2D, DOMCoreException, DOMImplementation, DOMParser, EventException, History, NamedNodeMap, NodeFilter, NodeIterator, NodeList, Range, RangeException, TreeWalker, XMLHttpRequestException, XMLSerializer, Clipboard but what's the reason? Is it because these classes are essentially simple and just acting as a tool? The hash map is to ensure that DOM wrappers are unique but created on demand, without consuming a pointer in the underlying C++ object. For DOM Nodes, we use a hash table in the Node's owner document, but in the case of non-Node objects and the Document itself (which has no owner document), we need this global hash table. Regards, Maciej ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev