Skip to content

Commit

Permalink
Update to the latest quickjs-ng and pin commit to fix vs2022 build ##…
Browse files Browse the repository at this point in the history
…r2js
  • Loading branch information
trufae authored Nov 18, 2024
1 parent 8da0782 commit a33b03e
Show file tree
Hide file tree
Showing 13 changed files with 59,899 additions and 2,039 deletions.
4 changes: 4 additions & 0 deletions shlr/qjs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include deps.mk
QJS_BRANCH?=quickjs-ng
USE_MINIFY=0
USE_UGLIFY=0
QJS_COMMIT=55b67a6591071b2ada8895a7000e0fec5f348016

ifeq ($(QJS_BRANCH),frida)
QJS_NAME=quickjs-frida
Expand Down Expand Up @@ -178,6 +179,9 @@ lang_qjs.${EXT_SO}: src js_repl.c js_require.c

$(QJS_NAME):
git clone $(QJS_GITURL) $(QJS_NAME)
ifeq ($(QJS_BRANCH),quickjs-ng)
cd $(QJS_NAME) && git reset --hard $(QJS_COMMIT)
endif

o:
make clean && make && make user-install
14 changes: 13 additions & 1 deletion shlr/qjs/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ distclean:
stats: $(QJS)
$(QJS) -qd

# effectively .PHONY because it doesn't generate output
ctest: CFLAGS=-std=c11 -fsyntax-only -Wall -Wextra -Werror -pedantic
ctest: ctest.c quickjs.h
$(CC) $(CFLAGS) -DJS_NAN_BOXING=0 $<
$(CC) $(CFLAGS) -DJS_NAN_BOXING=1 $<

# effectively .PHONY because it doesn't generate output
cxxtest: CXXFLAGS=-std=c++11 -fsyntax-only -Wall -Wextra -Werror -pedantic
cxxtest: cxxtest.cc quickjs.h
$(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=0 $<
$(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=1 $<

test: $(QJS)
$(RUN262) -c tests.conf

Expand Down Expand Up @@ -110,4 +122,4 @@ unicode_gen: $(BUILD_DIR)
libunicode-table.h: unicode_gen
$(BUILD_DIR)/unicode_gen unicode $@

.PHONY: all debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC)
.PHONY: all ctest cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC)
2 changes: 1 addition & 1 deletion shlr/qjs/src/cutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
va_start(ap, fmt);
len = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (len < sizeof(buf)) {
if (len < (int)sizeof(buf)) {
/* fast case */
return dbuf_put(s, (uint8_t *)buf, len);
} else {
Expand Down
8 changes: 8 additions & 0 deletions shlr/qjs/src/cutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ extern "C" {
#include <pthread.h>
#endif

#if defined(__SANITIZE_ADDRESS__)
# define __ASAN__ 1
#elif defined(__has_feature)
# if __has_feature(address_sanitizer)
# define __ASAN__ 1
# endif
#endif

#if defined(_MSC_VER) && !defined(__clang__)
# define likely(x) (x)
# define unlikely(x) (x)
Expand Down
3,366 changes: 1,771 additions & 1,595 deletions shlr/qjs/src/libunicode-table.h

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions shlr/qjs/src/libunicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "libunicode.h"
#include "libunicode-table.h"

// note: stored as 4 bit tag, not much room left
enum {
RUN_TYPE_U,
RUN_TYPE_L,
Expand Down Expand Up @@ -544,6 +545,13 @@ BOOL lre_is_id_continue(uint32_t c)
sizeof(unicode_prop_ID_Continue1_index) / 3);
}

BOOL lre_is_white_space(uint32_t c)
{
return lre_is_in_table(c, unicode_prop_White_Space_table,
unicode_prop_White_Space_index,
sizeof(unicode_prop_White_Space_index) / 3);
}

#define UNICODE_DECOMP_LEN_MAX 18

typedef enum {
Expand Down
1 change: 1 addition & 0 deletions shlr/qjs/src/libunicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int cr_regexp_canonicalize(CharRange *cr, BOOL is_unicode);

LRE_BOOL lre_is_id_start(uint32_t c);
LRE_BOOL lre_is_id_continue(uint32_t c);
LRE_BOOL lre_is_white_space(uint32_t c);

int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
UnicodeNormalizationEnum n_type,
Expand Down
3 changes: 3 additions & 0 deletions shlr/qjs/src/quickjs-atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ DEF(not_equal, "not-equal")
DEF(timed_out, "timed-out")
DEF(ok, "ok")
DEF(toJSON, "toJSON")
DEF(maxByteLength, "maxByteLength")
/* class names */
DEF(Object, "Object")
DEF(Array, "Array")
Expand Down Expand Up @@ -216,6 +217,8 @@ DEF(Set, "Set") /* Map + 1 */
DEF(WeakMap, "WeakMap") /* Map + 2 */
DEF(WeakSet, "WeakSet") /* Map + 3 */
DEF(Iterator, "Iterator")
DEF(IteratorHelper, "Iterator Helper")
DEF(IteratorWrap, "Iterator Wrap")
DEF(Map_Iterator, "Map Iterator")
DEF(Set_Iterator, "Set Iterator")
DEF(Array_Iterator, "Array Iterator")
Expand Down
Loading

0 comments on commit a33b03e

Please sign in to comment.