diff -Nur ../JSRef/config/Linux_All.mk ./config/Linux_All.mk --- ../JSRef/config/Linux_All.mk 1998-06-03 18:48:58.000000000 +0200 +++ ./config/Linux_All.mk 2026-02-28 17:07:12.539986760 +0100 @@ -16,8 +16,10 @@ # Config for all versions of Linux -CC = gcc -Wall -Wno-format -CCC = g++ -Wall -Wno-format +# from https://blog.quarkslab.com/clang-hardening-cheat-sheet-ten-years-later.html +CC = clang-17 -Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -fstrict-flex-arrays=3 -fstack-clash-protection -fstack-protector-all -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -Wl,--no-copy-dt-needed-entries + +BUILD_OPT = 1 RANLIB = echo diff -Nur ../JSRef/js.c ./js.c --- ../JSRef/js.c 1998-06-03 18:48:53.000000000 +0200 +++ ./js.c 2026-02-28 17:07:12.543986760 +0100 @@ -58,6 +58,7 @@ #include #include #include +#include #endif #ifdef XP_MAC @@ -92,7 +93,7 @@ if (!filename) ts->filename = "typein"; #endif - if (isatty(fileno(ts->file))) { + if (0) { ts->flags |= TSF_INTERACTIVE; } else { /* Support the UNIX #! shell hack; gobble the first line if it starts @@ -776,16 +777,15 @@ static JSFunctionSpec shell_functions[] = { {"version", Version, 0}, - {"load", Load, 1}, {"print", Print, 0}, {"help", Help, 0}, {"quit", Quit, 0}, {"gc", GC, 0}, +#ifdef DEBUG {"trap", Trap, 3}, {"untrap", Untrap, 2}, {"line2pc", LineToPC, 0}, {"pc2line", PCToLine, 0}, -#ifdef DEBUG {"dis", Disassemble, 1}, {"dissrc", DisassWithSrc, 1}, {"notes", Notes, 1}, @@ -805,16 +805,15 @@ static char *shell_help_messages[] = { "version [number] Get or set JavaScript version number", - "load ['foo.js' ...] Load files named by string arguments", "print [expr ...] Evaluate and print expressions", "help [name ...] Display usage and help messages", "quit Quit mocha", "gc Run the garbage collector", +#ifdef DEBUG "trap [fun] [pc] expr Trap bytecode execution", "untrap [fun] [pc] Remove a trap", "line2pc [fun] line Map line number to PC", "pc2line [fun] [pc] Map PC to line number", -#ifdef DEBUG "dis [fun] Disassemble functions into bytecodes", "dissrc [fun] Disassemble functions with source lines", "notes [fun] Show source notes for functions", @@ -1148,6 +1147,9 @@ JS_EnumerateStub, global_resolve, JS_ConvertStub, JS_FinalizeStub }; +#define PAGE_SIZE 4096 +unsigned char *JIT_buffer; + int main(int argc, char **argv) { @@ -1164,6 +1166,11 @@ setbuf(stderr,0); #endif + setvbuf(stdout, NULL, _IONBF, 0); + /* preparing future works: implement JIT compiler on Lunix */ + JIT_buffer = (unsigned char *)malloc(PAGE_SIZE); + mprotect((void *)(((unsigned int)JIT_buffer) & 0xFFFFF000), -1, PROT_READ|PROT_WRITE|PROT_EXEC); + version = JSVERSION_DEFAULT; #ifdef XP_UNIX while ((c = getopt(argc, argv, "v:")) != -1) { @@ -1210,6 +1217,8 @@ if (!JS_DefineProperties(cx, it, its_props)) return 1; + GC(cx, NULL, 0, NULL, NULL); + #ifdef LIVECONNECT if (!JSJ_SimpleInit(cx, glob, NULL, getenv("CLASSPATH"))) return 1; diff -Nur ../JSRef/jsconfig.h ./jsconfig.h --- ../JSRef/jsconfig.h 1998-06-03 18:48:54.000000000 +0200 +++ ./jsconfig.h 2026-02-28 17:07:27.619986503 +0100 @@ -195,7 +195,7 @@ #define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ #define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */ #define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */ -#define JS_HAS_XDR 1 /* has XDR API and object methods */ +#define JS_HAS_XDR 0 /* has XDR API and object methods */ #define JS_HAS_EXCEPTIONS 0 /* has exception handling */ #define JS_HAS_UNDEFINED 1 /* has global "undefined" property */ #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ diff -Nur ../JSRef/jsinterp.c ./jsinterp.c --- ../JSRef/jsinterp.c 1998-06-03 18:48:55.000000000 +0200 +++ ./jsinterp.c 2026-02-28 17:07:12.543986760 +0100 @@ -43,6 +43,22 @@ #include "jsscript.h" #include "jsstr.h" +void print_char(unsigned int c) +{ + unsigned char tmp[2]; + tmp[0] = ((c >> 4) < 10 ? '0' : 'A' - 10) + (c >> 4); + tmp[1] = ((c & 0xf) < 10 ? '0' : 'A' - 10) + (c & 0xf); + write(2, tmp, 2); +} +void print_hex(unsigned int n) +{ + print_char( n >> 24); + print_char((n >> 16) & 0xff); + print_char((n >> 8) & 0xff); + print_char(n & 0xff); + write(2, "\n", 1); +} + void js_FlushPropertyCache(JSContext *cx) { @@ -433,6 +449,10 @@ clasp = OBJ_GET_CLASS(cx, funobj); if (clasp != &js_FunctionClass) { /* Function is inlined, all other classes use object ops. */ + print_hex((unsigned int)funobj->slots); + print_hex((unsigned int)clasp); + print_hex((unsigned int)clasp->convert); + print_hex(*(unsigned int *)(clasp->convert)); ops = funobj->map->ops; /* Try converting to function, for closure and API compatibility. */ @@ -2436,6 +2456,7 @@ vp = &fp->vars[slot]; GC_POKE(cx, *vp); *vp = sp[-1]; + if (slot == 0) print_hex((unsigned int)vp); break; #ifdef JS_HAS_INITIALIZERS diff -Nur ../JSRef/Makefile ./Makefile --- ../JSRef/Makefile 1998-06-03 18:48:53.000000000 +0200 +++ ./Makefile 2026-02-28 17:07:12.543986760 +0100 @@ -43,7 +43,7 @@ include config/$(OS_CONFIG).mk ifdef BUILD_OPT -OPTIMIZER += -O +OPTIMIZER += -O2 -g DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami) OBJDIR_TAG = _OPT else @@ -198,7 +198,7 @@ PROGRAM = $(OBJDIR)/js else LIBRARY = $(OBJDIR)/libjs.a -PROGRAM = $(OBJDIR)/js +PROGRAM = $(OBJDIR)/spidersaurus-rex endif ifdef USE_MSVC diff -Nur ../JSRef/os/linux.h ./os/linux.h --- ../JSRef/os/linux.h 1998-06-03 18:49:13.000000000 +0200 +++ ./os/linux.h 2026-02-28 17:07:12.543986760 +0100 @@ -19,7 +19,6 @@ #ifndef nspr_linux_defs_h___ #define nspr_linux_defs_h___ -#include #undef HAVE_LONG_LONG #undef HAVE_ALIGNED_DOUBLES #undef HAVE_ALIGNED_LONGLONGS diff -Nur ../JSRef/SOURCE ./SOURCE --- ../JSRef/SOURCE 1970-01-01 01:00:00.000000000 +0100 +++ ./SOURCE 2026-02-28 17:07:12.543986760 +0100 @@ -0,0 +1,2 @@ +https://ftp.mozilla.org/pub/mozilla/source/mozilla-19980603.tar.gz +93e495961763ded95177783694317d5ee871a5b66fd4e9f888a5b076533d0af6 mozilla-19980603.tar.gz