WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
Bug 20574
bindings need better internal support for binding-object-to-webkit-c++-object mapping
https://bugs.webkit.org/show_bug.cgi?id=20574
Summary
bindings need better internal support for binding-object-to-webkit-c++-object...
Luke Kenneth Casson Leighton
Reported
2008-08-30 01:06:54 PDT
the addition of the glib bindings to the DOM highlight clearly that better support is needed for bindings. you now have three bindings systems, each of which are duplicating thousands of lines of code to provide, in their own special and absolutely identical way: * object type mapping on a per-object per-binding basis, to mirror Node::nodeType() onto e.g. GDOM_TYPE_XXX for glib * object hash-mapping on a per-binding basis, to match unique creation of binding-objects onto webkit objects. * a "wrapper" factory on a per-object-type per-binding basis, to actually _create_ the binding-objects of the right type, when the binding system doesn't know what type of webkit object it's being asked to create. for the glib bindings, i've cut and paste and global-search-replaced about _two thousand_ lines of JS wrapper factory and other code, in order to duplicate the exact same required functionality line-for-line, concept-for-concept, as can be seen in GDOMBinding.cpp and GDOMHTMLElementWrapperfactory.cpp to add support for SVG Document objects will require duplication of and global-search-replace modification of another thousand or so lines of code. it would be very simple to add: * a templated version of the wrapper factory system * a per-webkit-object pointer to a "private" wrapper class, which can contain a list of binding objects, covered and accessed by an enum. one single extra pointer is not that much space to save vs the _three_ (at the moment) comparatively inefficient and duplicated sets of hash-map code, each of which require "safety checks" to help deal with bugs (e.g. see addWrapper in JSDOMBindings.cpp) those bugs don't _exist_ if you have a pointer to a list of binding objects _in_ the webkit class: when the webkit class is delete()d the binding objects can be double-checked to be non-existent.
Attachments
Add attachment
proposed patch, testcase, etc.
Mark Rowe (bdash)
Comment 1
2008-08-30 13:15:33 PDT
Increasing the size of every DOM object by four/eight bytes is not the right way to address this.
Luke Kenneth Casson Leighton
Comment 2
2008-08-31 06:51:45 PDT
have you considered doing a test evaluation - especially on AJAX web sites - to get some statistics on how many entries there are in the various HashMaps? bearing in mind that the HashMaps are... at least double the amount of memory of a single per-object pointer, then if over 50% of the c++ DOM model objects have javascript binding objects attached to them, you're not saving any memory at all, and adding complexity andd overhead to boot. if the overhead of the HashMaps are _three_ times that of a single per-object pointer, then ... so, i believe it may be worthwhile adding in some printfs into addWrapper in JSDOMBindings.cpp to print out the count of the number of HashMap entries, and also have a count printout of the number of c++ DOM objects. even if it turns out that, even on heavy-javascript-based web sites such as gmail, yahoo mail and other sites, that the memory overhead of the HashMaps is significantly less than having a single pointer in the c++ DOM objects which goes unused (perhaps a lot of the time), the issue of my having to cut-and-paste and global-search-replace a good 1,500 line of code to get a corresponding object map for the glib bindinds remains.
Anders Carlsson
Comment 3
2014-02-08 08:33:58 PST
Regressing memory is a big no-no, so let's not do this.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug