Remove CONFIG_BIGNUM, always enable BigInt (#34)

Fixes: https://github.com/quickjs-ng/quickjs/issues/17
This commit is contained in:
Ben Noordhuis 2023-11-10 16:09:54 +01:00 committed by GitHub
parent 3c144fd553
commit 38f88c0898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 702 deletions

View file

@ -45,6 +45,7 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE)
set(qjs_sources
cutils.c
libbf.c
libregexp.c
libunicode.c
quickjs.c
@ -55,12 +56,6 @@ list(APPEND qjs_defines _GNU_SOURCE)
file(STRINGS "VERSION" QJS_VERSION_STR)
list(APPEND qjs_defines CONFIG_VERSION="${QJS_VERSION_STR}")
option(CONFIG_BIGNUM "Enable BigNum extensions" ON)
if(CONFIG_BIGNUM)
list(APPEND qjs_defines CONFIG_BIGNUM=1)
list(APPEND qjs_sources libbf.c)
endif()
add_library(qjs STATIC ${qjs_sources})
target_compile_definitions(qjs PUBLIC
QJS_VERSION_STR="${QJS_VERSION_STR}"

View file

@ -54,8 +54,6 @@ prefix=/usr/local
#CONFIG_MSAN=y
# use UB sanitizer
#CONFIG_UBSAN=y
# include the code for BigInt
CONFIG_BIGNUM=y
OBJDIR=.obj
@ -115,9 +113,6 @@ ifdef CONFIG_WERROR
CFLAGS+=-Werror
endif
DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\"
ifdef CONFIG_BIGNUM
DEFINES+=-DCONFIG_BIGNUM
endif
ifdef CONFIG_WIN32
DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior
endif
@ -198,9 +193,7 @@ all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o
QJS_OBJS=$(OBJDIR)/qjs.o $(OBJDIR)/repl.o $(QJS_LIB_OBJS)
ifdef CONFIG_BIGNUM
QJS_LIB_OBJS+=$(OBJDIR)/libbf.o
endif
HOST_LIBS=-lm -ldl -lpthread
LIBS=-lm
@ -341,9 +334,6 @@ HELLO_SRCS=examples/hello.js
HELLO_OPTS=-fno-string-normalize -fno-map -fno-promise -fno-typedarray \
-fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy \
-fno-date -fno-module-loader
ifdef CONFIG_BIGNUM
HELLO_OPTS+=-fno-bigint
endif
hello.c: $(QJSC) $(HELLO_SRCS)
$(QJSC) -e $(HELLO_OPTS) -o $@ $(HELLO_SRCS)
@ -425,9 +415,7 @@ ifndef CONFIG_DARWIN
./qjs examples/test_point.js
endif
endif
ifdef CONFIG_BIGNUM
./qjs tests/test_bignum.js
endif
./qjs tests/test_bigint.js
ifdef CONFIG_M32
./qjs32 tests/test_closure.js
./qjs32 tests/test_language.js
@ -435,9 +423,7 @@ ifdef CONFIG_M32
./qjs32 tests/test_loop.js
./qjs32 tests/test_std.js
./qjs32 tests/test_worker.js
ifdef CONFIG_BIGNUM
./qjs32 tests/test_bignum.js
endif
./qjs32 tests/test_bigint.js
endif
stats: qjs qjs32

2
qjsc.c
View file

@ -76,9 +76,7 @@ static const FeatureEntry feature_list[] = {
{ "promise", "Promise" },
#define FE_MODULE_LOADER 9
{ "module-loader", NULL },
#ifdef CONFIG_BIGNUM
{ "bigint", "BigInt" },
#endif
};
void namelist_add(namelist_t *lp, const char *name, const char *short_name,

View file

@ -169,9 +169,7 @@ DEF(groups, "groups")
DEF(status, "status")
DEF(reason, "reason")
DEF(globalThis, "globalThis")
#ifdef CONFIG_BIGNUM
DEF(bigint, "bigint")
#endif
#ifdef CONFIG_ATOMICS
DEF(not_equal, "not-equal")
DEF(timed_out, "timed-out")
@ -204,16 +202,12 @@ DEF(Int16Array, "Int16Array")
DEF(Uint16Array, "Uint16Array")
DEF(Int32Array, "Int32Array")
DEF(Uint32Array, "Uint32Array")
#ifdef CONFIG_BIGNUM
DEF(BigInt64Array, "BigInt64Array")
DEF(BigUint64Array, "BigUint64Array")
#endif
DEF(Float32Array, "Float32Array")
DEF(Float64Array, "Float64Array")
DEF(DataView, "DataView")
#ifdef CONFIG_BIGNUM
DEF(BigInt, "BigInt")
#endif
DEF(Map, "Map")
DEF(Set, "Set") /* Map + 1 */
DEF(WeakMap, "WeakMap") /* Map + 2 */

View file

@ -233,15 +233,20 @@ DEF( typeof, 1, 1, 1, none)
DEF( delete, 1, 2, 1, none)
DEF( delete_var, 5, 0, 1, atom)
/* warning: order matters (see js_parse_assign_expr) */
DEF( mul, 1, 2, 1, none)
DEF( div, 1, 2, 1, none)
DEF( mod, 1, 2, 1, none)
DEF( add, 1, 2, 1, none)
DEF( sub, 1, 2, 1, none)
DEF( pow, 1, 2, 1, none)
DEF( shl, 1, 2, 1, none)
DEF( sar, 1, 2, 1, none)
DEF( shr, 1, 2, 1, none)
DEF( and, 1, 2, 1, none)
DEF( xor, 1, 2, 1, none)
DEF( or, 1, 2, 1, none)
DEF( pow, 1, 2, 1, none)
DEF( lt, 1, 2, 1, none)
DEF( lte, 1, 2, 1, none)
DEF( gt, 1, 2, 1, none)
@ -252,9 +257,6 @@ DEF( eq, 1, 2, 1, none)
DEF( neq, 1, 2, 1, none)
DEF( strict_eq, 1, 2, 1, none)
DEF( strict_neq, 1, 2, 1, none)
DEF( and, 1, 2, 1, none)
DEF( xor, 1, 2, 1, none)
DEF( or, 1, 2, 1, none)
DEF(is_undefined_or_null, 1, 1, 1, none)
/* must be the last non short and non temporary opcode */
DEF( nop, 1, 0, 0, none)

711
quickjs.c

File diff suppressed because it is too large Load diff