Closed Bug 744103 Opened 12 years ago Closed 12 years ago

eliminate the cycle collector's vestigial language agnosticism

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: mccr8, Assigned: mccr8)

References

(Blocks 2 open bugs)

Details

Attachments

(5 files, 7 obsolete files)

6.05 KB, patch
smaug
: review+
Details | Diff | Splinter Review
32.41 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.98 KB, patch
smaug
: review+
Details | Diff | Splinter Review
15.73 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.90 KB, patch
smaug
: review+
Details | Diff | Splinter Review
nsXPConnect::ToParticipant does a redundant check, then returns XPConnect.

We also end up checking in NoteScriptChild that JS is a valid langID, that has a runtime.

With a little bit of cleanup, we can avoid all of this, while still leaving in the vestigial support for other languages.

We could also avoid the language validity checks in NoteRoot, but that would require adding new variants of NoteRoot which is kind of gross, and they aren't virtual so they probably are not that bad.
Can we remove the vestigial support for other languages?
I thought pyxpcom is still alive.
Does it have a working (or even non-working cycle collector)?
Don't know, but I don't see why it couldn't have.
Attached patch WIP (obsolete) — Splinter Review
Assignee: nobody → continuation
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #1)
> Can we remove the vestigial support for other languages?

Possibly, but that will require modifying all Trace functions.  Mostly hidden behind macro gunk, of course.  I thought I saw some place where it might be a problem, with some kind of script context, but I don't see it now.
Oh that explains it!  Bug 738380 removed the problem, but I haven't updated my tree since that landed.  That makes me feel better.  Maybe it is doable after all.
Depends on: 738380
Ugh, the one place where we can't turn NoteScriptChild to just always be JS is nsXULPrototypeScript, which in theory could be other things.  I think it is always only JS, but it will require a bit of patching to get to the point where that could be done.
Depends on: 744332
I think I'll just add a local check in nsXULPrototypeScript, and just do nothing if it isn't JS.  Later if 744322 gets fixed, the check can be removed.

I looked at PyXPCOM.  They do use some of the script context things (but not all of them?) but I don't see any kind of cycle collector integration, so it should be okay to remove this support.
This is on top of the other patch, though it makes more sense to fold them together.
Attachment #614062 - Attachment description: remove fake language agnosticism of NoteRoot → part 2: remove fake language agnosticism of NoteRoot
Summary: don't use ToParticipant for JS objects → eliminate the cycle collector's vestigial language agnosticism
Depends on: 744088
Attachment #613743 - Attachment is obsolete: true
Attachment #614054 - Attachment is obsolete: true
Attachment #614062 - Attachment is obsolete: true
In this patch, I eliminate nsCycleCollectionLanguageRuntime and the array of runtimes the cycle collector carries around.  Instead, there's a pointer to a nsCycleCollectionJSRuntime, which gets all of the methods of nsCycleCollectionLanguageRuntime that we need for JS.
This removes the mLangID field from DEBUG_CC PtrInfo, and all of the passing around of langIDs to support that.  The only place it is used is in "pinfo->mLangID == nsIProgrammingLanguage::CPLUSPLUS", but we know that anything in the purple buffer must be C++, so the check is redundant.

With all of these patches, JAVASCRIPT, CPLUSPLUS and langID are nowhere to be found in the nsCycleCollector.cpp.
I downloaded PyXPCOM, and the sources don't contain the string "nsCycleCollectionLanguageRuntime" anywhere, which I think means they can't have implemented cycle collection, so they can't be reporting any Python objects to the CC, so this shouldn't affect them.
Depends on: 678615
We don't really need bug 744332 for this, as I have just patched around that one problem.  There aren't many script prototype objects in the CC graph, so it shouldn't be a big deal.
No longer depends on: 744332
try run on Linux: https://tbpl.mozilla.org/?tree=Try&rev=915c3dbfe6ce

Interestingly it triggers an assertion during make check in the build process:

Should Release and destroy one |TestRefObject|:
  Release to 0 on TestRefObject 0x1ff24ab0.
  Destroying TestRefObject 0x1ff24ab0.
Assertion failure: mJSParticipant, at /builds/slave/try-lnx64-dbg/build/xpcom/base/nsCycleCollector.cpp:1719
/bin/sh: line 1:  8428 Aborted                 XPCOM_DEBUG_BREAK=stack-and-abort /builds/slave/try-lnx64-dbg/build/obj-firefox/dist/bin/run-mozilla.sh ../../dist/bin/$f
make[2]: *** [check] Error 134
make -C external check
make[3]: Entering directory `/builds/slave/try-lnx64-dbg/build/obj-firefox/xpcom/tests/external'
make[3]: Nothing to be done for `check'.

During the GCGraphBuilder constructor, apparently XPConnect isn't set up.  Maybe this test doesn't use it somehow?  I'll have to be more generous with how I detect that.  I guess we do need to be able to run the CC without JS being active.
Depends on: 744332
Attachment #614113 - Attachment is obsolete: true
Attachment #614140 - Attachment is obsolete: true
Attachment #614164 - Attachment is obsolete: true
part 1: Store a copy of the JS CC runtime pointer separately from mRuntimes.  mRuntimes is going to be removed in part 4.  Doing this first simplifies part 2.

part 2: This is the largest patch, but it is mostly mechanical removal of the langID argument from various callbacks.  In addition, nsXPConnect.cpp, xpcprivate.h, nsCycleCollector.h mostly just define GetParticipant.  nsCycleCollector.cpp has a number of changes, of course.
These patches eliminate a number of checks, so it should have at least some impact on CC speed.  On the other hand, the checks always succeed, so maybe it won't matter much.
Blocks: 698919
Blocks: CleanupCC
Attachment #618353 - Flags: review?(bugs)
Attachment #618354 - Flags: review?(bugs)
Attachment #618355 - Flags: review?(bugs)
Attachment #618357 - Flags: review?(bugs)
Attachment #618358 - Flags: review?(bugs)
Attachment #618353 - Flags: review?(bugs) → review+
Comment on attachment 618354 [details] [diff] [review]
part 2: change NoteScriptChild to NoteJSChild

Please ask still PyXPCOM devs whether they are or would like to use this stuff.
Attachment #618354 - Flags: review?(bugs) → review+
Attachment #618355 - Flags: review?(bugs) → review+
Attachment #618357 - Flags: review?(bugs) → review+
Attachment #618358 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] from comment #26)
> Please ask still PyXPCOM devs whether they are or would like to use this
> stuff.

Yeah, it wouldn't be a big deal to just leave these hooks around if there is actually somebody who might want them, and still use the "fast path" things for JS.
I wrote to Todd Whiteman and he said they probably aren't going to work on Python-CC integration in the next 12 months, and the chances weren't high they would ever do it.  I'll go ahead and land this when the tree opens again (though I do wonder if this could reduce memory usage by PGO ;).  It wouldn't be that hard to add some special support for an additional scripting language without reverting most of these changes to the handling of JS.
No longer blocks: 698919
Blocks: 698919
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: