From 2b7077ca705a60216586ef49850c69364431adca Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 13 Jan 2024 13:04:19 +0000 Subject: [PATCH] quickjs-2024-01-13.tar.xz git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4765 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- deps/quickjs/Changelog | 19 + deps/quickjs/Makefile | 83 +- deps/quickjs/TODO | 5 +- deps/quickjs/VERSION | 2 +- deps/quickjs/cutils.h | 3 + deps/quickjs/doc/quickjs.html | 61 +- deps/quickjs/doc/quickjs.pdf | Bin 166097 -> 167595 bytes deps/quickjs/doc/quickjs.texi | 53 +- deps/quickjs/libbf.h | 2 +- deps/quickjs/libregexp-opcode.h | 3 +- deps/quickjs/libregexp.c | 170 +- deps/quickjs/libregexp.h | 1 + deps/quickjs/libunicode-table.h | 124 +- deps/quickjs/libunicode.c | 386 ++- deps/quickjs/libunicode.h | 3 + deps/quickjs/list.h | 3 +- deps/quickjs/qjs.c | 21 +- deps/quickjs/qjsc.c | 5 +- deps/quickjs/quickjs-atom.h | 6 +- deps/quickjs/quickjs-libc.c | 74 +- deps/quickjs/quickjs-opcode.h | 11 +- deps/quickjs/quickjs.c | 3578 ++++++++++++++++------ deps/quickjs/quickjs.h | 15 +- deps/quickjs/release.sh | 26 +- deps/quickjs/repl.js | 116 +- deps/quickjs/run-test262.c | 64 +- deps/quickjs/test262.conf | 20 +- deps/quickjs/test262_errors.txt | 37 +- deps/quickjs/tests/microbench.js | 20 +- deps/quickjs/tests/test_builtin.js | 30 +- deps/quickjs/tests/test_language.js | 59 + deps/quickjs/tests/test_loop.js | 24 + deps/quickjs/tests/test_std.js | 23 + deps/quickjs/tests/test_worker_module.js | 1 + deps/quickjs/unicode_gen.c | 204 +- 35 files changed, 3799 insertions(+), 1453 deletions(-) diff --git a/deps/quickjs/Changelog b/deps/quickjs/Changelog index 0ced9956..944d96ac 100644 --- a/deps/quickjs/Changelog +++ b/deps/quickjs/Changelog @@ -1,3 +1,22 @@ +2024-01-13: + +- top-level-await support in modules +- allow 'await' in the REPL +- added Array.prototype.{with,toReversed,toSpliced,toSorted} and +TypedArray.prototype.{with,toReversed,toSorted} +- added String.prototype.isWellFormed and String.prototype.toWellFormed +- added Object.groupBy and Map.groupBy +- added Promise.withResolvers +- class static block +- 'in' operator support for private fields +- optional chaining fixes +- added RegExp 'd' flag +- fixed RegExp zero length match logic +- fixed RegExp case insensitive flag +- added os.getpid() and os.now() +- added cosmopolitan build +- misc bug fixes + 2023-12-09: - added Object.hasOwn, {String|Array|TypedArray}.prototype.at, diff --git a/deps/quickjs/Makefile b/deps/quickjs/Makefile index 39bd3ad6..57cdd7ef 100644 --- a/deps/quickjs/Makefile +++ b/deps/quickjs/Makefile @@ -33,15 +33,11 @@ CONFIG_LTO=y #CONFIG_WERROR=y # force 32 bit build for some utilities #CONFIG_M32=y - -ifdef CONFIG_DARWIN -# use clang instead of gcc -CONFIG_CLANG=y -CONFIG_DEFAULT_AR=y -endif +# cosmopolitan build (see https://github.com/jart/cosmopolitan) +#CONFIG_COSMO=y # installation directory -prefix=/usr/local +PREFIX?=/usr/local # use the gprof profiler #CONFIG_PROFILE=y @@ -52,21 +48,28 @@ CONFIG_BIGNUM=y OBJDIR=.obj +ifdef CONFIG_DARWIN +# use clang instead of gcc +CONFIG_CLANG=y +CONFIG_DEFAULT_AR=y +endif + ifdef CONFIG_WIN32 ifdef CONFIG_M32 - CROSS_PREFIX=i686-w64-mingw32- + CROSS_PREFIX?=i686-w64-mingw32- else - CROSS_PREFIX=x86_64-w64-mingw32- + CROSS_PREFIX?=x86_64-w64-mingw32- endif EXE=.exe else - CROSS_PREFIX= + CROSS_PREFIX?= EXE= endif + ifdef CONFIG_CLANG HOST_CC=clang CC=$(CROSS_PREFIX)clang - CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d + CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d CFLAGS += -Wextra CFLAGS += -Wno-sign-compare CFLAGS += -Wno-missing-field-initializers @@ -84,10 +87,18 @@ ifdef CONFIG_CLANG AR=$(CROSS_PREFIX)ar endif endif +else ifdef CONFIG_COSMO + CONFIG_LTO= + HOST_CC=gcc + CC=cosmocc + # cosmocc does not correct support -MF + CFLAGS=-g -Wall #-MMD -MF $(OBJDIR)/$(@F).d + CFLAGS += -Wno-array-bounds -Wno-format-truncation + AR=cosmoar else HOST_CC=gcc CC=$(CROSS_PREFIX)gcc - CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d + CFLAGS+=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d CFLAGS += -Wno-array-bounds -Wno-format-truncation ifdef CONFIG_LTO AR=$(CROSS_PREFIX)gcc-ar @@ -96,6 +107,7 @@ else endif endif STRIP=$(CROSS_PREFIX)strip +CFLAGS+=-fwrapv # ensure that signed overflows behave as expected ifdef CONFIG_WERROR CFLAGS+=-Werror endif @@ -112,7 +124,11 @@ CFLAGS_DEBUG=$(CFLAGS) -O0 CFLAGS_SMALL=$(CFLAGS) -Os CFLAGS_OPT=$(CFLAGS) -O2 CFLAGS_NOLTO:=$(CFLAGS_OPT) -LDFLAGS=-g +ifdef CONFIG_COSMO +LDFLAGS+=-s # better to strip by default +else +LDFLAGS+=-g +endif ifdef CONFIG_LTO CFLAGS_SMALL+=-flto CFLAGS_OPT+=-flto @@ -132,6 +148,12 @@ else LDEXPORT=-rdynamic endif +ifndef CONFIG_COSMO +ifndef CONFIG_DARWIN +CONFIG_SHARED_LIBS=y # building shared libraries is supported +endif +endif + PROGS=qjs$(EXE) qjsc$(EXE) run-test262 ifneq ($(CROSS_PREFIX),) QJSC_CC=gcc @@ -154,13 +176,12 @@ endif # examples ifeq ($(CROSS_PREFIX),) -ifdef CONFIG_ASAN -PROGS+= -else -PROGS+=examples/hello examples/hello_module examples/test_fib -ifndef CONFIG_DARWIN -PROGS+=examples/fib.so examples/point.so +PROGS+=examples/hello +ifndef CONFIG_ASAN +PROGS+=examples/hello_module endif +ifdef CONFIG_SHARED_LIBS +PROGS+=examples/test_fib examples/fib.so examples/point.so endif endif @@ -200,11 +221,11 @@ $(QJSC): $(OBJDIR)/qjsc.host.o \ endif #CROSS_PREFIX -QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(prefix)\" +QJSC_DEFINES:=-DCONFIG_CC=\"$(QJSC_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" ifdef CONFIG_LTO QJSC_DEFINES+=-DCONFIG_LTO endif -QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(prefix)\" +QJSC_HOST_DEFINES:=-DCONFIG_CC=\"$(HOST_CC)\" -DCONFIG_PREFIX=\"$(PREFIX)\" $(OBJDIR)/qjsc.o: CFLAGS+=$(QJSC_DEFINES) $(OBJDIR)/qjsc.host.o: CFLAGS+=$(QJSC_HOST_DEFINES) @@ -297,17 +318,17 @@ clean: rm -rf run-test262-debug run-test262-32 install: all - mkdir -p "$(DESTDIR)$(prefix)/bin" + mkdir -p "$(DESTDIR)$(PREFIX)/bin" $(STRIP) qjs qjsc - install -m755 qjs qjsc "$(DESTDIR)$(prefix)/bin" - ln -sf qjs "$(DESTDIR)$(prefix)/bin/qjscalc" - mkdir -p "$(DESTDIR)$(prefix)/lib/quickjs" - install -m644 libquickjs.a "$(DESTDIR)$(prefix)/lib/quickjs" + install -m755 qjs qjsc "$(DESTDIR)$(PREFIX)/bin" + ln -sf qjs "$(DESTDIR)$(PREFIX)/bin/qjscalc" + mkdir -p "$(DESTDIR)$(PREFIX)/lib/quickjs" + install -m644 libquickjs.a "$(DESTDIR)$(PREFIX)/lib/quickjs" ifdef CONFIG_LTO - install -m644 libquickjs.lto.a "$(DESTDIR)$(prefix)/lib/quickjs" + install -m644 libquickjs.lto.a "$(DESTDIR)$(PREFIX)/lib/quickjs" endif - mkdir -p "$(DESTDIR)$(prefix)/include/quickjs" - install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(prefix)/include/quickjs" + mkdir -p "$(DESTDIR)$(PREFIX)/include/quickjs" + install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(PREFIX)/include/quickjs" ############################################################################### # examples @@ -373,7 +394,7 @@ doc/%.html: doc/%.html.pre ############################################################################### # tests -ifndef CONFIG_DARWIN +ifdef CONFIG_SHARED_LIBS test: tests/bjson.so examples/point.so endif ifdef CONFIG_M32 @@ -387,7 +408,7 @@ test: qjs ./qjs tests/test_loop.js ./qjs tests/test_std.js ./qjs tests/test_worker.js -ifndef CONFIG_DARWIN +ifdef CONFIG_SHARED_LIBS ifdef CONFIG_BIGNUM ./qjs --bignum tests/test_bjson.js else diff --git a/deps/quickjs/TODO b/deps/quickjs/TODO index 2722ab07..bbd1a450 100644 --- a/deps/quickjs/TODO +++ b/deps/quickjs/TODO @@ -1,6 +1,3 @@ -Bugs: -- modules: better error handling with cyclic module references - Misc ideas: - use custom printf to avoid compatibility issues with floating point numbers - consistent naming for preprocessor defines @@ -66,5 +63,5 @@ Optimization ideas: Test262o: 0/11262 errors, 463 excluded Test262o commit: 7da91bceb9ce7613f87db47ddd1292a2dda58b42 (es5-tests branch) -Result: 41/76133 errors, 1497 excluded, 8650 skipped +Result: 10/76947 errors, 1497 excluded, 8117 skipped Test262 commit: 6cbb6da9473c56d95358d8e679c5a6d2b4574efb diff --git a/deps/quickjs/VERSION b/deps/quickjs/VERSION index 08d12220..e89de35f 100644 --- a/deps/quickjs/VERSION +++ b/deps/quickjs/VERSION @@ -1 +1 @@ -2023-12-09 +2024-01-13 diff --git a/deps/quickjs/cutils.h b/deps/quickjs/cutils.h index 31f7cd84..8399d614 100644 --- a/deps/quickjs/cutils.h +++ b/deps/quickjs/cutils.h @@ -49,6 +49,9 @@ #define countof(x) (sizeof(x) / sizeof((x)[0])) #endif +/* return the pointer of type 'type *' containing 'ptr' as field 'member' */ +#define container_of(ptr, type, member) ((type *)((uint8_t *)(ptr) - offsetof(type, member))) + typedef int BOOL; #ifndef FALSE diff --git a/deps/quickjs/doc/quickjs.html b/deps/quickjs/doc/quickjs.html index cd07ed7e..1ac9c547 100644 --- a/deps/quickjs/doc/quickjs.html +++ b/deps/quickjs/doc/quickjs.html @@ -72,7 +72,7 @@ ul.no-bullet {list-style: none}