зеркало из https://github.com/mozilla/gecko-dev.git
Bug 771281 - Remove js shell workers. r=jorendorff
This commit is contained in:
Родитель
ad470f865a
Коммит
a2586840c2
|
@ -14,7 +14,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
PROGRAM = js$(BIN_SUFFIX)
|
||||
CPPSRCS = \
|
||||
js.cpp \
|
||||
jsworkers.cpp \
|
||||
jsoptparse.cpp \
|
||||
jsheaptools.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "prmjtime.h"
|
||||
|
||||
#include "jsoptparse.h"
|
||||
#include "jsworkers.h"
|
||||
#include "jsheaptools.h"
|
||||
|
||||
#include "jsinferinlines.h"
|
||||
|
@ -157,10 +156,6 @@ bool gQuitting = false;
|
|||
bool gGotError = false;
|
||||
FILE *gErrFile = NULL;
|
||||
FILE *gOutFile = NULL;
|
||||
#ifdef JS_THREADSAFE
|
||||
JSObject *gWorkers = NULL;
|
||||
js::workers::ThreadPool *gWorkerThreadPool = NULL;
|
||||
#endif
|
||||
|
||||
static bool reportWarnings = true;
|
||||
static bool compileOnly = false;
|
||||
|
@ -1207,10 +1202,6 @@ Quit(JSContext *cx, unsigned argc, jsval *vp)
|
|||
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "/ i", &gExitCode);
|
||||
|
||||
gQuitting = true;
|
||||
#ifdef JS_THREADSAFE
|
||||
if (gWorkerThreadPool)
|
||||
js::workers::terminateAll(gWorkerThreadPool);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3035,10 +3026,6 @@ CancelExecution(JSRuntime *rt)
|
|||
gCanceled = true;
|
||||
if (gExitCode == 0)
|
||||
gExitCode = EXITCODE_TIMEOUT;
|
||||
#ifdef JS_THREADSAFE
|
||||
if (gWorkerThreadPool)
|
||||
js::workers::terminateAll(gWorkerThreadPool);
|
||||
#endif
|
||||
JS_TriggerOperationCallback(rt);
|
||||
|
||||
static const char msg[] = "Script runs for too long, terminating.\n";
|
||||
|
@ -4700,29 +4687,8 @@ Shell(JSContext *cx, OptionParser *op, char **envp)
|
|||
return 1;
|
||||
JS_SetPrivate(envobj, envp);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
class ShellWorkerHooks : public js::workers::WorkerHooks {
|
||||
public:
|
||||
JSObject *newGlobalObject(JSContext *cx) {
|
||||
return NewGlobalObject(cx);
|
||||
}
|
||||
};
|
||||
ShellWorkerHooks hooks;
|
||||
if (!JS_AddNamedObjectRoot(cx, &gWorkers, "Workers") ||
|
||||
(gWorkerThreadPool = js::workers::init(cx, &hooks, glob, &gWorkers)) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int result = ProcessArgs(cx, glob, op);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
js::workers::finish(cx, gWorkerThreadPool);
|
||||
JS_RemoveObjectRoot(cx, &gWorkers);
|
||||
if (result == 0)
|
||||
result = gExitCode;
|
||||
#endif
|
||||
|
||||
if (enableDisassemblyDumps)
|
||||
JS_DumpCompartmentPCCounts(cx);
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sw=4 et tw=99:
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef jsworkers_h___
|
||||
#define jsworkers_h___
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
/*
|
||||
* Workers for the JS shell.
|
||||
*
|
||||
* Note: The real implementation of DOM Workers is in dom/workers.
|
||||
*/
|
||||
namespace js {
|
||||
namespace workers {
|
||||
class ThreadPool;
|
||||
|
||||
class WorkerHooks {
|
||||
public:
|
||||
virtual JSObject *newGlobalObject(JSContext *cx) = 0;
|
||||
virtual ~WorkerHooks() {}
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize workers. This defines the Worker constructor on global.
|
||||
* Requires request. rootp must point to a GC root.
|
||||
*
|
||||
* On success, *rootp receives a pointer to an object, and init returns
|
||||
* a non-null value. The caller must keep the object rooted and must
|
||||
* pass it to js::workers::finish later.
|
||||
*/
|
||||
ThreadPool *init(JSContext *cx, WorkerHooks *hooks, JSObject *global, JSObject **rootp);
|
||||
|
||||
/* Asynchronously signal for all workers to terminate.
|
||||
*
|
||||
* Call this before calling finish() to shut down without waiting for
|
||||
* all messages to be proceesed.
|
||||
*/
|
||||
void terminateAll(ThreadPool *tp);
|
||||
|
||||
/*
|
||||
* Finish running any workers, shut down the thread pool, and free all
|
||||
* resources associated with workers. The application must call this
|
||||
* before shutting down the runtime, and not during GC.
|
||||
*
|
||||
* Requires request.
|
||||
*/
|
||||
void finish(JSContext *cx, ThreadPool *tp);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* JS_THREADSAFE */
|
||||
|
||||
#endif /* jsworkers_h___ */
|
|
@ -401,17 +401,6 @@ function outputscripttag(src, properties, e4x)
|
|||
document.write(s);
|
||||
}
|
||||
|
||||
var JSTest = {
|
||||
waitForExplicitFinish: function () {
|
||||
gDelayTestDriverEnd = true;
|
||||
},
|
||||
|
||||
testFinished: function () {
|
||||
gDelayTestDriverEnd = false;
|
||||
jsTestDriverEnd();
|
||||
}
|
||||
};
|
||||
|
||||
function jsTestDriverEnd()
|
||||
{
|
||||
// gDelayTestDriverEnd is used to
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
function onmessage(event) {
|
||||
throw new Error("fail");
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
function onmessage(event) {
|
||||
var n = +event.data;
|
||||
if (n == 0)
|
||||
throw new Error("boom");
|
||||
var w = new Worker(workerDir + "worker-error-propagation-child.js");
|
||||
w.onmessage = function (event) { postMessage(event.data); };
|
||||
// No w.onerror here. We are testing error propagation when it is absent.
|
||||
w.postMessage(n - 1 + "");
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
var w = Worker(workerDir + "worker-error-propagation-child.js");
|
||||
var errors = 0;
|
||||
w.onmessage = function () { throw new Error("no reply expected"); };
|
||||
w.onerror = function (event) {
|
||||
reportCompare("string", typeof event.message, "typeof event.message");
|
||||
JSTest.testFinished();
|
||||
};
|
||||
w.postMessage("5");
|
||||
} else {
|
||||
reportCompare(0, 0, " PASSED! Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell) -- these tests sometimes hang in browser, bug 559954, bug 562333
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
|
||||
// The script throws new Error("fail") on first message.
|
||||
var w = Worker(workerDir + "worker-error-child.js");
|
||||
var a = [];
|
||||
w.onerror = function (event) {
|
||||
reportCompare("fail", event.message, "worker-error");
|
||||
JSTest.testFinished();
|
||||
};
|
||||
w.postMessage("hello");
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
function onmessage(event) {
|
||||
var a = event.data.split(/\t/);
|
||||
var n = Number(a[0]);
|
||||
var workerDir = a[1];
|
||||
|
||||
if (n <= 1) {
|
||||
postMessage("" + n);
|
||||
} else {
|
||||
var w1 = new Worker(workerDir + "worker-fib-child.js"),
|
||||
w2 = new Worker(workerDir + "worker-fib-child.js");
|
||||
var a = [];
|
||||
w1.onmessage = w2.onmessage = function(event) {
|
||||
a.push(+event.data);
|
||||
if (a.length == 2)
|
||||
postMessage(a[0] + a[1] + "");
|
||||
};
|
||||
w1.postMessage(n - 1 + "\t" + workerDir);
|
||||
w2.postMessage(n - 2 + "\t" + workerDir);
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
var w = Worker(workerDir + "worker-fib-child.js");
|
||||
w.onmessage = function (event) {
|
||||
reportCompare("21", event.data, "worker-fib");
|
||||
JSTest.testFinished();
|
||||
};
|
||||
w.postMessage("8\t" + workerDir); // 0 1 1 2 3 5 8 13 21
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
postMessage('do your worst');
|
||||
for (;;) ;
|
|
@ -1,20 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
// Messages sent during initialization are a corner case, but in any case
|
||||
// they should be delivered (no waiting until initialization is complete).
|
||||
var w = new Worker(workerDir + "worker-init-child.js"); // posts a message, then loops forever
|
||||
w.onmessage = function (event) {
|
||||
reportCompare(0, 0, "worker-init");
|
||||
JSTest.testFinished();
|
||||
};
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
onmessage = function (event) { postMessage(event.data); };
|
|
@ -1,21 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
var w = new Worker(workerDir + "worker-simple-child.js");
|
||||
var a = [];
|
||||
w.onmessage = function (event) {
|
||||
a.push(event.data);
|
||||
reportCompare(0, 0, "worker-simple");
|
||||
JSTest.testFinished();
|
||||
};
|
||||
w.postMessage("hello");
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
onmessage = function (event) {
|
||||
var workerDir = event.message;
|
||||
var child = new Worker(workerDir + 'worker-terminate-iloop.js'); // loops forever
|
||||
child.terminate();
|
||||
postMessage("killed");
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
;
|
|
@ -1,38 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff <jorendorff@mozilla.com>
|
||||
*/
|
||||
|
||||
if (typeof Worker != 'undefined') {
|
||||
JSTest.waitForExplicitFinish();
|
||||
|
||||
// This tests that a parent worker can terminate a child. We run the test
|
||||
// several times serially. If terminate() doesn't work, the runaway Workers
|
||||
// will soon outnumber the number of threads in the thread pool, and we
|
||||
// will deadlock.
|
||||
var i = 0;
|
||||
|
||||
function next() {
|
||||
if (++i == 10) {
|
||||
reportCompare(0, 0, "worker-terminate");
|
||||
JSTest.testFinished();
|
||||
return;
|
||||
}
|
||||
|
||||
var w = new Worker(workerDir + "worker-terminate-child.js");
|
||||
w.onmessage = function (event) {
|
||||
reportCompare("killed", event.data, "killed runaway worker #" + i);
|
||||
next();
|
||||
};
|
||||
w.onerror = function (event) {
|
||||
reportCompare(0, 1, "Got error: " + event.message);
|
||||
};
|
||||
w.postMessage(workerDir);
|
||||
}
|
||||
next();
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers required.");
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
// |reftest| skip
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
;
|
|
@ -1,19 +0,0 @@
|
|||
// |reftest| skip-if(!xulRuntime.shell||Android)
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
* Contributor: Jason Orendorff
|
||||
*/
|
||||
|
||||
if (typeof timeout == 'function' && typeof Worker != 'undefined') {
|
||||
// We don't actually ever call JSTest.testFinished(); instead we
|
||||
// time out and exit the shell with exit code 6.
|
||||
JSTest.waitForExplicitFinish();
|
||||
expectExitCode(6);
|
||||
timeout(1.0);
|
||||
for (var i = 0; i < 5; i++)
|
||||
new Worker(workerDir + "worker-timeout-child.js"); // just loops forever
|
||||
} else {
|
||||
reportCompare(0, 0, "Test skipped. Shell workers and timeout required.");
|
||||
}
|
|
@ -797,18 +797,6 @@ function getFailedCases() {
|
|||
}
|
||||
}
|
||||
|
||||
var JSTest = {
|
||||
waitForExplicitFinish: function () {
|
||||
gDelayTestDriverEnd = true;
|
||||
},
|
||||
|
||||
testFinished: function () {
|
||||
gDelayTestDriverEnd = false;
|
||||
jsTestDriverEnd();
|
||||
quit();
|
||||
}
|
||||
};
|
||||
|
||||
function jsTestDriverEnd()
|
||||
{
|
||||
// gDelayTestDriverEnd is used to
|
||||
|
|
Загрузка…
Ссылка в новой задаче