Commit ac8b946a authored by atwilson@chromium.org's avatar atwilson@chromium.org

REGRESSION: fast/workers/dedicated-worker-lifecycle.html failing intermittently on leopard bot

https://bugs.webkit.org/show_bug.cgi?id=29344

Reviewed by Eric Seidel.

* fast/workers/resources/dedicated-worker-lifecycle.js:
(runTests):
Allocate objects on the stack to try to force a GC to eliminate flakiness.
* fast/workers/resources/worker-util.js:
(gc):
Added an optional "forceAlloc" parameter which causes a more extensive stack-clobbering algorithm to be run.
(waitUntilThreadCountMatches):
Pass the forceAlloc flag to gc() to try to force unreferenced workers to get GC'd.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 52176259
2009-10-01 Drew Wilson <atwilson@chromium.org>
Reviewed by Eric Seidel.
REGRESSION: fast/workers/dedicated-worker-lifecycle.html failing intermittently on leopard bot
https://bugs.webkit.org/show_bug.cgi?id=29344
* fast/workers/resources/dedicated-worker-lifecycle.js:
(runTests):
Allocate objects on the stack to try to force a GC to eliminate flakiness.
* fast/workers/resources/worker-util.js:
(gc):
Added an optional "forceAlloc" parameter which causes a more extensive stack-clobbering algorithm to be run.
(waitUntilThreadCountMatches):
Pass the forceAlloc flag to gc() to try to force unreferenced workers to get GC'd.
2009-10-01 Kenneth Rohde Christiansen <kenneth@webkit.org>
Rubberstamped by Simon Hausmann.
......
......@@ -26,6 +26,8 @@ function runTests()
// Orphan our worker (no more references to it) and wait for it to exit.
worker.onmessage = 0;
worker = 0;
// Allocating a Date object seems to scramble the stack and force the worker object to get GC'd.
new Date();
waitUntilWorkerThreadsExit(orphanedWorkerExited);
}
}
......
......@@ -5,13 +5,21 @@ function log(message)
document.getElementById("result").innerHTML += message + "<br>";
}
function gc()
function gc(forceAlloc)
{
if (window.GCController)
return GCController.collect();
if (typeof GCController !== "undefined")
GCController.collect();
for (var i = 0; i < 10000; i++) { // force garbage collection (FF requires about 9K allocations before a collect)
var s = new String("abc");
if (typeof GCController == "undefined" || forceAlloc) {
function gcRec(n) {
if (n < 1)
return {};
var temp = {i: "ab" + i + (i / 100000)};
temp += "foo";
gcRec(n-1);
}
for (var i = 0; i < 1000; i++)
gcRec(10)
}
}
......@@ -24,7 +32,7 @@ function waitUntilThreadCountMatches(callback, count)
{
// When running in a browser, just wait for one second then call the callback.
if (!window.layoutTestController) {
setTimeout(function() { gc(); callback(); }, 1000);
setTimeout(function() { gc(true); callback(); }, 1000);
return;
}
......@@ -33,7 +41,8 @@ function waitUntilThreadCountMatches(callback, count)
callback();
} else {
// Poll until worker threads have been GC'd/exited.
gc();
// Force a GC with a bunch of allocations to try to scramble the stack and force worker objects to be collected.
gc(true);
setTimeout(function() { waitUntilThreadCountMatches(callback, count); }, 10);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment