Last Comment Bug 655089 - nsXPConnect::ToParticipant calls js_GetGCThingTraceKind twice
: nsXPConnect::ToParticipant calls js_GetGCThingTraceKind twice
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: XPConnect (show other bugs)
: Other Branch
: All All
: -- normal (vote)
: mozilla7
Assigned To: Andrew McCreight [:mccr8]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-05 11:19 PDT by Andrew McCreight [:mccr8]
Modified: 2011-06-13 14:34 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
turn CC_KIND into a call (3.45 KB, patch)
2011-05-25 16:12 PDT, Andrew McCreight [:mccr8]
no flags Details | Diff | Review
change CC_KIND macro to a function to avoid double call (3.90 KB, patch)
2011-06-10 11:11 PDT, Andrew McCreight [:mccr8]
mrbkap: review+
ehsan: checkin+
Details | Diff | Review

Description Andrew McCreight [:mccr8] 2011-05-05 11:19:30 PDT
It looks to me that in nsXPConnect.cpp, nsXPConnect::ToParticipant calls js_GetGCThingTraceKind twice due to macro'age:

420 #define ADD_TO_CC(_kind)    ((_kind) == JSTRACE_OBJECT || (_kind) == JSTRACE_XML)
[...]
533 nsCycleCollectionParticipant *
534 nsXPConnect::ToParticipant(void *p)
535 {
536     if (!ADD_TO_CC(js_GetGCThingTraceKind(p)))
537         return NULL;
538     return this;
539 }

Not a huge deal as this function has no side effects, but it work that doesn't need to be done.

This can be fixed by creating a new variable and assigning the result of the function to it, or by turning ADD_TO_CC into an inline function called addToCCKind or something.  The latter would be a bit more civilized, if we can rely on the inlining.  I used the former fix in my patch for Bug 650519.
Comment 1 Andrew McCreight [:mccr8] 2011-05-25 16:12:17 PDT
Created attachment 535223 [details] [diff] [review]
turn CC_KIND into a call
Comment 2 Andrew McCreight [:mccr8] 2011-05-26 08:57:24 PDT
I ran this on try, and it looks okay, except mobile looks kind of bad.  One of the Maemo builds is burning, which I will retry, and the Android tests are still running, 8 or so hours later.
Comment 3 Andrew McCreight [:mccr8] 2011-06-10 11:11:19 PDT
Created attachment 538561 [details] [diff] [review]
change CC_KIND macro to a function to avoid double call

fixed bitrot
Comment 4 Andrew McCreight [:mccr8] 2011-06-10 16:45:43 PDT
Comment on attachment 538561 [details] [diff] [review]
change CC_KIND macro to a function to avoid double call

Passed a try run.
Comment 5 Blake Kaplan (:mrbkap) (please use needinfo!) 2011-06-13 07:57:21 PDT
Comment on attachment 538561 [details] [diff] [review]
change CC_KIND macro to a function to avoid double call

Good catch.
Comment 6 :Ehsan Akhgari (busy, don't ask for review please) 2011-06-13 12:08:06 PDT
Comment on attachment 538561 [details] [diff] [review]
change CC_KIND macro to a function to avoid double call

Landed on inbound.
Comment 7 :Ehsan Akhgari (busy, don't ask for review please) 2011-06-13 14:34:41 PDT
http://hg.mozilla.org/mozilla-central/rev/0321e3569921

Note You need to log in before you can comment on or make changes to this bug.