quickjs 0.19.0 → 0.20.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/quickjsrb/quickjs/cutils.c +31 -23
- data/ext/quickjsrb/quickjs/cutils.h +40 -6
- data/ext/quickjsrb/quickjs/libregexp-opcode.h +14 -8
- data/ext/quickjsrb/quickjs/libregexp.c +658 -490
- data/ext/quickjsrb/quickjs/libregexp.h +4 -0
- data/ext/quickjsrb/quickjs/libunicode-table.h +2273 -2216
- data/ext/quickjsrb/quickjs/libunicode.c +3 -2
- data/ext/quickjsrb/quickjs/libunicode.h +10 -0
- data/ext/quickjsrb/quickjs/qjs.c +24 -7
- data/ext/quickjsrb/quickjs/quickjs-atom.h +13 -0
- data/ext/quickjsrb/quickjs/quickjs-libc.c +90 -29
- data/ext/quickjsrb/quickjs/quickjs-opcode.h +5 -9
- data/ext/quickjsrb/quickjs/quickjs.c +7997 -2829
- data/ext/quickjsrb/quickjs/quickjs.h +35 -23
- data/ext/quickjsrb/quickjs/run-test262.c +377 -150
- data/ext/quickjsrb/quickjs/unicode_gen_def.h +5 -0
- data/lib/quickjs/version.rb +1 -1
- data/polyfills/package-lock.json +2 -2
- data/polyfills/package.json +1 -1
- metadata +1 -1
|
@@ -95,6 +95,7 @@ enum {
|
|
|
95
95
|
/* any larger tag is FLOAT64 if JS_NAN_BOXING */
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
/* must match the layout of 'JSMallocBlockHeader' */
|
|
98
99
|
typedef struct JSRefCountHeader {
|
|
99
100
|
int ref_count;
|
|
100
101
|
} JSRefCountHeader;
|
|
@@ -215,7 +216,7 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int32_t d)
|
|
|
215
216
|
#else /* !JS_NAN_BOXING */
|
|
216
217
|
|
|
217
218
|
typedef union JSValueUnion {
|
|
218
|
-
|
|
219
|
+
uint64_t uint64;
|
|
219
220
|
double float64;
|
|
220
221
|
void *ptr;
|
|
221
222
|
#if JS_SHORT_BIG_INT_BITS == 32
|
|
@@ -235,13 +236,15 @@ typedef struct JSValue {
|
|
|
235
236
|
#define JS_VALUE_GET_TAG(v) ((int32_t)(v).tag)
|
|
236
237
|
/* same as JS_VALUE_GET_TAG, but return JS_TAG_FLOAT64 with NaN boxing */
|
|
237
238
|
#define JS_VALUE_GET_NORM_TAG(v) JS_VALUE_GET_TAG(v)
|
|
238
|
-
#define JS_VALUE_GET_INT(v) ((v).u.
|
|
239
|
-
#define JS_VALUE_GET_BOOL(v) ((v).u.
|
|
239
|
+
#define JS_VALUE_GET_INT(v) ((int)(v).u.uint64)
|
|
240
|
+
#define JS_VALUE_GET_BOOL(v) ((int)(v).u.uint64)
|
|
240
241
|
#define JS_VALUE_GET_FLOAT64(v) ((v).u.float64)
|
|
241
242
|
#define JS_VALUE_GET_SHORT_BIG_INT(v) ((v).u.short_big_int)
|
|
242
243
|
#define JS_VALUE_GET_PTR(v) ((v).u.ptr)
|
|
243
244
|
|
|
244
|
-
|
|
245
|
+
/* avoid uninitialized data by using a 64 bit field even if only 32
|
|
246
|
+
bits are needed because some compilers generate slower code */
|
|
247
|
+
#define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ .uint64 = (uint32_t)(val) }, tag }
|
|
245
248
|
#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag }
|
|
246
249
|
|
|
247
250
|
#define JS_TAG_IS_FLOAT64(tag) ((unsigned)(tag) == JS_TAG_FLOAT64)
|
|
@@ -319,8 +322,7 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
|
|
319
322
|
(JS_SetProperty) */
|
|
320
323
|
#define JS_PROP_THROW_STRICT (1 << 15)
|
|
321
324
|
|
|
322
|
-
#define
|
|
323
|
-
#define JS_PROP_NO_EXOTIC (1 << 17) /* internal use */
|
|
325
|
+
#define JS_PROP_NO_EXOTIC (1 << 16) /* internal use */
|
|
324
326
|
|
|
325
327
|
#ifndef JS_DEFAULT_STACK_SIZE
|
|
326
328
|
#define JS_DEFAULT_STACK_SIZE (1024 * 1024)
|
|
@@ -395,18 +397,18 @@ JSValue JS_GetClassProto(JSContext *ctx, JSClassID class_id);
|
|
|
395
397
|
/* the following functions are used to select the intrinsic object to
|
|
396
398
|
save memory */
|
|
397
399
|
JSContext *JS_NewContextRaw(JSRuntime *rt);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
int JS_AddIntrinsicBaseObjects(JSContext *ctx);
|
|
401
|
+
int JS_AddIntrinsicDate(JSContext *ctx);
|
|
402
|
+
int JS_AddIntrinsicEval(JSContext *ctx);
|
|
403
|
+
int JS_AddIntrinsicStringNormalize(JSContext *ctx);
|
|
402
404
|
void JS_AddIntrinsicRegExpCompiler(JSContext *ctx);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
405
|
+
int JS_AddIntrinsicRegExp(JSContext *ctx);
|
|
406
|
+
int JS_AddIntrinsicJSON(JSContext *ctx);
|
|
407
|
+
int JS_AddIntrinsicProxy(JSContext *ctx);
|
|
408
|
+
int JS_AddIntrinsicMapSet(JSContext *ctx);
|
|
409
|
+
int JS_AddIntrinsicTypedArrays(JSContext *ctx);
|
|
410
|
+
int JS_AddIntrinsicPromise(JSContext *ctx);
|
|
411
|
+
int JS_AddIntrinsicWeakRef(JSContext *ctx);
|
|
410
412
|
|
|
411
413
|
JSValue js_string_codePointRange(JSContext *ctx, JSValueConst this_val,
|
|
412
414
|
int argc, JSValueConst *argv);
|
|
@@ -676,10 +678,16 @@ JSValue __js_printf_like(2, 3) JS_ThrowInternalError(JSContext *ctx, const char
|
|
|
676
678
|
JSValue JS_ThrowOutOfMemory(JSContext *ctx);
|
|
677
679
|
|
|
678
680
|
void __JS_FreeValue(JSContext *ctx, JSValue v);
|
|
681
|
+
|
|
682
|
+
static inline JSRefCountHeader *__js_rc(void *ptr)
|
|
683
|
+
{
|
|
684
|
+
return (JSRefCountHeader *)((uint32_t *)ptr - 1);
|
|
685
|
+
}
|
|
686
|
+
|
|
679
687
|
static inline void JS_FreeValue(JSContext *ctx, JSValue v)
|
|
680
688
|
{
|
|
681
689
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
|
682
|
-
JSRefCountHeader *p = (
|
|
690
|
+
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
|
683
691
|
if (--p->ref_count <= 0) {
|
|
684
692
|
__JS_FreeValue(ctx, v);
|
|
685
693
|
}
|
|
@@ -689,7 +697,7 @@ void __JS_FreeValueRT(JSRuntime *rt, JSValue v);
|
|
|
689
697
|
static inline void JS_FreeValueRT(JSRuntime *rt, JSValue v)
|
|
690
698
|
{
|
|
691
699
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
|
692
|
-
JSRefCountHeader *p = (
|
|
700
|
+
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
|
693
701
|
if (--p->ref_count <= 0) {
|
|
694
702
|
__JS_FreeValueRT(rt, v);
|
|
695
703
|
}
|
|
@@ -699,7 +707,7 @@ static inline void JS_FreeValueRT(JSRuntime *rt, JSValue v)
|
|
|
699
707
|
static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
|
700
708
|
{
|
|
701
709
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
|
702
|
-
JSRefCountHeader *p = (
|
|
710
|
+
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
|
703
711
|
p->ref_count++;
|
|
704
712
|
}
|
|
705
713
|
return (JSValue)v;
|
|
@@ -708,7 +716,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v)
|
|
|
708
716
|
static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v)
|
|
709
717
|
{
|
|
710
718
|
if (JS_VALUE_HAS_REF_COUNT(v)) {
|
|
711
|
-
JSRefCountHeader *p = (
|
|
719
|
+
JSRefCountHeader *p = __js_rc(JS_VALUE_GET_PTR(v));
|
|
712
720
|
p->ref_count++;
|
|
713
721
|
}
|
|
714
722
|
return (JSValue)v;
|
|
@@ -1053,8 +1061,8 @@ static inline JSValue JS_NewCFunctionMagic(JSContext *ctx, JSCFunctionMagic *fun
|
|
|
1053
1061
|
JSCFunctionType ft = { .generic_magic = func };
|
|
1054
1062
|
return JS_NewCFunction2(ctx, ft.generic, name, length, cproto, magic);
|
|
1055
1063
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1064
|
+
int JS_SetConstructor(JSContext *ctx, JSValueConst func_obj,
|
|
1065
|
+
JSValueConst proto);
|
|
1058
1066
|
|
|
1059
1067
|
/* C property definition */
|
|
1060
1068
|
|
|
@@ -1098,6 +1106,8 @@ typedef struct JSCFunctionListEntry {
|
|
|
1098
1106
|
#define JS_DEF_PROP_UNDEFINED 7
|
|
1099
1107
|
#define JS_DEF_OBJECT 8
|
|
1100
1108
|
#define JS_DEF_ALIAS 9
|
|
1109
|
+
#define JS_DEF_PROP_ATOM 10
|
|
1110
|
+
#define JS_DEF_PROP_BOOL 11
|
|
1101
1111
|
|
|
1102
1112
|
/* Note: c++ does not like nested designators */
|
|
1103
1113
|
#define JS_CFUNC_DEF(name, length, func1) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_CFUNC, 0, .u = { .func = { length, JS_CFUNC_generic, { .generic = func1 } } } }
|
|
@@ -1111,6 +1121,8 @@ typedef struct JSCFunctionListEntry {
|
|
|
1111
1121
|
#define JS_PROP_INT64_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_INT64, 0, .u = { .i64 = val } }
|
|
1112
1122
|
#define JS_PROP_DOUBLE_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_DOUBLE, 0, .u = { .f64 = val } }
|
|
1113
1123
|
#define JS_PROP_UNDEFINED_DEF(name, prop_flags) { name, prop_flags, JS_DEF_PROP_UNDEFINED, 0, .u = { .i32 = 0 } }
|
|
1124
|
+
#define JS_PROP_ATOM_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_ATOM, 0, .u = { .i32 = val } }
|
|
1125
|
+
#define JS_PROP_BOOL_DEF(name, val, prop_flags) { name, prop_flags, JS_DEF_PROP_BOOL, 0, .u = { .i32 = val } }
|
|
1114
1126
|
#define JS_OBJECT_DEF(name, tab, len, prop_flags) { name, prop_flags, JS_DEF_OBJECT, 0, .u = { .prop_list = { tab, len } } }
|
|
1115
1127
|
#define JS_ALIAS_DEF(name, from) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, -1 } } }
|
|
1116
1128
|
#define JS_ALIAS_BASE_DEF(name, from, base) { name, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE, JS_DEF_ALIAS, 0, .u = { .alias = { from, base } } }
|