Closed
Bug 243488
Opened 21 years ago
Closed 21 years ago
[FIXr]Consider ways to speed up documentNeedsSecurityCheck
Categories
(Core :: DOM: Core & HTML, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla1.8alpha3
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
(Keywords: perf)
Attachments
(1 file, 2 obsolete files)
5.63 KB,
patch
|
brendan
:
superreview+
|
Details | Diff | Splinter Review |
To be precise, does the new stuff brendan adds in the patches in bug 213946 make
it possible to speed up this code a bit? It looks to me like it maybe should....
See http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsDOMClassInfo.cpp#5086
and especially the loop at
http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsDOMClassInfo.cpp#5121
![]() |
Assignee | |
Comment 1•21 years ago
|
||
OK, it looks like that code only returns principals, whereas what we want here
is the global object associated to whatever function object is on the stack....
I still wonder whether it's worth a JS api change to speed this up -- it's done
for all sorts of access of properties of document objects, so it may help some
DHTML stuff along a tad...
![]() |
Assignee | |
Comment 2•21 years ago
|
||
Note that needsSecurityCheck() has similar issues/code.
![]() |
Assignee | |
Comment 3•21 years ago
|
||
I bet this will help!
![]() |
Assignee | |
Comment 4•21 years ago
|
||
Attachment #148546 -
Attachment is obsolete: true
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #148547 -
Flags: superreview?(brendan)
Attachment #148547 -
Flags: review?(jst)
![]() |
||
Comment 5•21 years ago
|
||
bz: any perf numbers or profiling before/after?
/be
![]() |
Assignee | |
Comment 6•21 years ago
|
||
I think it sped up the "many document.write calls" testcase by about 1% or so;
I'd need to retest to make sure... too many patches hanging out in my build at
this point to tell off the top of my head.
If you need more specifics, let me know and I'll reprofile.
Comment 7•21 years ago
|
||
Comment on attachment 148547 [details] [diff] [review]
Actual patch
static inline PRBool
needsSecurityCheck(JSContext *cx, nsIXPConnectWrappedNative *wrapper)
{
- // Cache a pointer to a wrapper and a context and set these pointers
- // to point to the wrapper and context that doesn't need a security
- // check, thus we avoid doing all this work to find out if we need
- // to do the security check, in most cases this check would end up
- // being two pointer compares.
+ // We cache a pointer to a wrapper and a context that we've last vetted
+ // and cache what the verdict was.
// First, compare the context and wrapper with the cached ones
- if (cx != cached_cx || wrapper != cached_wrapper) {
- cached_cx = nsnull;
- cached_wrapper = nsnull;
+ if (cx == cached_win_cx && wrapper == cached_win_wrapper) {
+ return !cached_win_skip_check;
Since this cached_win_skip_check is used in a method that checks whether or not
we *need* to do a security check, maybe you should name that new static
variable cached_win_needs_check? If you'd do that, you can remove some reverse
logic as well.
r=jst
Attachment #148547 -
Flags: review?(jst) → review+
![]() |
Assignee | |
Comment 8•21 years ago
|
||
I did it to avoid static PR_TRUE, but you're right -- the reversed logic is not
worth it. I'll rename accordingly.
Assignee: general → bzbarsky
Priority: -- → P1
Target Milestone: --- → mozilla1.8alpha
![]() |
Assignee | |
Updated•21 years ago
|
Summary: Consider ways to speed up documentNeedsSecurityCheck → [FIX]Consider ways to speed up documentNeedsSecurityCheck
![]() |
Assignee | |
Updated•21 years ago
|
Target Milestone: mozilla1.8alpha1 → mozilla1.8alpha2
![]() |
Assignee | |
Comment 9•21 years ago
|
||
Attachment #148547 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 10•21 years ago
|
||
Comment on attachment 149567 [details] [diff] [review]
Updated patch
Brendan, would you sr?
One other thing. I've been running into these functions in some DHTML profiles
for things that use chained setTimeout() calls (setting a timeout from within a
timeout). I assume that's because the JSContext will be different for each
timeout firing? If so, we may want to still reduce the overhead here....
Attachment #149567 -
Flags: superreview?(brendan)
![]() |
Assignee | |
Updated•21 years ago
|
Attachment #148547 -
Flags: superreview?(brendan)
![]() |
||
Comment 11•21 years ago
|
||
> One other thing. I've been running into these functions in some DHTML profiles
> for things that use chained setTimeout() calls (setting a timeout from within a
> timeout). I assume that's because the JSContext will be different for each
> timeout firing?
No, that shouldn't be happening if the setTimeout is on the current window. Can
you dig into why the cache is being missed? Something's not quite right here.
/be
![]() |
Assignee | |
Comment 12•21 years ago
|
||
Ok. I'll check on it (need to recall which profile this was...).
Probably when I come back from my trip.
![]() |
Assignee | |
Comment 13•21 years ago
|
||
OK, I can't reproduce the cache misses on any of the profiles I tried today...
if I see them again, I'll look into it. Brendan, are you happy enough with the
patch as-is to sr?
![]() |
||
Comment 14•21 years ago
|
||
Comment on attachment 149567 [details] [diff] [review]
Updated patch
Sure.
/be
Attachment #149567 -
Flags: superreview?(brendan) → superreview+
![]() |
Assignee | |
Updated•21 years ago
|
Summary: [FIX]Consider ways to speed up documentNeedsSecurityCheck → [FIXr]Consider ways to speed up documentNeedsSecurityCheck
![]() |
Assignee | |
Updated•21 years ago
|
Target Milestone: mozilla1.8alpha2 → mozilla1.8beta
![]() |
Assignee | |
Comment 15•21 years ago
|
||
Checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.8beta → mozilla1.8alpha3
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•