Index: ossp-pkg/js/Makefile.in
RCS File: /v/ossp/cvs/ossp-pkg/js/Makefile.in,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/Makefile.in,v' 2>/dev/null
--- Makefile.in 2006/07/22 11:04:43 1.1
+++ Makefile.in 2006/07/22 13:48:03 1.2
@@ -40,10 +40,10 @@
libdir = @libdir@
includedir = @includedir@
mandir = @mandir@
-
+datarootdir = @datarootdir@
CXX = @CXX@
-CPPFLAGS = -I. -I$(S) -Isrc -I($S)/src @CPPFLAGS@ @DEFS@
+CPPFLAGS = @CPPFLAGS@ @DEFS@ -Isrc
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
LDFLAGS = @LDFLAGS@
@@ -109,7 +109,6 @@
src/jsatom.lo \
src/jsbool.lo \
src/jscntxt.lo \
- src/jscpucfg.lo \
src/jsdate.lo \
src/jsdbgapi.lo \
src/jsdhash.lo \
@@ -138,7 +137,40 @@
src/jsutil.lo \
src/jsxdrapi.lo \
src/jsxml.lo \
- src/prmjtime.lo
+ src/prmjtime.lo \
+ src/fdlibm/e_acos.lo \
+ src/fdlibm/e_asin.lo \
+ src/fdlibm/e_atan2.lo \
+ src/fdlibm/e_exp.lo \
+ src/fdlibm/e_fmod.lo \
+ src/fdlibm/e_log.lo \
+ src/fdlibm/e_pow.lo \
+ src/fdlibm/e_rem_pio2.lo \
+ src/fdlibm/s_scalbn.lo \
+ src/fdlibm/e_sqrt.lo \
+ src/fdlibm/k_cos.lo \
+ src/fdlibm/k_sin.lo \
+ src/fdlibm/k_rem_pio2.lo \
+ src/fdlibm/k_tan.lo \
+ src/fdlibm/s_atan.lo \
+ src/fdlibm/s_ceil.lo \
+ src/fdlibm/s_copysign.lo \
+ src/fdlibm/s_cos.lo \
+ src/fdlibm/s_fabs.lo \
+ src/fdlibm/s_finite.lo \
+ src/fdlibm/s_floor.lo \
+ src/fdlibm/s_isnan.lo \
+ src/fdlibm/s_lib_version.lo \
+ src/fdlibm/s_sin.lo \
+ src/fdlibm/s_tan.lo \
+ src/fdlibm/w_acos.lo \
+ src/fdlibm/w_asin.lo \
+ src/fdlibm/w_atan2.lo \
+ src/fdlibm/w_exp.lo \
+ src/fdlibm/w_fmod.lo \
+ src/fdlibm/w_log.lo \
+ src/fdlibm/w_pow.lo \
+ src/fdlibm/w_sqrt.lo
LIB_NAME = libjs.la
PRG_NAME = js
@@ -152,10 +184,10 @@
all: $(TARGETS)
.c.o:
- $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
.c.lo:
- @$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
+ @$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
$(LIB_NAME): $(LIB_OBJS)
@$(LIBTOOL) --mode=link $(CC) -o $(LIB_NAME) $(LIB_OBJS) -rpath $(libdir) \
@@ -164,6 +196,16 @@
$(PRG_NAME): $(PRG_OBJS) $(LIB_NAME)
@$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $(PRG_NAME) $(PRG_OBJS) $(LIB_NAME) $(LIBS)
+$(LIB_OBJS): src/jsautocfg.h
+src/jsautocfg.h: jscpucfg
+ -rm -f $@ src/jsautocfg.h
+ $(LIBTOOL) --mode=execute ./jscpucfg >src/jsautocfg.h
+jscpucfg.o: src/jscpucfg.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
+jscpucfg: jscpucfg.o
+ @$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o jscpucfg jscpucfg.o $(LIBS)
+src/jsopcode.h src/jsopcode.c: src/jsopcode.tbl
+
.PHONY: install
install:
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(prefix)
Index: ossp-pkg/js/README
RCS File: /v/ossp/cvs/ossp-pkg/js/README,v
co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/js/README,v' | diff -u /dev/null - -L'ossp-pkg/js/README' 2>/dev/null
--- ossp-pkg/js/README
+++ - 2025-05-20 13:19:57.388336557 +0200
@@ -0,0 +1,53 @@
+ _ ___ ____ ____ ____ _
+ |_|_ _ / _ \/ ___/ ___|| _ \ (_)___
+ _|_||_| | | | \___ \___ \| |_) | | / __|
+ |_||_|_| | |_| |___) |__) | __/ | \__ \
+ |_|_|_| \___/|____/____/|_| _/ |___/
+ |__/
+
+ OSSP js - Mozilla JavaScript Engine
+ Version 1.6.1.5.0.5.0.9 (11-May-2006)
+
+ ABSTRACT
+
+ OSSP js is a 1:1 repackaging of the Mozilla SpiderMonkey JavaScript
+ C engine. It is fully JavaScript 1.6 and ECMAScript 3 compliant.
+
+ JavaScript is a high-level programming language. Brendan Eich
+ originally invented JavaScript under the name Livescript at Netscape
+ Communications in 1995. The language is heavily influenced by other
+ languages like Java, C, and Perl. JavaScript was standardized by ECMA
+ and ISO as ECMAScript. JavaScript 1.5 is identical to ECMAScript 3
+ (ECMA-262) and ISO/IEC 16262:2002.
+
+ COPYRIGHT AND LICENSE
+
+ Copyright (c) 1998-2006 Mozilla Foundation
+ Copyright (c) 2006 Ralf S. Engelschall
+ Copyright (c) 2006 The OSSP Project
+
+ This file is part of OSSP js, a version of the Mozilla JavaScript
+ reference implementation, which can found at http://www.ossp.org/pkg/lib/js/
+
+ The code is covered by either MPL 1.1, GPL 2.0 or LGPL 2.1
+
+ HOME AND DOCUMENTATION
+
+ The documentation and latest release can be found on
+
+ o http://www.ossp.org/pkg/lib/js/
+ o ftp://ftp.ossp.org/pkg/lib/js/
+
+ SEE ALSO
+
+ http://www.mozilla.org/js/
+ http://www.mozilla.org/js/language/
+ http://www.mozilla.org/js/spidermonkey/
+ http://www.ecma-international.org/publications/standards/Ecma-262.htm
+ http://developer.mozilla.org/en/docs/JavaScript_C_Engine_Embedder's_Guide
+ http://developer.mozilla.org/en/docs/JSAPI_Reference
+ http://lxr.mozilla.org/mozilla/source/js/src
+ http://lxr.mozilla.org/mozilla/source/js/src/README.html
+ http://www.jibbering.com/faq/
+ http://www.faqts.com/knowledge_base/index.phtml/fid/53/
+
Index: ossp-pkg/js/configure.ac
RCS File: /v/ossp/cvs/ossp-pkg/js/configure.ac,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/configure.ac,v' 2>/dev/null
--- configure.ac 2006/07/22 11:04:43 1.1
+++ configure.ac 2006/07/22 13:48:03 1.2
@@ -36,9 +36,14 @@
AC_PROG_MAKE_SET
AC_PROG_CC
AC_CHECK_DEBUGGING
+AC_CHECK_LIB(nsl, gethostname)
+if test ".`echo $LIBS | grep nsl`" = .; then
+ AC_CHECK_LIB(nsl, gethostbyname)
+fi
+AC_CHECK_LIB(socket, accept)
+AC_CHECK_LIB(m, floor)
-CPPFLAGS="$CPPFLAGS -DXP_UNIX"
-CPPFLAGS="$CPPFLAGS -DNDEBUG"
+CPPFLAGS="$CPPFLAGS -DOSSP"
with_tags=""
sinclude(libtool.m4)
Index: ossp-pkg/js/js.pc.in
RCS File: /v/ossp/cvs/ossp-pkg/js/js.pc.in,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/js.pc.in,v' 2>/dev/null
--- js.pc.in 2006/07/22 11:04:43 1.1
+++ js.pc.in 2006/07/22 13:48:03 1.2
@@ -6,5 +6,5 @@
Name: OSSP js
Description: JavaScript Engine
Version: @version@
-Libs: -L${libdir} -ljs -lm
+Libs: -L${libdir} -ljs @LIBS@
Cflags: -DXP_UNIX -I${includedir}
Index: ossp-pkg/js/src/fdlibm/fdlibm.h
RCS File: /v/ossp/cvs/ossp-pkg/js/src/fdlibm/fdlibm.h,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/src/fdlibm/fdlibm.h,v' 2>/dev/null
--- fdlibm.h 2006/04/23 06:33:26 1.1
+++ fdlibm.h 2006/07/22 13:48:03 1.2
@@ -49,6 +49,97 @@
* ====================================================
*/
+#ifdef OSSP
+/* select functionality */
+#define _IEEE_LIBM
+/* avoid namespace pollution */
+#define __ieee754_acos js___ieee754_acos
+#define __ieee754_acosh js___ieee754_acosh
+#define __ieee754_asin js___ieee754_asin
+#define __ieee754_atan2 js___ieee754_atan2
+#define __ieee754_atanh js___ieee754_atanh
+#define __ieee754_cosh js___ieee754_cosh
+#define __ieee754_exp js___ieee754_exp
+#define __ieee754_fmod js___ieee754_fmod
+#define __ieee754_gamma js___ieee754_gamma
+#define __ieee754_gamma_r js___ieee754_gamma_r
+#define __ieee754_hypot js___ieee754_hypot
+#define __ieee754_j0 js___ieee754_j0
+#define __ieee754_j1 js___ieee754_j1
+#define __ieee754_jn js___ieee754_jn
+#define __ieee754_lgamma js___ieee754_lgamma
+#define __ieee754_lgamma_r js___ieee754_lgamma_r
+#define __ieee754_log js___ieee754_log
+#define __ieee754_log10 js___ieee754_log10
+#define __ieee754_pow js___ieee754_pow
+#define __ieee754_rem_pio2 js___ieee754_rem_pio2
+#define __ieee754_remainder js___ieee754_remainder
+#define __ieee754_scalb js___ieee754_scalb
+#define __ieee754_sinh js___ieee754_sinh
+#define __ieee754_sqrt js___ieee754_sqrt
+#define __ieee754_y0 js___ieee754_y0
+#define __ieee754_y1 js___ieee754_y1
+#define __ieee754_yn js___ieee754_yn
+#define __kernel_cos js___kernel_cos
+#define __kernel_rem_pio2 js___kernel_rem_pio2
+#define __kernel_sin js___kernel_sin
+#define __kernel_standard js___kernel_standard
+#define __kernel_tan js___kernel_tan
+#define fd_acos js_fd_acos
+#define fd_acosh js_fd_acosh
+#define fd_asin js_fd_asin
+#define fd_asinh js_fd_asinh
+#define fd_atan js_fd_atan
+#define fd_atan2 js_fd_atan2
+#define fd_atanh js_fd_atanh
+#define fd_cbrt js_fd_cbrt
+#define fd_ceil js_fd_ceil
+#define fd_copysign js_fd_copysign
+#define fd_cos js_fd_cos
+#define fd_cosh js_fd_cosh
+#define fd_erf js_fd_erf
+#define fd_erfc js_fd_erfc
+#define fd_exp js_fd_exp
+#define fd_expm1 js_fd_expm1
+#define fd_fabs js_fd_fabs
+#define fd_finite js_fd_finite
+#define fd_floor js_fd_floor
+#define fd_fmod js_fd_fmod
+#define fd_frexp js_fd_frexp
+#define fd_gamma js_fd_gamma
+#define fd_hypot js_fd_hypot
+#define fd_ilogb js_fd_ilogb
+#define fd_isnan js_fd_isnan
+#define fd_j0 js_fd_j0
+#define fd_j1 js_fd_j1
+#define fd_jn js_fd_jn
+#define fd_ldexp js_fd_ldexp
+#define fd_lgamma js_fd_lgamma
+#define fd_log js_fd_log
+#define fd_log10 js_fd_log10
+#define fd_log1p js_fd_log1p
+#define fd_logb js_fd_logb
+#define fd_matherr js_fd_matherr
+#define fd_modf js_fd_modf
+#define fd_nextafter js_fd_nextafter
+#define fd_pow js_fd_pow
+#define fd_remainder js_fd_remainder
+#define fd_rint js_fd_rint
+#define fd_scalb js_fd_scalb
+#define fd_scalbn js_fd_scalbn
+#define fd_sin js_fd_sin
+#define fd_sinh js_fd_sinh
+#define fd_sqrt js_fd_sqrt
+#define fd_tan js_fd_tan
+#define fd_tanh js_fd_tanh
+#define fd_y0 js_fd_y0
+#define fd_y1 js_fd_y1
+#define fd_yn js_fd_yn
+#define gamma_r js_gamma_r
+#define lgamma_r js_lgamma_r
+#define significand js_significand
+#endif
+
/* Modified defines start here.. */
#undef __LITTLE_ENDIAN
Index: ossp-pkg/js/src/jscntxt.c
RCS File: /v/ossp/cvs/ossp-pkg/js/src/jscntxt.c,v
co -q -kk -p'1.2' '/v/ossp/cvs/ossp-pkg/js/src/jscntxt.c,v' | diff -u /dev/null - -L'ossp-pkg/js/src/jscntxt.c' 2>/dev/null
--- ossp-pkg/js/src/jscntxt.c
+++ - 2025-05-20 13:19:57.403264309 +0200
@@ -0,0 +1,1071 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** 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 Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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 ***** */
+
+/*
+ * JS execution context.
+ */
+#include "jsstddef.h"
+#include
+#include
+#include
+#include "jstypes.h"
+#include "jsarena.h" /* Added by JSIFY */
+#include "jsutil.h" /* Added by JSIFY */
+#include "jsclist.h"
+#include "jsprf.h"
+#include "jsatom.h"
+#include "jscntxt.h"
+#include "jsconfig.h"
+#include "jsdbgapi.h"
+#include "jsexn.h"
+#include "jsgc.h"
+#include "jslock.h"
+#include "jsnum.h"
+#include "jsobj.h"
+#include "jsopcode.h"
+#include "jsscan.h"
+#include "jsscript.h"
+#include "jsstr.h"
+
+void
+js_OnVersionChange(JSContext *cx)
+{
+#if !JS_BUG_FALLIBLE_EQOPS
+ if (JS_VERSION_IS_1_2(cx)) {
+ cx->jsop_eq = JSOP_NEW_EQ;
+ cx->jsop_ne = JSOP_NEW_NE;
+ } else {
+ cx->jsop_eq = JSOP_EQ;
+ cx->jsop_ne = JSOP_NE;
+ }
+#endif /* !JS_BUG_FALLIBLE_EQOPS */
+}
+
+void
+js_SetVersion(JSContext *cx, JSVersion version)
+{
+ cx->version = version;
+ js_OnVersionChange(cx);
+}
+
+JSContext *
+js_NewContext(JSRuntime *rt, size_t stackChunkSize)
+{
+ JSContext *cx;
+ JSBool ok, first;
+
+ cx = (JSContext *) malloc(sizeof *cx);
+ if (!cx)
+ return NULL;
+ memset(cx, 0, sizeof *cx);
+
+ cx->runtime = rt;
+#if JS_STACK_GROWTH_DIRECTION > 0
+ cx->stackLimit = (jsuword)-1;
+#endif
+#ifdef JS_THREADSAFE
+ js_InitContextForLocking(cx);
+#endif
+
+ JS_LOCK_GC(rt);
+ for (;;) {
+ first = (rt->contextList.next == &rt->contextList);
+ if (rt->state == JSRTS_UP) {
+ JS_ASSERT(!first);
+ break;
+ }
+ if (rt->state == JSRTS_DOWN) {
+ JS_ASSERT(first);
+ rt->state = JSRTS_LAUNCHING;
+ break;
+ }
+ JS_WAIT_CONDVAR(rt->stateChange, JS_NO_TIMEOUT);
+ }
+ JS_APPEND_LINK(&cx->links, &rt->contextList);
+ JS_UNLOCK_GC(rt);
+
+ /*
+ * First we do the infallible, every-time per-context initializations.
+ * Should a later, fallible initialization (js_InitRegExpStatics, e.g.,
+ * or the stuff under 'if (first)' below) fail, at least the version
+ * and arena-pools will be valid and safe to use (say, from the last GC
+ * done by js_DestroyContext).
+ */
+ cx->version = JSVERSION_DEFAULT;
+ cx->jsop_eq = JSOP_EQ;
+ cx->jsop_ne = JSOP_NE;
+ JS_InitArenaPool(&cx->stackPool, "stack", stackChunkSize, sizeof(jsval));
+ JS_InitArenaPool(&cx->tempPool, "temp", 1024, sizeof(jsdouble));
+
+#if JS_HAS_REGEXPS
+ if (!js_InitRegExpStatics(cx, &cx->regExpStatics)) {
+ js_DestroyContext(cx, JS_NO_GC);
+ return NULL;
+ }
+#endif
+#if JS_HAS_EXCEPTIONS
+ cx->throwing = JS_FALSE;
+#endif
+
+ /*
+ * If cx is the first context on this runtime, initialize well-known atoms,
+ * keywords, numbers, and strings. If one of these steps should fail, the
+ * runtime will be left in a partially initialized state, with zeroes and
+ * nulls stored in the default-initialized remainder of the struct. We'll
+ * clean the runtime up under js_DestroyContext, because cx will be "last"
+ * as well as "first".
+ */
+ if (first) {
+ /*
+ * Both atomState and the scriptFilenameTable may be left over from a
+ * previous episode of non-zero contexts alive in rt, so don't re-init
+ * either table if it's not necessary. Just repopulate atomState with
+ * well-known internal atoms, and with the reserved identifiers added
+ * by the scanner.
+ */
+ ok = (rt->atomState.liveAtoms == 0)
+ ? js_InitAtomState(cx, &rt->atomState)
+ : js_InitPinnedAtoms(cx, &rt->atomState);
+ if (ok)
+ ok = js_InitScanner(cx);
+ if (ok && !rt->scriptFilenameTable)
+ ok = js_InitRuntimeScriptState(rt);
+ if (ok)
+ ok = js_InitRuntimeNumberState(cx);
+ if (ok)
+ ok = js_InitRuntimeStringState(cx);
+ if (!ok) {
+ js_DestroyContext(cx, JS_NO_GC);
+ return NULL;
+ }
+
+ JS_LOCK_GC(rt);
+ rt->state = JSRTS_UP;
+ JS_NOTIFY_ALL_CONDVAR(rt->stateChange);
+ JS_UNLOCK_GC(rt);
+ }
+
+ return cx;
+}
+
+void
+js_DestroyContext(JSContext *cx, JSGCMode gcmode)
+{
+ JSRuntime *rt;
+ JSBool last;
+ JSArgumentFormatMap *map;
+ JSLocalRootStack *lrs;
+ JSLocalRootChunk *lrc;
+
+ rt = cx->runtime;
+
+ /* Remove cx from context list first. */
+ JS_LOCK_GC(rt);
+ JS_ASSERT(rt->state == JSRTS_UP || rt->state == JSRTS_LAUNCHING);
+ JS_REMOVE_LINK(&cx->links);
+ last = (rt->contextList.next == &rt->contextList);
+ if (last)
+ rt->state = JSRTS_LANDING;
+ JS_UNLOCK_GC(rt);
+
+ if (last) {
+#ifdef JS_THREADSAFE
+ /*
+ * If cx is not in a request already, begin one now so that we wait
+ * for any racing GC started on a not-last context to finish, before
+ * we plow ahead and unpin atoms. Note that even though we begin a
+ * request here if necessary, we end all requests on cx below before
+ * forcing a final GC. This lets any not-last context destruction
+ * racing in another thread try to force or maybe run the GC, but by
+ * that point, rt->state will not be JSRTS_UP, and that GC attempt
+ * will return early.
+ */
+ if (cx->requestDepth == 0)
+ JS_BeginRequest(cx);
+#endif
+
+ /* Unpin all pinned atoms before final GC. */
+ js_UnpinPinnedAtoms(&rt->atomState);
+
+ /* Unlock and clear GC things held by runtime pointers. */
+ js_FinishRuntimeNumberState(cx);
+ js_FinishRuntimeStringState(cx);
+
+ /* Clear debugging state to remove GC roots. */
+ JS_ClearAllTraps(cx);
+ JS_ClearAllWatchPoints(cx);
+ }
+
+#if JS_HAS_REGEXPS
+ /*
+ * Remove more GC roots in regExpStatics, then collect garbage.
+ * XXX anti-modularity alert: we rely on the call to js_RemoveRoot within
+ * XXX this function call to wait for any racing GC to complete, in the
+ * XXX case where JS_DestroyContext is called outside of a request on cx
+ */
+ js_FreeRegExpStatics(cx, &cx->regExpStatics);
+#endif
+
+#ifdef JS_THREADSAFE
+ /*
+ * Destroying a context implicitly calls JS_EndRequest(). Also, we must
+ * end our request here in case we are "last" -- in that event, another
+ * js_DestroyContext that was not last might be waiting in the GC for our
+ * request to end. We'll let it run below, just before we do the truly
+ * final GC and then free atom state.
+ *
+ * At this point, cx must be inaccessible to other threads. It's off the
+ * rt->contextList, and it should not be reachable via any object private
+ * data structure.
+ */
+ while (cx->requestDepth != 0)
+ JS_EndRequest(cx);
+#endif
+
+ if (last) {
+ /* Always force, so we wait for any racing GC to finish. */
+ js_ForceGC(cx, GC_LAST_CONTEXT);
+
+ /* Iterate until no finalizer removes a GC root or lock. */
+ while (rt->gcPoke)
+ js_GC(cx, GC_LAST_CONTEXT);
+
+ /* Try to free atom state, now that no unrooted scripts survive. */
+ if (rt->atomState.liveAtoms == 0)
+ js_FreeAtomState(cx, &rt->atomState);
+
+ /* Also free the script filename table if it exists and is empty. */
+ if (rt->scriptFilenameTable && rt->scriptFilenameTable->nentries == 0)
+ js_FinishRuntimeScriptState(rt);
+
+ /* Take the runtime down, now that it has no contexts or atoms. */
+ JS_LOCK_GC(rt);
+ rt->state = JSRTS_DOWN;
+ JS_NOTIFY_ALL_CONDVAR(rt->stateChange);
+ JS_UNLOCK_GC(rt);
+ } else {
+ if (gcmode == JS_FORCE_GC)
+ js_ForceGC(cx, 0);
+ else if (gcmode == JS_MAYBE_GC)
+ JS_MaybeGC(cx);
+ }
+
+ /* Free the stuff hanging off of cx. */
+ JS_FinishArenaPool(&cx->stackPool);
+ JS_FinishArenaPool(&cx->tempPool);
+ if (cx->lastMessage)
+ free(cx->lastMessage);
+
+ /* Remove any argument formatters. */
+ map = cx->argumentFormatMap;
+ while (map) {
+ JSArgumentFormatMap *temp = map;
+ map = map->next;
+ JS_free(cx, temp);
+ }
+
+ /* Destroy the resolve recursion damper. */
+ if (cx->resolvingTable) {
+ JS_DHashTableDestroy(cx->resolvingTable);
+ cx->resolvingTable = NULL;
+ }
+
+ lrs = cx->localRootStack;
+ if (lrs) {
+ while ((lrc = lrs->topChunk) != &lrs->firstChunk) {
+ lrs->topChunk = lrc->down;
+ JS_free(cx, lrc);
+ }
+ JS_free(cx, lrs);
+ }
+
+ /* Finally, free cx itself. */
+ free(cx);
+}
+
+JSBool
+js_ValidContextPointer(JSRuntime *rt, JSContext *cx)
+{
+ JSCList *cl;
+
+ for (cl = rt->contextList.next; cl != &rt->contextList; cl = cl->next) {
+ if (cl == &cx->links)
+ return JS_TRUE;
+ }
+ JS_RUNTIME_METER(rt, deadContexts);
+ return JS_FALSE;
+}
+
+JSContext *
+js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp)
+{
+ JSContext *cx = *iterp;
+
+ if (unlocked)
+ JS_LOCK_GC(rt);
+ if (!cx)
+ cx = (JSContext *)&rt->contextList;
+ cx = (JSContext *)cx->links.next;
+ if (&cx->links == &rt->contextList)
+ cx = NULL;
+ *iterp = cx;
+ if (unlocked)
+ JS_UNLOCK_GC(rt);
+ return cx;
+}
+
+JS_STATIC_DLL_CALLBACK(const void *)
+resolving_GetKey(JSDHashTable *table, JSDHashEntryHdr *hdr)
+{
+ JSResolvingEntry *entry = (JSResolvingEntry *)hdr;
+
+ return &entry->key;
+}
+
+JS_STATIC_DLL_CALLBACK(JSDHashNumber)
+resolving_HashKey(JSDHashTable *table, const void *ptr)
+{
+ const JSResolvingKey *key = (const JSResolvingKey *)ptr;
+
+ return ((JSDHashNumber)JS_PTR_TO_UINT32(key->obj) >> JSVAL_TAGBITS) ^ key->id;
+}
+
+#ifdef OSSP
+JS_STATIC_DLL_CALLBACK(JSBool)
+#else
+JS_PUBLIC_API(JSBool)
+#endif
+resolving_MatchEntry(JSDHashTable *table,
+ const JSDHashEntryHdr *hdr,
+ const void *ptr)
+{
+ const JSResolvingEntry *entry = (const JSResolvingEntry *)hdr;
+ const JSResolvingKey *key = (const JSResolvingKey *)ptr;
+
+ return entry->key.obj == key->obj && entry->key.id == key->id;
+}
+
+static const JSDHashTableOps resolving_dhash_ops = {
+ JS_DHashAllocTable,
+ JS_DHashFreeTable,
+ resolving_GetKey,
+ resolving_HashKey,
+ resolving_MatchEntry,
+ JS_DHashMoveEntryStub,
+ JS_DHashClearEntryStub,
+ JS_DHashFinalizeStub,
+ NULL
+};
+
+JSBool
+js_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag,
+ JSResolvingEntry **entryp)
+{
+ JSDHashTable *table;
+ JSResolvingEntry *entry;
+
+ table = cx->resolvingTable;
+ if (!table) {
+ table = JS_NewDHashTable(&resolving_dhash_ops, NULL,
+ sizeof(JSResolvingEntry),
+ JS_DHASH_MIN_SIZE);
+ if (!table)
+ goto outofmem;
+ cx->resolvingTable = table;
+ }
+
+ entry = (JSResolvingEntry *)
+ JS_DHashTableOperate(table, key, JS_DHASH_ADD);
+ if (!entry)
+ goto outofmem;
+
+ if (entry->flags & flag) {
+ /* An entry for (key, flag) exists already -- dampen recursion. */
+ entry = NULL;
+ } else {
+ /* Fill in key if we were the first to add entry, then set flag. */
+ if (!entry->key.obj)
+ entry->key = *key;
+ entry->flags |= flag;
+ }
+ *entryp = entry;
+ return JS_TRUE;
+
+outofmem:
+ JS_ReportOutOfMemory(cx);
+ return JS_FALSE;
+}
+
+void
+js_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag,
+ JSResolvingEntry *entry, uint32 generation)
+{
+ JSDHashTable *table;
+
+ /*
+ * Clear flag from entry->flags and return early if other flags remain.
+ * We must take care to re-lookup entry if the table has changed since
+ * it was found by js_StartResolving.
+ */
+ table = cx->resolvingTable;
+ if (!entry || table->generation != generation) {
+ entry = (JSResolvingEntry *)
+ JS_DHashTableOperate(table, key, JS_DHASH_LOOKUP);
+ }
+ JS_ASSERT(JS_DHASH_ENTRY_IS_BUSY(&entry->hdr));
+ entry->flags &= ~flag;
+ if (entry->flags)
+ return;
+
+ /*
+ * Do a raw remove only if fewer entries were removed than would cause
+ * alpha to be less than .5 (alpha is at most .75). Otherwise, we just
+ * call JS_DHashTableOperate to re-lookup the key and remove its entry,
+ * compressing or shrinking the table as needed.
+ */
+ if (table->removedCount < JS_DHASH_TABLE_SIZE(table) >> 2)
+ JS_DHashTableRawRemove(table, &entry->hdr);
+ else
+ JS_DHashTableOperate(table, key, JS_DHASH_REMOVE);
+}
+
+JSBool
+js_EnterLocalRootScope(JSContext *cx)
+{
+ JSLocalRootStack *lrs;
+ int mark;
+
+ lrs = cx->localRootStack;
+ if (!lrs) {
+ lrs = (JSLocalRootStack *) JS_malloc(cx, sizeof *lrs);
+ if (!lrs)
+ return JS_FALSE;
+ lrs->scopeMark = JSLRS_NULL_MARK;
+ lrs->rootCount = 0;
+ lrs->topChunk = &lrs->firstChunk;
+ lrs->firstChunk.down = NULL;
+ cx->localRootStack = lrs;
+ }
+
+ /* Push lrs->scopeMark to save it for restore when leaving. */
+ mark = js_PushLocalRoot(cx, lrs, INT_TO_JSVAL(lrs->scopeMark));
+ if (mark < 0)
+ return JS_FALSE;
+ lrs->scopeMark = (uint32) mark;
+ return JS_TRUE;
+}
+
+void
+js_LeaveLocalRootScope(JSContext *cx)
+{
+ JSLocalRootStack *lrs;
+ unsigned mark, m, n;
+ JSLocalRootChunk *lrc;
+
+ /* Defend against buggy native callers. */
+ lrs = cx->localRootStack;
+ JS_ASSERT(lrs && lrs->rootCount != 0);
+ if (!lrs || lrs->rootCount == 0)
+ return;
+
+ mark = lrs->scopeMark;
+ JS_ASSERT(mark != JSLRS_NULL_MARK);
+ if (mark == JSLRS_NULL_MARK)
+ return;
+
+ /* Free any chunks being popped by this leave operation. */
+ m = mark >> JSLRS_CHUNK_SHIFT;
+ n = (lrs->rootCount - 1) >> JSLRS_CHUNK_SHIFT;
+ while (n > m) {
+ lrc = lrs->topChunk;
+ JS_ASSERT(lrc != &lrs->firstChunk);
+ lrs->topChunk = lrc->down;
+ JS_free(cx, lrc);
+ --n;
+ }
+
+ /* Pop the scope, restoring lrs->scopeMark. */
+ lrc = lrs->topChunk;
+ m = mark & JSLRS_CHUNK_MASK;
+ lrs->scopeMark = (uint32) JSVAL_TO_INT(lrc->roots[m]);
+ lrc->roots[m] = JSVAL_NULL;
+ lrs->rootCount = (uint32) mark;
+
+ /*
+ * Free the stack eagerly, risking malloc churn. The alternative would
+ * require an lrs->entryCount member, maintained by Enter and Leave, and
+ * tested by the GC in addition to the cx->localRootStack non-null test.
+ *
+ * That approach would risk hoarding 264 bytes (net) per context. Right
+ * now it seems better to give fresh (dirty in CPU write-back cache, and
+ * the data is no longer needed) memory back to the malloc heap.
+ */
+ if (mark == 0) {
+ cx->localRootStack = NULL;
+ JS_free(cx, lrs);
+ } else if (m == 0) {
+ lrs->topChunk = lrc->down;
+ JS_free(cx, lrc);
+ }
+}
+
+void
+js_ForgetLocalRoot(JSContext *cx, jsval v)
+{
+ JSLocalRootStack *lrs;
+ unsigned i, j, m, n, mark;
+ JSLocalRootChunk *lrc, *lrc2;
+ jsval top;
+
+ lrs = cx->localRootStack;
+ JS_ASSERT(lrs && lrs->rootCount);
+ if (!lrs || lrs->rootCount == 0)
+ return;
+
+ /* Prepare to pop the top-most value from the stack. */
+ n = lrs->rootCount - 1;
+ m = n & JSLRS_CHUNK_MASK;
+ lrc = lrs->topChunk;
+ top = lrc->roots[m];
+
+ /* Be paranoid about calls on an empty scope. */
+ mark = lrs->scopeMark;
+ JS_ASSERT(mark < n);
+ if (mark >= n)
+ return;
+
+ /* If v was not the last root pushed in the top scope, find it. */
+ if (top != v) {
+ /* Search downward in case v was recently pushed. */
+ i = n;
+ j = m;
+ lrc2 = lrc;
+ while (--i > mark) {
+ if (j == 0)
+ lrc2 = lrc2->down;
+ j = i & JSLRS_CHUNK_MASK;
+ if (lrc2->roots[j] == v)
+ break;
+ }
+
+ /* If we didn't find v in this scope, assert and bail out. */
+ JS_ASSERT(i != mark);
+ if (i == mark)
+ return;
+
+ /* Swap top and v so common tail code can pop v. */
+ lrc2->roots[j] = top;
+ }
+
+ /* Pop the last value from the stack. */
+ lrc->roots[m] = JSVAL_NULL;
+ lrs->rootCount = n;
+ if (m == 0) {
+ JS_ASSERT(n != 0);
+ JS_ASSERT(lrc != &lrs->firstChunk);
+ lrs->topChunk = lrc->down;
+ JS_free(cx, lrc);
+ }
+}
+
+int
+js_PushLocalRoot(JSContext *cx, JSLocalRootStack *lrs, jsval v)
+{
+ unsigned n, m;
+ JSLocalRootChunk *lrc;
+
+ n = lrs->rootCount;
+ m = n & JSLRS_CHUNK_MASK;
+ if (n == 0 || m != 0) {
+ /*
+ * At start of first chunk, or not at start of a non-first top chunk.
+ * Check for lrs->rootCount overflow.
+ */
+ if ((uint32)(n + 1) == 0) {
+ JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
+ JSMSG_TOO_MANY_LOCAL_ROOTS);
+ return -1;
+ }
+ lrc = lrs->topChunk;
+ JS_ASSERT(n != 0 || lrc == &lrs->firstChunk);
+ } else {
+ /*
+ * After lrs->firstChunk, trying to index at a power-of-two chunk
+ * boundary: need a new chunk.
+ */
+ lrc = (JSLocalRootChunk *) JS_malloc(cx, sizeof *lrc);
+ if (!lrc)
+ return -1;
+ lrc->down = lrs->topChunk;
+ lrs->topChunk = lrc;
+ }
+ lrs->rootCount = n + 1;
+ lrc->roots[m] = v;
+ return (int) n;
+}
+
+void
+js_MarkLocalRoots(JSContext *cx, JSLocalRootStack *lrs)
+{
+ unsigned n, m, mark;
+ JSLocalRootChunk *lrc;
+
+ n = lrs->rootCount;
+ if (n == 0)
+ return;
+
+ mark = lrs->scopeMark;
+ lrc = lrs->topChunk;
+ do {
+ while (--n > mark) {
+#ifdef GC_MARK_DEBUG
+ char name[22];
+ JS_snprintf(name, sizeof name, "", n);
+#else
+ const char *name = NULL;
+#endif
+ m = n & JSLRS_CHUNK_MASK;
+ JS_ASSERT(JSVAL_IS_GCTHING(lrc->roots[m]));
+ JS_MarkGCThing(cx, JSVAL_TO_GCTHING(lrc->roots[m]), name, NULL);
+ if (m == 0)
+ lrc = lrc->down;
+ }
+ m = n & JSLRS_CHUNK_MASK;
+ mark = JSVAL_TO_INT(lrc->roots[m]);
+ if (m == 0)
+ lrc = lrc->down;
+ } while (n != 0);
+ JS_ASSERT(!lrc);
+}
+
+static void
+ReportError(JSContext *cx, const char *message, JSErrorReport *reportp)
+{
+ /*
+ * Check the error report, and set a JavaScript-catchable exception
+ * if the error is defined to have an associated exception. If an
+ * exception is thrown, then the JSREPORT_EXCEPTION flag will be set
+ * on the error report, and exception-aware hosts should ignore it.
+ */
+ if (reportp && reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
+ reportp->flags |= JSREPORT_EXCEPTION;
+
+#if JS_HAS_ERROR_EXCEPTIONS
+ /*
+ * Call the error reporter only if an exception wasn't raised.
+ *
+ * If an exception was raised, then we call the debugErrorHook
+ * (if present) to give it a chance to see the error before it
+ * propagates out of scope. This is needed for compatability
+ * with the old scheme.
+ */
+ if (!js_ErrorToException(cx, message, reportp)) {
+ js_ReportErrorAgain(cx, message, reportp);
+ } else if (cx->runtime->debugErrorHook && cx->errorReporter) {
+ JSDebugErrorHook hook = cx->runtime->debugErrorHook;
+ /* test local in case debugErrorHook changed on another thread */
+ if (hook)
+ hook(cx, message, reportp, cx->runtime->debugErrorHookData);
+ }
+#else
+ js_ReportErrorAgain(cx, message, reportp);
+#endif
+}
+
+/*
+ * We don't post an exception in this case, since doing so runs into
+ * complications of pre-allocating an exception object which required
+ * running the Exception class initializer early etc.
+ * Instead we just invoke the errorReporter with an "Out Of Memory"
+ * type message, and then hope the process ends swiftly.
+ */
+void
+js_ReportOutOfMemory(JSContext *cx, JSErrorCallback callback)
+{
+ JSStackFrame *fp;
+ JSErrorReport report;
+ JSErrorReporter onError = cx->errorReporter;
+
+ /* Get the message for this error, but we won't expand any arguments. */
+ const JSErrorFormatString *efs = callback(NULL, NULL, JSMSG_OUT_OF_MEMORY);
+ const char *msg = efs ? efs->format : "Out of memory";
+
+ /* Fill out the report, but don't do anything that requires allocation. */
+ memset(&report, 0, sizeof (struct JSErrorReport));
+ report.flags = JSREPORT_ERROR;
+ report.errorNumber = JSMSG_OUT_OF_MEMORY;
+
+ /*
+ * Walk stack until we find a frame that is associated with some script
+ * rather than a native frame.
+ */
+ for (fp = cx->fp; fp; fp = fp->down) {
+ if (fp->script && fp->pc) {
+ report.filename = fp->script->filename;
+ report.lineno = js_PCToLineNumber(cx, fp->script, fp->pc);
+ break;
+ }
+ }
+
+ /*
+ * If debugErrorHook is present then we give it a chance to veto
+ * sending the error on to the regular ErrorReporter.
+ */
+ if (onError) {
+ JSDebugErrorHook hook = cx->runtime->debugErrorHook;
+ if (hook &&
+ !hook(cx, msg, &report, cx->runtime->debugErrorHookData)) {
+ onError = NULL;
+ }
+ }
+
+ if (onError)
+ onError(cx, msg, &report);
+}
+
+JSBool
+js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap)
+{
+ char *last;
+ JSStackFrame *fp;
+ JSErrorReport report;
+ JSBool warning;
+
+ if ((flags & JSREPORT_STRICT) && !JS_HAS_STRICT_OPTION(cx))
+ return JS_TRUE;
+
+ last = JS_vsmprintf(format, ap);
+ if (!last)
+ return JS_FALSE;
+
+ memset(&report, 0, sizeof (struct JSErrorReport));
+ report.flags = flags;
+
+ /* Find the top-most active script frame, for best line number blame. */
+ for (fp = cx->fp; fp; fp = fp->down) {
+ if (fp->script && fp->pc) {
+ report.filename = fp->script->filename;
+ report.lineno = js_PCToLineNumber(cx, fp->script, fp->pc);
+ break;
+ }
+ }
+
+ warning = JSREPORT_IS_WARNING(report.flags);
+ if (warning && JS_HAS_WERROR_OPTION(cx)) {
+ report.flags &= ~JSREPORT_WARNING;
+ warning = JS_FALSE;
+ }
+
+ ReportError(cx, last, &report);
+ free(last);
+ return warning;
+}
+
+/*
+ * The arguments from ap need to be packaged up into an array and stored
+ * into the report struct.
+ *
+ * The format string addressed by the error number may contain operands
+ * identified by the format {N}, where N is a decimal digit. Each of these
+ * is to be replaced by the Nth argument from the va_list. The complete
+ * message is placed into reportp->ucmessage converted to a JSString.
+ *
+ * Returns true if the expansion succeeds (can fail if out of memory).
+ */
+JSBool
+js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
+ void *userRef, const uintN errorNumber,
+ char **messagep, JSErrorReport *reportp,
+ JSBool *warningp, JSBool charArgs, va_list ap)
+{
+ const JSErrorFormatString *efs;
+ int i;
+ int argCount;
+
+ *warningp = JSREPORT_IS_WARNING(reportp->flags);
+ if (*warningp && JS_HAS_WERROR_OPTION(cx)) {
+ reportp->flags &= ~JSREPORT_WARNING;
+ *warningp = JS_FALSE;
+ }
+
+ *messagep = NULL;
+ if (callback) {
+ efs = callback(userRef, NULL, errorNumber);
+ if (efs) {
+ size_t totalArgsLength = 0;
+ size_t argLengths[10]; /* only {0} thru {9} supported */
+ argCount = efs->argCount;
+ JS_ASSERT(argCount <= 10);
+ if (argCount > 0) {
+ /*
+ * Gather the arguments into an array, and accumulate
+ * their sizes. We allocate 1 more than necessary and
+ * null it out to act as the caboose when we free the
+ * pointers later.
+ */
+ reportp->messageArgs = (const jschar **)
+ JS_malloc(cx, sizeof(jschar *) * (argCount + 1));
+ if (!reportp->messageArgs)
+ return JS_FALSE;
+ reportp->messageArgs[argCount] = NULL;
+ for (i = 0; i < argCount; i++) {
+ if (charArgs) {
+ char *charArg = va_arg(ap, char *);
+ reportp->messageArgs[i]
+ = js_InflateString(cx, charArg, strlen(charArg));
+ if (!reportp->messageArgs[i])
+ goto error;
+ }
+ else
+ reportp->messageArgs[i] = va_arg(ap, jschar *);
+ argLengths[i] = js_strlen(reportp->messageArgs[i]);
+ totalArgsLength += argLengths[i];
+ }
+ /* NULL-terminate for easy copying. */
+ reportp->messageArgs[i] = NULL;
+ }
+ /*
+ * Parse the error format, substituting the argument X
+ * for {X} in the format.
+ */
+ if (argCount > 0) {
+ if (efs->format) {
+ const char *fmt;
+ const jschar *arg;
+ jschar *out;
+ int expandedArgs = 0;
+ size_t expandedLength
+ = strlen(efs->format)
+ - (3 * argCount) /* exclude the {n} */
+ + totalArgsLength;
+ /*
+ * Note - the above calculation assumes that each argument
+ * is used once and only once in the expansion !!!
+ */
+ reportp->ucmessage = out = (jschar *)
+ JS_malloc(cx, (expandedLength + 1) * sizeof(jschar));
+ if (!out)
+ goto error;
+ fmt = efs->format;
+ while (*fmt) {
+ if (*fmt == '{') {
+ if (isdigit(fmt[1])) {
+ int d = JS7_UNDEC(fmt[1]);
+ JS_ASSERT(d < argCount);
+ arg = reportp->messageArgs[d];
+ js_strncpy(out, arg, argLengths[d]);
+ out += argLengths[d];
+ fmt += 3;
+ expandedArgs++;
+ continue;
+ }
+ }
+ /*
+ * is this kosher?
+ */
+ *out++ = (unsigned char)(*fmt++);
+ }
+ JS_ASSERT(expandedArgs == argCount);
+ *out = 0;
+ *messagep =
+ js_DeflateString(cx, reportp->ucmessage,
+ (size_t)(out - reportp->ucmessage));
+ if (!*messagep)
+ goto error;
+ }
+ } else {
+ /*
+ * Zero arguments: the format string (if it exists) is the
+ * entire message.
+ */
+ if (efs->format) {
+ *messagep = JS_strdup(cx, efs->format);
+ if (!*messagep)
+ goto error;
+ reportp->ucmessage
+ = js_InflateString(cx, *messagep, strlen(*messagep));
+ if (!reportp->ucmessage)
+ goto error;
+ }
+ }
+ }
+ }
+ if (*messagep == NULL) {
+ /* where's the right place for this ??? */
+ const char *defaultErrorMessage
+ = "No error message available for error number %d";
+ size_t nbytes = strlen(defaultErrorMessage) + 16;
+ *messagep = (char *)JS_malloc(cx, nbytes);
+ if (!*messagep)
+ goto error;
+ JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);
+ }
+ return JS_TRUE;
+
+error:
+ if (reportp->messageArgs) {
+ i = 0;
+ while (reportp->messageArgs[i])
+ JS_free(cx, (void *)reportp->messageArgs[i++]);
+ JS_free(cx, (void *)reportp->messageArgs);
+ reportp->messageArgs = NULL;
+ }
+ if (reportp->ucmessage) {
+ JS_free(cx, (void *)reportp->ucmessage);
+ reportp->ucmessage = NULL;
+ }
+ if (*messagep) {
+ JS_free(cx, (void *)*messagep);
+ *messagep = NULL;
+ }
+ return JS_FALSE;
+}
+
+JSBool
+js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
+ void *userRef, const uintN errorNumber,
+ JSBool charArgs, va_list ap)
+{
+ JSStackFrame *fp;
+ JSErrorReport report;
+ char *message;
+ JSBool warning;
+
+ if ((flags & JSREPORT_STRICT) && !JS_HAS_STRICT_OPTION(cx))
+ return JS_TRUE;
+
+ memset(&report, 0, sizeof (struct JSErrorReport));
+ report.flags = flags;
+ report.errorNumber = errorNumber;
+
+ /*
+ * If we can't find out where the error was based on the current frame,
+ * see if the next frame has a script/pc combo we can use.
+ */
+ for (fp = cx->fp; fp; fp = fp->down) {
+ if (fp->script && fp->pc) {
+ report.filename = fp->script->filename;
+ report.lineno = js_PCToLineNumber(cx, fp->script, fp->pc);
+ break;
+ }
+ }
+
+ if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber,
+ &message, &report, &warning, charArgs, ap)) {
+ return JS_FALSE;
+ }
+
+ ReportError(cx, message, &report);
+
+ if (message)
+ JS_free(cx, message);
+ if (report.messageArgs) {
+ int i = 0;
+ while (report.messageArgs[i])
+ JS_free(cx, (void *)report.messageArgs[i++]);
+ JS_free(cx, (void *)report.messageArgs);
+ }
+ if (report.ucmessage)
+ JS_free(cx, (void *)report.ucmessage);
+
+ return warning;
+}
+
+JS_FRIEND_API(void)
+js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
+{
+ JSErrorReporter onError;
+
+ if (!message)
+ return;
+
+ if (cx->lastMessage)
+ free(cx->lastMessage);
+ cx->lastMessage = JS_strdup(cx, message);
+ if (!cx->lastMessage)
+ return;
+ onError = cx->errorReporter;
+
+ /*
+ * If debugErrorHook is present then we give it a chance to veto
+ * sending the error on to the regular ErrorReporter.
+ */
+ if (onError) {
+ JSDebugErrorHook hook = cx->runtime->debugErrorHook;
+ if (hook &&
+ !hook(cx, cx->lastMessage, reportp,
+ cx->runtime->debugErrorHookData)) {
+ onError = NULL;
+ }
+ }
+ if (onError)
+ onError(cx, cx->lastMessage, reportp);
+}
+
+void
+js_ReportIsNotDefined(JSContext *cx, const char *name)
+{
+ JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_DEFINED, name);
+}
+
+#if defined DEBUG && defined XP_UNIX
+/* For gdb usage. */
+void js_traceon(JSContext *cx) { cx->tracefp = stderr; }
+void js_traceoff(JSContext *cx) { cx->tracefp = NULL; }
+#endif
+
+JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
+#if JS_HAS_DFLT_MSG_STRINGS
+#define MSG_DEF(name, number, count, exception, format) \
+ { format, count } ,
+#else
+#define MSG_DEF(name, number, count, exception, format) \
+ { NULL, count } ,
+#endif
+#include "js.msg"
+#undef MSG_DEF
+};
+
+const JSErrorFormatString *
+js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber)
+{
+ if ((errorNumber > 0) && (errorNumber < JSErr_Limit))
+ return &js_ErrorFormatString[errorNumber];
+ return NULL;
+}
Index: ossp-pkg/js/src/jslong.h
RCS File: /v/ossp/cvs/ossp-pkg/js/src/jslong.h,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/src/jslong.h,v' 2>/dev/null
--- jslong.h 2004/10/05 10:19:07 1.1
+++ jslong.h 2006/07/22 13:48:03 1.2
@@ -51,6 +51,13 @@
JS_BEGIN_EXTERN_C
+#ifdef OSSP
+#define JSLL_MaxInt JS_LL_MaxInt
+#define JSLL_MinInt JS_LL_MinInt
+#define JSLL_Zero JS_LL_Zero
+#define jsll_udivmod js_ll_udivmod
+#endif
+
/***********************************************************************
** DEFINES: JSLL_MaxInt
** JSLL_MinInt
Index: ossp-pkg/js/src/jstypes.h
RCS File: /v/ossp/cvs/ossp-pkg/js/src/jstypes.h,v
co -q -kk -p'1.2' '/v/ossp/cvs/ossp-pkg/js/src/jstypes.h,v' | diff -u /dev/null - -L'ossp-pkg/js/src/jstypes.h' 2>/dev/null
--- ossp-pkg/js/src/jstypes.h
+++ - 2025-05-20 13:19:57.410795933 +0200
@@ -0,0 +1,428 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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 Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * IBM Corp.
+ *
+ * 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 ***** */
+
+/*
+** File: jstypes.h
+** Description: Definitions of NSPR's basic types
+**
+** Prototypes and macros used to make up for deficiencies in ANSI environments
+** that we have found.
+**
+** Since we do not wrap and all the other standard headers, authors
+** of portable code will not know in general that they need these definitions.
+** Instead of requiring these authors to find the dependent uses in their code
+** and take the following steps only in those C files, we take steps once here
+** for all C files.
+**/
+
+#ifndef jstypes_h___
+#define jstypes_h___
+
+#include
+
+#ifdef OSSP
+/* select functionality */
+#define XP_UNIX
+#define NDEBUG
+#define EXPORT_JS_API
+#endif
+
+/***********************************************************************
+** MACROS: JS_EXTERN_API
+** JS_EXPORT_API
+** DESCRIPTION:
+** These are only for externally visible routines and globals. For
+** internal routines, just use "extern" for type checking and that
+** will not export internal cross-file or forward-declared symbols.
+** Define a macro for declaring procedures return types. We use this to
+** deal with windoze specific type hackery for DLL definitions. Use
+** JS_EXTERN_API when the prototype for the method is declared. Use
+** JS_EXPORT_API for the implementation of the method.
+**
+** Example:
+** in dowhim.h
+** JS_EXTERN_API( void ) DoWhatIMean( void );
+** in dowhim.c
+** JS_EXPORT_API( void ) DoWhatIMean( void ) { return; }
+**
+**
+***********************************************************************/
+#ifdef WIN32
+/* These also work for __MWERKS__ */
+#define JS_EXTERN_API(__type) extern __declspec(dllexport) __type
+#define JS_EXPORT_API(__type) __declspec(dllexport) __type
+#define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+#define JS_EXPORT_DATA(__type) __declspec(dllexport) __type
+
+#define JS_DLL_CALLBACK
+#define JS_STATIC_DLL_CALLBACK(__x) static __x
+
+#elif defined(WIN16)
+
+#ifdef _WINDLL
+#define JS_EXTERN_API(__type) extern __type _cdecl _export _loadds
+#define JS_EXPORT_API(__type) __type _cdecl _export _loadds
+#define JS_EXTERN_DATA(__type) extern __type _export
+#define JS_EXPORT_DATA(__type) __type _export
+
+#define JS_DLL_CALLBACK __cdecl __loadds
+#define JS_STATIC_DLL_CALLBACK(__x) static __x CALLBACK
+
+#else /* this must be .EXE */
+#define JS_EXTERN_API(__type) extern __type _cdecl _export
+#define JS_EXPORT_API(__type) __type _cdecl _export
+#define JS_EXTERN_DATA(__type) extern __type _export
+#define JS_EXPORT_DATA(__type) __type _export
+
+#define JS_DLL_CALLBACK __cdecl __loadds
+#define JS_STATIC_DLL_CALLBACK(__x) __x JS_DLL_CALLBACK
+#endif /* _WINDLL */
+
+#else /* Unix */
+
+#ifdef HAVE_VISIBILITY_PRAGMA
+#define JS_EXTERNAL_VIS __attribute__((visibility ("default")))
+#else
+#define JS_EXTERNAL_VIS
+#endif
+
+#define JS_EXTERN_API(__type) extern JS_EXTERNAL_VIS __type
+#define JS_EXPORT_API(__type) JS_EXTERNAL_VIS __type
+#define JS_EXTERN_DATA(__type) extern JS_EXTERNAL_VIS __type
+#define JS_EXPORT_DATA(__type) JS_EXTERNAL_VIS __type
+
+#define JS_DLL_CALLBACK
+#define JS_STATIC_DLL_CALLBACK(__x) static __x
+
+#endif
+
+#ifdef _WIN32
+# if defined(__MWERKS__) || defined(__GNUC__)
+# define JS_IMPORT_API(__x) __x
+# else
+# define JS_IMPORT_API(__x) __declspec(dllimport) __x
+# endif
+#else
+# define JS_IMPORT_API(__x) JS_EXPORT_API (__x)
+#endif
+
+#if defined(_WIN32) && !defined(__MWERKS__)
+# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x
+#else
+# define JS_IMPORT_DATA(__x) JS_EXPORT_DATA (__x)
+#endif
+
+/*
+ * The linkage of JS API functions differs depending on whether the file is
+ * used within the JS library or not. Any source file within the JS
+ * interpreter should define EXPORT_JS_API whereas any client of the library
+ * should not.
+ */
+#ifdef EXPORT_JS_API
+#define JS_PUBLIC_API(t) JS_EXPORT_API(t)
+#define JS_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
+#else
+#define JS_PUBLIC_API(t) JS_IMPORT_API(t)
+#define JS_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
+#endif
+
+#define JS_FRIEND_API(t) JS_PUBLIC_API(t)
+#define JS_FRIEND_DATA(t) JS_PUBLIC_DATA(t)
+
+#ifdef _WIN32
+# define JS_INLINE __inline
+#elif defined(__GNUC__)
+# define JS_INLINE
+#else
+# define JS_INLINE
+#endif
+
+/***********************************************************************
+** MACROS: JS_BEGIN_MACRO
+** JS_END_MACRO
+** DESCRIPTION:
+** Macro body brackets so that macros with compound statement definitions
+** behave syntactically more like functions when called.
+***********************************************************************/
+#define JS_BEGIN_MACRO do {
+#define JS_END_MACRO } while (0)
+
+/***********************************************************************
+** MACROS: JS_BEGIN_EXTERN_C
+** JS_END_EXTERN_C
+** DESCRIPTION:
+** Macro shorthands for conditional C++ extern block delimiters.
+***********************************************************************/
+#ifdef __cplusplus
+#define JS_BEGIN_EXTERN_C extern "C" {
+#define JS_END_EXTERN_C }
+#else
+#define JS_BEGIN_EXTERN_C
+#define JS_END_EXTERN_C
+#endif
+
+/***********************************************************************
+** MACROS: JS_BIT
+** JS_BITMASK
+** DESCRIPTION:
+** Bit masking macros. XXX n must be <= 31 to be portable
+***********************************************************************/
+#define JS_BIT(n) ((JSUint32)1 << (n))
+#define JS_BITMASK(n) (JS_BIT(n) - 1)
+
+/***********************************************************************
+** MACROS: JS_PTR_TO_INT32
+** JS_PTR_TO_UINT32
+** JS_INT32_TO_PTR
+** JS_UINT32_TO_PTR
+** DESCRIPTION:
+** Integer to pointer and pointer to integer conversion macros.
+***********************************************************************/
+#define JS_PTR_TO_INT32(x) ((jsint)((char *)(x) - (char *)0))
+#define JS_PTR_TO_UINT32(x) ((jsuint)((char *)(x) - (char *)0))
+#define JS_INT32_TO_PTR(x) ((void *)((char *)0 + (jsint)(x)))
+#define JS_UINT32_TO_PTR(x) ((void *)((char *)0 + (jsuint)(x)))
+
+/***********************************************************************
+** MACROS: JS_HOWMANY
+** JS_ROUNDUP
+** JS_MIN
+** JS_MAX
+** DESCRIPTION:
+** Commonly used macros for operations on compatible types.
+***********************************************************************/
+#define JS_HOWMANY(x,y) (((x)+(y)-1)/(y))
+#define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y))
+#define JS_MIN(x,y) ((x)<(y)?(x):(y))
+#define JS_MAX(x,y) ((x)>(y)?(x):(y))
+
+#if (defined(XP_WIN) && !defined(CROSS_COMPILE)) || defined (WINCE)
+# include "jscpucfg.h" /* Use standard Mac or Windows configuration */
+#elif defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_OS2) || defined(CROSS_COMPILE)
+# include "jsautocfg.h" /* Use auto-detected configuration */
+# include "jsosdep.h" /* ...and platform-specific flags */
+#else
+# error "Must define one of XP_BEOS, XP_OS2, XP_WIN or XP_UNIX"
+#endif
+
+JS_BEGIN_EXTERN_C
+
+/************************************************************************
+** TYPES: JSUint8
+** JSInt8
+** DESCRIPTION:
+** The int8 types are known to be 8 bits each. There is no type that
+** is equivalent to a plain "char".
+************************************************************************/
+#if JS_BYTES_PER_BYTE == 1
+typedef unsigned char JSUint8;
+typedef signed char JSInt8;
+#else
+#error No suitable type for JSInt8/JSUint8
+#endif
+
+/************************************************************************
+** TYPES: JSUint16
+** JSInt16
+** DESCRIPTION:
+** The int16 types are known to be 16 bits each.
+************************************************************************/
+#if JS_BYTES_PER_SHORT == 2
+typedef unsigned short JSUint16;
+typedef short JSInt16;
+#else
+#error No suitable type for JSInt16/JSUint16
+#endif
+
+/************************************************************************
+** TYPES: JSUint32
+** JSInt32
+** DESCRIPTION:
+** The int32 types are known to be 32 bits each.
+************************************************************************/
+#if JS_BYTES_PER_INT == 4
+typedef unsigned int JSUint32;
+typedef int JSInt32;
+#define JS_INT32(x) x
+#define JS_UINT32(x) x ## U
+#elif JS_BYTES_PER_LONG == 4
+typedef unsigned long JSUint32;
+typedef long JSInt32;
+#define JS_INT32(x) x ## L
+#define JS_UINT32(x) x ## UL
+#else
+#error No suitable type for JSInt32/JSUint32
+#endif
+
+/************************************************************************
+** TYPES: JSUint64
+** JSInt64
+** DESCRIPTION:
+** The int64 types are known to be 64 bits each. Care must be used when
+** declaring variables of type JSUint64 or JSInt64. Different hardware
+** architectures and even different compilers have varying support for
+** 64 bit values. The only guaranteed portability requires the use of
+** the JSLL_ macros (see jslong.h).
+************************************************************************/
+#ifdef JS_HAVE_LONG_LONG
+#if JS_BYTES_PER_LONG == 8
+typedef long JSInt64;
+typedef unsigned long JSUint64;
+#elif defined(WIN16)
+typedef __int64 JSInt64;
+typedef unsigned __int64 JSUint64;
+#elif defined(WIN32) && !defined(__GNUC__)
+typedef __int64 JSInt64;
+typedef unsigned __int64 JSUint64;
+#else
+typedef long long JSInt64;
+typedef unsigned long long JSUint64;
+#endif /* JS_BYTES_PER_LONG == 8 */
+#else /* !JS_HAVE_LONG_LONG */
+typedef struct {
+#ifdef IS_LITTLE_ENDIAN
+ JSUint32 lo, hi;
+#else
+ JSUint32 hi, lo;
+#endif
+} JSInt64;
+typedef JSInt64 JSUint64;
+#endif /* !JS_HAVE_LONG_LONG */
+
+/************************************************************************
+** TYPES: JSUintn
+** JSIntn
+** DESCRIPTION:
+** The JSIntn types are most appropriate for automatic variables. They are
+** guaranteed to be at least 16 bits, though various architectures may
+** define them to be wider (e.g., 32 or even 64 bits). These types are
+** never valid for fields of a structure.
+************************************************************************/
+#if JS_BYTES_PER_INT >= 2
+typedef int JSIntn;
+typedef unsigned int JSUintn;
+#else
+#error 'sizeof(int)' not sufficient for platform use
+#endif
+
+/************************************************************************
+** TYPES: JSFloat64
+** DESCRIPTION:
+** NSPR's floating point type is always 64 bits.
+************************************************************************/
+typedef double JSFloat64;
+
+/************************************************************************
+** TYPES: JSSize
+** DESCRIPTION:
+** A type for representing the size of objects.
+************************************************************************/
+typedef size_t JSSize;
+
+/************************************************************************
+** TYPES: JSPtrDiff
+** DESCRIPTION:
+** A type for pointer difference. Variables of this type are suitable
+** for storing a pointer or pointer sutraction.
+************************************************************************/
+typedef ptrdiff_t JSPtrdiff;
+
+/************************************************************************
+** TYPES: JSUptrdiff
+** DESCRIPTION:
+** A type for pointer difference. Variables of this type are suitable
+** for storing a pointer or pointer sutraction.
+************************************************************************/
+typedef unsigned long JSUptrdiff;
+
+/************************************************************************
+** TYPES: JSBool
+** DESCRIPTION:
+** Use JSBool for variables and parameter types. Use JS_FALSE and JS_TRUE
+** for clarity of target type in assignments and actual arguments. Use
+** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
+** just as you would C int-valued conditions.
+************************************************************************/
+typedef JSIntn JSBool;
+#define JS_TRUE (JSIntn)1
+#define JS_FALSE (JSIntn)0
+
+/************************************************************************
+** TYPES: JSPackedBool
+** DESCRIPTION:
+** Use JSPackedBool within structs where bitfields are not desireable
+** but minimum and consistant overhead matters.
+************************************************************************/
+typedef JSUint8 JSPackedBool;
+
+/*
+** A JSWord is an integer that is the same size as a void*
+*/
+typedef long JSWord;
+typedef unsigned long JSUword;
+
+#include "jsotypes.h"
+
+/***********************************************************************
+** MACROS: JS_LIKELY
+** JS_UNLIKELY
+** DESCRIPTION:
+** These macros allow you to give a hint to the compiler about branch
+** probability so that it can better optimize. Use them like this:
+**
+** if (JS_LIKELY(v == 1)) {
+** ... expected code path ...
+** }
+**
+** if (JS_UNLIKELY(v == 0)) {
+** ... non-expected code path ...
+** }
+**
+***********************************************************************/
+#if defined(__GNUC__) && (__GNUC__ > 2)
+#define JS_LIKELY(x) (__builtin_expect((x), 1))
+#define JS_UNLIKELY(x) (__builtin_expect((x), 0))
+#else
+#define JS_LIKELY(x) (x)
+#define JS_UNLIKELY(x) (x)
+#endif
+
+JS_END_EXTERN_C
+
+#endif /* jstypes_h___ */
Index: ossp-pkg/js/src/prmjtime.h
RCS File: /v/ossp/cvs/ossp-pkg/js/src/prmjtime.h,v
rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/js/src/prmjtime.h,v' 2>/dev/null
--- prmjtime.h 2004/12/09 01:32:19 1.1
+++ prmjtime.h 2006/07/22 13:48:03 1.2
@@ -49,6 +49,14 @@
#include "jscompat.h"
#endif
+#ifdef OSSP
+/* avoid namespace pollution */
+#define PRMJ_Now js_PRMJ_Now
+#define PRMJ_LocalGMTDifference js_PRMJ_LocalGMTDifference
+#define PRMJ_FormatTime js_PRMJ_FormatTime
+#define PRMJ_DSTOffset js_PRMJ_DSTOffset
+#endif
+
JS_BEGIN_EXTERN_C
typedef struct PRMJTime PRMJTime;