Update to the latest quickjs-ng and pin commit to fix vs2022 build ##r2js

This commit is contained in:
pancake 2024-11-18 12:00:00 +01:00 committed by GitHub
parent 8da078247f
commit a33b03e8ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 59900 additions and 2040 deletions

View File

@ -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
@ -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

View File

@ -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
@ -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)

View File

@ -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 {

View File

@ -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)

File diff suppressed because it is too large Load Diff

View File

@ -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,
@ -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 {

View File

@ -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,

View File

@ -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")
@ -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")

File diff suppressed because it is too large Load Diff

56162
shlr/qjs/src/quickjs.c-e Normal file

File diff suppressed because it is too large Load Diff

View File

@ -61,9 +61,11 @@ typedef uint32_t JSAtom;
- string contents is either pure ASCII or is UTF-8 encoded.
*/
/* Overridable purely for testing purposes; don't touch. */
#ifndef JS_NAN_BOXING
#if INTPTR_MAX < INT64_MAX
/* Use NAN boxing for 32bit builds. */
#define JS_NAN_BOXING
#define JS_NAN_BOXING 1 /* Use NAN boxing for 32bit builds. */
#endif
#endif
enum {
@ -90,7 +92,7 @@ enum {
#define JS_FLOAT64_NAN NAN
#define JSValueConst JSValue /* For backwards compatibility. */
#if defined(JS_NAN_BOXING)
#if defined(JS_NAN_BOXING) && JS_NAN_BOXING
typedef uint64_t JSValue;
@ -174,13 +176,41 @@ typedef struct JSValue {
#define JS_VALUE_GET_FLOAT64(v) ((v).u.float64)
#define JS_VALUE_GET_PTR(v) ((v).u.ptr)
/* msvc doesn't understand designated initializers without /std:c++20 */
#ifdef __cplusplus
static inline JSValue JS_MKPTR(int64_t tag, void *ptr)
{
JSValue v;
v.u.ptr = ptr;
v.tag = tag;
return v;
}
static inline JSValue JS_MKVAL(int64_t tag, int32_t int32)
{
JSValue v;
v.u.int32 = int32;
v.tag = tag;
return v;
}
static inline JSValue JS_MKNAN(void)
{
JSValue v;
v.u.float64 = JS_FLOAT64_NAN;
v.tag = JS_TAG_FLOAT64;
return v;
}
/* provide as macros for consistency and backward compat reasons */
#define JS_MKPTR(tag, ptr) JS_MKPTR(tag, ptr)
#define JS_MKVAL(tag, val) JS_MKVAL(tag, val)
#define JS_NAN JS_MKNAN() /* alas, not a constant expression */
#else
#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag }
#define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ .int32 = val }, tag }
#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag }
#define JS_NAN (JSValue){ (JSValueUnion){ .float64 = JS_FLOAT64_NAN }, JS_TAG_FLOAT64 }
#endif
#define JS_TAG_IS_FLOAT64(tag) ((unsigned)(tag) == JS_TAG_FLOAT64)
#define JS_NAN (JSValue){ (JSValueUnion){ .float64 = JS_FLOAT64_NAN }, JS_TAG_FLOAT64 }
static inline JSValue __JS_NewFloat64(double d)
{
JSValue v;
@ -484,21 +514,25 @@ JS_EXTERN int JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id);
static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val)
{
(void)&ctx;
return JS_MKVAL(JS_TAG_BOOL, (val != 0));
}
static js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val)
{
(void)&ctx;
return JS_MKVAL(JS_TAG_INT, val);
}
static js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double val)
{
(void)&ctx;
return __JS_NewFloat64(val);
}
static js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val)
{
(void)&ctx;
return JS_MKVAL(JS_TAG_CATCH_OFFSET, val);
}
@ -536,8 +570,8 @@ static inline JS_BOOL JS_IsNumber(JSValue v)
static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v)
{
int tag = JS_VALUE_GET_TAG(v);
return tag == JS_TAG_BIG_INT;
(void)&ctx;
return JS_VALUE_GET_TAG(v) == JS_TAG_BIG_INT;
}
static inline JS_BOOL JS_IsBool(JSValue v)
@ -721,7 +755,8 @@ JS_EXTERN int JS_DefinePropertyValueStr(JSContext *ctx, JSValue this_obj,
JS_EXTERN int JS_DefinePropertyGetSet(JSContext *ctx, JSValue this_obj,
JSAtom prop, JSValue getter, JSValue setter,
int flags);
JS_EXTERN void JS_SetOpaque(JSValue obj, void *opaque);
/* Only supported for custom classes, returns 0 on success < 0 otherwise. */
JS_EXTERN int JS_SetOpaque(JSValue obj, void *opaque);
JS_EXTERN void *JS_GetOpaque(JSValue obj, JSClassID class_id);
JS_EXTERN void *JS_GetOpaque2(JSContext *ctx, JSValue obj, JSClassID class_id);
JS_EXTERN void *JS_GetAnyOpaque(JSValue obj, JSClassID *class_id);
@ -900,7 +935,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun
int length, JSCFunctionEnum cproto, int magic)
{
/* Used to squelch a -Wcast-function-type warning. */
JSCFunctionType ft = { .generic_magic = func };
JSCFunctionType ft;
ft.generic_magic = func;
return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic);
}
JS_EXTERN void JS_SetConstructor(JSContext *ctx, JSValue func_obj,
@ -934,6 +970,7 @@ typedef struct JSCFunctionListEntry {
const char *str; /* pure ASCII or UTF-8 encoded */
int32_t i32;
int64_t i64;
uint64_t u64;
double f64;
} u;
} JSCFunctionListEntry;
@ -962,6 +999,7 @@ typedef struct JSCFunctionListEntry {
#define JS_PROP_INT32_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT32, 0, { .i32 = val } }
#define JS_PROP_INT64_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT64, 0, { .i64 = val } }
#define JS_PROP_DOUBLE_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_DOUBLE, 0, { .f64 = val } }
#define JS_PROP_U2D_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_DOUBLE, 0, { .u64 = val } }
#define JS_PROP_UNDEFINED_DEF(name, prop_flags) { name, prop_flags, JS_DEF_PROP_UNDEFINED, 0, { .i32 = 0 } }
#define JS_OBJECT_DEF(name, tab, len, prop_flags) { name, prop_flags, JS_DEF_OBJECT, 0, { .prop_list = { tab, len } } }
#define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, { .alias = { from, -1 } } }
@ -990,12 +1028,15 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
/* Version */
#define QJS_VERSION_MAJOR 0
#define QJS_VERSION_MINOR 6
#define QJS_VERSION_PATCH 1
#define QJS_VERSION_MINOR 7
#define QJS_VERSION_PATCH 0
#define QJS_VERSION_SUFFIX ""
JS_EXTERN const char* JS_GetVersion(void);
/* Integration point for quickjs-libc.c, not for public use. */
JS_EXTERN uintptr_t js_std_cmd(int cmd, ...);
#undef JS_EXTERN
#undef js_force_inline
#undef __js_printf_like

View File

@ -85,11 +85,13 @@ DEF(Ethiopic, "Ethi")
DEF(Georgian, "Geor")
DEF(Glagolitic, "Glag")
DEF(Gothic, "Goth")
DEF(Garay, "Gara")
DEF(Grantha, "Gran")
DEF(Greek, "Grek")
DEF(Gujarati, "Gujr")
DEF(Gunjala_Gondi, "Gong")
DEF(Gurmukhi, "Guru")
DEF(Gurung_Khema, "Gukh")
DEF(Han, "Hani")
DEF(Hangul, "Hang")
DEF(Hanifi_Rohingya, "Rohg")
@ -112,6 +114,7 @@ DEF(Khmer, "Khmr")
DEF(Khojki, "Khoj")
DEF(Khitan_Small_Script, "Kits")
DEF(Khudawadi, "Sind")
DEF(Kirat_Rai, "Krai")
DEF(Lao, "Laoo")
DEF(Latin, "Latn")
DEF(Lepcha, "Lepc")
@ -149,6 +152,7 @@ DEF(Nushu, "Nshu")
DEF(Nyiakeng_Puachue_Hmong, "Hmnp")
DEF(Ogham, "Ogam")
DEF(Ol_Chiki, "Olck")
DEF(Ol_Onal, "Onao")
DEF(Old_Hungarian, "Hung")
DEF(Old_Italic, "Ital")
DEF(Old_North_Arabian, "Narb")
@ -180,6 +184,7 @@ DEF(Sogdian, "Sogd")
DEF(Sora_Sompeng, "Sora")
DEF(Soyombo, "Soyo")
DEF(Sundanese, "Sund")
DEF(Sunuwar, "Sunu")
DEF(Syloti_Nagri, "Sylo")
DEF(Syriac, "Syrc")
DEF(Tagalog, "Tglg")
@ -197,7 +202,9 @@ DEF(Tibetan, "Tibt")
DEF(Tifinagh, "Tfng")
DEF(Tirhuta, "Tirh")
DEF(Tangsa, "Tnsa")
DEF(Todhri, "Todr")
DEF(Toto, "Toto")
DEF(Tulu_Tigalari, "Tutg")
DEF(Ugaritic, "Ugar")
DEF(Vai, "Vaii")
DEF(Vithkuqi, "Vith")
@ -236,11 +243,13 @@ DEF(Deprecated, "Dep")
DEF(Diacritic, "Dia")
DEF(Extender, "Ext")
DEF(Hex_Digit, "Hex")
DEF(IDS_Unary_Operator, "IDSU")
DEF(IDS_Binary_Operator, "IDSB")
DEF(IDS_Trinary_Operator, "IDST")
DEF(Ideographic, "Ideo")
DEF(Join_Control, "Join_C")
DEF(Logical_Order_Exception, "LOE")
DEF(Modifier_Combining_Mark, "MCM")
DEF(Noncharacter_Code_Point, "NChar")
DEF(Pattern_Syntax, "Pat_Syn")
DEF(Pattern_White_Space, "Pat_WS")
@ -279,6 +288,8 @@ DEF(Changes_When_Uppercased, "CWU")
DEF(Grapheme_Base, "Gr_Base")
DEF(Grapheme_Extend, "Gr_Ext")
DEF(ID_Continue, "IDC")
DEF(ID_Compat_Math_Start, "")
DEF(ID_Compat_Math_Continue, "")
DEF(Lowercase, "Lower")
DEF(Math, "")
DEF(Uppercase, "Upper")
@ -288,4 +299,7 @@ DEF(XID_Start, "XIDS")
/* internal tables with index */
DEF(Cased1, "")
/* unused by us */
DEF(InCB, "")
#endif

View File

@ -11,7 +11,7 @@ EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
ERROR: ReferenceError: a is not defined
ERROR: at <eval> (-:1:1)
ERROR: at <eval> (-:1:4)
ERROR: [uninitialized]
EOF