Bug 1480244: Part 3c - Fix GC test with bad assumptions. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Fri, 03 Aug 2018 14:11:38 -0700
changeset 431524 7d6c6e052339d90767d18403826f0a316521074f
parent 431523 7aa3ada140f74e48947a4c69a1fd53b84b39a51e
child 431525 c7a263321e999b1806b8facd31177ca026a7a33f
push id106466
push usermaglione.k@gmail.com
push dateTue, 14 Aug 2018 18:54:25 +0000
treeherdermozilla-inbound@b712d41d4745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480244: Part 3c - Fix GC test with bad assumptions. r=aswan This failure starts showing up after these changes by chance. Some aspect of the environment or other causes a map() call to be baseline-optimized, which causes its IC stubs to hold its function environemnt alive, which causes it to hold the context we're checking alive. Forcing a shrinking GC makes the IC stub go away sooner, and therefore allows the test to pass. MozReview-Commit-ID: LXp5mgMZeB1
--- a/toolkit/components/extensions/test/xpcshell/test_ext_contexts_gc.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_contexts_gc.js
@@ -28,17 +28,21 @@ async function reloadTopContext(contentP
 async function assertContextReleased(contentPage, description) {
   await contentPage.spawn(description, async assertionDescription => {
     // Force GC, see https://searchfox.org/mozilla-central/rev/b0275bc977ad7fda615ef34b822bba938f2b16fd/testing/talos/talos/tests/devtools/addon/content/damp.js#84-98
     // and https://searchfox.org/mozilla-central/rev/33c21c060b7f3a52477a73d06ebcb2bf313c4431/xpcom/base/nsMemoryReporterManager.cpp#2574-2585,2591-2594
     let gcCount = 0;
     while (gcCount < 30 && this.contextWeakRef.get() !== null) {
-      Cu.forceGC();
+      // The JS engine will sometimes hold IC stubs for function
+      // environments alive across multiple CCs, which can keep
+      // closed-over JS objects alive. A shrinking GC will throw those
+      // stubs away, and therefore side-step the problem.
+      Cu.forceShrinkingGC();
       await new Promise(resolve => this.content.setTimeout(resolve, 0));
     // The above loop needs to be repeated at most 3 times according to MinimizeMemoryUsage:
     // https://searchfox.org/mozilla-central/rev/6f86cc3479f80ace97f62634e2c82a483d1ede40/xpcom/base/nsMemoryReporterManager.cpp#2644-2647
     Assert.lessOrEqual(gcCount, 3, `Context should have been GCd within a few GC attempts.`);