Closed
Bug 500850
Opened 15 years ago
Closed 15 years ago
Make inline style use wrapper cache and slimwrappers
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla1.9.2a1
People
(Reporter: bzbarsky, Assigned: peterv)
References
Details
Attachments
(2 files, 4 obsolete files)
22.87 KB,
patch
|
peterv
:
review+
peterv
:
superreview+
|
Details | Diff | Splinter Review |
1.52 KB,
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
As the summary says: make inline style use wrapper cache and slimwrappers. Should help scripts that do foo.style.top all the time...
Assignee | ||
Comment 1•15 years ago
|
||
This adds cached wrappers to nsDOMCSSAttrDeclaration and nsComputedDOMStyle, but not to DOMCSSDeclarationImpl (in nsCSSStyleRule.cpp). Bz: it's not really hard to add it to DOMCSSDeclarationImpl, do you think it would be worth it? This also adds thisptr offset tables to nsDOMCSSDeclaration and nsComputedDOMStyle, and makes nsGlobalWindow::GetComputedStyle not go through a factory to create a nsComputedDOMStyle. Note that because nsIDOMCSS2Properties and nsIDOMNSCSS2Properties are implemented in a tearoff the thisptr offset tables won't make a huge difference with this patch alone.
Assignee: nobody → peterv
Status: NEW → ASSIGNED
Attachment #387528 -
Flags: superreview?(bzbarsky)
Attachment #387528 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 2•15 years ago
|
||
This makes better use of the thisptr offset table by autogenerating all the quickstubs for nsIDOMCSS2Properties and nsIDOMNSCSS2Properties by forwarding to semi-generated quickstubs for nsICSSDeclaration_GetPropertyValue and nsICSSDeclaration_GetPropertyValue. Not entirely happy with the fact that those are semi-generated.
Assignee | ||
Comment 3•15 years ago
|
||
If we take part 2 we can make CSS2PropertiesTearoff a real non-cached tearoff without a performance penalty when calling from JS. It would shrink nsDOMCSSDeclaration and nsComputedDOMStyle by two words.
Reporter | ||
Comment 4•15 years ago
|
||
Comment on attachment 387528 [details] [diff] [review] Part 1 v1 > Bz: it's not really hard to add it to DOMCSSDeclarationImpl, do you think it > would be worth it? I doubt it; that's not touched very often. >+++ b/dom/base/nsDOMClassInfo.cpp >+nsCSSStyleDeclSH::PreCreate(nsISupports *nativeObj, JSContext *cx, >+ if (!cache) { >+ return nsDOMClassInfo::PreCreate(nativeObj, cx, globalObj, parentObj); Why do we not need to make an equivalent call in, say, nsNodeListSH::PreCreate? Or is that just a bug? >+ nsISupports *native_parent = declaration->GetParentObject(); ... >+ nsresult rv = WrapNative(cx, globalObj, native_parent, &v); Hmm. So doesn't this change property lookup on CSS declarations? Or is that not an issue for some reason? I thought the scope parent thing just affected stuff like event handlers (probably not an issue here) and with() (might be an issue). Or are we overloading scope parents to mean something else too now? The rest of this looks fine.
Reporter | ||
Comment 5•15 years ago
|
||
David might be interested in the part 3 there.... Note that that seems to make performance a tiny worse for C++ callers, right? Probably not an issue in any case... Would it help with the autogeneration bit if nsICSSDeclaration were in the form of [noscript] idl or some such?
Assignee | ||
Comment 6•15 years ago
|
||
(In reply to comment #4) > Why do we not need to make an equivalent call in, say, nsNodeListSH::PreCreate? > Or is that just a bug? I'm not sure yet, but I think it might be. I'll file a bug about it. > Hmm. So doesn't this change property lookup on CSS declarations? Or is that > not an issue for some reason? I thought the scope parent thing just affected > stuff like event handlers (probably not an issue here) and with() (might be an > issue). Or are we overloading scope parents to mean something else too now? I'll check this. We're not really overloading scope parent, the problem is that in order to have just one wrapper in the whole system for these objects we need a specific parent, regardless of the scope we're wrapping in. And if we want to cache wrappers we can only have one wrapper in the whole system for these objects.
Reporter | ||
Comment 7•15 years ago
|
||
> just one wrapper in the whole system for these objects we need a specific parent
Ah, right. But _which_ parent sort of matters, as I recall... Please do check on this?
Reporter | ||
Comment 8•15 years ago
|
||
Comment on attachment 387528 [details] [diff] [review] Part 1 v1 Per discussion.
Attachment #387528 -
Flags: superreview?(bzbarsky)
Attachment #387528 -
Flags: superreview+
Attachment #387528 -
Flags: review?(bzbarsky)
Attachment #387528 -
Flags: review+
Reporter | ||
Comment 9•15 years ago
|
||
So I just tried these patches... Part 3 doesn't link. Parts 1+2 together seem to speed up the test in bug 229391 by 5% or so, but after running it a few times crash in cycle collection somewhere. Not sure whether I need to have both patches applied to hit that.
Assignee | ||
Comment 10•15 years ago
|
||
The cycle collection crash was a regression from a last-minute change I made to the patch just before attaching :-/. The NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY is slightly different from others, because it doesn't have an else at the end and so we have to be careful wrt what other macros follow it (NS_IMPL_QUERY_TAIL_INHERITING sets foundInterface to 0 as its first line). I'll file a bug to figure out if we can change NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY to avoid these problems (by adding an else?).
Attachment #387528 -
Attachment is obsolete: true
Attachment #388668 -
Flags: superreview+
Attachment #388668 -
Flags: review+
Assignee | ||
Comment 11•15 years ago
|
||
Updated patch, this one should link.
Attachment #387530 -
Attachment is obsolete: true
Reporter | ||
Comment 12•15 years ago
|
||
Yeah, that seems to run fine; drops times from the 815ms range to 770ms range on that testcase.
Reporter | ||
Comment 13•15 years ago
|
||
I just had a nice conversation with mrbkap, who told me that I'm on crack about how with() works. It doesn't push the object it's given on the scope chain; it puts a With object which then delegates to the given object and its proto chain. So with() behavior is not affected by an object's parent chain. As long as we don't have DOM event handlers on inline style, this change should cause no observable behavior differences, sounds like.
Assignee | ||
Comment 14•15 years ago
|
||
Checked in part 1: http://hg.mozilla.org/mozilla-central/rev/0ab9276e2dba
Reporter | ||
Comment 15•15 years ago
|
||
It might be worth spinning off the other parts into separate bugs, then, just so we can track the state of things.
Comment on attachment 388668 [details] [diff] [review] Part 1 v1 >+ NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "slots mStyle"); >+ cb.NoteXPCOMChild(slots->mStyle.get()); Why no addition to the unlink method?
Assignee | ||
Comment 17•15 years ago
|
||
Yeah, we should unlink. I also added traversal of the script object to nsComputedDOMStyle, I don't think we currently preserve any of these wrappers (when someone sets an expando on them), but it shouldn't cost much to try to traverse them and if we ever do preserve them we're already safe.
Attachment #387529 -
Attachment is obsolete: true
Attachment #388669 -
Attachment is obsolete: true
Attachment #392932 -
Flags: superreview?(bzbarsky)
Attachment #392932 -
Flags: review?(bzbarsky)
Reporter | ||
Updated•15 years ago
|
Attachment #392932 -
Flags: superreview?(bzbarsky)
Attachment #392932 -
Flags: superreview+
Attachment #392932 -
Flags: review?(bzbarsky)
Attachment #392932 -
Flags: review+
Assignee | ||
Comment 18•15 years ago
|
||
Attachment 392932 [details] [diff] landed. http://hg.mozilla.org/mozilla-central/rev/a8c89c6a48e6
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•