Date: Sat, 26 Jun 2021 11:24:43 GMT From: Rene Ladan <rene@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: e7caeb58488c - main - */*: Remove expired ports: Message-ID: <202106261124.15QBOhGm032634@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rene: URL: https://cgit.FreeBSD.org/ports/commit/?id=e7caeb58488c6a6924571a5297ac8a745c2e1c52 commit e7caeb58488c6a6924571a5297ac8a745c2e1c52 Author: Rene Ladan <rene@FreeBSD.org> AuthorDate: 2021-06-26 11:24:09 +0000 Commit: Rene Ladan <rene@FreeBSD.org> CommitDate: 2021-06-26 11:24:09 +0000 */*: Remove expired ports: 2021-06-23 multimedia/gxine: Uses EOL Python 2.7 via lang/spidermonkey185 2020-12-31 lang/spidermonkey185: Uses Python 2.7 which is EOLed upstream --- MOVED | 2 + lang/Makefile | 1 - lang/spidermonkey185/Makefile | 129 -- lang/spidermonkey185/distinfo | 2 - .../patch-assembler_jit_ExecutableAllocator.h | 14 - .../files/patch-assembler_wtf_Platform.h | 18 - lang/spidermonkey185/files/patch-bug771281 | 1839 -------------------- lang/spidermonkey185/files/patch-c++11 | 291 ---- lang/spidermonkey185/files/patch-configure.in | 36 - lang/spidermonkey185/files/patch-jsscript.h | 48 - lang/spidermonkey185/files/patch-jsstr.cpp | 36 - .../files/patch-methodjit_MethodJIT.cpp | 38 - .../files/patch-nanojit_CodeAlloc.cpp | 10 - .../files/patch-nanojit_njcpudetect.h | 11 - lang/spidermonkey185/pkg-descr | 3 - lang/spidermonkey185/pkg-plist | 106 -- multimedia/Makefile | 1 - multimedia/gxine/Makefile | 60 - multimedia/gxine/distinfo | 3 - multimedia/gxine/files/patch-src__Makefile.in | 11 - multimedia/gxine/files/patch-src__lirc.c | 12 - multimedia/gxine/files/patch-src_console__output.c | 162 -- .../gxine/files/patch-src_desktop__integration.c | 20 - multimedia/gxine/pkg-descr | 4 - multimedia/gxine/pkg-plist | 57 - 25 files changed, 2 insertions(+), 2912 deletions(-) diff --git a/MOVED b/MOVED index 2cbd7f248d13..dce64f25beb6 100644 --- a/MOVED +++ b/MOVED @@ -16424,3 +16424,5 @@ lang/pypy||2021-06-26|Has expired: Uses Python 2.7 which is EOLed upstream databases/pypy-gdbm||2021-06-26|Has expired: Uses EOL Python 2.7 via lang/pypy databases/pypy-sqlite3||2021-06-26|Has expired: Uses EOL Python 2.7 via lang/pypy x11-toolkits/pypy-tkinter||2021-06-26|Has expired: Uses EOL Python 2.7 via lang/pypy +multimedia/gxine||2021-06-26|Has expired: Uses EOL Python 2.7 via lang/spidermonkey185 +lang/spidermonkey185||2021-06-26|Has expired: Uses Python 2.7 which is EOLed upstream diff --git a/lang/Makefile b/lang/Makefile index f588858b9b1a..60a3695160bc 100644 --- a/lang/Makefile +++ b/lang/Makefile @@ -334,7 +334,6 @@ SUBDIR += snobol4 SUBDIR += solidity SUBDIR += spidermonkey17 - SUBDIR += spidermonkey185 SUBDIR += spidermonkey60 SUBDIR += spidermonkey78 SUBDIR += spl diff --git a/lang/spidermonkey185/Makefile b/lang/spidermonkey185/Makefile deleted file mode 100644 index 1cc54bc5296d..000000000000 --- a/lang/spidermonkey185/Makefile +++ /dev/null @@ -1,129 +0,0 @@ -# Created by: Kubilay Kocak <koobs@FreeBSD.org> - -PORTNAME= spidermonkey185 -PORTVERSION= 1.8.5 -PORTREVISION= 5 -CATEGORIES= lang -MASTER_SITES= MOZILLA/js -DISTNAME= js185-1.0.0 - -MAINTAINER= koobs@FreeBSD.org -COMMENT= Standalone JavaScript (1.8.5) interpreter from Mozilla - -BUILD_DEPENDS= zip:archivers/zip \ - autoconf-2.13:devel/autoconf213 -LIB_DEPENDS= libnspr4.so:devel/nspr - -USES= gmake pathfix perl5 pkgconfig python:2.7,build -GNU_CONFIGURE= yes -USE_LDCONFIG= yes -USE_PERL5= build - -WRKSRC= ${WRKDIR}/js-${PORTVERSION}/js/src - -BROKEN_aarch64= Does not compile: error: cacheFlush support is missing on this platform -BROKEN_mips64= Does not compile: error: const union jsval_layout has no member named word -BROKEN_riscv64= Does not compile: jsiter.cpp:270:16: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t' -BROKEN_sparc64= Does not build: fails to link -BROKEN_FreeBSD_13= does not compile: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t' -BROKEN_FreeBSD_14= does not compile: cannot initialize return object of type 'bool' with an rvalue of type 'nullptr_t' - -NOT_FOR_ARCHS= powerpc powerpc64 -NOT_FOR_ARCHS_REASON= PowerPC is not supported - -CONFIGURE_ARGS= --with-pthreads \ - --with-system-nspr - -# This comes from bsd.gecko.mk, fixes linking issues on 9.0 and higher. -post-configure: - ${ECHO_CMD} "fenv.h" >> ${WRKSRC}/config/system-headers - ${ECHO_CMD} "pthread_np.h" >> ${WRKSRC}/config/system-headers - -OPTIONS_DEFINE= DEBUG GCZEAL JEMALLOC METHODJIT OPTIMIZE READLINE \ - THREADSAFE TRACEJIT UTF8 \ - -OPTIONS_DEFAULT= METHODJIT OPTIMIZE READLINE THREADSAFE TRACEJIT - -GCZEAL_DESC= Enable Zealous garbage collecting -JEMALLOC_DESC= Use jemalloc as memory allocator -METHODJIT_DESC= Enable method JIT support -OPTIMIZE_DESC= Enable compiler optimizations -READLINE_DESC= Link js shell to system readline library -THREADSAFE_DESC= Enable multiple thread support -TRACEJIT_DESC= Enable tracing JIT support -UTF8_DESC= Treat strings as UTF8 instead of ISO-8859-1 - -DEBUG_CONFIGURE_ENABLE= debug -DEBUG_CONFIGURE_ON= --enable-debug-sumbols -GCZEAL_CONFIGURE_ENABLE= gczeal -JEMALLOC_CONFIGURE_ENABLE= jemalloc -METHODJIT_CONFIGURE_ENABLE= methodjit -OPTIMIZE_CONFIGURE_ENABLE= optimize -READLINE_CONFIGURE_ENABLE= readline -READLINE_USES= readline -THREADSAFE_CONFIGURE_ENABLE= threadsafe -TRACEJIT_CONFIGURE_ENABLE= tracejit -UTF8_CFLAGS= -DJS_C_STRINGS_ARE_UTF8 - -.include <bsd.port.options.mk> - -.if ${ARCH} == amd64 -CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} -.endif - -.if ${ARCH} == "amd64" -PLIST_SUB+= AMD64="" -.else -PLIST_SUB+= AMD64="@comment " -.endif - -.if ${ARCH} == "i386" -PLIST_SUB+= I386="" -.else -PLIST_SUB+= I386="@comment " -.endif - -.if ${ARCH} == "arm" -PLIST_SUB+= ARM="" -.else -PLIST_SUB+= ARM="@comment " -.endif - -.if ${ARCH} == "mips" -PLIST_SUB+= MIPS="" -.else -PLIST_SUB+= MIPS="@comment " -.endif - -.if ${ARCH} == "powerpc" || ${ARCH} == "powerpc64" -PLIST_SUB+= PPC="" -.else -PLIST_SUB+= PPC="@comment " -.endif - -.if ${ARCH} == "sparc64" -PLIST_SUB+= SPARC="" -.else -PLIST_SUB+= SPARC="@comment " -.endif - -pre-configure: - (cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf-2.13) - -do-test: - @${ECHO_MSG} -n "===> Running jstests.py: " - @cd ${WRKSRC} && ${SETENV} TZ=PST8PDT ${PYTHON_CMD} tests/jstests.py \ - --no-progress --worker-count=${MAKE_JOBS_NUMBER} ./js -.if ${PORT_OPTIONS:MMETHODJIT} || ${PORT_OPTIONS:MTRACEJIT} - @${ECHO_MSG} -n "===> Running jit_test.py: " - @cd ${WRKSRC} && ${SETENV} TZ=PST8PDT ${PYTHON_CMD} jit-test/jit_test.py \ - --no-progress --jitflags=,m,j,mj,mjp,am,amj,amjp,amd ./js -.endif - -post-install: - ${LN} -sf libmozjs185.so.1.0.0 ${STAGEDIR}${PREFIX}/lib/libmozjs185.so - ${LN} -sf libmozjs185.so.1.0.0 ${STAGEDIR}${PREFIX}/lib/libmozjs185.so.1 - ${LN} -sf libmozjs185.so.1.0.0 ${STAGEDIR}${PREFIX}/lib/libmozjs185.so.1.0 - @${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libmozjs185.so.1.0.0 - -.include <bsd.port.mk> diff --git a/lang/spidermonkey185/distinfo b/lang/spidermonkey185/distinfo deleted file mode 100644 index ac820e9f43a3..000000000000 --- a/lang/spidermonkey185/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -SHA256 (js185-1.0.0.tar.gz) = 5d12f7e1f5b4a99436685d97b9b7b75f094d33580227aa998c406bbae6f2a687 -SIZE (js185-1.0.0.tar.gz) = 6164605 diff --git a/lang/spidermonkey185/files/patch-assembler_jit_ExecutableAllocator.h b/lang/spidermonkey185/files/patch-assembler_jit_ExecutableAllocator.h deleted file mode 100644 index 94770e435051..000000000000 --- a/lang/spidermonkey185/files/patch-assembler_jit_ExecutableAllocator.h +++ /dev/null @@ -1,14 +0,0 @@ ---- assembler/jit/ExecutableAllocator.h.orig 2016-09-07 UTC -+++ assembler/jit/ExecutableAllocator.h -@@ -391,6 +391,11 @@ public: - { - CacheRangeFlush(code, size, CACHE_SYNC_ALL); - } -+#elif WTF_CPU_ARM_TRADITIONAL && WTF_PLATFORM_FREEBSD -+ static void cacheFlush(void* code, size_t size) -+ { -+ __clear_cache(code, reinterpret_cast<char*>(code) + size); -+ } - #else - #error "The cacheFlush support is missing on this platform." - #endif diff --git a/lang/spidermonkey185/files/patch-assembler_wtf_Platform.h b/lang/spidermonkey185/files/patch-assembler_wtf_Platform.h deleted file mode 100644 index 9556c0f7e638..000000000000 --- a/lang/spidermonkey185/files/patch-assembler_wtf_Platform.h +++ /dev/null @@ -1,18 +0,0 @@ ---- ./assembler/wtf/Platform.h.orig 2016-09-07 UTC -+++ ./assembler/wtf/Platform.h -@@ -213,6 +213,7 @@ - #elif defined(__ARM_ARCH_6__) \ - || defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) \ -+ || defined(__ARM_ARCH_6KZ__) \ - || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) \ - || defined(__ARM_ARCH_6T2__) \ -@@ -243,6 +244,7 @@ - - #elif defined(__ARM_ARCH_6J__) \ - || defined(__ARM_ARCH_6K__) \ -+ || defined(__ARM_ARCH_6KZ__) \ - || defined(__ARM_ARCH_6Z__) \ - || defined(__ARM_ARCH_6ZK__) \ - || defined(__ARM_ARCH_6M__) diff --git a/lang/spidermonkey185/files/patch-bug771281 b/lang/spidermonkey185/files/patch-bug771281 deleted file mode 100644 index 1b59e5dfeafb..000000000000 --- a/lang/spidermonkey185/files/patch-bug771281 +++ /dev/null @@ -1,1839 +0,0 @@ -diff -ruN src/shell/Makefile.in src.new/shell/Makefile.in ---- shell/Makefile.in 2011-04-01 06:08:36.000000000 +1100 -+++ shell/Makefile.in 2013-03-23 22:01:26.876752286 +1100 -@@ -47,7 +47,6 @@ - PROGRAM = js$(BIN_SUFFIX) - CPPSRCS = \ - js.cpp \ -- jsworkers.cpp \ - $(NULL) - - DEFINES += -DEXPORT_JS_API -diff -ruN src/shell/js.cpp src.new/shell/js.cpp ---- shell/js.cpp 2011-04-01 06:08:36.000000000 +1100 -+++ shell/js.cpp 2013-03-23 22:02:46.436700725 +1100 -@@ -91,8 +91,6 @@ - #endif /* JSDEBUGGER_C_UI */ - #endif /* JSDEBUGGER */ - --#include "jsworkers.h" -- - #include "jsinterpinlines.h" - #include "jsobjinlines.h" - #include "jsscriptinlines.h" -@@ -194,10 +192,6 @@ - JSBool gQuitting = JS_FALSE; - FILE *gErrFile = NULL; - FILE *gOutFile = NULL; --#ifdef JS_THREADSAFE --JSObject *gWorkers = NULL; --js::workers::ThreadPool *gWorkerThreadPool = NULL; --#endif - - static JSBool reportWarnings = JS_TRUE; - static JSBool compileOnly = JS_FALSE; -@@ -1315,10 +1309,6 @@ - JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "/ i", &gExitCode); - - gQuitting = JS_TRUE; --#ifdef JS_THREADSAFE -- if (gWorkerThreadPool) -- js::workers::terminateAll(JS_GetRuntime(cx), gWorkerThreadPool); --#endif - return JS_FALSE; - } - -@@ -4150,10 +4140,6 @@ - gCanceled = true; - if (gExitCode == 0) - gExitCode = EXITCODE_TIMEOUT; --#ifdef JS_THREADSAFE -- if (gWorkerThreadPool) -- js::workers::terminateAll(rt, gWorkerThreadPool); --#endif - JS_TriggerAllOperationCallbacks(rt); - - static const char msg[] = "Script runs for too long, terminating.\n"; -@@ -5681,29 +5667,8 @@ - #endif /* JSDEBUGGER_C_UI */ - #endif /* JSDEBUGGER */ - --#ifdef JS_THREADSAFE -- class ShellWorkerHooks : public js::workers::WorkerHooks { -- public: -- JSObject *newGlobalObject(JSContext *cx) { -- return NewGlobalObject(cx, NEW_COMPARTMENT); -- } -- }; -- 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, argv, argc); - --#ifdef JS_THREADSAFE -- js::workers::finish(cx, gWorkerThreadPool); -- JS_RemoveObjectRoot(cx, &gWorkers); -- if (result == 0) -- result = gExitCode; --#endif -- - #ifdef JSDEBUGGER - if (jsdc) { - #ifdef JSDEBUGGER_C_UI -diff -ruN src/shell/jsworkers.cpp src.new/shell/jsworkers.cpp ---- shell/jsworkers.cpp 2011-04-01 06:08:36.000000000 +1100 -+++ shell/jsworkers.cpp 1970-01-01 10:00:00.000000000 +1000 -@@ -1,1280 +0,0 @@ --/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- -- * vim: set ts=8 sw=4 et tw=99: -- * -- * ***** BEGIN LICENSE BLOCK ***** -- * Version: MPL 1.1/GPL 2.0/LGPL 2.1 -- * -- * The contents of this file are subject to the Mozilla Public License Version -- * 1.1 (the "License"); you may not use this file except in compliance with -- * the License. You may obtain a copy of the License at -- * http://www.mozilla.org/MPL/ -- * -- * Software distributed under the License is distributed on an "AS IS" basis, -- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -- * for the specific language governing rights and limitations under the -- * License. -- * -- * The Original Code is JavaScript shell workers. -- * -- * The Initial Developer of the Original Code is -- * Mozilla Corporation. -- * Portions created by the Initial Developer are Copyright (C) 2010 -- * the Initial Developer. All Rights Reserved. -- * -- * Contributor(s): -- * Jason Orendorff <jorendorff@mozilla.com> -- * -- * Alternatively, the contents of this file may be used under the terms of -- * either of the GNU General Public License Version 2 or later (the "GPL"), -- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -- * in which case the provisions of the GPL or the LGPL are applicable instead -- * of those above. If you wish to allow use of your version of this file only -- * under the terms of either the GPL or the LGPL, and not to allow others to -- * use your version of this file under the terms of the MPL, indicate your -- * decision by deleting the provisions above and replace them with the notice -- * and other provisions required by the GPL or the LGPL. If you do not delete -- * the provisions above, a recipient may use your version of this file under -- * the terms of any one of the MPL, the GPL or the LGPL. -- * -- * ***** END LICENSE BLOCK ***** */ -- --#ifdef JS_THREADSAFE -- --#include <algorithm> --#include <string.h> --#include "prthread.h" --#include "prlock.h" --#include "prcvar.h" --#include "jsapi.h" --#include "jscntxt.h" --#include "jshashtable.h" --#include "jsstdint.h" --#include "jslock.h" --#include "jsvector.h" --#include "jsworkers.h" -- --extern size_t gMaxStackSize; -- --/* -- * JavaScript shell workers. -- * -- * == Object lifetime rules == -- * -- * - The ThreadPool lasts from init() to finish(). -- * -- * - The ThreadPool owns the MainQueue and the WorkerQueue. Those live from -- * the time the first Worker is created until finish(). -- * -- * - Each JS Worker object has the same lifetime as the corresponding C++ -- * Worker object. A Worker is live if (a) the Worker JSObject is still -- * live; (b) the Worker has an incoming event pending or running; (c) it -- * has sent an outgoing event to its parent that is still pending; or (d) -- * it has any live child Workers. -- * -- * - finish() continues to wait for events until all threads are idle. -- * -- * Event objects, however, are basically C++-only. The JS Event objects are -- * just plain old JSObjects. They don't keep anything alive. -- * -- * == Locking scheme == -- * -- * When mixing mutexes and the JSAPI request model, there are two choices: -- * -- * - Always nest the mutexes in requests. Since threads in requests are not -- * supposed to block, this means the mutexes must be only briefly held. -- * -- * - Never nest the mutexes in requests. Since this allows threads to race -- * with the GC, trace() methods must go through the mutexes just like -- * everyone else. -- * -- * This code uses the latter approach for all locks. -- * -- * In one case, a thread holding a Worker's mutex can acquire the mutex of one -- * of its child Workers. See Worker::terminateSelf. (This can't deadlock because -- * the parent-child relationship is a partial order.) -- */ -- --namespace js { --namespace workers { -- --template <class T, class AllocPolicy> --class Queue { -- private: -- typedef Vector<T, 4, AllocPolicy> Vec; -- Vec v1; -- Vec v2; -- Vec *front; -- Vec *back; -- -- // Queue is not copyable. -- Queue(const Queue &); -- Queue & operator=(const Queue &); -- -- public: -- Queue() : front(&v1), back(&v2) {} -- bool push(T t) { return back->append(t); } -- bool empty() { return front->empty() && back->empty(); } -- -- T pop() { -- if (front->empty()) { -- std::reverse(back->begin(), back->end()); -- Vec *tmp = front; -- front = back; -- back = tmp; -- } -- T item = front->back(); -- front->popBack(); -- return item; -- } -- -- void clear() { -- v1.clear(); -- v2.clear(); -- } -- -- void trace(JSTracer *trc) { -- for (T *p = v1.begin(); p != v1.end(); p++) -- (*p)->trace(trc); -- for (T *p = v2.begin(); p != v2.end(); p++) -- (*p)->trace(trc); -- } --}; -- --class Event; --class ThreadPool; --class Worker; -- --class WorkerParent { -- protected: -- typedef HashSet<Worker *, DefaultHasher<Worker *>, SystemAllocPolicy> ChildSet; -- ChildSet children; -- -- bool initWorkerParent() { return children.init(8); } -- -- public: -- virtual JSLock *getLock() = 0; -- virtual ThreadPool *getThreadPool() = 0; -- virtual bool post(Event *item) = 0; // false on OOM or queue closed -- virtual void trace(JSTracer *trc) = 0; -- -- bool addChild(Worker *w) { -- AutoLock hold(getLock()); -- return children.put(w) != NULL; -- } -- -- // This must be called only from GC or when all threads are shut down. It -- // does not bother with locking. -- void removeChild(Worker *w) { -- ChildSet::Ptr p = children.lookup(w); -- JS_ASSERT(p); -- children.remove(p); -- } -- -- void disposeChildren(); --}; -- --template <class T> --class ThreadSafeQueue --{ -- protected: -- Queue<T, SystemAllocPolicy> queue; -- JSLock *lock; -- PRCondVar *condvar; -- bool closed; -- -- private: -- Vector<T, 8, SystemAllocPolicy> busy; -- -- protected: -- ThreadSafeQueue() : lock(NULL), condvar(NULL), closed(false) {} -- -- ~ThreadSafeQueue() { -- if (condvar) -- JS_DESTROY_CONDVAR(condvar); -- if (lock) -- JS_DESTROY_LOCK(lock); -- } -- -- // Called by take() with the lock held. -- virtual bool shouldStop() { return closed; } -- -- public: -- bool initThreadSafeQueue() { -- JS_ASSERT(!lock); -- JS_ASSERT(!condvar); -- return (lock = JS_NEW_LOCK()) && (condvar = JS_NEW_CONDVAR(lock)); -- } -- -- bool post(T t) { -- AutoLock hold(lock); -- if (closed) -- return false; -- if (queue.empty()) -- JS_NOTIFY_ALL_CONDVAR(condvar); -- return queue.push(t); -- } -- -- void close() { -- AutoLock hold(lock); -- closed = true; -- queue.clear(); -- JS_NOTIFY_ALL_CONDVAR(condvar); -- } -- -- // The caller must hold the lock. -- bool take(T *t) { -- while (queue.empty()) { -- if (shouldStop()) -- return false; -- JS_WAIT_CONDVAR(condvar, JS_NO_TIMEOUT); -- } -- *t = queue.pop(); -- busy.append(*t); -- return true; -- } -- -- // The caller must hold the lock. -- void drop(T item) { -- for (T *p = busy.begin(); p != busy.end(); p++) { -- if (*p == item) { -- *p = busy.back(); -- busy.popBack(); -- return; -- } -- } -- JS_NOT_REACHED("removeBusy"); -- } -- -- bool lockedIsIdle() { return busy.empty() && queue.empty(); } -- -- bool isIdle() { -- AutoLock hold(lock); -- return lockedIsIdle(); -- } -- -- void wake() { -- AutoLock hold(lock); -- JS_NOTIFY_ALL_CONDVAR(condvar); -- } -- -- void trace(JSTracer *trc) { -- AutoLock hold(lock); -- for (T *p = busy.begin(); p != busy.end(); p++) -- (*p)->trace(trc); -- queue.trace(trc); -- } --}; -- --class MainQueue; -- --class Event --{ -- protected: -- virtual ~Event() { JS_ASSERT(!data); } -- -- WorkerParent *recipient; -- Worker *child; -- uint64 *data; -- size_t nbytes; -- -- public: -- enum Result { fail = JS_FALSE, ok = JS_TRUE, forwardToParent }; -- -- virtual void destroy(JSContext *cx) { -- JS_free(cx, data); --#ifdef DEBUG -- data = NULL; --#endif -- delete this; -- } -- -- void setChildAndRecipient(Worker *aChild, WorkerParent *aRecipient) { -- child = aChild; -- recipient = aRecipient; -- } -- -- bool deserializeData(JSContext *cx, jsval *vp) { -- return !!JS_ReadStructuredClone(cx, data, nbytes, JS_STRUCTURED_CLONE_VERSION, vp, -- NULL, NULL); -- } -- -- virtual Result process(JSContext *cx) = 0; -- -- inline void trace(JSTracer *trc); -- -- template <class EventType> -- static EventType *createEvent(JSContext *cx, WorkerParent *recipient, Worker *child, -- jsval v) -- { -- uint64 *data; -- size_t nbytes; -- if (!JS_WriteStructuredClone(cx, v, &data, &nbytes, NULL, NULL)) -- return NULL; -- -- EventType *event = new EventType; -- if (!event) { -- JS_ReportOutOfMemory(cx); -- return NULL; -- } -- event->recipient = recipient; -- event->child = child; -- event->data = data; -- event->nbytes = nbytes; -- return event; -- } -- -- Result dispatch(JSContext *cx, JSObject *thisobj, const char *dataPropName, -- const char *methodName, Result noHandler) -- { -- if (!data) -- return fail; -- -- JSBool found; -- if (!JS_HasProperty(cx, thisobj, methodName, &found)) -- return fail; -- if (!found) -- return noHandler; -- -- // Create event object. -- jsval v; -- if (!deserializeData(cx, &v)) -- return fail; -- JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL); -- if (!obj || !JS_DefineProperty(cx, obj, dataPropName, v, NULL, NULL, 0)) -- return fail; -- -- // Call event handler. -- jsval argv[1] = { OBJECT_TO_JSVAL(obj) }; -- jsval rval = JSVAL_VOID; -- return Result(JS_CallFunctionName(cx, thisobj, methodName, 1, argv, &rval)); -- } --}; -- --typedef ThreadSafeQueue<Event *> EventQueue; -- --class MainQueue : public EventQueue, public WorkerParent --{ -- private: -- ThreadPool *threadPool; -- -- public: -- explicit MainQueue(ThreadPool *tp) : threadPool(tp) {} -- -- ~MainQueue() { -- JS_ASSERT(queue.empty()); -- } -- -- bool init() { return initThreadSafeQueue() && initWorkerParent(); } -- -- void destroy(JSContext *cx) { -- while (!queue.empty()) -- queue.pop()->destroy(cx); -- delete this; -- } -- -- virtual JSLock *getLock() { return lock; } -- virtual ThreadPool *getThreadPool() { return threadPool; } -- -- protected: -- virtual bool shouldStop(); -- -- public: -- virtual bool post(Event *event) { return EventQueue::post(event); } -- -- virtual void trace(JSTracer *trc); -- -- void traceChildren(JSTracer *trc) { EventQueue::trace(trc); } -- -- JSBool mainThreadWork(JSContext *cx, bool continueOnError) { -- JSAutoSuspendRequest suspend(cx); -- AutoLock hold(lock); -- -- Event *event; -- while (take(&event)) { -- JS_RELEASE_LOCK(lock); -- Event::Result result; -- { -- JSAutoRequest req(cx); -- result = event->process(cx); -- if (result == Event::forwardToParent) { -- // FIXME - pointlessly truncates the string to 8 bits -- jsval data; -- JSAutoByteString bytes; -- if (event->deserializeData(cx, &data) && -- JSVAL_IS_STRING(data) && -- bytes.encode(cx, JSVAL_TO_STRING(data))) { -- JS_ReportError(cx, "%s", bytes.ptr()); -- } else { -- JS_ReportOutOfMemory(cx); -- } -- result = Event::fail; -- } -- if (result == Event::fail && continueOnError) { -- if (JS_IsExceptionPending(cx) && !JS_ReportPendingException(cx)) -- JS_ClearPendingException(cx); -- result = Event::ok; -- } -- } -- JS_ACQUIRE_LOCK(lock); -- drop(event); -- event->destroy(cx); -- if (result != Event::ok) -- return false; -- } -- return true; -- } --}; -- --/* -- * A queue of workers. -- * -- * We keep a queue of workers with pending events, rather than a queue of -- * events, so that two threads won't try to run a Worker at the same time. -- */ --class WorkerQueue : public ThreadSafeQueue<Worker *> --{ -- private: -- MainQueue *main; -- -- public: -- explicit WorkerQueue(MainQueue *main) : main(main) {} -- -- void work(); --}; -- --/* The top-level object that owns everything else. */ --class ThreadPool --{ -- private: -- enum { threadCount = 6 }; -- -- JSObject *obj; -- WorkerHooks *hooks; -- MainQueue *mq; -- WorkerQueue *wq; -- PRThread *threads[threadCount]; -- int32_t terminating; -- -- static JSClass jsClass; -- -- static void start(void* arg) { -- ((WorkerQueue *) arg)->work(); -- } -- -- explicit ThreadPool(WorkerHooks *hooks) : hooks(hooks), mq(NULL), wq(NULL), terminating(0) { -- for (int i = 0; i < threadCount; i++) -- threads[i] = NULL; -- } -- -- public: -- ~ThreadPool() { -- JS_ASSERT(!mq); -- JS_ASSERT(!wq); -- JS_ASSERT(!threads[0]); -- } -- -- static ThreadPool *create(JSContext *cx, WorkerHooks *hooks) { -- ThreadPool *tp = new ThreadPool(hooks); -- if (!tp) { -- JS_ReportOutOfMemory(cx); -- return NULL; -- } -- -- JSObject *obj = JS_NewObject(cx, &jsClass, NULL, NULL); -- if (!obj || !JS_SetPrivate(cx, obj, tp)) { -- delete tp; -- return NULL; -- } -- tp->obj = obj; -- return tp; -- } -- -- JSObject *asObject() { return obj; } -- WorkerHooks *getHooks() { return hooks; } -- WorkerQueue *getWorkerQueue() { return wq; } -- MainQueue *getMainQueue() { return mq; } -- bool isTerminating() { return terminating != 0; } -- -- /* -- * Main thread only. Requires request (to prevent GC, which could see the -- * object in an inconsistent state). -- */ -- bool start(JSContext *cx) { -- JS_ASSERT(!mq && !wq); -- mq = new MainQueue(this); -- if (!mq || !mq->init()) { -- mq->destroy(cx); -- mq = NULL; -- return false; -- } -- wq = new WorkerQueue(mq); -- if (!wq || !wq->initThreadSafeQueue()) { -- delete wq; -- wq = NULL; -- mq->destroy(cx); -- mq = NULL; -- return false; -- } -- JSAutoSuspendRequest suspend(cx); -- bool ok = true; -- for (int i = 0; i < threadCount; i++) { -- threads[i] = PR_CreateThread(PR_USER_THREAD, start, wq, PR_PRIORITY_NORMAL, -- PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0); -- if (!threads[i]) { -- shutdown(cx); -- ok = false; -- break; -- } -- } -- return ok; -- } -- -- void terminateAll(JSRuntime *rt) { -- // See comment about JS_ATOMIC_SET in the implementation of -- // JS_TriggerOperationCallback. -- JS_ATOMIC_SET(&terminating, 1); -- JS_TriggerAllOperationCallbacks(rt); -- } -- -- /* This context is used only to free memory. */ -- void shutdown(JSContext *cx) { -- wq->close(); -- for (int i = 0; i < threadCount; i++) { -- if (threads[i]) { -- PR_JoinThread(threads[i]); -- threads[i] = NULL; -- } -- } -- -- delete wq; -- wq = NULL; -- -- mq->disposeChildren(); -- mq->destroy(cx); -- mq = NULL; -- terminating = 0; -- } -- -- private: -- static void jsTraceThreadPool(JSTracer *trc, JSObject *obj) { -- ThreadPool *tp = unwrap(trc->context, obj); -- if (tp->mq) { -- tp->mq->traceChildren(trc); -- tp->wq->trace(trc); -- } -- } -- -- -- static void jsFinalize(JSContext *cx, JSObject *obj) { -- if (ThreadPool *tp = unwrap(cx, obj)) -- delete tp; -- } -- -- public: -- static ThreadPool *unwrap(JSContext *cx, JSObject *obj) { -- JS_ASSERT(JS_GET_CLASS(cx, obj) == &jsClass); -- return (ThreadPool *) JS_GetPrivate(cx, obj); -- } --}; -- --/* -- * A Worker is always in one of 4 states, except when it is being initialized -- * or destroyed, or its lock is held: -- * - idle (!terminated && current == NULL && events.empty()) -- * - enqueued (!terminated && current == NULL && !events.empty()) -- * - busy (!terminated && current != NULL) -- * - terminated (terminated && current == NULL && events.empty()) -- * -- * Separately, there is a terminateFlag that other threads can set -- * asynchronously to tell the Worker to terminate. -- */ --class Worker : public WorkerParent --{ -- private: -- ThreadPool *threadPool; -- WorkerParent *parent; -- JSObject *object; // Worker object exposed to parent -- JSContext *context; -- JSLock *lock; -- Queue<Event *, SystemAllocPolicy> events; // owning pointers to pending events -- Event *current; -- bool terminated; -- int32_t terminateFlag; -- -- static JSClass jsWorkerClass; -- -- Worker() -- : threadPool(NULL), parent(NULL), object(NULL), -- context(NULL), lock(NULL), current(NULL), terminated(false), terminateFlag(0) {} -- -- bool init(JSContext *parentcx, WorkerParent *parent, JSObject *obj) { -- JS_ASSERT(!threadPool && !this->parent && !object && !lock); -- -- if (!initWorkerParent() || !parent->addChild(this)) -- return false; -- threadPool = parent->getThreadPool(); -- this->parent = parent; -- this->object = obj; -- lock = JS_NEW_LOCK(); -- return lock && -- createContext(parentcx, parent) && -- JS_SetPrivate(parentcx, obj, this); -- } -- -- bool createContext(JSContext *parentcx, WorkerParent *parent) { -- JSRuntime *rt = JS_GetRuntime(parentcx); -- context = JS_NewContext(rt, 8192); -- if (!context) -- return false; -- -- // The Worker has a strong reference to the global; see jsTraceWorker. -- // JSOPTION_UNROOTED_GLOBAL ensures that when the worker becomes -- // unreachable, it and its global object can be collected. Otherwise -- // the cx->globalObject root would keep them both alive forever. -- JS_SetOptions(context, JS_GetOptions(parentcx) | JSOPTION_UNROOTED_GLOBAL | -- JSOPTION_DONT_REPORT_UNCAUGHT); -- JS_SetVersion(context, JS_GetVersion(parentcx)); -- JS_SetContextPrivate(context, this); -- JS_SetOperationCallback(context, jsOperationCallback); -- JS_BeginRequest(context); -- *** 2131 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106261124.15QBOhGm032634>