RESOLVED WONTFIX Bug 78052
[V8] Allow bindings for attributes on DOM nodes to also set a named hidden reference
https://bugs.webkit.org/show_bug.cgi?id=78052
Summary [V8] Allow bindings for attributes on DOM nodes to also set a named hidden re...
Erik Arvidsson
Reported 2012-02-07 15:53:34 PST
[V8] Allow bindings for attributes on DOM nodes to also set a named hidden reference
Attachments
Patch (12.66 KB, patch)
2012-02-07 15:55 PST, Erik Arvidsson
no flags
Patch (20.17 KB, patch)
2012-02-16 18:59 PST, Erik Arvidsson
no flags
Patch (20.17 KB, patch)
2012-02-16 19:06 PST, Erik Arvidsson
webkit.review.bot: commit-queue-
Erik Arvidsson
Comment 1 2012-02-07 15:55:53 PST
Nate Chapin
Comment 2 2012-02-07 16:04:31 PST
Comment on attachment 125947 [details] Patch Ur doin it rite.
WebKit Review Bot
Comment 3 2012-02-07 20:23:51 PST
Comment on attachment 125947 [details] Patch Clearing flags on attachment: 125947 Committed r107035: <http://trac.webkit.org/changeset/107035>
WebKit Review Bot
Comment 4 2012-02-07 20:23:56 PST
All reviewed patches have been landed. Closing bug.
Erik Arvidsson
Comment 6 2012-02-09 10:11:46 PST
(In reply to comment #5) > This patch regressed DOMDivWalk: > http://build.chromium.org/f/chromium/perf/mac-release-10.6-webkit-latest/dom_perf/report.html?history=150&rev=-1&graph=DOMDivWalk > http://build.chromium.org/p/chromium.webkit/builders/Mac10.6%20Perf/builds/6278 > > The result is much easier to see on Perf-o-matic: http://webkit-perf.appspot.com/graph.html?#tests=[[6104,2001,3001]]&sel=1328173376951,1328778176951&displayrange=7&datatype=running Ouch, that is bad. At this point in time I don't see how to fix that without reintroducing the bugs that this fixed. The problem is that when we do things like foo.bar in js we didn't use to keep a reference from the foo object to the bar object which lead to bugs where we lost the data stored on the bar object. foo.bar.baz = 42 gc() assert(foo.bar.baz === 42) Now we keep a reference if the webidl attribute is readonly and if the wrapper is a non node wrapper.
Ryosuke Niwa
Comment 7 2012-02-09 10:45:41 PST
Can we at least see the the diff in the generated binding code and profile results?
Erik Arvidsson
Comment 8 2012-02-09 12:02:13 PST
(In reply to comment #7) > Can we at least see the the diff in the generated binding code and profile results? With this patch: static v8::Handle<v8::Value> childNodesAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.Node.childNodes._get"); Node* imp = V8Node::toNative(info.Holder()); RefPtr<NodeList> result = imp->childNodes(); v8::Handle<v8::Value> wrapper = result.get() ? V8NodeList::existingWrapper(result.get()) : v8::Handle<v8::Object>(); if (wrapper.IsEmpty()) { wrapper = toV8(result.get()); if (!wrapper.IsEmpty()) V8DOMWrapper::setNamedHiddenReference(info.Holder(), "childNodes", wrapper); } return wrapper; } without this patch: static v8::Handle<v8::Value> childNodesAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.Node.childNodes._get"); Node* imp = V8Node::toNative(info.Holder()); return toV8(imp->childNodes()); }
Erik Arvidsson
Comment 9 2012-02-14 13:52:57 PST
This was rolled back due to the perf impact.
Erik Arvidsson
Comment 10 2012-02-16 18:59:26 PST
Erik Arvidsson
Comment 11 2012-02-16 19:06:10 PST
WebKit Review Bot
Comment 12 2012-02-17 05:17:34 PST
Comment on attachment 127497 [details] Patch Attachment 127497 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/11541403 New failing tests: fast/filesystem/workers/file-writer-write-overlapped.html fast/files/workers/worker-read-blob-sync.html fast/workers/worker-location.html storage/indexeddb/objectstore-basics-workers.html fast/filesystem/workers/file-writer-sync-write-overlapped.html storage/indexeddb/basics.html fast/filesystem/workers/simple-temporary-sync.html http/tests/workers/terminate-during-sync-operation.html
Erik Arvidsson
Comment 13 2012-02-17 11:07:41 PST
Anton, this patch has some bad perf regressions. I was wondering if you have any advice on this problem. The problem is that we do not keep a reference from a Node to its childNodes NodeList (for example, same thing applies to all non node wrappers). The current solution has been to add a custom toV8 that adds a V8 hidden property that keeps the wrapper alive. Since this was only done manually we missed a couple hundred cases ;-) However, adding the hidden property is quite slow and it regresses the DOMDivWalk.html perf test by something like 100%. The way that JSC gets away with this is by making the GC call JSNodeListOwner::isReachableFromOpaqueRoots which of course makes the GC slower. The nice thing about the JSC solution is that it does not keep alive wrappers that do not have custom properties so the NodeList wrapper will be collectable in almost all cases. What is the best approach here? Should we follow JSC and let the GC ask the wrapper if it is reachable? I assume V8 has no concept of custom properties? This path needs a lot of custom code which sucks too.
anton muhin
Comment 14 2012-02-20 06:02:50 PST
Erik, we have pretty similar tools with object groups and implicit references. Instead of using hidden references, I would use implicit refs. From benchmarks point of view, that should have negligible effect---so far prologue phase never surfaced as a major hot-spot. And that would protect you from the unpleasant case when C++ object identity changes for any reason---in this case you would still retain old nodelist with hidden properties. Overall, I think hidden references should go away completely---implicit references look like notably superior approach. But we have had only limited experience with implicit refs so far. (In reply to comment #13) > Anton, this patch has some bad perf regressions. I was wondering if you have any advice on this problem. > > The problem is that we do not keep a reference from a Node to its childNodes NodeList (for example, same thing applies to all non node wrappers). The current solution has been to add a custom toV8 that adds a V8 hidden property that keeps the wrapper alive. Since this was only done manually we missed a couple hundred cases ;-) However, adding the hidden property is quite slow and it regresses the DOMDivWalk.html perf test by something like 100%. > > The way that JSC gets away with this is by making the GC call JSNodeListOwner::isReachableFromOpaqueRoots which of course makes the GC slower. The nice thing about the JSC solution is that it does not keep alive wrappers that do not have custom properties so the NodeList wrapper will be collectable in almost all cases. > > What is the best approach here? Should we follow JSC and let the GC ask the wrapper if it is reachable? I assume V8 has no concept of custom properties? This path needs a lot of custom code which sucks too.
Sam Weinig
Comment 15 2013-04-05 17:23:50 PDT
V8 is no longer supported in WebKit.
Note You need to log in before you can comment on or make changes to this bug.