Skip to content

Commit

Permalink
Remove CONFIG_BIGNUM, always enable BigInt (#34)
Browse files Browse the repository at this point in the history
Fixes: #17
  • Loading branch information
bnoordhuis authored Nov 10, 2023
1 parent 3c144fd commit 38f88c0
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 702 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE)

set(qjs_sources
cutils.c
libbf.c
libregexp.c
libunicode.c
quickjs.c
Expand All @@ -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}"
Expand Down
18 changes: 2 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -425,19 +415,15 @@ 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
./qjs32 tests/test_builtin.js
./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
Expand Down
2 changes: 0 additions & 2 deletions qjsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions quickjs-atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 6 additions & 4 deletions quickjs-opcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 38f88c0

Please sign in to comment.