We currently use two different approaches for associating JavaScript wrappers with DOM objects. For some objects, we store the wrapper inline in the object itself by making object inherit from ScriptWrappable. For other types of objects, we use a HashMap to translate the object into a JavaScript wrapper.
Whether to use ScriptWrappable or a HashMap is a trade-off that depends on the workload. For DOM objects that rarely have a JavaScript wrapper, using a HashMap is more memory efficient because we don't need to store a large number of null pointers in objects that do not have wrappers. By contrast, if an object almost always has a JavaScript wrapper, using ScriptWrappable is both faster (because we avoid the hash table lookup) and uses less memory (because we don't need to store both the key and the value in the HashMap---we just need to store the value in the object itself). Today, we use ScriptWrappable for Nodes only, but we would benefit by making more use of ScriptWrappable, particularly for DOM objects that almost always have JavaScript wrappers. For example, XMLHttpRequest objects exist only when created by script, which means that every XMLHttpRequest object has a JavaScript wrapper. My plan is to introduce an interface-level IDL attribute named something like [OftenHasJSWrapper] that informs the code generator that the object inherits from ScriptWrappable and that we should make use of the inline wrapper. We can then deploy this attribute as appropriate throughout WebCore to reduce memory usage and improve performance. Please let me know if you have any feedback. Thanks! Adam _______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-dev